Native deriveBits rejects a small-order X25519 public key with an
OperationError on Node, Bun and Deno, which currently surfaces as Unknown.
A peer's invalid key is rejected input data, so expect InvalidData.
Mutating a PBKDF2 options object's iteration count after the operation
starts must not change the result. This currently fails on every runtime
because the Web Crypto backend reads the count after its first await.
Replace per-runtime copies of the RSA-OAEP, HMAC, and PBKDF2 tests with one
shared describeCrypto suite of published known-answer vectors, following the
node-shared *.test-utils.ts convention. Drop tests that mock SubtleCrypto
internals, inspect batching or freezing, or exercise the internal HChaCha20
helper, and keep one core regression test per random-sampling fix plus one
for make's argument validation.
Each native random fill costs about as much for 4 KiB as for 7 bytes, so
serving per-draw requests from a reusable buffer makes randomShuffle about
15x faster on Node and 3x on Bun. Requests return fresh copies, consumed
bytes are zeroed, and the buffer is discarded before a V8 startup snapshot
is serialized so snapshot-started processes never share random bytes.
Add deriveSharedSecret for full-length ECDH and X25519 shared secrets,
rejecting mismatched keys and all-zero X25519 output (RFC 7748). Add
AES-CTR secret keys and cipher options, deriveBits key usage, and raw
import/export of ECDSA, ECDH, Ed25519, and X25519 public keys. Key usages
are now reported in a canonical order across backends.
Default importJwk usages to the JWK key_ops, bound PBKDF2 iterations and
length to Web Crypto's 32-bit limits, sample narrow integer ranges without
BigInt, report a missing SubtleCrypto backend explicitly, reuse shared
digest paths in Deno, and avoid leaving XChaCha plaintext in the Buffer pool.