Skip to main content
Challenges GCM: nonce reuse
Cryptography Expert Authenticated encryption Solves: 11

GCM: nonce reuse

Author: CyberSamSU
Points
170

AES-GCM is the most widely used mode today (TLS, VPN, disk encryption). It provides confidentiality (CTR mode) and integrity (GHASH authentication tag) at the same time. But it has one unforgiving condition: you can use a single nonce with a single key only once.

If the nonce is repeated, not only are the plaintexts exposed (as in CTR), but the attacker can also recover the authentication key H and forge a valid tag for any message. This is called the "forbidden attack" (Joux, 2004).

Required formulas

For a single 16-byte block and no AAD (our case), GHASH has a very simple form. Here * is multiplication in GF(2^128), and + is XOR:

H   = AES-ECB(K, 16 ta nol bayt)          <- autentifikatsiya kaliti
L   = 00000000000000000000000000000080    <- uzunliklar bloki
GHASH(C) = ((C * H) + L) * H
TEG(C)   = GHASH(C) + E(J0)               <- E(J0) faqat nonce ga bog'liq

Attack

Two messages are encrypted with the same key and the same nonce, which means E(J0) is the same in both. If we XOR the tags, it cancels out:

T1 + T2 = ((C1 * H) + L) * H  +  ((C2 * H) + L) * H
        = (C1 + C2) * H^2

=>  H^2 = (T1 + T2) * (C1 + C2)^(-1)
=>  H   = (H^2)^(2^127)        <- GF(2^128) da kvadrat ildiz yagona

Once H is found: E(J0) = T1 + GHASH(C1). Now you can calculate a valid tag for any ciphertext.

Given data

nonce = f301895fc7e3d44d2df4b7fa   (ikkala xabarda bir xil!)
P1    = salom_dunyo_2026
C1    = b2db49dd66374de60d0a5109eb674977
T1    = adbfeab583f83ea7d2cdd4ff7cf1341e
C2    = a8d14edb650b41fa3c0b5f34b8252470
T2    = 306b9d610a405cef52c3600dd7d7286e

Task: calculate a valid GCM tag for the following message (with the same key and the same nonce):

P* = "admin=true_hozir"

To do this, first find the keystream (KS = C1 + P1), then C* = P* + KS, and finally T* = GHASH(C*) + E(J0). Write the 16 bytes of the tag in lowercase hex format:

BAYROQ{A3S_gcm_forge_<teg hex>}

GF(2^128) arithmetic is provided ready-to-use in the attached gf128.py file (gf_mul, gf_pow, gf_inv). You can run it to ensure the functions work correctly.

Check: if you found H correctly, the equation T2 = GHASH(C2) + E(J0) must also hold true. This will show you an error immediately.

Attached files
gf128.py Log in to download
SHA-256 checksums
gf128.py: 23d0dc635d15b9a6c65cb9f4edefd841287cf72adc27762c96a81f624493fd51
Theory: learn the topic
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −17 pts Log in
Hint 2 −34 pts Log in
Hint 3 −51 pts Log in
To submit a flag, log in.

First solvers

1. Stiv_084100 10.09.2026
2. W.o.X 11.09.2026
3. Абдул 15.09.2026
4. Лазиз 01.10.2026
5. bunyod 05.10.2026
6. testrejim 09.10.2026
7. 11111tttt 09.10.2026
8. Mirjaxon Qaxxarov 26.10.2026
9. Odam 04.11.2026
10. Ulugʻbek 27.11.2026