Skip to main content

Module aes_cbc

Module aes_cbc 

Source
Expand description

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

Ciphertext is the padded encryption of the plaintext: always a non-zero multiple of 16 bytes (a full padding block is added when the plaintext is already block-aligned).

Security:

  • The 16-byte IV must be unpredictable to an attacker who can influence future plaintexts (CWE-329; the BEAST class), not merely unique: generate it fresh and randomly per message.
  • CBC with visible decryption failures is padding-oracle-prone by nature. The cipher kind’s uniform-failure rule bounds what this API reveals to the verdict itself; protocols that surface the verdict per message to an active attacker remain at risk. Prefer aes-gcm anywhere the format is not already fixed.

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-CBC key of the declared variant. The key must be an oct key whose alg, if present, names the declared variant ("A128CBC"/"A192CBC"/"A256CBC"); 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