BLOCK CIPHER MODES a strong cipher, used wrong, leaks the picture
A block cipher only enciphers one fixed-size block; a mode says how to chain it over a long message. The naive mode, ECB, enciphers each block independently — so identical plaintext blocks become identical ciphertext blocks, and the message’s patterns show straight through (the infamous “ECB penguin”). CBC and CTR fix it by chaining in the previous ciphertext or a counter, so repeats vanish. The cipher can be perfect and the mode still betray you.
THE TECHNIQUE ECB: same block -> same cipher; CBC chains the last block
Encrypt a message with two identical blocks. Under ECB they produce two identical ciphertext blocks — the repeat leaks. Under CBC, each block is XORed with the previous ciphertext first, so the two come out different: live demo
HISTORY & CREDIT ECB/CBC/CFB/OFB: FIPS 81, 1980; CTR 1979
“If the block cipher is secure, any mode is fine.” — no. ECB leaks every repeated block regardless of how strong the cipher is; a bitmap encrypted with AES-ECB still shows its outline. Security is cipher and mode — the mode is not a detail. cited
1979 · Diffie & Hellman — describe counter (CTR) mode. 1980 · FIPS 81 (DES modes of operation) — standardises ECB, CBC, CFB, OFB; CBC chaining is IBM’s (Ehrsam, Meyer, Smith, Tuchman, 1976 patent). 2000s · authenticated modes (GCM, McGrew & Viega) — encryption and integrity in one pass; ECB survives only as a teaching cautionary tale.
CBC needs a random initialisation vector so even two identical messages encrypt differently; the IV is the seed that breaks the last symmetry ECB leaves. A mode is a small state machine wrapped around the block cipher. FIPS 81, 1980
RECOMMEND FOR I-13 the ECB leak, computed
On the canonical compiler ECB maps two identical blocks to identical ciphertext (the leak); CBC chains them apart:
$ i13 run modes.i13 # message = [A, A] (two identical blocks)
ECB: block1 = 41 block2 = 41 -> IDENTICAL (the pattern leaks)
CBC: block1 = 3 block2 = 42 -> different (each XORed with the previous cipher)
Recommend: block-cipher modes are LIT and the mode-matters lesson for I-13 — verified that encrypting two identical blocks under ECB gives identical ciphertext (41, 41 — the repeat leaks) while CBC chains them to 3, 42 by XORing each block with the previous ciphertext. It is a small state machine over any I-13 block cipher (Feistel 190 / SPN 192): CBC and CTR are a few XORs and a carried variable. The honest teaching: a strong cipher used in ECB still betrays structure — correctness is cipher and mode, and a random IV is what finishes the job.