refactor(rust_crypto): move RSA backend to rsa 0.10.0-rc.17 - #502
refactor(rust_crypto): move RSA backend to rsa 0.10.0-rc.17#502EffortlessSteven wants to merge 3 commits into
Conversation
|
Let's not depend on a rc version |
|
Absolutely. Leaving the RC alone makes sense. This shook out the rust_crypto-side changes ahead of stable 0.10 and surfaced the wasm/getrandom wrinkle. Happy to revisit once 0.10.0 is out. |
| DecodingKeyKind::RsaModulusExponent { n, e } => { | ||
| RsaPublicKey::new(BigUint::from_bytes_be(n), BigUint::from_bytes_be(e))? | ||
| .verify(scheme, &digest, signature) | ||
| RsaPublicKey::new(to_boxed_uint(n)?, to_boxed_uint(e)?) |
There was a problem hiding this comment.
I'd recommend the use of BoxedUint::from_be_slice_vartime:
| RsaPublicKey::new(to_boxed_uint(n)?, to_boxed_uint(e)?) | |
| RsaPublicKey::new(BoxedUint::from_be_slice_vartime(bytes), BoxedUint::from_be_slice_vartime(bytes)) |
NOTE(security): Now this is a variable time function (and inherently dangerous), but here this is only used on a public key and no secret is involved.
|
Change looks good, but I think I would recommend to bump the other members of rustcrypto (hmac, p256, p384, ...) as this would make the dependency cleaner. |
| let public_key = private_key.to_public_key(); | ||
| Ok((public_key.n().to_bytes_be(), public_key.e().to_bytes_be())) | ||
| Ok(( | ||
| trim_leading_zeroes(public_key.n().to_be_bytes().as_ref()), |
There was a problem hiding this comment.
BoxedUint::to_be_bytes_trimmed_vartime is the function you're looking for.
NOTE(security): variable timed function, only to be used on public components.
Addresses #495.
I kept this to the rust_crypto RSA seam.
Scope
Dependency note
Review map
What changed
Existing coverage already exercising the touched paths
Validated locally
Non-goal