Skip to main content

Module aes_kw

Module aes_kw 

Source
Expand description

AES-KW key minting (RFC 3394; NIST SP 800-38F’s KW): key-wrap.kw-keys for the deterministic key-wrapping mode, the Web Cryptography API’s AES-KW. Read the key-wrap interface’s Security notes first.

Keys minted here drive kw-key.wrap/unwrap. The wrapped form is RFC 3394’s: the input’s length plus 8 bytes, carrying the 64-bit ICV whose failure unwrap reports as error.authentication-failed.

Input domains:

  • kw-key.wrap: the serialized input must be a multiple of 8 bytes, at least 16 (RFC 3394 §2; every AES and multiple-of-8 HMAC raw key qualifies). Anything else fails error.invalid-key.
  • JWK-formatted wrap input (a to-wrap-input-jwk serialization) is first padded with ASCII spaces (0x20) to a multiple of 8 — the behavior Web Cryptography API engines interoperate on. The JWK contract’s trailing-space tolerance carries the round trip (see README.md, “JWK contract”). No other format is padded.
  • kw-key.unwrap: a wrapped input is a multiple of 8 bytes, at least 24 (the wrapped form of the smallest wrap input). Input outside that domain cannot carry the wire format and fails error.authentication-failed, indistinguishable from an ICV failure.

A FIPS 140-3 approved-mode provider may serve this interface: KW is an SP 800-38F approved mode and draws no IV.

Functions§

derive_key
Mint a key from a parameterized derivation (the aes-gcm.derive-key contract, minting a kw-key).
generate_key
Generate a fresh random key of the given AES variant. Fails with error.unsupported if this implementation does not serve the variant.
import_key_jwk
Import an RFC 7517 JSON Web Key as an AES-KW key of the declared variant. The key must be an oct key whose alg, if present, names the declared variant ("A128KW"/"A192KW"/"A256KW"); otherwise as aes-gcm.import-key-jwk.
import_key_raw
Import raw key material as the declared AES variant (see aes-gcm.import-key-raw for the variant-redundancy contract).
unwrap_key_jwk
Mint a key from unwrapped key material read as an oct JWK, subject to import-key-jwk’s contract. input is consumed.
unwrap_key_raw
Mint a key from unwrapped key material read as raw bytes, subject to import-key-raw’s contract. input is consumed; see aes-gcm.unwrap-key-raw for the options model.

Type Aliases§

AesVariant
DeriveInput
Error
KwKey
KwKeyOptions
UnwrapInput