Kex, Packet, and Signatures are internal Context services built from Crypto.
The transport yields them; public constructors (SshClient.make,
SshClient.makeConnector, SshKey.make) provide their layers internally, so
public requirements stay Crypto only.
Internal kex, signatures, and packet modules now expose constructor effects
that read Crypto once and return closures; the transport, SshKeys,
SshKnownHosts, and OpenSsh factories build their helpers inside the
constructor after yielding their dependencies.
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.
make now takes a shallow copy of KDF, Argon2id, XChaCha, cipher, signing
and key-algorithm options when the effect runs, validates that copy, and
passes only the copy to the backend. A caller that changes its options
object afterwards can no longer alter a running derivation or bypass the
validated bounds, and changes made between building and running an effect
are validated too.
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.
- make takes a named Crypto.Backend: randomBytes, optional subtle, and
optional byte-level primitives. Key operations come only from subtle,
since a Key only works with the backend that created it. An omitted or
undefined subtle behave the same.
- Add an Unsupported SystemErrorTag for operations and algorithms a
backend cannot perform, separate from BadArgument caller mistakes.
- Add hmacVerify, which compares HMACs in constant time.
- Drop the bit length from HMAC key algorithms; generated keys use the
hash block size and imported keys their material length.
- Deno computes digests with node:crypto instead of building a second
service for MD5.
- TestCrypto builds its random members with make and delegates the rest
through a type-checked object.
Crypto.make now takes an optional Web Crypto `subtle` backend plus optional
per-operation overrides, replacing the exported makeSubtle. Operations with
no backend fail with BadArgument, so make({ randomBytes, digest }) keeps
working and custom services are no longer broken.
- pbkdf2 and hkdf take options objects; HKDF salt and info default to empty.
- Remove rsaOaepEncrypt; importKey("spki") plus encrypt covers it.
- Rename HmacAlgorithm to HashAlgorithm.
- Failed authenticated decryption and malformed key data fail with a
SystemError tagged InvalidData; unsupported algorithms, usages, and
missing native support fail with BadArgument.
- Node keeps createHash/createHmac overrides and drops its PBKDF2 and
RSA-OAEP overrides in favour of webcrypto.
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.