pkcs1v15: retrofit deterministic implicit rejection for decryption#685
Open
EffortlessSteven wants to merge 5 commits intoRustCrypto:masterfrom
Open
pkcs1v15: retrofit deterministic implicit rejection for decryption#685EffortlessSteven wants to merge 5 commits intoRustCrypto:masterfrom
EffortlessSteven wants to merge 5 commits intoRustCrypto:masterfrom
Conversation
8e622fd to
4a7234a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PKCS#1 v1.5 decrypt currently leaks padding validity through
Error::Decryption. This PR removes that distinguisher without changing the public decrypt API.It keeps the existing trait surface and
Result<Vec<u8>>, standardizes the outer public-invalid boundary so wrong-length ciphertexts and out-of-range ciphertext representatives still returnErr(Error::Decryption), and changes only padding-invalid but otherwise public-valid ciphertexts to return the deterministic rejection symbol.What changes
src/algorithms/pad.rs,src/algorithms/pkcs1v15.rs, andsrc/pkcs1v15.rssha2feature name for compatibility. SHA-256 is now an unconditional internal dependency for PKCS#1 v1.5 implicit rejection, while thesha2feature continues to gate the SHA-2 reexport and PKCS#1 v1.5 signature OID implsWhat does not change
sha2feature rename or removalDH = SHA256(D)caching optimizationEvidence
c >= nciphertexts still returnErr(Error::Decryption); identical invalid ciphertexts remain deterministic; distinct invalid ciphertexts produce distinct rejection symbols; valid ciphertexts still decrypt normally;RsaPrivateKey::decrypt(...)andpkcs1v15::DecryptingKeyagree on the shared pathcargo test --test pkcs1v15_implicit_rejection --all-features;cargo test --lib --tests --all-features;cargo check --all-features;cargo check --no-default-featuresvalid_0vszero_byte_in_padding_48_4suspicion. Current conclusion: supportive evidence, not closure.Follow-up work
Phase-two follow-ups should stay separate from this retrofit: