Stop globally registering RSA key methods - #675
Open
mtrojnar wants to merge 1 commit into
Open
Conversation
mtrojnar
force-pushed
the
fix-rsa-method-scope-672
branch
2 times, most recently
from
August 12, 2026 18:12
ad3c89b to
f520426
Compare
Member
Author
|
Moved the OpenSSL ENGINE method-selection and lifetime management out of Revalidated the strict build, focused engine/provider RSA tests, and a clean |
mtrojnar
force-pushed
the
fix-rsa-method-scope-672
branch
from
August 12, 2026 19:01
f520426 to
9ab98f8
Compare
Member
Author
|
Reworked the fix to preserve the architecture boundary:
The branch remains a single squashed commit ( |
mtrojnar
force-pushed
the
fix-rsa-method-scope-672
branch
from
August 13, 2026 07:26
9ab98f8 to
71408f4
Compare
Loading a private key through the public libp11 API must not register an OpenSSL 3.x EVP_PKEY_METHOD process-wide. The registration changes method selection for every RSA key and breaks unrelated provider-backed software keys. Keep libp11 limited to constructing PKCS#11-backed RSA keys. ENGINE method selection remains in the existing eng_* integration, while the provider uses its own provider implementation. This preserves the project architecture without introducing deprecated ENGINE calls into the libp11 library. Add regression coverage for software-key isolation through the public API and exercise both raw-RSA and native-PSS mechanisms through the ENGINE interface.
mtrojnar
force-pushed
the
fix-rsa-method-scope-672
branch
from
August 13, 2026 07:39
71408f4 to
76c05a2
Compare
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.
Pull Request Type
Related Issue
Fixes #672
Current Behavior
On OpenSSL 3.x,
PKCS11_get_private_key()registers libp11's custom RSAEVP_PKEY_METHODprocess-wide withEVP_PKEY_meth_add0().That registration changes method selection for unrelated software RSA keys.
Provider-backed keys created before the PKCS#11 key can subsequently fail in
operations such as
X509_sign()with:Software RSA keys created afterward can also silently fall back to legacy
implementations instead of remaining backed by the default provider.
The registration also crosses an important architecture boundary: the
libp11 library initializes deprecated OpenSSL method integration that belongs
to the ENGINE component.
New Behavior
The public libp11 API constructs PKCS#11-backed RSA keys without globally
registering an OpenSSL
EVP_PKEY_METHOD. Loading such a key no longer changesRSA method selection elsewhere in the process, so existing and newly created
software RSA keys remain provider-backed and continue to work.
RSA-PSS method selection remains in the existing ENGINE integration. The
ENGINE tests verify both:
CKM_RSA_X_509whennative PSS is unavailable;
CKM_RSA_PKCS_PSSwhen raw RSA is unavailable.The OpenSSL provider continues to use its separate provider implementation.
Scope of Changes
EVP_PKEY_METHODregistration from the libp11library.
eng_*integration instead ofinvoking deprecated ENGINE APIs from
p11_*sources.created before and after
PKCS11_get_private_key().ENGINE interface.
No public API or ABI is changed.
Testing
Built with OpenSSL 3.6.3 using strict configuration and ran:
Result: 51 total, 46 passed, 5 skipped due to unavailable ML-DSA/ML-KEM
features, 0 failed.
Focused engine/provider RSA-PSS and RSA-OAEP tests pass using
/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so.A clean strict build with
CPPFLAGS=-DOPENSSL_NO_ENGINEalso passed the newpublic-API software-key isolation test. In that configuration the ENGINE
RSA-PSS scenarios are skipped because the ENGINE component is unavailable.
Additional Notes
The custom RSA PKEY method is an ENGINE integration detail. Applications
using the public libp11 API directly retain the key-specific
RSA_METHODandraw-RSA fallback, but do not receive ENGINE-only parameter callbacks for
native-PSS-only or parameterized-OAEP operations. Applications requiring
those OpenSSL interfaces should use the ENGINE or provider component.
License Declaration