Improve RSA exponent checks #11
Open
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 pull request enhances RSA key validation in the
pkg/jwk
package by introducing stricter checks for RSA modulus size and public exponent values, along with comprehensive tests to ensure the robustness of these validations. The key changes include updates to theRSAPublicKey
function and the addition of new test cases.RSA Key Validation Enhancements:
RSAPublicKey
to reject RSA keys with a modulus size smaller than 2048 bits. This ensures compliance with security best practices.RSAPublicKey
to ensure the public exponent is a positive integer between 2 andmath.MaxInt32
, rejecting invalid values.Test Coverage Improvements:
TestErrorMessages
to verify that excessively large public exponents are correctly rejected.TestRSAModulusSizeValidation
to ensure RSA keys with moduli smaller than 2048 bits are rejected, while valid moduli are accepted.TestRSAPublicKeyExponentValidation
to test various exponent values, ensuring invalid exponents are rejected and valid ones are accepted.These changes improve the security and reliability of RSA key handling in the
pkg/jwk
package.https://chatgpt.com/codex/tasks/task_e_6866d2118ff0833195a7b340a95ffc90