Chapter 04 · Block ciphers
Confusion and diffusion: from DES to AES
A block cipher scrambles a fixed-size block of bits under a key, so thoroughly that without the key it looks like a random permutation. IBM's Lucifer became the US standard DES in 1977; twenty years later its 56-bit key fell to a machine built for $250,000, and an open competition chose its successor: Rijndael, now AES, the most used cipher in history.
In this chapter
The ciphers of the computer age encrypt bits, and most of them work on blocks: 64 or 128 bits at a time. A block cipher is a family of permutations , one for each key . What we ask of it is easy to state and hard to achieve: for anyone who does not know , should be indistinguishable from a permutation chosen completely at random among the possible ones. This is a pseudorandom permutation. How to encrypt messages longer than one block is the subject of the next chapter; this one is about the block itself.
Horst Feistel's network
Horst Feistel emigrated from Germany to the United States in 1934 and, after years of working on cryptography for the US Air Force, joined IBM, where in the early 1970s he designed Lucifer, a cipher for banks. Its structure, now called a Feistel network, solves a design problem elegantly: how to build an invertible function out of round functions that need not be invertible at all.
Split the block into two halves . Each round, with its own round key , does
For any function , invertible or not, each Feistel round is a bijection, and its inverse is computed with the same : and . Decryption is encryption with the round keys in reverse order.
Proof
From we read directly. Then can be recomputed, and because . is only ever evaluated, never inverted.
In 1988 Michael Luby and Charles Rackoff proved what Feistel had found by engineering: if the round functions are random functions, three rounds already give a pseudorandom permutation, and four rounds give one that resists even an adversary who can also ask for decryptions. Real ciphers use many more rounds because their round functions are not random, only fast.
DES: the Data Encryption Standard
In 1973 the US National Bureau of Standards asked for a public cipher to protect government and commercial data. IBM submitted a version of Lucifer; after review by the NSA it was published in 1977 as DES (FIPS 46): a 16-round Feistel network on 64-bit blocks with a 56-bit key. Its round function expands the half-block to 48 bits, XORs the round key, passes the result through eight S-boxes (small lookup tables, 6 bits in, 4 out, the only non-linear part) and permutes the bits.
Two changes made by the NSA were controversial. The key was shortened from Lucifer's 128 bits to 56, and Whitfield Diffie and Martin Hellman calculated in 1977 that a $20 million machine could find a DES key in a day. And the S-boxes were changed with no explanation, which raised suspicion of a back door. The truth came out in 1990, when Eli Biham and Adi Shamir published differential cryptanalysis, which follows how differences between pairs of plaintexts propagate through the rounds: DES resisted it far better than random S-boxes would. In 1994 Don Coppersmith of IBM confirmed that the designers had known the technique since 1974 and had chosen the S-boxes against it. In 1993 Mitsuru Matsui found linear cryptanalysis, which approximates the cipher by linear equations that hold slightly more than half of the time; it breaks DES with known plaintexts, which was not practical either.
What killed DES was the key length. In 1998 the Electronic Frontier Foundation built Deep Crack, a machine of 1,856 custom chips that cost about $250,000 and found a DES key in 56 hours; in January 1999, with the help of distributed.net's volunteers, it took 22 hours and 15 minutes. Today a key falls in minutes. The desktop app keeps DES only to read old data, and marks it in red.
Why not double DES?
The obvious repair, encrypting twice with two keys, , barely helps.
Given one known pair , double encryption with two -bit keys can be broken with about encryptions and memory, not .
The attack
Encrypt under every and store the results in a table. Then decrypt under every and look up in the table: a match means , so is a candidate. A second known pair eliminates the false candidates. The two halves meet in the middle.
Hence triple DES, , with an effective strength of about 112 bits. It kept banks and payment cards going for twenty more years. Its 64-bit block became its downfall: after about blocks under one key, block collisions become likely (the birthday bound), and the Sweet32 attack of 2016 exploited exactly that in HTTPS and OpenVPN. NIST disallowed triple DES for encryption after 2023.
Blowfish
In 1993 Bruce Schneier published Blowfish, a fast, free, unpatented alternative to DES: a 16-round Feistel network on 64-bit blocks with keys of up to 448 bits, whose S-boxes are generated from the key by a deliberately slow procedure. No practical attack on full Blowfish has been found, but its 64-bit block has the same birthday problem as triple DES, and Schneier himself recommends its successors. Its slow key setup lives on in bcrypt, the password hash. cryptoKit 1.0 offered Blowfish, so version 2 keeps it, marked as legacy.
The AES competition
In 1997 NIST did something new: instead of designing the replacement of DES behind closed doors, it organised an open international competition. Fifteen candidates from twelve countries were submitted in 1998; the cryptographic community attacked them in public for two years; five finalists remained (MARS, RC6, Rijndael, Serpent and Twofish). In October 2000 NIST chose Rijndael, by the Belgian cryptographers Joan Daemen and Vincent Rijmen, for its combination of security, speed on everything from smart cards to servers, and mathematical clarity. It became the Advanced Encryption Standard, FIPS 197, in November 2001. The competition model was so successful that it has been repeated for hash functions (SHA-3), password hashing (Argon2) and post-quantum cryptography.
Inside AES
AES is not a Feistel network but a substitution–permutation network: every round transforms the whole 128-bit block, arranged as a grid of bytes called the state. Its arithmetic lives in a finite field.
A byte is read as the polynomial with coefficients in . Bytes are added with and multiplied as polynomials modulo the irreducible polynomial . With these operations the 256 bytes form the field .
Because is irreducible over , every non-zero byte has a multiplicative inverse , and .
Proof
Polynomials modulo an irreducible polynomial form a field (as integers modulo a prime do): if , then and the extended Euclidean algorithm gives with . The non-zero elements form a group of order 255, so by Lagrange's theorem and .
Each of the 10 rounds of AES-128 (12 for AES-192, 14 for AES-256) applies four steps:
- SubBytes: each byte is replaced by , the inverse in followed by a fixed affine map over bits. Inversion is highly non-linear; the affine map removes its fixed points. This is the confusion.
- ShiftRows: row of the state rotates bytes to the left.
- MixColumns: each column is multiplied by the matrix with rows , , , over . It is maximum distance separable: changing bytes of a column changes at least bytes of the result. With ShiftRows, this is the diffusion.
- AddRoundKey: XOR with a round key derived from the key by the key schedule.
The last round omits MixColumns, and there is an extra AddRoundKey before the first round. Daemen and Rijmen's wide trail strategy proves that any differential or linear trail through four rounds activates at least 25 S-boxes, which bounds the probability of the best trail far below anything exploitable.
The avalanche effect
Diffusion has a visible signature: flip one bit of the plaintext and, after a few rounds, about half of the output bits change, in a pattern that looks random. Horst Feistel called it the avalanche effect. AES achieves full diffusion in two rounds: after round two, every output byte depends on every input byte.
AES today
A quarter of a century after its selection, the best attack on full AES-128, the biclique attack of 2011, needs operations: a factor of four better than brute force, and of no practical importance. The real attacks have been on implementations: Daniel Bernstein showed in 2005 that table-based software leaks the key through cache timing. Since 2010 most processors include AES-NI instructions, which run each round in hardware, fast and in constant time. Against quantum computers, Grover's algorithm would reduce the security of a -bit key to about bits, so AES-256 is the conservative choice for data that must stay secret for decades (see chapter 10).
Further reading
- Horst Feistel, “Cryptography and Computer Privacy”, Scientific American 228(5), 1973.
- Don Coppersmith, “The Data Encryption Standard (DES) and its strength against attacks”, IBM Journal of Research and Development 38(3), 1994.
- Electronic Frontier Foundation, Cracking DES (1998).
- Joan Daemen and Vincent Rijmen, The Design of Rijndael (2002; 2nd ed. 2020).
- NIST, FIPS 197, Advanced Encryption Standard (2001, updated 2023).