Skip to content

crypto: deduplicate and canonicalize CryptoKey usages - #62902

Merged
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
panva:canonical-usages
Apr 25, 2026
Merged

nodejs-github-bot merged 3 commits into
nodejs:mainfrom
panva:canonical-usages

Conversation

@panva

@panva panva commented Apr 23, 2026

Copy link
Copy Markdown
Member

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