[v24.x backport] backend split, KT12 limit, ByteSource MemoryRetainer + fixes and improvements - #65087
Closed
panva wants to merge 16 commits into
Closed
[v24.x backport] backend split, KT12 limit, ByteSource MemoryRetainer + fixes and improvements#65087panva wants to merge 16 commits into
panva wants to merge 16 commits into
Conversation
This separates the native crypto backend paths for OpenSSL >= 3, BoringSSL, and legacy OpenSSL. The OpenSSL >= 3 path now builds with `OPENSSL_API_COMPAT=30000` and `OPENSSL_NO_DEPRECATED`, moving normal crypto/TLS code away from APIs that OpenSSL 3.0.0 marks deprecated. BoringSSL remains on its own branch, and OpenSSL < 3 remains the legacy fallback. The exception is ENGINE support. ENGINE APIs are isolated into a dedicated compatibility target so they can remain available while the JS-facing engine APIs are runtime-deprecated in 27.x. That gives us a clear removal point for 28.x, without letting ENGINE usage leak back into the strict OpenSSL 3 path. The split also makes the eventual OpenSSL 1.1.1 removal easier to reason about. Once support for OpenSSL < 3 is dropped, the legacy branch can be removed in a focused follow-up, possibly targeting 27.x, instead of untangling mixed version guards throughout the crypto implementation. No public crypto or TLS API behavior is intentionally changed. Assisted-by: Codex:gpt-5 Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64211 Refs: nodejs#56733 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
To align with a future OpenSSL-imposed limit. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64557 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
Limit the g >= p rejection needed by the provider backend to OpenSSL 3. Preserve the legacy DiffieHellman object and expose the validation result through verifyError as before. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64547 Refs: nodejs#64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Treat missing private RSA parameters as an export failure instead of passing null BIGNUM pointers to the JWK encoder. Also stop constructing a usable RSA view when reading an optional parameter itself fails. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64547 Refs: nodejs#64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Clear provider-exported RSA, EC, and DH private BIGNUMs before freeing them. Also cleanse OSSL_PARAM builder copies and the plaintext DER intermediate used for encrypted traditional PEM output. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64547 Refs: nodejs#64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Recreate the historical rsaEncryption AlgorithmIdentifier used by X509Certificate legacy pubkey output for restricted and unrestricted RSA-PSS keys without relying on deprecated RSA APIs. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64547 Refs: nodejs#64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Report DH failures instead of aborting or returning an empty secret. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64851 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Create the mutex before sharing key data so every copy uses one lock. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64851 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Report the correct parameter name for invalid optional inputs. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64852 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Reject null options with ERR_INVALID_ARG_TYPE. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64852 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Avoid a second native call when reading the issuer certificate. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64852 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Explain that a cipher is required when a passphrase is provided. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64852 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
KEM encapsulation produces separate ciphertext and shared-secret allocations. The existing DeriveBitsJob path packs both values into an intermediate buffer, then copies them again into separate buffers. Instead, this uses a dedicated KEMEncapsulateJob to retain both outputs across the worker boundary and convert each directly through ByteSource. This removes the intermediate allocation and at least one complete round of copies. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64553 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64660 Reviewed-By: James M Snell <[email protected]>
Return an operation error when XOF output allocation fails. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64851 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and the traits insert their own message, which makes DeriveBitsJob skip errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were therefore bare Errors with no code and no opensslErrorStack. Drop the guard, which DeriveBitsJob already provides, and capture before inserting since Capture() clears the store. Signed-off-by: Filip Skokan <[email protected]> PR-URL: nodejs#64776 Reviewed-By: Yagiz Nizipli <[email protected]>
Collaborator
|
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v24.x-staging #65087 +/- ##
=================================================
+ Coverage 89.92% 90.29% +0.37%
=================================================
Files 686 711 +25
Lines 208389 228117 +19728
Branches 40077 43132 +3055
=================================================
+ Hits 187387 205985 +18598
- Misses 13238 14081 +843
- Partials 7764 8051 +287
🚀 New features to boost your workflow:
|
Collaborator
aduh95
approved these changes
Aug 6, 2026
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
This separates the native crypto backend paths for OpenSSL >= 3, BoringSSL, and legacy OpenSSL. The OpenSSL >= 3 path now builds with `OPENSSL_API_COMPAT=30000` and `OPENSSL_NO_DEPRECATED`, moving normal crypto/TLS code away from APIs that OpenSSL 3.0.0 marks deprecated. BoringSSL remains on its own branch, and OpenSSL < 3 remains the legacy fallback. The exception is ENGINE support. ENGINE APIs are isolated into a dedicated compatibility target so they can remain available while the JS-facing engine APIs are runtime-deprecated in 27.x. That gives us a clear removal point for 28.x, without letting ENGINE usage leak back into the strict OpenSSL 3 path. The split also makes the eventual OpenSSL 1.1.1 removal easier to reason about. Once support for OpenSSL < 3 is dropped, the legacy branch can be removed in a focused follow-up, possibly targeting 27.x, instead of untangling mixed version guards throughout the crypto implementation. No public crypto or TLS API behavior is intentionally changed. Assisted-by: Codex:gpt-5 Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64211 Backport-PR-URL: #65087 Refs: #56733 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
To align with a future OpenSSL-imposed limit. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64557 Backport-PR-URL: #65087 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Limit the g >= p rejection needed by the provider backend to OpenSSL 3. Preserve the legacy DiffieHellman object and expose the validation result through verifyError as before. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64547 Backport-PR-URL: #65087 Refs: #64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Treat missing private RSA parameters as an export failure instead of passing null BIGNUM pointers to the JWK encoder. Also stop constructing a usable RSA view when reading an optional parameter itself fails. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64547 Backport-PR-URL: #65087 Refs: #64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Clear provider-exported RSA, EC, and DH private BIGNUMs before freeing them. Also cleanse OSSL_PARAM builder copies and the plaintext DER intermediate used for encrypted traditional PEM output. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64547 Backport-PR-URL: #65087 Refs: #64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Recreate the historical rsaEncryption AlgorithmIdentifier used by X509Certificate legacy pubkey output for restricted and unrestricted RSA-PSS keys without relying on deprecated RSA APIs. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64547 Backport-PR-URL: #65087 Refs: #64211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Report DH failures instead of aborting or returning an empty secret. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64851 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Create the mutex before sharing key data so every copy uses one lock. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64851 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Report the correct parameter name for invalid optional inputs. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64852 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Reject null options with ERR_INVALID_ARG_TYPE. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64852 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Avoid a second native call when reading the issuer certificate. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64852 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Explain that a cipher is required when a passphrase is provided. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64852 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
KEM encapsulation produces separate ciphertext and shared-secret allocations. The existing DeriveBitsJob path packs both values into an intermediate buffer, then copies them again into separate buffers. Instead, this uses a dedicated KEMEncapsulateJob to retain both outputs across the worker boundary and convert each directly through ByteSource. This removes the intermediate allocation and at least one complete round of copies. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64553 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64660 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
Return an operation error when XOF output allocation fails. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64851 Backport-PR-URL: #65087 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
aduh95
pushed a commit
that referenced
this pull request
Aug 6, 2026
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and the traits insert their own message, which makes DeriveBitsJob skip errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were therefore bare Errors with no code and no opensslErrorStack. Drop the guard, which DeriveBitsJob already provides, and capture before inserting since Capture() clears the store. Signed-off-by: Filip Skokan <[email protected]> PR-URL: #64776 Backport-PR-URL: #65087 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Contributor
|
Landed in c7a0440...3cd1576 |
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.
@aduh95 out of the list requested for 24.x backport this does:
crypto: support loading private keys through STORE loaders #63949565c3dadepends on lib,permission: add permission.drop #62672b6a9111already on v24.x-staging