p256,P384,P521: reject keys as bytes if out of curve range#43
Merged
Conversation
dovydas55
previously approved these changes
Jun 23, 2026
rsa: add missing exponent too small check
dovydas55
approved these changes
Jun 23, 2026
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.
Note
Medium Risk
Stricter crypto key parsing can reject previously accepted malformed keys (especially EC JWK
dand RSAe=1), which is desirable for security but may break callers relying on lax behavior.Overview
Tightens key import validation for NIST EC curves and RSA public material.
P-256, P-384, and P-521:
PrivateKeyFromBytesnow rejects scalars outside [1, N−1] (zero and curve order N), with matching unit tests and JWK tests that expect unmarshaling invaliddvalues to fail.RSA:
PublicKeyFromNErejects exponents < 2 (e.g. e = 1). New tests cover PKCS1/NE/NEDPQ round-trips and rejection of bad modulus/exponent inputs (empty, wrong size, even modulus, even exponent, exponent too large for int64).Reviewed by Cursor Bugbot for commit 8d239bb. Bugbot is set up for automated code reviews on this repo. Configure here.