Skip to main content

Module aes_ctr

Module aes_ctr 

Source
Expand description

AES-CTR key minting (NIST SP 800-38A counter mode, the Web Cryptography API’s AES-CTR): cipher.cipher-keys for the unauthenticated mode, served for compatibility with CTR-committed formats. Read the cipher interface’s Security notes first.

Ciphertext is exactly the plaintext’s length. The per-call iv is the 16-byte initial counter block, and counter-length (required; 1 to 128) is the width in bits of its rightmost, incrementing portion — WebCrypto’s AesCtrParams. The counter wraps around within that width without carrying into the fixed portion; a message longer than 2^counter-length blocks fails rather than reuse counter values.

Security:

  • Every counter block a key ever consumes must be unique: a repeated block is a two-time pad and forfeits confidentiality outright. Uniqueness spans messages — the caller partitions the counter space across messages via the fixed portion, per SP 800-38A Appendix B.

Functions§

derive_key
Mint a key from a parameterized derivation (the aes-gcm.derive-key contract, minting a cipher-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-CTR key of the declared variant. The key must be an oct key whose alg, if present, names the declared variant ("A128CTR"/"A192CTR"/"A256CTR"); 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
CipherKey
CipherKeyOptions
DeriveInput
Error
UnwrapInput