crypto: discover hashes and ciphers from providers - #65484
Open
panva wants to merge 2 commits into
Open
Conversation
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65484 +/- ##
==========================================
+ Coverage 90.11% 90.12% +0.01%
==========================================
Files 751 751
Lines 252473 252688 +215
Branches 47487 47558 +71
==========================================
+ Hits 227517 227742 +225
+ Misses 16270 16240 -30
- Partials 8686 8706 +20
🚀 New features to boost your workflow:
|
panva
marked this pull request as draft
August 22, 2026 18:56
panva
force-pushed
the
crypto-provider-ciphers
branch
from
August 22, 2026 20:11
9242acf to
2cebe48
Compare
panva
marked this pull request as ready for review
August 22, 2026 20:12
jasnell
approved these changes
Aug 22, 2026
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
panva
marked this pull request as draft
August 23, 2026 09:57
Enumerate usable digests and aliases from activated OpenSSL 3 providers rather than relying only on the legacy digest registry. Normalize provider aliases, omit numeric OIDs and NULL, and validate them against the active default property query. Preserve legacy names and the OpenSSL 1.1.1 and BoringSSL paths. Expose KECCAK-KMAC-128, KECCAK-256, SHA256-192, and other provider digests. Add `functionName` and `customization` options for cSHAKE digests in `createHash()` and `crypto.hash()` with OpenSSL 4.0 or later. Resolve provider-only digest names across hashing, HMAC, KDF, signing, verification, and RSA digest options. Keep ordinary hash construction and one-shot hashing on the original binding arities and direct initialization paths. Use parameterized setup only when cSHAKE options are supplied. Lazily cache successful provider fetches per Environment. Index entries by case-insensitive query, canonical, and alias names. Deduplicate owners by provider and canonical identity. Return borrowed pointers on warm hits. Introduce a process-wide FIPS-state generation that advances only after successful, state-changing `setFips()` calls. Use it to invalidate per-Environment digest caches and refresh `getHashes()` snapshots in the main thread and workers. Keep cache IDs monotonic across invalidation because JavaScript Realms can retain them. Existing hash contexts can finish across a transition. Release provider owners before unloading worker addon DSOs. Document provider-dependent availability and operation-specific restrictions. Add known-answer vectors, option validation, provider resolution, property-query, FIPS transition, worker, snapshot, and cross-API coverage. Refs: nodejs#62982 Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Enumerate usable ciphers and aliases from activated OpenSSL 3 providers instead of maintaining lists of provider-only algorithms. Skip numeric OID aliases and filter NULL, TLS composite, multiblock, and encrypt-then-MAC implementations that the Cipher APIs cannot use. Preserve the OpenSSL 1.1.1 and BoringSSL paths. Expose CBC-CTS, SM4-GCM, SM4-CCM, SM4-XTS, and additional AES key wrap implementations. Add `ctsMode` (CS1/CS2/CS3) and `xtsStandard` (GB/IEEE) options for selecting provider CTS and SM4-XTS variants. Keep ordinary cipher construction on the original binding and legacy lookup paths. Lazily cache successful provider fetches per Environment for string initialization and `getCipherInfo()`. Index entries by case-insensitive query, canonical, and alias names. Deduplicate owners by provider and canonical identity. Return borrowed pointers on warm hits. Use the shared process-wide FIPS-state generation to invalidate per-Environment cipher caches and refresh `getCiphers()` snapshots in the main thread and workers. Existing cipher contexts retain their implementation and can finish across a transition. Release provider owners before unloading worker addon DSOs. Enforce one-shot updates for CBC-CTS, AES key wrap, SIV/GCM-SIV, and CCM decryption. Reject finalization without required input or CCM tags, and defer authentication failures to `final()`. Document streaming and XTS data-unit constraints. Add known-answer vectors, option validation, provider round trips, cache, worker, snapshot, FIPS transition, and construction benchmark coverage. Fixes: nodejs#43040 Fixes: nodejs#64866 Refs: nodejs#62982 Signed-off-by: Filip Skokan <panva.ip@gmail.com>
panva
force-pushed
the
crypto-provider-ciphers
branch
from
August 23, 2026 12:14
4bca8c4 to
54489eb
Compare
panva
marked this pull request as ready for review
August 23, 2026 12:17
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.
OpenSSL 3 provider implementations are not necessarily registered in the legacy digest and cipher tables used by
EVP_get_digestbyname()andEVP_get_cipherbyname(). As a result, Node.js can omit usable provider-only algorithms fromgetHashes()andgetCiphers()and reject them in crypto operations even when they match the active OpenSSL property query. The permanently memoized algorithm lists can also remain stale aftersetFips()changes that query.This change discovers usable hashes, ciphers, and aliases from activated OpenSSL providers while preserving the legacy registries. Numeric OID aliases, NULL implementations, and cipher implementations unsupported by the Node.js Cipher APIs are excluded.
Resolution and API support
getCipherInfo()while preserving numeric, WebCrypto, TLS, and predefined-cipher paths.createHash()andcrypto.hash()acceptfunctionNameandcustomizationfor cSHAKE digests with OpenSSL 4.0 or later.ctsModefor CBC-CTS andxtsStandardfor selecting the provider XTS variant.Caching and invalidation
Environmentunder case-insensitive query, canonical, and alias names, with owners deduplicated by provider and canonical identity.setFips()call that changes the FIPS state.Environmentlazily clears aliases before releasing owning provider references when it observes a new generation.getHashes()andgetCiphers()keep independent generation-aware snapshots, retry enumeration if the generation changes concurrently, return defensive copies, and discard their JavaScript snapshots during snapshot serialization.Fixes: #43040
Fixes: #64866
Refs: #62982