Skip to content

rsa: add missing exponent too small check#44

Merged
MichaelMure merged 1 commit into
reject-out-rangefrom
rsa-hardening
Jun 23, 2026
Merged

rsa: add missing exponent too small check#44
MichaelMure merged 1 commit into
reject-out-rangefrom
rsa-hardening

Conversation

@MichaelMure

@MichaelMure MichaelMure commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Note

Low Risk
Tightens input validation on RSA key import with new tests; only rejects previously accepted invalid exponents like 1.

Overview
PublicKeyFromNE now rejects public exponents < 2 (e.g. exponent 1) with exponent too small, in addition to existing positive/odd/int64 checks. That path is used when building keys from raw N/E bytes and from PrivateKeyFromNEDPQ.

key_test.go adds round-trip tests for PKCS#1 DER, N/E, and N/E/D/P/Q reconstruction, plus TestRejectWeirdPublicKeyInputs table tests that assert PublicKeyFromNE errors on bad moduli (empty, short, oversized, even) and bad exponents (empty, one, even, too large for int64).

Reviewed by Cursor Bugbot for commit ed857fe. Bugbot is set up for automated code reviews on this repo. Configure here.

@MichaelMure MichaelMure merged commit 8d239bb into reject-out-range Jun 23, 2026
7 checks passed
@MichaelMure MichaelMure deleted the rsa-hardening branch June 23, 2026 09:38
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