feat(iroh): Pluggable crypto backends#3992
Conversation
7a3b41c to
bf8ea8b
Compare
|
Probably not for this PR, but we could have another feature where we enable a rust-only crypto provider. It is the only major non-feature change I have to make to get esp32 to work. |
|
We should also extend the deps test that I added in #4011 to make sure ring and aws-lc-rs are truly gone when running with default-features = false. |
PresetsBuilderFactoryProvider |
Happened to me a few times. First try to "make invalid states unrepresentable" in builders, then scrap it all because the API surface area is just so large. I think if you just don't have the preset at all if you don't have the features, starting from scratch with .builder(presets::Empty) and having to set everything manually is unsurprising. This is only an issue for a small fraction of our users, and most of them will just copy and paste an example. So I think it's fine. By the way: isn't the crypto provider a global? So would it even work if you had 2 endpoints with different cryptoproviders? Is the setter on the builder just a fancy decoration for a global, or is it for real? |
It... does have this annoying API to make it globally available, but it doesn't have to be. For all of iroh's uses of CryptoProvider it is passed in - never using the global. The only places where I use the global are some edge-cases where constructing an Other than that, it's always passed around. So yes, you can have two iroh endpoints with different crypto providers in the same process. |
…icate `NoCertProvider`
Description
ringfeature flag that enables turning off the ring dependencyaws-lc-rsfeature flag that enables using aws-lc-rs as the crypto provider for rustls for everything TLS in irohiroh::endpoint::Builder::crypto_providerallowing anyone to configure custom crypto providers beyond ring and aws-lc-rs. This is a required call when neitherringnoraws-lc-rsare enabled, but will default to either (preferring ring) if the features are enabled.presets::Emptyandpresets::Minimal. The latter sets the minimal set of required options on the builder, but is only available on theringoraws-lc-rsfeature flags.Endpoint::empty_builderin favor ofEndpoint::buildertogether with either thepresets::Emptyorpresets::Minimal.Depends on n0-computer/noq#496
Breaking Changes
iroh::endpoint::Builder::crypto_providerfor configuring the crypto provider. After having built the Endpoint, you can get back the crypto provider viaendpoint.tls_config().crypto_provider().Endpoint::empty_builder. UseEndpoint::builder(presets::Empty)orEndpoint::builder(presets::Minimal)instead.iroh::endpoint::Builder::crypto_provider, you will get an error when building in the callBuilder::bind().Notes & Open Questions
It's probably worth asking ourselves if we want to change the way we run CI now.
Most of our tests are cfg-ed out when you disable both the ring and aws-lc-rs features.
However, maybe we should add another test category that's like
--no-default-features --feature ring/aws-lc-rs?We could call it
minimal(and I guess we'd have to decide to use either ring or aws-lc-rs).