-
Notifications
You must be signed in to change notification settings - Fork 173
Remove 'unsalted' PSS handling #294
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
Conversation
tarcieri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I don't understand the potential real-world usages of unsalted PSS, but from a theoretical perspective it makes no sense: the purpose of having a salt is to increase the tightness of the security proof. I don't understand why one would want to use PSS in a way which defeats the security proof.
So that said, I'm all for removing the unsalted API.
I think we could further improve the API by having one where the default salt length equals the output length of the digest function, but I'm happy to open a followup PR to add that.
|
@tarcieri sounds good to me. |
|
@lumag alternatively, you could implement ^^^ proposed API in this PR, which would avoid the need to deprecate anything. Instead, change (Or I'm still happy to do that as a followup, which would simplify the overall changes and help organize discussion perhaps) |
|
Sure, I'll do that in a minute |
Current new() and random() functions cause confusion. There is the default from ASN.1 encoding of RSAPSS parameters (20). There is also another default of (mod_size - 2 - hash_size). And there is a recommendation to use salt_len of hash_size. Drop old defaults and always use digest output size as the salt_len. Clearly document new default. Signed-off-by: Dmitry Baryshkov <[email protected]>
All RSA PSS standards (e.g. RFC 8017) clearly specify that RSA PSS verification has an explicit salt length parameter (rather than determining it from the message). Drop our 'automagic' code and pass salt length when verifying the message. Old functions now default to digest output size as a hash length. Signed-off-by: Dmitry Baryshkov <[email protected]>
The emsa_pss_get_salt() is possibly non-constant-time op. Change it to be a contant-time operation. Signed-off-by: Dmitry Baryshkov <[email protected]>
|
done |
…n during verification (#546) This PR adds an optional method to automatically detect the salt length during RSA-PSS signature verification. Should Fix: #361 and similar situations. ### Problem The crate currently requires a fixed salt length for PSS verification. This prevents verification of signatures where the salt length is not known beforehand, a situation not uncommon in interoperability contexts. This capability was previously available but was removed in PR #294. ### Solution This change re-introduces salt length auto-detection as an explicit, opt-in feature. A new constructor, `VerifyingKey::new_with_auto_salt_len`, creates a verifier that performs this detection during verification. * The change is opt-in and does not affect default behavior. * It improves interoperability by handling signatures with variable / unknown salt lengths. * The salt detection logic is implemented in constant(-ish) time to resist timing attacks. ### Commit Structure This PR consists of three commits: 1. **test:** Adds a failing unit test to demonstrate the issue. 2. **feat:** Implements `new_with_auto_salt_len` and re-introduces the previous detection logic. 3. **fix:** Updates the detection logic to be less prone to timing attacks. Because salt length auto-detection is OpenSSL's default, it's likely that many systems were built without a mechanism to enforce or communicate a fixed salt length. Without this PR, it was impossible to reliably use this crate in my current project, and I suspect others face the same blocker. I've lost quite a bit of time dealing with seemingly random signature verification failures until I realized the crux of the problem.
The 'unsalted' PSS handling is not behaving like one would expect. It doesn't use salt of 0 length, but insteaad it uses some defaults which are not properly documented. Make the
salt_lenmandatatory for both singing and verification.