K025 / Cipher modes and AEAD
AES-GCM
AES-GCM is a GCM mode that provides authenticated encryption with associated data (AEAD).
CRYPTOGRAPHY LAB / K025
Cryptography Lab · AES-GCM
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
AES-GCM (96-bit nonce, empty AAD, 128-bit tag)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- AES-GCM is a GCM mode that provides authenticated encryption with associated data (AEAD). Source document ↗
- Classification and reversibility
- Classified as AEAD; decryption requires successful authentication. Source document ↗
- Key or secret requirements
- A secret symmetric key is required; AES keys of 128, 192 or 256 bits are used. Source document ↗
- Operating principle and structure
- Encrypts in CTR mode and calculates an authentication tag with operations in GF(2^128). Source document ↗
- Key size, block size and parameters
- AES has a 128-bit block size and supports 128-, 192- and 256-bit keys. Source document ↗
- Security strength and recommendation
- NIST decided to remove support for authentication tags shorter than 96 bits in its revision of SP 800-38D. Source document ↗
- Known attacks and vulnerabilities
- Nonce or IV reuse can lead to key exposure; attacks such as the Forbidden Attack are known. Source document ↗
- Standards and certification
- NIST SP 800-38D is the standard document for GCM and GMAC. Source document ↗
- Typical uses
- Used to protect stored data, database fields and inter-service messages. Source document ↗
- Implementations, libraries and tools
- Can be implemented with the AESGCM class in Python's cryptography library, among others. Source document ↗
- Decryption or decoding
- Verifies authentication during decryption and returns an error on failure. Source document ↗
- Advantages
- Fast, standardized and supported by most cryptographic libraries. Source document ↗
- Limitations and cautions
- Pay attention to short tags and IV uniqueness requirements. Source document ↗
- Distinguishing encryption, encoding and hashing
- This is encryption requiring a secret key, distinct from keyless encoding and one-way hashing. Source document ↗
Practical examples
Example
Encrypt plaintext and AAD with a secret key and unique nonce to obtain ciphertext and an authentication tag. During decryption, use the same key, nonce and tag to verify integrity before using plaintext.
Procedure
Encryption: generate and store a secret key, generate a unique nonce, supply plaintext and AAD to AES-GCM, then store or transmit ciphertext and tag. Decryption: verify and decrypt with key, nonce, ciphertext and tag; discard plaintext if tag verification fails. Encoding such as Base64 is a separate representation transformation.
Scenario
For inter-service messages or database field encryption, generate a unique nonce per record and encrypt and authenticate with AES-GCM. The receiver uses only data that passes tag verification and logs failures to detect attempted tampering.
Pitfalls and alternatives
Never reuse a nonce with the same key; avoid short tags and never use plaintext after tag verification failure. Use a KDF rather than a password directly as a key. Do not mistake Base64 or URL encoding for encryption. Use a vetted AEAD library.
References
- NIST SP 800-38D, Recommendationfor Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC ↗
- Sources/Crypto/AEADs/AES/GCM/AES-GCM.swift ↗
- Authenticated encryption ↗
- Galois/Counter Mode ↗
- AES-GCM Brief (Intel) ↗
- NIST to Revise Special Publication 800-38D | Galois/Counter Mode (GCM) and GMAC Block Cipher Modes | NIST ↗
- Public Comments on SP 800-38D, Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC ↗
- Report on the Block Cipher Modes of Operation in the NIST SP 800-38 Series ↗
- Encrypt data with a secret key - PyCryptodome ↗
- Block Cipher Techniques | CSRC ↗