Skip to content

crypto: deduplicate and canonicalize CryptoKey usages#62902

Open
panva wants to merge 3 commits intonodejs:mainfrom
panva:canonical-usages
Open

crypto: deduplicate and canonicalize CryptoKey usages#62902
panva wants to merge 3 commits intonodejs:mainfrom
panva:canonical-usages

Conversation

@panva
Copy link
Copy Markdown
Member

@panva panva commented Apr 23, 2026

This was way more fun to track down than I expected.

The usage intersection operation requires the resulting [[usages]] slot to contain "each recognized key usage value that appears in both a and b, in the order listed in the list of recognized key usage values. This mandates both deduplication and a canonical ordering that is independent of the input order.

list of recognized key usage values and hence the canonical order is in W3C Web Cryptography API Level 2

encrypt, decrypt, sign, verify, deriveKey, deriveBits, wrapKey, unwrapKey

And then further overloaded by Modern Algorithms in the Web Cryptography API to be

encrypt, decrypt, sign, verify, deriveKey, deriveBits, wrapKey, unwrapKey, encapsulateKey, encapsulateBits, decapsulateKey, decapsulateBits

Fixes: #62899

Fixes: nodejs#62899

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva requested a review from ChALkeR April 23, 2026 00:02
@panva panva added confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem. webcrypto labels Apr 23, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.61%. Comparing base (9531947) to head (b9bc0f0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62902      +/-   ##
==========================================
- Coverage   89.62%   89.61%   -0.01%     
==========================================
  Files         706      706              
  Lines      219197   219224      +27     
  Branches    41995    42001       +6     
==========================================
+ Hits       196459   196467       +8     
- Misses      14640    14656      +16     
- Partials     8098     8101       +3     
Files with missing lines Coverage Δ
lib/internal/crypto/aes.js 89.86% <100.00%> (-0.04%) ⬇️
lib/internal/crypto/cfrg.js 93.23% <100.00%> (ø)
lib/internal/crypto/chacha20_poly1305.js 92.00% <100.00%> (-0.06%) ⬇️
lib/internal/crypto/ec.js 94.17% <100.00%> (ø)
lib/internal/crypto/keys.js 96.90% <100.00%> (+0.10%) ⬆️
lib/internal/crypto/mac.js 92.67% <100.00%> (-0.04%) ⬇️
lib/internal/crypto/ml_dsa.js 95.39% <100.00%> (ø)
lib/internal/crypto/ml_kem.js 92.83% <100.00%> (ø)
lib/internal/crypto/rsa.js 94.51% <100.00%> (ø)
lib/internal/crypto/util.js 95.66% <100.00%> (+0.26%) ⬆️

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

panva added 2 commits April 23, 2026 08:08
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Key usages should be an unique set

2 participants