crypto: discover hashes and ciphers from providers - #65484
Conversation
|
Review requested:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #65484 +/- ##
==========================================
- Coverage 90.11% 90.09% -0.03%
==========================================
Files 751 751
Lines 252473 253124 +651
Branches 47487 47659 +172
==========================================
+ Hits 227517 228040 +523
- Misses 16270 16351 +81
- Partials 8686 8733 +47
🚀 New features to boost your workflow:
|
9242acf to
2cebe48
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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>
4bca8c4 to
54489eb
Compare
|
Compared One-shot hashing, HMAC, signing, The |
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
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