Skip to content

fix: add missing check_public validation in OAEP decrypt#656

Closed
sashass1315 wants to merge 1 commit intoRustCrypto:masterfrom
sashass1315:bug
Closed

fix: add missing check_public validation in OAEP decrypt#656
sashass1315 wants to merge 1 commit intoRustCrypto:masterfrom
sashass1315:bug

Conversation

@sashass1315
Copy link

The oaep::decrypt function (used by the PaddingScheme trait impl for Oaep) was missing a check_public() call, unlike every other encrypt/decrypt function in the codebase:

  • oaep::encrypt — has check_public
  • oaep::encrypt_digest — has check_public
  • oaep::decrypt_digest — has check_public
  • pkcs1v15::decrypt — has check_public
  • oaep::decrypt — MISSING

This meant that when using the Oaep padding scheme directly via RsaPrivateKey::decrypt(), the public key components were not validated, breaking the defense-in-depth pattern used throughout the library.

The fix adds the missing check_public() call at the top of oaep::decrypt, consistent with all sibling functions.

A regression test (behind the hazmat feature) is included that constructs a key with an oversized public exponent and verifies that
both OAEP decrypt paths (PaddingScheme and DecryptingKey) correctly reject it.

@tarcieri
Copy link
Member

This is effectively reverting #441, which was removed to address #418

@sashass1315
Copy link
Author

This is effectively reverting #441, which was removed to address #418

Hm, I will close then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments