Expand description
AES-GCM key minting (NIST SP 800-38D).
Keys minted here drive aead.aead-key.seal/open with the parameters
as the Web Cryptography API’s AesGcmParams defines them, per call.
Security:
- The caller owns nonce uniqueness. Nonce reuse under one key defeats the algorithm’s confidentiality and authenticity guarantees; use a deterministic per-key uniqueness scheme (SP 800-38D §8), or draw 96-bit nonces at random only within §8.2.2’s invocation bounds.
- Short tags weaken the forgery bound (SP 800-38D Appendix C) and are
opt-in only, behind an explicit
tag-size. - 96 bits (12 bytes) is the standard nonce size (the
nonce-sizegetter) and the fast path. Other lengths cost an extra GHASH pass (SP 800-38D §7.1) and forfeit §8.2’s deterministic-construction guidance.
Parameter acceptance:
- Nonce: 12 to 128 bytes inclusive; a length outside that window
fails
error.invalid-nonceon every implementation (seeREADME.md, “Portability contract”). The window is the range every implementation serves identically. Nonces shorter than the 96-bit standard size are cryptographically discouraged (SP 800-38D recommends the 96-bit construction), and lengths beyond 128 bytes serve no protocol in use. - Tag size: 16 bytes by default (
tag-sizeofnone); the algorithm’s set is 4, 8, 12, 13, 14, 15, or 16 bytes (the registry’s 32–128-bit set). Implementations MAY decline sizes their security policy does not serve witherror.unsupported. - Bounds: GCM defines a maximum plaintext of 2^39 − 256 bits
(~64 GiB) per invocation and an AAD bound of 2^64 − 1 bits.
Implementations reaching them fail rather than wrap, but their
buffering limits (
error.other) are reached far earlier in practice.
Functions§
- derive_
key - Mint a key from a parameterized derivation: the derivation runs
at the variant’s key length (WebCrypto’s
deriveKeychain — get key length, derive bits, import) and the result is subject toimport-key-raw’s contract. - generate_
key - Generate a fresh random key of the given AES variant. Fails with
error.unsupportedif this implementation does not serve the variant. - import_
key_ jwk - Import an RFC 7517 JSON Web Key as an AES-GCM key of the declared variant.
- import_
key_ raw - Import raw key material as the declared AES variant.
- unwrap_
key_ jwk - Mint a key from unwrapped key material read as an RFC 7517 JSON
Web Key, subject to
import-key-jwk’s contract plus the unwrap-pathuse/key_opschecks (seeREADME.md, “JWK contract”).inputis consumed; seeunwrap-key-rawfor the options model. - unwrap_
key_ raw - Mint a key from unwrapped key material (see the
wrappinginterface):input’s bytes are read as raw key material, subject toimport-key-raw’s contract.inputis consumed.