Skip to main content
Cipher Visualizers home

Breaking AES-GCM When the Nonce Repeats

AES-GCM is safe only while every nonce is used once. Reuse one and the whole guarantee collapses. This guide recovers a plaintext from a two-time pad, then recovers the GHASH authentication key from a few captured tags with a polynomial GCD, and forges a valid tag for a message the server never sent, all without the AES key.

Pashalis Laoutaris 19 min read

Try it

Interactive AES-GCM Nonce Reuse Breaker

🔐 AES-GCM Nonce Reuse Breaker

The server reuses one nonce for every message. The key and nonce are its secrets; the attacker sees only the ciphertexts and tags.
Enter text and click a button to start!
1. What the eavesdropper captures
2. Leak one: the two-time pad
3. Leak two: recover the hash key H
4. Forge a tag for a new message
Click the button to break AES-GCM when the nonce is reused.

Breaking AES-GCM When the Nonce Repeats

Introduction

AES-GCM is the most widely used authenticated cipher on the internet. It encrypts and authenticates at once, and it is the default in TLS. It rests on one rule: a nonce must never repeat under the same key. The AES-GCM guide and the GMAC guide both warn that reuse is catastrophic. This guide shows exactly how catastrophic.

A nonce that repeats leaks two things. The first is the plaintext, the same way a reused one-time pad does. The second is worse. From a few captured tags, an attacker recovers the secret GHASH key H, the value that authenticates every message. With H, the attacker forges a valid tag for any message of their choice. The AES key is never found and never needed. This is Antoine Joux’s “forbidden attack”, and in 2016 it was found live on 184 HTTPS servers.

Table of Contents

AES-GCM in One Paragraph

GCM encrypts with AES in counter mode. It derives a keystream from the key, the nonce, and a counter, then XORs that keystream into the plaintext. For authentication it uses a function called GHASH. GHASH has one secret input, H = AES(key, 0), the encryption of the all-zero block. GHASH folds the ciphertext blocks together with repeated multiplication by H in the finite field GF(2^128). The tag is this GHASH value, masked by one more AES call:

tag = GHASH_H(ciphertext) xor AES(key, J0)

J0 comes from the nonce. With the standard 12-byte nonce, J0 is the nonce followed by the counter 1. So the mask AES(key, J0) depends only on the key and the nonce. Reuse the nonce, and that mask is identical for every message.

Leak One: The Two-Time Pad

The counter-mode keystream also depends only on the key, the nonce, and the block position. If two messages share a nonce, they share a keystream. Let C1 and C2 be their ciphertexts:

C1 = P1 xor keystream
C2 = P2 xor keystream
C1 xor C2 = P1 xor P2

The keystream cancels out of both sides. The attacker is left holding the XOR of the two plaintexts. If either plaintext is known or guessable, the other falls out directly. This is the classic two-time pad, and it needs no field math at all. It already breaks confidentiality, before we touch the tag.

Leak Two: The Tag Is a Polynomial in H

Authentication fails even harder, and here the field math earns its keep. For a ciphertext of n blocks C_1, ..., C_n and a trailing block L that holds the lengths, the tag is:

tag = C_1 * H^(n+1) xor C_2 * H^n xor ... xor C_n * H^2 xor L * H xor S

where S = AES(key, J0) is the mask. Every multiplication is in GF(2^128). Think of this as a polynomial in the unknown H. The attacker knows every coefficient, because the coefficients are the ciphertext blocks and the length block, all visible on the wire. Only S and H are secret.

Now take two messages under the same nonce. They have the same S and the same L if they are the same length. Add the two tag equations. In GF(2^128), addition is XOR, so the S terms cancel and the L terms cancel:

tag1 xor tag2 = (C1_1 xor C2_1) * H^(n+1) xor ... xor (C1_n xor C2_n) * H^2

Move tag1 xor tag2 to the other side and you have a polynomial whose every coefficient is known and which is zero at the true H. In other words, H is a root of a polynomial the attacker can write down.

Recovering H by Polynomial GCD

One such polynomial has several roots, and H is only one of them. The fix is a second pair. A third captured message gives a second polynomial, built the same way, that also has H as a root. The true H is the root they share.

