Skip to main content

Module wrapping

Module wrapping 

Source
Expand description

Provider-held intermediates for key wrapping: moving one key’s material under another key without the material transiting the caller.

Wrapping is two composable halves, mirroring how derivation trades in derive-input:

  • Wrap: a key resource serializes its material into a wrap-input (to-wrap-input-raw and its format siblings, behind the key’s extractability gate), and a wrapping-capable key encrypts it into wrapped bytes (aead.aead-key.wrap, cipher.cipher-key.wrap, key-wrap.kw-key.wrap).
  • Unwrap: a wrapping-capable key decrypts wrapped bytes into an unwrap-input (aead.aead-key.unwrap and siblings), and a minting interface’s unwrap function mints a typed resource from it — a key (aes-gcm.unwrap-key-raw, hmac-sha2.unwrap-key-jwk, …) or a KDF base secret (hkdf.unwrap-ikm, pbkdf2.unwrap-password).

A wrap-input is the input to wrap; an unwrap-input is the input to the unwrap mints — the output of unwrap, never its argument (the wrapped bytes are).

Security:

  • The decrypted material never transits the consumer: unwrapping can mint a non-extractable key from wrapped transport, which no composition of open and import-key-raw can do.
  • Neither resource exposes the material it holds, and neither is reusable: the operation that takes one consumes it, on failure as on success. Implementations SHOULD NOT retain the material longer than the resource that denotes it.

Resource types are per-instance, so an intermediate cannot cross providers: both halves of a wrap or unwrap run inside one provider, and only the wrapped bytes travel (see README.md, “Design notes”).

Key material is small, so wrapping trades in list<u8> rather than the byte streams the bulk operations use.

Structs§

UnwrapInput
Key material from a wrapped input, awaiting a typed mint.
WrapInput
Serialized key material awaiting encryption under a wrapping key.