Default RSA KeyPairGenerator params, null AlgorithmParameters for non-PSS, RSA exponent sanitization#155
Merged
rlm2002 merged 3 commits intowolfSSL:masterfrom Sep 10, 2025
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances RSA key generation and signature handling in the WolfSSL JCE provider by implementing proper default parameter handling and input validation. The changes improve compatibility with OpenJDK SunJCE RSA tests.
- Set default RSA key generation parameters (2048-bit keys) when not explicitly initialized
- Allow null AlgorithmParameterSpec for non-PSS signature algorithms while rejecting non-null parameters
- Add RSA public exponent validation to ensure it's positive and odd
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| WolfCryptKeyPairGenerator.java | Adds default RSA parameters initialization and public exponent validation |
| WolfCryptSignature.java | Updates parameter handling to accept null for non-PSS algorithms |
| WolfCryptKeyPairGeneratorTest.java | Adds tests for default RSA key generation and invalid exponent validation |
| WolfCryptSignatureTest.java | Adds tests for null parameter handling in non-PSS signatures |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/java/com/wolfssl/provider/jce/WolfCryptKeyPairGenerator.java
Outdated
Show resolved
Hide resolved
05887e6 to
6851635
Compare
rlm2002
approved these changes
Sep 10, 2025
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.
This PR includes three fixes:
KeyPairGenerator, set default RSA key size and parameters if the application has not explicitly set. We default to RSA 2048 for interop compatibility.Signature, allow nullAlgorithmParameterSpecto be passed in for non-PSS algorithmsKeyPairGenerator, add RSA exponent sanitization. Must be larger than 1 and odd.JUnit tests are included for regression prevention.
This fixes some of the OpenJDK SunJCE RSA tests.