To find the shared root, take the greatest common divisor of the two polynomials. Polynomial GCD over GF(2^128) is just the Euclidean algorithm, with field arithmetic for the coefficients. When the messages differ enough, the GCD comes out as a degree-one polynomial, x + H, and the root is read off at once. This avoids any general root-finding or factoring. Real tools, such as the nonce-disrespect toolkit from the 2016 paper, factor the polynomial with Sage; the GCD shortcut is enough whenever a few varied captures are available.

Forging a Tag

Once H is known, the mask comes back from any single genuine capture:

S = tag1 xor GHASH_H(C1)

Now the attacker holds both secrets of the authenticator, H and S, for this nonce. For any ciphertext C* they choose, a valid tag is GHASH_H(C*) xor S. They can also build C* for a chosen plaintext, because the two-time pad already gave them the keystream. The result is a complete message, ciphertext and tag, that the server accepts as genuine. The AES key stayed secret the whole time, and it did not matter.

Interactive Visualizer

The visualizer above runs the full break in your browser. The server encrypts three messages with a real AES-128-GCM, using one key and one reused nonce. Everything after that uses only the captured ciphertexts and tags.

The four cards show the capture, the two-time pad that recovers message 2, the polynomial GCD that recovers H, and a forged tag for a message you type. You can edit all three messages and the forged message. The recovered H is checked against the server’s real H = AES(key, 0), and the forged tag is checked against the tag the server itself would compute. The same arithmetic runs in the Python below, and the two agree byte for byte.

A Worked Example

The server uses the key and nonce from the GMAC guide: key feffe9928665731c6d6a8f9467308308, nonce cafebabefacedbaddecaf888. It sends three 32-byte messages, each two blocks long, under that one nonce. The attacker captures three ciphertexts and three tags.

The two-time pad. XOR the first two ciphertexts and the keystream cancels, leaving P1 xor P2. The attacker, who already knows message 1, recovers message 2 as From Carol to Dave: send 9500 EU.

Recovering H. The error polynomial from captures 1 and 2 has degree 3, and so does the one from captures 1 and 3. Their GCD has degree 1, so its single root is H:

H = b83b533708bf535d0aa6e52980d53b78

This equals the server’s real H = AES(key, 0), which the guide can check because it holds the key. The attacker could not compute it that way, but arrived at the same value from tags alone.

Forging. With H and the mask, the attacker builds a ciphertext for From Alice to Eve: send 9999 EUR from the recovered keystream, then signs it. The forged tag matches the tag the server would compute, so the server accepts a message it never sent.

Python Implementation

This is a complete AES-128-GCM, reused from the AES-GCM guide, followed by the attack: the two-time pad, the error polynomials, the GCD that recovers H, and the forgery. It reproduces the NIST test vector and the worked example above.

# gcm_nonce_reuse.py
#
# The "forbidden attack": when AES-GCM reuses a nonce under one key, an eavesdropper who sees a few
# (ciphertext, tag) pairs recovers the GHASH authentication key H and can then forge a valid tag for
# any message of their choice. The key is never recovered and is never needed. This builds on the
# AES-128-GCM of the AES-GCM guide. Teaching code.

SBOX = [
0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16,
]
RCON = [0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36]


def xtime(a):
    a <<= 1
    return (a ^ 0x11b) & 0xff if a & 0x100 else a


def gmul(a, b):
    p = 0
    for _ in range(8):
        if b & 1:
            p ^= a
        a = xtime(a)
        b >>= 1
    return p


def key_expansion(key):
    words = [list(key[4 * i:4 * i + 4]) for i in range(4)]
    for i in range(4, 44):
        temp = list(words[i - 1])
        if i % 4 == 0:
            temp = temp[1:] + temp[:1]
            temp = [SBOX[b] for b in temp]
            temp[0] ^= RCON[i // 4 - 1]
        words.append([words[i - 4][j] ^ temp[j] for j in range(4)])
    return [b''.join(bytes(words[r * 4 + c]) for c in range(4)) for r in range(11)]


def aes128_encrypt_block(key, block):
    rk = key_expansion(key)
    state = bytes(s ^ k for s, k in zip(block, rk[0]))
    for r in range(1, 10):
        state = bytes(SBOX[b] for b in state)
        state = bytes(state[((c + r) % 4) * 4 + r] for c in range(4) for r in range(4))
        out = bytearray(16)
        for c in range(4):
            a = state[c * 4:c * 4 + 4]
            out[c*4+0] = gmul(a[0],2) ^ gmul(a[1],3) ^ a[2] ^ a[3]
            out[c*4+1] = a[0] ^ gmul(a[1],2) ^ gmul(a[2],3) ^ a[3]
            out[c*4+2] = a[0] ^ a[1] ^ gmul(a[2],2) ^ gmul(a[3],3)
            out[c*4+3] = gmul(a[0],3) ^ a[1] ^ a[2] ^ gmul(a[3],2)
        state = bytes(s ^ k for s, k in zip(bytes(out), rk[r]))
    state = bytes(SBOX[b] for b in state)
    state = bytes(state[((c + r) % 4) * 4 + r] for c in range(4) for r in range(4))
    return bytes(s ^ k for s, k in zip(state, rk[10]))


# ---- GF(2^128) in GCM's bit order: elements are 16-byte values, held here as integers ----
R = 0xE1000000000000000000000000000000


def gf_mul(x, y):
    z, v = 0, x
    for i in range(127, -1, -1):
        if (y >> i) & 1:
            z ^= v
        v = (v >> 1) ^ R if v & 1 else v >> 1
    return z


def gf_pow(a, e):
    result = 1 << 127          # the field's identity is the block 80 00 ... 00
    while e:
        if e & 1:
            result = gf_mul(result, a)
        a = gf_mul(a, a)
        e >>= 1
    return result


def gf_inv(a):
    return gf_pow(a, (1 << 128) - 2)


def to_int(b):
    return int.from_bytes(b, "big")


def to_bytes(n):
    return n.to_bytes(16, "big")


# ---- AES-128-GCM, 96-bit IV, as in the guide ----
def ghash(H, aad, ct):
    pad = lambda d: d + b"\x00" * (-len(d) % 16)
    blocks = pad(aad) + pad(ct)
    y = 0
    for i in range(0, len(blocks), 16):
        y = gf_mul(y ^ to_int(blocks[i:i + 16]), H)
    lenblock = (len(aad) * 8).to_bytes(8, "big") + (len(ct) * 8).to_bytes(8, "big")
    return gf_mul(y ^ to_int(lenblock), H)


def gcm_encrypt(key, iv, pt, aad=b""):
    H = to_int(aes128_encrypt_block(key, b"\x00" * 16))
    j0 = iv + b"\x00\x00\x00\x01"
    ctr = to_int(j0)
    ct = bytearray()
    for i in range(0, len(pt), 16):
        ctr = (ctr & ~0xffffffff) | ((ctr + 1) & 0xffffffff)
        ks = aes128_encrypt_block(key, to_bytes(ctr))
        ct += bytes(c ^ k for c, k in zip(pt[i:i + 16], ks))
    tag = ghash(H, aad, bytes(ct)) ^ to_int(aes128_encrypt_block(key, j0))
    return bytes(ct), to_bytes(tag)


# ---- polynomials over GF(2^128): a list of coefficients, index i is the x^i coefficient ----
def p_trim(p):
    while len(p) > 1 and p[-1] == 0:
        p.pop()
    return p


def p_add(a, b):
    n = max(len(a), len(b))
    return p_trim([(a[i] if i < len(a) else 0) ^ (b[i] if i < len(b) else 0) for i in range(n)])


def p_scale(p, c):
    return [gf_mul(x, c) for x in p]


def p_mul_mono(p, k):
    return [0] * k + list(p)


def p_mod(a, b):
    a = list(a)
    b = p_trim(list(b))
    inv_lead = gf_inv(b[-1])
    while len(a) >= len(b) and p_trim(a) != [0]:
        a = p_trim(a)
        if len(a) < len(b):
            break
        shift = len(a) - len(b)
        factor = gf_mul(a[-1], inv_lead)
        sub = p_mul_mono(p_scale(b, factor), shift)
        a = p_add(a, sub)
    return p_trim(a)


def p_gcd(a, b):
    a, b = p_trim(list(a)), p_trim(list(b))
    while b != [0]:
        a, b = b, p_mod(a, b)
    # make monic
    inv = gf_inv(a[-1])
    return p_trim([gf_mul(x, inv) for x in a])


def ghash_poly(aad, ct):
    """GHASH as a polynomial in H: block X_i (from the start) multiplies H^(m-i+1)."""
    pad = lambda d: d + b"\x00" * (-len(d) % 16)
    blocks = pad(aad) + pad(ct)
    lenblock = (len(aad) * 8).to_bytes(8, "big") + (len(ct) * 8).to_bytes(8, "big")
    words = [blocks[i:i + 16] for i in range(0, len(blocks), 16)] + [lenblock]
    m = len(words)
    poly = [0] * (m + 1)
    for i, w in enumerate(words):
        poly[m - i] = to_int(w)   # X_1 -> H^m, ..., last -> H^1; constant term is 0
    return p_trim(poly)


def error_poly(c_a, t_a, c_b, t_b):
    """P(H) for two captures that share the nonce; H is a root. aad empty, equal lengths."""
    poly = p_add(ghash_poly(b"", c_a), ghash_poly(b"", c_b))
    poly = p_add(poly, [to_int(t_a) ^ to_int(t_b)])   # constant term = t_a xor t_b
    return poly


def gf_sqrt(a):
    return gf_pow(a, 1 << 127)     # (a^(2^127))^2 = a^(2^128) = a, so this is the square root


def recover_H(captures):
    """captures: list of (ciphertext, tag) under the same key and nonce. Returns (H, gcd).

    Each pair of captures gives a polynomial with H as a root; their GCD isolates it. With distinct
    enough messages the GCD is linear (x + H). When the message differences line up, the GCD can be
    the perfect square x^2 + c, and then H is the square root of c (division by the leading term first).
    """
    c0, t0 = captures[0]
    g = None
    for c, t in captures[1:]:
        p = error_poly(c0, t0, c, t)
        g = p if g is None else p_gcd(g, p)
    if len(g) == 2:
        return g[0], g                                  # x + H  ->  root is H
    if len(g) == 3 and g[1] == 0:
        return gf_sqrt(gf_mul(g[0], gf_inv(g[2]))), g    # a x^2 + c  ->  H = sqrt(c / a)
    return None, g                                       # would need equal-degree factoring


def forge(H, known_c, known_t, target_c):
    """With H and one genuine capture, S = tag xor GHASH(c); a forged tag for any ciphertext is GHASH xor S."""
    s = to_int(known_t) ^ ghash(H, b"", known_c)
    return to_bytes(ghash(H, b"", target_c) ^ s)


def xor_bytes(a, b):
    return bytes(x ^ y for x, y in zip(a, b))


if __name__ == "__main__":
    # ---- the server's secret world ----
    KEY = bytes.fromhex("feffe9928665731c6d6a8f9467308308")   # the key, held only by the server
    IV = bytes.fromhex("cafebabefacedbaddecaf888")            # reused for every message: the bug

    # three 32-byte (two-block) messages the server sends, all under the same key and nonce
    msgs = [b"From Alice to Bob: send 100 EUR.",
            b"From Carol to Dave: send 9500 EU",
            b"Refund Erin 42 EUR immediately!!"]
    caps = [gcm_encrypt(KEY, IV, m) for m in msgs]

    # ---- from here on, the attacker uses only the ciphertexts and tags below ----
    print("what the eavesdropper captures (nonce %s reused):" % IV.hex())
    for i, (c, t) in enumerate(caps, 1):
        print("  C%d = %s  tag %s" % (i, c.hex(), t.hex()))

    print("\n-- leak 1: the two-time pad (no H needed) --")
    xor = xor_bytes(caps[0][0], caps[1][0])
    print("C1 xor C2 = P1 xor P2 =", xor.hex())
    print("holds:", xor == xor_bytes(msgs[0], msgs[1]))
    print("if the attacker knows message 1, message 2 falls out:", xor_bytes(xor, msgs[0]))

    print("\n-- leak 2: recover H by polynomial GCD --")
    p_ab = error_poly(caps[0][0], caps[0][1], caps[1][0], caps[1][1])
    p_ac = error_poly(caps[0][0], caps[0][1], caps[2][0], caps[2][1])
    print("error polynomial from captures 1,2: degree", len(p_ab) - 1)
    print("error polynomial from captures 1,3: degree", len(p_ac) - 1)
    g = p_gcd(p_ab, p_ac)
    print("gcd degree:", len(g) - 1, "-> the single common root is H")
    H, _ = recover_H(caps)
    H_true = to_int(aes128_encrypt_block(KEY, b"\x00" * 16))
    print("recovered H = %032x" % H)
    print("true H      = %032x" % H_true)
    print("match       =", H == H_true)

    # ---- the attacker recovers the keystream from a known message, then forges at will ----
    print("\n-- forging a tag for a message the server never sent --")
    keystream = xor_bytes(caps[0][0], msgs[0])          # knows message 1 (a crib), so knows the keystream
    forged_pt = b"From Alice to Eve: send 9999 EUR"   # 32 bytes, same length as the crib
    forged_ct = xor_bytes(keystream, forged_pt)         # built from keystream, not the key
    forged_tag = forge(H, caps[0][0], caps[0][1], forged_ct)
    print("forged C =", forged_ct.hex())
    print("forged tag =", forged_tag.hex())
    # the server would accept it: decrypt and check the tag the honest way
    real_ct, real_tag = gcm_encrypt(KEY, IV, forged_pt)
    print("server's own tag for this ciphertext =", real_tag.hex())
    print("forgery accepted =", forged_tag == real_tag and forged_ct == real_ct)

Running it prints this:

what the eavesdropper captures (nonce cafebabefacedbaddecaf888 reused):
  C1 = ddc0438af9b21ea88d4e08064405b0690737a80f5c58371a2abd7e3ee6c87972  tag 01864cb3c27397ad8d6693e8d9b53f44
  C2 = ddc0438af9b013b3814708064405b6671368b25c4a533d5e3bb47b2e93bd6e09  tag 19413365060759480f109df0cdc8fd2d
  C3 = c9d74a92b79752849c4246521f17d243305fa815545b365e72ec3a7bcfe40a7d  tag cd9d9daad801ec7b204db0e9c43da0e9

-- leak 1: the two-time pad (no H needed) --
C1 xor C2 = P1 xor P2 = 0000000000020d1b0c0900000000060e145f1a53160b0a44110905107575177b
holds: True
if the attacker knows message 1, message 2 falls out: b'From Carol to Dave: send 9500 EU'

-- leak 2: recover H by polynomial GCD --
error polynomial from captures 1,2: degree 3
error polynomial from captures 1,3: degree 3
gcd degree: 1 -> the single common root is H
recovered H = b83b533708bf535d0aa6e52980d53b78
true H      = b83b533708bf535d0aa6e52980d53b78
match       = True

-- forging a tag for a message the server never sent --
forged C = ddc0438af9b21ea88d4e08064405b7700037a80f5c58371a22b4772783d87e0e
forged tag = d9c54417921106d6e558a59b43ab7e34
server's own tag for this ciphertext = d9c54417921106d6e558a59b43ab7e34
forgery accepted = True

I checked the code in several ways. The AES-GCM core reproduces the NIST all-zero test vector, ciphertext 0388dace60b6a392f328c2b971b2fe78 and tag ab6e47d42cec13bdf53a67b21257bddf. It also matches the pycryptodome library on 200 random messages, and the JavaScript in the visualizer matches Node’s own AES-GCM on 300 random messages. The recovered H matches the GMAC guide’s published H for the same key. The attack was run on 1500 random cases of three to four captures and one to four blocks. Every case that produced a usable polynomial recovered the exact H. The JavaScript and Python agreed on the ciphertexts, tags, and recovered H for 120 shared cases.

Limitations

Same nonce, or no attack. The whole break rests on a repeated nonce under one key. With a fresh nonce for every message, as the standard requires, none of this works. This is a bug-finder, not a break of AES-GCM used correctly.

Equal lengths and empty associated data. The worked example uses messages of the same length and no associated data, so the length block and any AAD cancel cleanly. Different lengths or AAD only add known terms to the polynomial, which the real toolkits handle; the demo keeps them equal to stay readable.

The GCD must come out small. With messages that differ enough, three captures give a degree-one GCD and H is immediate. Near-identical messages can leave a higher-degree GCD, which needs a genuine root-finding step over GF(2^128), such as the equal-degree factoring in the nonce-disrespect toolkit. The code handles the degree-one and perfect-square cases and reports when more captures are needed.

Teaching code. The field and polynomial routines favor clarity over speed, and the demo uses two-block messages. It is here to show the mechanism, not to be a fast attack tool.

Security Status

AES-GCM is secure when used correctly, and it is a good default. The danger is entirely operational. A single repeated nonce under one key destroys authentication for that key, not just for the two messages involved, because the recovered H forges tags for any message. The 2016 internet scan by Böck and others found 184 HTTPS servers doing exactly this, including financial institutions and a credit card company.

The defenses are well known. Never reuse a nonce under one key. Use a counter, or derive the nonce so it cannot repeat. Where reuse cannot be ruled out, use a nonce-misuse-resistant mode such as AES-GCM-SIV, which degrades gracefully instead of collapsing. The AES-SIV guide on this site covers that family.

FAQ

Does the attacker recover the AES key?

No, it does not. The attack recovers H = AES(key, 0) and the per-nonce mask S, which together are everything GHASH needs. The AES key itself stays secret, and the attacker never needs it to read or forge messages under the reused nonce.

How many captured messages are needed?

Two are enough to recover a plaintext from the two-time pad. Recovering H needs at least two pairs, so three messages under the same nonce. More captures make the polynomial GCD collapse to a single root faster.

Why does reuse break authentication and not just secrecy?

Secrecy breaks because the keystream repeats, like a two-time pad. Authentication breaks because the mask S also repeats, which lets the attacker cancel it between two tags and expose H inside a polynomial. The first costs the two messages; the second costs every future message.

Is ChaCha20-Poly1305 affected the same way?

The same weakness applies. Poly1305 also needs a unique one-time key per message, and reusing it leaks the authentication key through a similar algebra. The ChaCha20-Poly1305 guide covers why its key must never repeat.

How is this different from the GMAC breaker example?

The GMAC guide runs the forbidden attack for single-block messages, where H comes from one division and one square root. This guide does the general case: multi-block ciphertexts, the tag as a polynomial in H, and a GCD across several captures, then a full forgery on real AES-GCM ciphertext.

References

  1. Joux, Antoine. “Authentication Failures in NIST Version of GCM.” Comments submitted to NIST, 2006.

  2. Böck, Hanno, Aaron Zauner, Sean Devlin, Juraj Somorovsky, and Philipp Jovanovic. “Nonce-Disrespecting Adversaries: Practical Forgery Attacks on GCM in TLS.” 10th USENIX Workshop on Offensive Technologies (WOOT 16), Austin, TX, 2016.

  3. NIST SP 800-38D. “Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC,” 2007.

  4. McGrew, David, and John Viega. “The Galois/Counter Mode of Operation (GCM),” 2005.

  5. Gueron, Shay, Adam Langley, and Yehuda Lindell. “AES-GCM-SIV: Nonce Misuse-Resistant Authenticated Encryption.” RFC 8452, 2019.

  6. The AES-GCM guide on this site, whose implementation this attack reuses: /blog/aes_gcm_guide/

A visual representation of recovering an ECDSA private key from two signatures that reused the same nonce
Modern & Applied Cryptography Breakers Advanced

Recovering a DSA or ECDSA Key from a Reused Nonce

DSA and ECDSA stake everything on a secret random nonce that must never repeat. Sign two messages with the same nonce and the private key drops out with a little algebra. This guide runs the real attack against real DSA and secp256k1, the same flaw that broke the PS3 and drained Bitcoin wallets.

12 min read

A visual representation of a faulty RSA-CRT signature being factored by a single gcd
Modern & Applied Cryptography Breakers Advanced

The Bellcore Attack: One Fault Breaks RSA-CRT

Most RSA implementations sign with the Chinese Remainder Theorem for a 4x speedup. A single bit-flip during that computation produces a faulty signature that is correct modulo one prime and wrong modulo the other, and one gcd then factors the key. This guide runs the Bellcore attack on a real 128-byte RSA key.

12 min read

A visual representation of recovering an ECDSA private key from biased-nonce signatures with a lattice
Modern & Applied Cryptography Breakers Advanced

Breaking ECDSA with Biased Nonces: The Hidden Number Problem

ECDSA stays secure only while every nonce is uniform and secret. If each nonce is slightly biased, even with no repeats, a handful of signatures leak the private key. This guide turns biased secp256k1 signatures into a lattice problem and recovers the key with LLL.

16 min read