New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: which traits must be implemented for a custom crypto provider #1603
Comments
the intention is that i think we have some docs work to do here. will prepare a PR for that in the morning (and use that to close the fledgling RFC PR). |
Those aren't useful anywhere yet and shouldn't have been included in the docs. Addressed by #1604 |
Thanks! And yeah, that makes sense. But say someone wants to not depend on ring or aws-lc-rs at all, which traits would they have to implement? While you're working on documentation in this area, |
@jsha what use case/audience do you have in mind here? |
My initial motivation was that @cpu had mentioned on rustls-ffi wanting to export the CryptoProvider API in FFI, so I wanted to understand the API upstream. For audiences, I've drawn from use cases I've seen mentioned on this repo:
Thanks for #1608, @ctz. And thanks for the clarification that But it seems like the other major use cases require implementing all the traits I listed up top, and it would be useful to list them out in one place or put them all in one module. That's particularly the case because some of the extension traits are located at one remove. For instance, Some questions I still have after reading the updated docs:
Also, the concept of delegating to an existing provider makes me think: a custom Anyhow I'm happy to take my own stab at writing the additional docs I'd like to see, if folks feel generally aligned on what I'm saying? I'd also like to add text to each |
Sounds like you may have missed #1372 (comment). 👍 |
So I don't think we should provide FFI APIs that allow custom What I think we should do in rustls-ffi, is allow the caller to specify which crypto provider they want to use. That could be at runtime (con: the library contains all the options) or compile/link time (con: there are many .a libraries to manage). |
That's more of what I had in mind 👍 Figuring out the right way to express the API for choosing aws-lc-rs as the provider, or another provider that lives outside of the Rustls tree. |
Yep, that's the conclusion I came to as well, in rustls/rustls-ffi#366. |
Aha, thanks for the link. Yes I saw that comment and then immediately forgot the specific recommendation of using CryptoProvider as the config surface here. Great, seems like we are all on the same page! |
It seems like https://docs.rs/rustls-pki-types/0.2.1/rustls_pki_types/trait.SignatureVerificationAlgorithm.html |
The goal is to version pki-types (which we control) to 1.0 before the release, and hopefully keep it at 1.x for a long time (although we might want to bump to 2.0 when |
The mix-and-match nature of the CryptoProvider API leads to this potentially surprising bit of code, if both use rustls::crypto::aws_lc_rs::cipher_suite::TLS13_CHACHA20_POLY1305_SHA256;
use rustls::crypto::aws_lc_rs::kx_group::X25519;
use rustls::crypto::ring::RING;
...
fn main() {
...
let config = rustls::ClientConfig::builder_with_provider(RING)
.with_cipher_suites(&[TLS13_CHACHA20_POLY1305_SHA256])
.with_kx_groups(&[X25519])
.with_protocol_versions(&[&rustls::version::TLS13])
.unwrap()
.with_root_certificates(root_store)
.with_no_client_auth(); This is a ClientConfig made with the This is particularly confusing because I'll see if I can write up some documentation to explain this nicely. It would be great if we could detect this situation and error. For instance, at the end of config building, if the cipher suites or kx groups aren't in the list provided by |
Ugh, that's a fair point. I feel like the better way forward here would be to follow through on #1372 (comment) in 0.22 instead of postponing it out to 0.23. |
I'm not sure I understand how that proposal improves this situation. Can you expand on where the improvement is in your eyes? If I write: use rustls::crypto::aws_lc_rs::cipher_suite::TLS13_CHACHA20_POLY1305_SHA256;
use rustls::crypto::aws_lc_rs::kx_group::X25519;
use rustls::crypto::ring::RING;
let provider = CryptoProvider {
cipher_suites: &[TLS13_CHACHA20_POLY1305_SHA256],
kx_groups: &[X25519],
.. RING
};
let config = rustls::ClientConfig::builder_with_provider(provider)
.with_protocol_versions(&[&rustls::version::TLS13])
.unwrap()
.with_root_certificates(root_store)
.with_no_client_auth(); We arrive at what feels like a very similar state, having only traded whether struct fields are used or builder methods. In both cases |
That's fair. I guess I feel like (a) the |
I can see what you mean & that does seem like an advantage. |
Here's a PR implementing the changes: #1628 |
Have all of these concerns been addressed? |
Mostly yes. I understand the mix-and-match nature, but I think it would still be useful to have a list of what needs implementing for the use case "I want to write a Since this would be a doc-only change it doesn't need to block an 0.22 release; we can always follow up with a patchlevel release containing doc improvements. |
I've struggled with rustls::SecureRandom - see Which may seem to be missing ? Ideally would love to see rng::CryptoRng supported but that is a feature req: |
I was looking up how to implement a custom crypto provider. It looks like it's not currently documented in a consolidated place. These are all the traits found in modules under rustls::crypto, plus some in rustls::quic. Could someone confirm whether this is the full set? Also, does each provider need to implement all of the ones not marked Optional, or is it expected that some providers would delegate to an existing default implementation for some of them?
Optional: QUIC
Optional: HPKE
The text was updated successfully, but these errors were encountered: