crypto-lab-nonce-guard

AES-GCM vs AES-GCM-SIV โ€” nonce misuse resistance compared

A โ€” The Nonce Problem

A1 โ€” What is a nonce?

A nonce (number used once) in AEAD schemes is a per-encryption value that must be unique for every encryption under the same key. It does not need to be secret. AES-GCM uses a 96-bit nonce (12 bytes). The security proof assumes the nonce is never reused.

NIST SP 800-38D calls it an Initialization Vector (IV); RFC 5116 calls it a nonce โ€” same concept.

96-BIT NONCE (12 BYTES)

A2 โ€” Why nonce reuse breaks AES-GCM

Level 1 โ€” Keystream reuse (confidentiality failure)

AES-GCM encrypts by XORing plaintext with a keystream derived from (key, nonce, counter). If the same (key, nonce) pair is used twice:

Cโ‚ = Pโ‚ โŠ• KS
Cโ‚‚ = Pโ‚‚ โŠ• KS
Cโ‚ โŠ• Cโ‚‚ = Pโ‚ โŠ• Pโ‚‚

The attacker recovers the XOR of the two plaintexts โ€” which often recovers both plaintexts in practice.

Level 2 โ€” Authentication key recovery (integrity failure)

AES-GCM's authentication tag uses a polynomial hash over GF(2ยนยฒโธ) with a key H = AES_K(0ยนยฒโธ). When the same nonce is reused, the attacker can solve for H algebraically from two (ciphertext, tag) pairs. Once H is known, the attacker can forge valid authentication tags for arbitrary ciphertexts โ€” total integrity failure.

tag = GHASH_H(AAD, C) โŠ• E_K(nonce โ€– 0ยณยน1)

GHASH_H uses H directly, making H recovery from two equations over GF(2ยนยฒโธ) a solvable linear algebra problem.

A3 โ€” The SIV construction (RFC 8452)

AES-GCM-SIV uses a synthetic IV approach:

  1. Derive a message-specific authentication key and encryption key from the (key, nonce)
  2. Compute a tag over the plaintext using POLYVAL (a GF(2ยนยฒโธ) variant defined in RFC 8452)
  3. Use that tag as the IV for AES-CTR encryption

The IV is derived from the plaintext itself. If the same (key, nonce) pair encrypts two different plaintexts, the two IVs differ. Nonce reuse degrades to leaking only whether two plaintexts were identical โ€” not the keystream, not the authentication key.

B โ€” Live Nonce Reuse Attack Demo

First plaintext message for encryption
Second plaintext message for encryption
Use same nonce (attack scenario)

๐Ÿ”“ AES-GCM Vulnerable

Click "Encrypt Both" to begin

๐Ÿ”’ AES-GCM-SIV Resistant

Click "Encrypt Both" to begin

C โ€” Synthetic IV Construction Visualizer

C1 โ€” Key Derivation

AES-GCM-SIV derives per-message keys from the master key and nonce:

C2 โ€” POLYVAL Authentication

POLYVAL is a GF(2ยนยฒโธ) polynomial hash defined in RFC 8452, using a different field representation than GHASH. The key distinction: POLYVAL's authentication key H is derived per-message from the (key, nonce) pair, not fixed per-key as in AES-GCM's GHASH.

tag = AES_K(POLYVAL(H, AAD, plaintext) โŠ• nonce) & clear MSB

C3 โ€” Tag-as-IV (Interactive)

The 128-bit POLYVAL tag becomes the synthetic IV after clearing one bit (preventing CTR counter overflow into tag space). Changing any byte of plaintext completely changes the tag and therefore the IV.

Type any message to see how the AES-GCM-SIV tag changes with each character

D โ€” When to Use Which

D1 โ€” Comparison Table

Comparison of AES-GCM and AES-GCM-SIV properties
PropertyAES-GCMAES-GCM-SIV
StandardNIST SP 800-38DRFC 8452
Nonce size96 bits96 bits
Nonce reuse consequenceKey recovery + full plaintext XORIdentical plaintext detection only
Performance~1 pass~2 passes (extra POLYVAL)
FIPS approvedYesNo (as of 2024)
Hardware accelerationAES-NI + PCLMULQDQAES-NI + PCLMULQDQ
Online encryptionYesNo โ€” must buffer full plaintext
Deployed inTLS 1.3, QUIC, IPsecGoogle internal, QUIC experiments
Recommendationโœ… Nonce uniqueness guaranteedโœ… Nonce uniqueness uncertain

D2 โ€” Decision Guidance

Scenario 1 โ€” Single server, sequential encryption

AES-GCM with a counter nonce is safe. Nonce uniqueness is easy to guarantee. No need for SIV overhead.

Scenario 2 โ€” Distributed system, multiple encryptors

Coordinating nonces across servers is error-prone. AES-GCM-SIV degrades gracefully on accidental reuse. Use SIV or use random 96-bit nonces with AES-GCM (collision risk is low at < 2ยณยฒ messages per key).

Scenario 3 โ€” Key wrapping and key storage

AES-GCM-SIV is designed for this โ€” short messages, repeated access to the same key, nonce coordination difficult. Google's Tink library uses it for key wrapping.

D3 โ€” Honest Limitations of AES-GCM-SIV

  • Not FIPS-approved โ€” cannot use in FIPS 140-2/3 contexts
  • No online encryption โ€” must have full plaintext before starting (not suitable for streaming)
  • Slightly slower โ€” the extra POLYVAL pass costs roughly 10โ€“20% throughput
  • Not yet widely deployed โ€” operational experience is thin compared to AES-GCM