Overview
AES-GCM decryption reverses the encryption process while verifying the authentication tag. This ensures that:- Ciphertext hasn’t been tampered with (integrity)
- Correct key and nonce were used (authentication)
- AAD matches encryption (if used)
Decryption Operation
Basic Decryption
How It Works
AES-GCM decryption involves three main steps:-
Separate Components
- Extract authentication tag (last 16 bytes)
- Extract ciphertext (remaining bytes)
-
Verify Authentication Tag
- Recompute tag using ciphertext, AAD, nonce, and key
- Compare computed tag with provided tag (constant-time)
- Fail immediately if tags don’t match
-
Decrypt Ciphertext (only if authentication passes)
- Generate keystream using counter mode
- XOR keystream with ciphertext to produce plaintext
- Return plaintext
Parameters
Ciphertext (Required)
The encrypted data including the 16-byte authentication tag:Key (Required)
Must be the same key used for encryption:Nonce (Required)
Must be the same nonce used for encryption:Additional Authenticated Data (Optional)
If AAD was used during encryption, the exact same AAD must be provided for decryption:Error Handling
Authentication Failures
Decryption throwsDecryptionError if authentication fails:
Common Failure Scenarios
1. Wrong key:Error Messages
Security Properties
Constant-Time Verification
Tag verification is performed in constant time to prevent timing attacks:All-or-Nothing Decryption
If authentication fails, no plaintext is returned - not even partial data:Advanced Usage
Batch Decryption
Decrypt multiple messages in parallel:Extract and Decrypt
Parse stored format and decrypt:Verify Without Decrypting
Check if decryption would succeed without actually decrypting:Performance
Decryption Speed
Similar to encryption (hardware-accelerated):- With AES-NI: ~2-5 GB/s
- Software-only: ~50-200 MB/s

