Repository navigation
Fix RSA verification panic for modulus with length not evenly divisible by LIMB_BYTES - #937
Conversation
| let (padding, decoded) = decoded.split_at(n_bytes_padded - n_bytes); | ||
| assert!(padding.iter().all(|&b| b == 0)); | ||
| decoded | ||
| }; |
There was a problem hiding this comment.
I'm not particularly happy with how ugly this is or how leaky the abstractions are. For example, this code is only correct assuming we've done various bounds checks that indicate the RSA modulus length is reasonable.
OTOH, for validation reasons it is important to avoid making the code in arithmetic and limbs more complicated than it is.
In the future, after the release that contains this fix, we should clean this up.
|
I posted this to get early feedback. Tests should arrive soon, followed by the release. |
2c5666a to
f5e3c3a
Compare
…le by `LIMB_BYTES`.
f5e3c3a to
bfc926e
Compare
|
I've tried this out with some samples generated using Go's crypto package and have had no issues. |
I did test this but I decided not to include the tests in the PR because there is a refactoring of the tests in progress and I don't want to interfere with that refactoring. The tests should appear later in a separate PR. Thanks @andrewtj for reporting this and for testing it. |
No description provided.