baml.crypto.Aes128GcmSiv
AES-128-GCM-SIV: nonce-misuse-resistant authenticated encryption (RFC 8452) under a 128-bit key.
Signature
class baml.crypto.Aes128GcmSivAES-128-GCM-SIV: nonce-misuse-resistant authenticated encryption (RFC 8452) under a 128-bit key.
Identical in construction and guarantees to [Aes256GcmSiv], with a shorter
key. Prefer Aes256GcmSiv unless a 128-bit key is dictated by an existing
format or peer.
Source:<builtin>/baml/ns_crypto/aes_gcm_siv.bamlbytes 4104–6617
Fields
_cipher
$rust_typeOpaque, runtime-owned cipher state: the expanded AES key schedule.
The key lives here rather than in a uint8array field so that a cipher
carrying a wrong-length key cannot be constructed, and so key material
stays unreachable from BAML. It cannot be read back, rendered by
string.from, or serialized by baml.json.from.
Static methods
Creates a cipher from a 16-byte (128-bit) key.
Throws
baml.errors.InvalidArgumentifkeyis not exactly 16 bytes.
Implementations
baml.Concrete for T
Source:<builtin>/baml/core.bamlbytes 763–795
baml.crypto.Aead for baml.crypto.Aes128GcmSiv
Instance methods
decrypt
(Authenticates and decrypts ciphertext, which must have been
produced by encrypt under the same key, nonce, and aad.
Throws
baml.errors.InvalidArgumentifnonceis not exactly 12 bytes, orciphertext/aadexceed the RFC 8452 limits.DecryptionFailureif the ciphertext does not authenticate.
encrypt
(Encrypts plaintext under nonce, authenticating aad alongside
it. The ciphertext is 16 bytes longer than plaintext, which is the
appended authentication tag.
Throws
baml.errors.InvalidArgumentifnonceis not exactly 12 bytes, orplaintext/aadexceed the RFC 8452 limit of 2^36 bytes.
Source:<builtin>/baml/ns_crypto/aes_gcm_siv.bamlbytes 4826–6205
baml.crypto.GenerateKey for baml.crypto.Aes128GcmSiv
Key = uint8arrayStatic methods
Draws a fresh 16-byte key from rng. Pass the result to
Aes128GcmSiv.new.
BUG: see Aes256GcmSiv.random_key. Self.Key lowers to an error type
at a concrete impl site, so the concrete type is spelled out.
Source:<builtin>/baml/ns_crypto/aes_gcm_siv.bamlbytes 6211–6615