-
Notifications
You must be signed in to change notification settings - Fork 155
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
RSA signatures larger than the modulus are accepted #272
Comments
I think this only applies to RSASSA-PKCS#1v1.5. It seems like the PSS implementation has always had checks for the signature length: 5d28baf#diff-22b3e2164bd21d723f22be3c3381f4f58ba9c360f2079d76b93bd50b37e43611R21 Anyway, will get them added to PKCS#1v1.5 too. |
In both the PKCS#1v1.5 and PSS implementations, checks the signature value to ensure it does not overflow the modulus. In the PKCS#1v1.5 implementation, checks the signature length to ensure it matches the public key size. The PSS implementation was already doing this. Closes #272
I believe #306 should address these concerns |
In both the PKCS#1v1.5 and PSS implementations, checks the signature value to ensure it does not overflow the modulus. In the PKCS#1v1.5 implementation, checks the signature length to ensure it matches the public key size. The PSS implementation was already doing this. Closes #272
chore(crypto): CRP-2038: Bump rsa version The previous version `rsa = "0.4.0"` in `ic-crypto-internal-basic-sig-rsa-pkcs1` depends on an older version on `simple_asn1`, which in turn uses `chrono`, which makes compiling crates to wasm difficult. The `rsa` version `0.6.1`, which is already used elsewhere, depends on a newer version of `simple_asn1`, which doesn't use `chrono`. This MR bumps the version to the latest version `0.9.2`. The `0.9` version also includes a fix for [this bug](RustCrypto/RSA#272), where RSA signatures larger than the modulus are accepted. See merge request dfinity-lab/public/ic!14315
raw_encryption_primitive
is used for verifying signatures. It does not check that the decoded integer value is less than the modulus, thus ifs
is a valid signature it will also accepts+k*n
wheren
is the public modulus andk
is any positive integer.This introduces signature malleability, which is probably not an enormous problem in most applications, but neither does it seem desirable.
A related issue is that signatures are decoded as big integers but it is never checked that the length of the signature is equal to the public modulus length. So if
sig
is the binary encoding of a valid signature, prefixing that signature with any number of zero bytes will also be accepted as valid.This may affect ciphertext decryption as well, but I haven't checked this.
The following patch to the tests demonstrates the issues
The text was updated successfully, but these errors were encountered: