Skip to content

fix(netssleay): bound RSA key generation sizes - #2171

Merged
fglock merged 2 commits into
masterfrom
fix/netssleay-rsa-key-size-20261124
Nov 24, 2026
Merged

fglock merged 2 commits into
masterfrom
fix/netssleay-rsa-key-size-20261124

Conversation

@fglock

@fglock fglock commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Summary

Bound Net::SSLeay::RSA_generate_key to integer sizes from 1024 through 8192 bits. Invalid, weaker, and unbounded requests now return undef before reaching the JCA provider.

The 1024-bit floor is a deliberate legacy exception: src/test/resources/unit/netssleay_phase5_6.t requests 1024 bits to keep its RSA round-trip test fast, and the OpenSSL-compatible API retains that caller-selected size. 1024-bit RSA is not suitable for new key material; the documentation recommends at least 2048 bits, and 3072 bits for 128-bit NIST strength. A narrow CodeQL suppression documents this compatibility case at the key-generation call.

This addresses the existing master CodeQL alert #3, which currently makes PR #1938's CodeQL check fail.

Verification

  • nice -n 19 make — passed in 6m19 on the code and regression-test commit.
  • perl src/test/resources/unit/netssleay_rsa_key_size_bounds.t — expected skip on system Perl because it tests the PerlOnJava adapter.
  • timeout 120 ./jperl src/test/resources/unit/netssleay_rsa_key_size_bounds.t — 7/7 passed.
  • timeout 120 ./jperl --interpreter src/test/resources/unit/netssleay_rsa_key_size_bounds.t — 7/7 passed.
  • make check-links — passed.
  • The regression fails on the pre-fix launcher for the five invalid-size cases and confirms the legacy 1024-bit request still works.

Checklist

  • make passes on this branch.
  • The new Perl test was run with standard Perl first; it skips because the adapter is PerlOnJava-specific.
  • Behavior was checked on JVM and interpreter backends.
  • Regression coverage covers invalid bounds and the documented legacy request.
  • Changelog and feature matrix updated.
  • Commits carry the required AI attribution.

fglock and others added 2 commits November 24, 2026 18:35
Reject RSA_generate_key sizes below the legacy 1024-bit floor and above
8192 bits before key generation. Retain 1024-bit generation for the bundled
fast RSA round-trip test and existing OpenSSL-compatible callers, with a
narrow CodeQL suppression documenting that exception.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Document that the bundled RSA round-trip test requests 1024 bits to keep the
test fast, and distinguish that compatibility exception from new-key guidance.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock merged commit fe8f9a3 into master Nov 24, 2026
9 checks passed
fglock added a commit that referenced this pull request Nov 24, 2026
Restore the NetSSLeay source to the merged #2171 implementation after
confirming the PR CodeQL alert remains present on the default branch.

Issue: #2043

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
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.

1 participant