fix: reject invalid RSA exponents before calling OpenSSL#151
Merged
timlegge merged 2 commits intoApr 3, 2026
Conversation
RSA_generate_key_ex() on OpenSSL 1.1.x enters an infinite loop when given an even exponent (e.g. 2). Add pre-validation in generate_key() to croak immediately if the exponent is < 3 or even, preventing the hang on all OpenSSL versions. Fixes the CI timeout on Debian Bullseye (OpenSSL 1.1.1d) reported in PR cpan-authors#95. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that generate_key() croaks immediately on even exponents (2, 100), exponent 1, and exponent 0 — all of which would hang on OpenSSL 1.1.x without the pre-validation check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
@timlegge looks like an interesting protection |
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.
What
Pre-validate RSA exponent in
generate_key()— croak immediately if exponent is even or < 3.Why
RSA_generate_key_ex()on OpenSSL 1.1.x enters an infinite loop when given an even exponent (e.g. 2), causing CI hangs on Debian Bullseye. This is the root cause of the timeout in PR #95. OpenSSL 3.x handles this gracefully, but 1.1.x does not.RSA exponents must be odd and >= 3 per FIPS 186-4 / RFC 8017. Validating before calling OpenSSL prevents the hang on all versions.
How
Two-line check at the top of
generate_key()in RSA.xs, before any OpenSSL allocation. Croak with a descriptive message including the invalid value.Testing
t/key_lifecycle.t(exponents 0, 1, 2, 100)Fixes the CI hang reported in #95.
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 21 insertions(+), 1 deletion(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline