Skip to Content
oxcrypto

AES-GCM

Encrypt with AES-128, AES-192 or AES-256 in Galois/Counter Mode.

import os

from oxcrypto.aead.aes_gcm import AES_GCM

key = AES_GCM.AES256.generate()
nonce = os.urandom(12)
sealed = key.encrypt(nonce, b"message", associated_data=b"header")
plaintext = key.decrypt(nonce, sealed, associated_data=b"header")

Variants: AES128, AES192, AES256.

Never reuse a nonce with the same key: reuse reveals the authentication key.

StandardNIST SP 800-38D (Recommendation, final).
Crateaes-gcm 0.11.1
MaturityStable release. No published audit of 0.11; NCC Group published an audit of aes-gcm 0.8 in 2020.
MSRVBuilds with Rust 1.88.
Zeroizationaes and ghash/polyval with zeroize are written to wipe the AES round keys and the GHASH key and state on drop, and ctr to wipe the counter state. oxcrypto has not verified this independently.
ExperimentalNo
Test vectorsWycheproof aes_gcm_test.json