Add configurable RSA-OAEP support (selectable OAEP & MGF1 digests)#244
Open
nquangit wants to merge 1 commit into
Open
Add configurable RSA-OAEP support (selectable OAEP & MGF1 digests)#244nquangit wants to merge 1 commit into
nquangit wants to merge 1 commit into
Conversation
The RSA Encryption/Decryption operations previously only did RSA/ECB/ PKCS1Padding in PEM mode, and in KeyStore mode relied on named OAEP transformations (e.g. OAEPWITHSHA-256ANDMGF1PADDING) which silently keep MGF1 at SHA-1 under SunJCE. Neither could reproduce a common client-side config such as forge's RSA-OAEP with SHA-256 for both the OAEP and MGF1 digests. Introduce RsaCipherBuilder, a small helper that builds an RSA Cipher from a padding plus, for OAEP, an explicit OAEPParameterSpec with independently selectable OAEP and MGF1 message digests. Both operations now expose 'Padding', 'OAEP Hash' and 'MGF1 Hash' dropdowns in PEM and KeyStore mode; the hash fields are shown only while OAEP is selected. Defaults stay on PKCS1Padding so existing recipes are unaffected. KeyStore padding choices are sourced from the provider but always include an OAEP option, since some JVMs (incl. Burp's bundled JRE) advertise a reduced RSA padding list that omits OAEP. Add RsaCipherBuilderTest covering OAEP round-trips, mixed digests, PKCS1 backward-compat and the KeyStore padding fallbacks.
Collaborator
|
Hi! Thanks for your contribution to the CSTC. We'll look into your proposed changes and will update you soon. |
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.
Summary
The RSA Encryption / Decryption operations could not reproduce RSA-OAEP where the OAEP digest and the MGF1 digest are configured independently — a common pattern in client-side encryption. For example, the widely used [node-forge] snippet below uses RSA-OAEP with SHA-256 for both the OAEP digest and MGF1:
Previously:
Changes
future is a one-line change.
How to reproduce the forge config
RSA Encryption → Input Type PEM → paste the public key → Padding OAEPPadding, OAEP Hash SHA-256, MGF1 Hash SHA-256. (UTF-8 encoding and Base64 wrapping are left to the existing operations, e.g. To Base64.)
Testing