Add rustcrypto as a backend#243
Add rustcrypto as a backend#243mike-marcacci wants to merge 5 commits intorusticata:x509-parser-0.18from
Conversation
I have a need for a pure-rust toolchain, even if it comes with some performance penalty. This adds a verify-rustcrypto feature that uses rustcrypto in place of ring or aws-lc-rs. The only meaningful changes are in verify.rs. I used substantial AI to check these implementations for correctness against the corresponding RFC's, but I am NOT an expert. This is working well in my proof-of-concept, but needs careful scrutiny by a human who has more familiarity with these specs than me. A couple notes: - Both ring and aws-lc-rs don't appear to support arbetrary salt lengths, while rustcrypto does. - The rustcrypto backend doesn't support ECDSA cross-pairings. It might be possible to work around this, but it's my understanding is this is rare in practice.
- Use PrehashVerifier in the RustCrypto backend to support P-256 with SHA-384 and P-384 with SHA-256 - Add tests for these ECDSA curve/hash combinations across backends - Tidy up comments
ee4c7db to
4fcb3aa
Compare
Restores Cargo.lock to the base and selectively updates crates introduced by this PR.
51876a9 to
b4d332b
Compare
|
To add, the security finding is real: the rust-native RSA implementation is not constant time, and this appears to still be outstanding. However, it is not exploitable here, as verification never sees the private key. |
|
I think maintaining first party cryptography integrations for every niche is going to be untenable, especially given the limited resources this crate has for maintenance. Ring and aws-lc-rs are reasonable choices for first party integration because they share the ~same API and cover most bases. Cargo features are also a frustratingly limited configuration mechanism with lots of downsides (as you mention w.r.t Do you have interest in proposing and/or developing a more general extension mechanism by which cryptography providers can be provided external to this crate? An integration with RustCrypto (or SymCrypt, or Botan, or OpenSSL, or Graviola, etc) could then be implemented with that mechanism without requiring this crate to maintain it. That's the approach that crates like rustls have pursued, and is also a pattern I've been pushing for crates like instant-acme. |
Have you considered using x509-cert instead of |
|
Thanks @cpu. I agree that using rust features feels a bit clumsy, especially with the meaningful new code I'm introducing. I considered making a trait abstraction, similar in spirit to rustls's On the surface If a more generic extension mechanism would be preferable, I can take a shot at that; if this introduces too substantial a maintenance burden, I'm happy to close it with no hard feelings and leave the PR as a reference for anybody who might have the same need. |
That would be my preference, but I can't speak for chifflier. I would recommend waiting on his reply before investing too much time one way or the other since he's the final authority for this crate. We can probably draw inspiration from instant-acme#268 and similar existing approaches.
That makes sense 👍
Let's leave it open for now, but I think I will probably hold off on doing a code review for now. When chifflier has a chance to weigh in I'll react accordingly, either helping review the code to get it merged as-is, or collaborating on a more extensible solution. In either case, thanks for the contribution + discussion :-) |
I have a need for a pure-rust toolchain, even if it comes with some performance penalty.
This adds a
verify-rustcryptofeature that usesrustcryptoin place of ring oraws-lc-rs. The only meaningful changes are in verify.rs.I used substantial AI to check these implementations for correctness against the corresponding RFC's, but I am NOT an expert. This is working well in my proof-of-concept, but needs careful scrutiny by a human who has more familiarity with these specs than me.
A few notes:
ringandaws-lc-rsdon't appear to support arbitrary salt lengths, while RustCrypto does.ring>aws-lc-rs>rustcrypto), but this means testing with--all-featurescan be unintuitive