Crypto Lecture 5 · AES, One Round at a Time

A step-by-step rebuild of the lecture's AES section. Students compute SubBytes, ShiftRows, a MixColumns column and the key schedule's g function by hand on the FIPS-197 example, watch one flipped bit spread through two rounds, and see why removing any one step breaks the cipher, before covering decryption and how AES fails in practice.

Subject: Computer Security · 74 slides · code lesson

Open the interactive version of this deck

What this lesson covers

The lesson, slide by slide

1. AES, One Round at a Time

Title

Crypto Lecture 5

SubBytes, ShiftRows, MixColumns, AddRoundKey and the key schedule, computed by hand on the standard's own example

2. Part 1 — From DES to AES

Section

Why a new standard, and the whole cipher on one page

3. What you will be able to do

Objectives

This lesson opens AES the way the lecture opened MD5: one box at a time, with real bytes from the standard's worked example, so that every number on the slides is one you could reproduce with a pencil.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes

4. Warm-up: what killed DES?

Warm-up

The last part of the lecture took DES apart. Before meeting its replacement, pull the key facts back out of memory.

Discussion prompt

How long is a DES key, how many keys does that give, and why was that a problem by the late 1990s?

Hint: Count the key bits, then think about what hardware could do by 1998.

Answer:

A DES key is 56 bits, so there are 2 to the power 56 keys, about 7.2 times 10 to the 16. That sounded like a lot in 1977. In 1998 the EFF built a machine, Deep Crack, that searched the key space in about 56 hours.

Nothing was wrong with the Feistel design itself; the key was simply too short to survive cheaper hardware. A replacement needed a much longer key and a larger block, and it needed to earn trust in public, which is how AES was chosen.

5. AES replaced DES in 2001

Concept

In 1997 NIST asked the world for a replacement for DES. Fifteen candidate designs were submitted and attacked in public for three years. The winner, Rijndael by the Belgian cryptographers Joan Daemen and Vincent Rijmen, became the Advanced Encryption Standard in 2001.

DESAES
standard since19772001, after an open competition with 15 candidates
designed byIBM, with changes by the NSADaemen and Rijmen, as Rijndael
block size (bits encrypted at once)64 bits128 bits
key size56 bits128, 192 or 256 bits
rounds1610, 12 or 14

The process matters as much as the design. Nobody had to trust the winner on faith: every candidate's internals were public, and the best cryptanalysts in the world spent years trying to break them. From here on we use AES-128, the version with a 128-bit key and ten rounds.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes

6. How much bigger is the AES-128 key space?

Estimation

DES has 2 to the power 56 keys. AES-128 has 2 to the power 128.

Predict first

How many times more AES-128 keys are there than DES keys?

  • About twice as many
  • About 72 times as many
  • About 4.7 times 10 to the 21 times as many
  • About 10 to the 128 times as many

Correct: About 4.7 times 10 to the 21 times as many

Why: Dividing the counts gives 2 to the power 128 minus 56, which is 2 to the 72, about 4.7 times 10 to the 21. If Deep Crack's 56 hours were sped up a billion times, searching AES-128 would still take on the order of 30 billion years. Adding bits multiplies the work; it does not add to it.

7. The whole of AES on one page

Concept

AES treats the 16 plaintext bytes as a 4 by 4 grid called the state. It XORs the key into the state once, then runs ten rounds. Every round applies the same four steps, and every round uses its own round key, made from the original key by the key schedule.

Figure (svg): The AES pipeline: plaintext, XOR with K0, then a round of SubBytes, ShiftRows, MixColumns and AddRoundKey repeated ten times, with a key schedule producing K0 to K10 on the side, then ciphertext

stepwhat it doesuses the key?
SubBytesreplaces each byte using one fixed tableno
ShiftRowsrotates row r left by r placesno
MixColumnsmixes the four bytes of each column (skipped in round 10)no
AddRoundKeyXORs in the round key Kryes, the only step that does

Each numbered box gets its own slides next. Keep this map in view: whenever a detail feels lost, ask which box it belongs to and what that box is for.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-map

8. Put one AES encryption in order

Ranking

Use the map. Order the operations from the plaintext to the end of round 1.

Put in order

  1. XOR the state with K0, the key itself
  2. SubBytes: look up every byte in the S-box
  3. ShiftRows: rotate row r left by r
  4. MixColumns: mix each column
  5. AddRoundKey: XOR in K1

Why: The key goes in once before any round, then every round runs SubBytes, ShiftRows, MixColumns, AddRoundKey in that order. Rounds 2 to 9 repeat the same four steps with K2 to K9, and round 10 drops MixColumns.

9. Which step has which job?

Matching

Each step looks simple on its own. Match each one to the job it does for the cipher as a whole; the second half of the lesson shows why each job is needed.

Match the pairs

  • sb. SubBytes
  • sr. ShiftRows
  • mc. MixColumns
  • ar. AddRoundKey
  • nl. the only non-linear step: it breaks any simple algebraic pattern
  • mv. moves bytes between columns
  • mx. makes each byte of a column depend on all four
  • key. the only place the secret enters a round

Why: SubBytes provides non-linearity, ShiftRows and MixColumns together provide diffusion (a change anywhere spreads everywhere), and AddRoundKey is what makes the result depend on the key. Remove any one and a different property is lost.

10. Part 2 — One round, step by step

Section

Real bytes from the FIPS-197 example

11. The plaintext becomes a grid, then meets K0

Concept

Our running example is the one printed in the standard itself: plaintext 00 11 22 ... ff and key 00 01 02 ... 0f. AES writes the 16 bytes into the 4 by 4 grid column by column: the first four bytes fill column 0, the next four fill column 1, and so on.

Figure (svg): Three 4 by 4 grids: the plaintext 00 to ff filled column by column, XOR the key grid 00 to 0f, equals the state 00 10 20 ... f0; one byte is worked in bits, 11 xor 01 = 10

Before round 1, every byte of the grid is XORed with the key byte in the same position. This first round key, K0, is simply the key itself. With this key and plaintext the result is especially tidy: 00 10 20 30 down column 0, then 40 50 60 70, and so on.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-state

12. Your turn: the first XOR

Fill the middle

Column 1 of the plaintext grid is 44 55 66 77 and column 1 of the key grid is 04 05 06 07. Write each result in lowercase hex.

Fill in the blanks

44 xor 04 = 40
55 xor 05 = 50
66 xor 06 = 60
77 xor 07 = 70

Why: XOR works bit by bit with no carries. 55 is 0101 0101 and 05 is 0000 0101, so the low four bits cancel and leave 0101 0000 = 50. The same happens for 66 xor 06 = 60 and 77 xor 07 = 70: in this example each key byte exactly cancels the low hex digit of its plaintext byte.

13. Step 1: SubBytes looks up every byte

Concept

SubBytes replaces each byte of the state with its entry in one fixed 256-entry table, the AES S-box. It is the same idea as the DES S-boxes, but with 8 bits in and 8 bits out. The first hex digit of the byte picks the row of the table and the second picks the column.

Figure (svg): Before and after grids for SubBytes; the byte 10 is looked up at row 1, column 0 of the S-box, giving ca

byteS-box row, columnresult
00row 0, column 063
10row 1, column 0ca
20row 2, column 0b7
30row 3, column 004

Three facts matter. Every byte is replaced on its own, with the same table. The table is one-to-one, so the step can be undone, which AES needs because it has no Feistel structure. And it is the only non-linear step in the whole cipher: the table follows no simple algebraic rule, so the S-box of an XOR is not the XOR of the S-boxes.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-sub

14. Look up the rest of column 1

Faded example

Column 0 of the AES S-box, read down rows 4 to 7, holds 09, 53, d0, 51. Our state's column 1 is 40 50 60 70, so each byte uses column 0 of the table. The first lookup is done.

Fill in the blanks

S[40] = 09
S[50] = 53
S[60] = d0
S[70] = 51

Why: For 50 the first digit 5 picks row 5 and the second digit 0 picks column 0, which holds 53; likewise S[60] = d0 and S[70] = 51. After SubBytes the whole state is 63 ca b7 04 | 09 53 d0 51 | cd 60 e0 e7 | ba 70 e1 8c, which matches the standard.

15. Two truths and a myth about the S-box

Two truths and a lie

Each statement is about the S-box used by SubBytes.

Eliminate the wrong options

Which statement is the myth?

  • t1. The same table is used for every byte, every round and every key
  • t2. No two inputs give the same output, so SubBytes can be undone
  • m. The table is secret, which is where AES gets its security

Survives elimination: m

Why: The S-box is printed in the standard for everyone to read; Kerckhoffs's principle says the only secret is the key. SubBytes contributes non-linearity, not secrecy. Its table was chosen so that no simple equation relates inputs and outputs.

16. Step 2: ShiftRows slides row r left by r

Concept

ShiftRows rotates each row of the state to the left. Row 0 stays where it is, row 1 moves one place, row 2 two places and row 3 three places. Bytes that fall off the left edge come back on the right.

Figure (svg): Before and after grids for ShiftRows; row 0 unchanged, rows 1 to 3 rotated left by 1, 2 and 3 places, with wrapped bytes in red

Who decides the amounts? The standard does. Row r always moves r places, for every key and every round; no key is involved. On its own this step looks like it achieves nothing, since every byte keeps its value. Its purpose shows up on the MixColumns slides: after ShiftRows, the four bytes in each column came from four different columns.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-shift

17. Your turn: shift the bottom rows

Fill the middle

After SubBytes, row 2 of the state reads b7 d0 e0 e1 and row 3 reads 04 51 e7 8c (left to right). Shift row 2 left by two places and row 3 left by three.

Fill in the blanks

row 2: b7 d0 e0 e1 -> e0 e1 b7 d0
row 3: 04 51 e7 8c -> 8c 04 51 e7

Why: Shifting left by two moves the first two bytes, b7 d0, to the end, giving e0 e1 b7 d0. Shifting left by three is the same as shifting right by one, so the last byte 8c comes to the front: 8c 04 51 e7. Together with rows 0 and 1, the new columns read 63 53 e0 8c, 09 60 e1 04, cd 70 b7 51 and ba ca d0 e7.

18. Where did the new column 0 come from?

Prediction

After ShiftRows, column 0 holds 63 53 e0 8c.

Predict first

From how many different columns of the state before ShiftRows did these four bytes come?

  • One: they were already together
  • Two
  • Three
  • Four: one from each column

Correct: Four: one from each column

Why: 63 stayed in column 0 (row 0 does not move), 53 came from column 1, e0 from column 2 and 8c from column 3. Every column after ShiftRows gathers one byte from each old column, which is exactly what MixColumns needs in order to spread information across the whole state.

19. Step 3: MixColumns needs three byte tools

Concept

MixColumns turns the four bytes of a column into four new bytes, each one a mix of all four old ones. Ordinary arithmetic would overflow a byte, so AES uses byte arithmetic that always stays inside 8 bits. Only three tools are needed: add, double and triple.

toolruleexample
addXOR, bit by bit, no carries63 + 53 = 0110 0011 xor 0101 0011 = 0011 0000 = 30
doubleshift the bits left by one2*63: 0110 0011 becomes 1100 0110 = c6
double, with overflowif a 1 falls off the left, drop it and XOR 1b2*e0: 1100 0000 xor 0001 1011 = 1101 1011 = db
tripledouble, then XOR the byte itself353 = 253 xor 53 = a6 xor 53 = f5

Why XOR 1b after an overflow? The bit that fell off stands for a value one byte cannot hold, and the standard folds it back in by XORing the fixed byte 1b. This keeps every product inside one byte and, just as importantly, keeps the arithmetic reversible, so MixColumns can be undone.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-bytes

20. Use the byte tools

Faded example

Double and triple some bytes. 53 is 0101 0011 and e0 is 1110 0000. The first line is done.

Fill in the blanks

2*63 = c6
2*53 = a6 # shift left, no overflow
353 = f5 # 253 xor 53
2*e0 = db # shift left, a 1 falls off: xor 1b

Why: Shifting 0101 0011 left gives 1010 0110 = a6, with no bit falling off. Tripling is a6 xor 53 = 1111 0101 = f5. Shifting e0 = 1110 0000 left gives 1100 0000 with a 1 falling off the top, so XOR 1b: 1100 0000 xor 0001 1011 = 1101 1011 = db.

21. Push the boundary: why not just drop the overflow?

Edge cases

Suppose doubling simply threw away the bit that falls off, without XORing 1b.

Discussion prompt

Doubling 80 and doubling 00 would then both give 00. Why is that a disaster for MixColumns, and what does XORing 1b fix?

Hint: Can two different inputs be sent to the same output?

Answer:

If two different bytes double to the same result, doubling is no longer one-to-one, and information is destroyed. MixColumns built on it could send two different columns to the same output, and then decryption could not tell which one was meant.

XORing 1b makes doubling a permutation of the 256 byte values: 80 doubles to 1b, not 00. Byte arithmetic with this rule is a finite field with 256 elements, where every non-zero byte can be divided by, which is what lets the inverse MixColumns exist.

22. Worked example: MixColumns on column 0

Worked example

After ShiftRows, column 0 is 63 53 e0 8c. Each new byte is one row of a fixed matrix times this column: multiply each old byte by 1, 2 or 3 using the byte tools, then XOR the four products.

Row 0 is 02 03 01 01

Why: 263 xor 353 xor e0 xor 8c = c6 xor f5 xor e0 xor 8c = 5f

Row 1 is 01 02 03 01

Why: 63 xor 253 xor 3e0 xor 8c = 63 xor a6 xor 3b xor 8c = 72

Row 2 is 01 01 02 03

Why: 63 xor 53 xor 2e0 xor 38c = 63 xor 53 xor db xor 8f = 64

Row 3 is 03 01 01 02

Why: 363 xor 53 xor e0 xor 28c = a5 xor 53 xor e0 xor 03 = 15

Verify: compare with the standard

Why: The new column 0 is 5f 72 64 15, exactly the first four bytes of the state after MixColumns printed in FIPS-197 appendix C.1.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-mix

23. The mixing, as a picture

Picture it

Lay the computation out as a matrix times a column. Each input byte has its own colour, and each output byte uses all four colours.

Figure (svg): The fixed matrix with rows 02 03 01 01, 01 02 03 01, 01 01 02 03, 03 01 01 02, times column 63 53 e0 8c, equals 5f 72 64 15, with the four XOR sums written beside each output byte

The other three columns are mixed the same way, with the same matrix. ShiftRows spreads bytes across columns and MixColumns mixes each column, so after two rounds every output byte depends on every input byte.

24. Your turn: MixColumns on column 1

Faded example

Column 1 after ShiftRows is 09 60 e1 04. Useful products: 209 = 12, 360 = a0, 260 = c0, 3e1 = 38. Row 0 is done for you.

Fill in the blanks

row 0: 209 xor 360 xor e1 xor 04 = 12 xor a0 xor e1 xor 04 = 57
row 1: 09 xor 260 xor 3e1 xor 04 = 09 xor c0 xor 38 xor 04 = f5

Why: Row 1 of the matrix is 01 02 03 01, so the products are 09, 260 = c0, 3e1 = 38 and 04. XOR them in any order: 09 xor c0 = c9, c9 xor 38 = f1, f1 xor 04 = f5. The full new column 1 is 57 f5 bc 92, matching the standard.

25. Step 4: AddRoundKey XORs in the round key

Concept

AddRoundKey XORs every byte of the state with the byte in the same position of this round's key. In round 1 that is K1, which the key schedule will produce in Part 3.

Figure (svg): The state after MixColumns XOR round key K1 equals the state after round 1; one byte worked in bits, 5f xor d6 = 89

It is the only step in a round that uses the key, which is why every round needs a different round key. And because XOR undoes itself, decryption removes a round key simply by XORing the same key again.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-ark

26. Your turn: finish round 1, column 0

Fill the middle

Column 0 after MixColumns is 5f 72 64 15 and the first word of K1 is d6 aa 74 fd. The first byte is done.

Fill in the blanks

5f xor d6 = 89
72 xor aa = d8
64 xor 74 = 10
15 xor fd = e8

Why: 72 = 0111 0010 and aa = 1010 1010 give 1101 1000 = d8. 64 = 0110 0100 and 74 = 0111 0100 give 0001 0000 = 10. 15 = 0001 0101 and fd = 1111 1101 give 1110 1000 = e8. Column 0 of the state after round 1 is 89 d8 10 e8, as the standard prints.

27. One AES round, as a recipe

Pattern

Everything in Part 2, as a procedure you can run by hand or recognise in code.

  1. Before round 1: write the 16 bytes into the grid column by column and XOR the key, K0
  2. SubBytes: replace each byte with S[byte], first hex digit = row, second = column
  3. ShiftRows: rotate row r left by r places
  4. MixColumns (rounds 1 to 9 only): each new byte = one matrix row times the column, using XOR, doubling with the 1b rule, and tripling
  5. AddRoundKey: XOR in this round's key Kr

Three of the four steps are fixed public operations. Only the XORs with round keys depend on the secret, which is why the key schedule, next, matters so much.

28. Checkpoint: where the key enters

Check

Solve it on paper before you click.

Check your understanding

In one round of AES, which steps depend on the key?

  • A. Only AddRoundKey (correct)
  • B. SubBytes and AddRoundKey, because the S-box is chosen by the key
  • C. All four steps
  • D. MixColumns and AddRoundKey, because the matrix comes from the key

Answer: A

Why: SubBytes, ShiftRows and MixColumns are fixed by the standard and identical for every key. The secret enters a round only through AddRoundKey, as the XOR with the round key Kr.

Why B tempts people
The S-box is one fixed public table. Some older ciphers used key-dependent S-boxes, but AES does not.
Why C tempts people
Three of the steps are public permutations; anyone can compute them without the key.
Why D tempts people
The MixColumns matrix, rows 02 03 01 01 and its rotations, is printed in the standard and never changes.

29. Part 3 — The key schedule

Section

One 16-byte key becomes eleven round keys

30. The key is a grid, just like the message

Concept

The key is written into a 4 by 4 grid column by column, exactly like the message. One column of the key, 4 bytes, is called a word: w0 = 00 01 02 03, w1 = 04 05 06 07, w2 = 08 09 0a 0b, w3 = 0c 0d 0e 0f. Those four words are K0.

The key schedule keeps making one new word at a time until it has 44 words. Every four consecutive words form one round key.

round keywordsused in
K0w0 to w3, the key itselfthe XOR before round 1
K1w4 to w7AddRoundKey in round 1
K2w8 to w11AddRoundKey in round 2
.........
K10w40 to w43AddRoundKey in round 10

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-keys

31. How much key material does AES-128 use?

Estimation

Eleven round keys of 16 bytes each, made from one 16-byte key.

Predict first

How many bytes of round-key material does one AES-128 encryption use, and how many of them are actually secret information?

  • 16 bytes in total, all of it secret
  • 176 bytes in total, but only 16 bytes of secret information
  • 176 bytes in total, all of it independent secret information
  • 128 bytes in total, 16 of them secret

Correct: 176 bytes in total, but only 16 bytes of secret information

Why: 44 words of 4 bytes is 176 bytes. But every word is computed from the 16-byte key by public rules, so there are still only 2 to the power 128 possibilities in total. The schedule stretches the key; it cannot add secrecy that was not there.

32. A word is the one above XOR the one to its left

Concept

Arrange the 44 words in rows of four, one row per round key. Then the rule of the key schedule is a picture: every new word is the word directly above it XOR the word just to its left.

Figure (svg): Rows of four words for K0, K1 and K2 with arrows from the word above and the word to the left; the first word of each row receives the last word of the row above through g

The first word of a row has nothing to its left, so it uses the last word of the row above, sent first through a scrambling function called g. In index form: w[i] = w[i-4] xor w[i-1], except that when i is a multiple of 4, w[i-1] is replaced by g(w[i-1]).

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-keys-picture

33. Your turn: the rest of K1

Fill the middle

w4 = d6aa74fd is given (it needs g, which comes next). The other three words of K1 use only XOR: each is the word above XOR the word to its left.

Fill in the blanks

w5 = w1 xor w4 = 04050607 xor d6aa74fd = d2af72fa
w6 = w2 xor w5 = 08090a0b xor d2af72fa = daa678f1
w7 = w3 xor w6 = 0c0d0e0f xor daa678f1 = d6ab76fe

Why: XOR byte by byte: 04 xor d6 = d2, 05 xor aa = af, 06 xor 74 = 72, 07 xor fd = fa, so w5 = d2af72fa. Then w6 = daa678f1 and w7 = d6ab76fe. Together K1 = d6aa74fd d2af72fa daa678f1 d6ab76fe, the round key printed in the standard.

34. Worked example: g on w3, then w4

Worked example

g takes one word and returns a scrambled word, reusing the S-box from SubBytes. Here it is on w3 = 0c 0d 0e 0f, the last word of K0, producing the first word of K1.

Figure (svg): The g pipeline: w3 = 0c 0d 0e 0f, rotate to 0d 0e 0f 0c, S-box to d7 ab 76 fe, XOR Rcon 01 00 00 00 to d6 ab 76 fe; then w0 xor g(w3) = d6 aa 74 fd

1. Rotate

Why: Move the first byte to the end: 0c 0d 0e 0f becomes 0d 0e 0f 0c.

2. S-box

Why: Replace each byte with its S-box entry: S[0d] = d7, S[0e] = ab, S[0f] = 76, S[0c] = fe, giving d7 ab 76 fe.

3. XOR the round constant

Why: Rcon for K1 is 01 00 00 00, so only the first byte changes: d7 xor 01 = d6. g(w3) = d6 ab 76 fe.

4. The usual XOR

Why: w4 = w0 xor g(w3) = 00010203 xor d6ab76fe = d6aa74fd.

Verify: compare with the standard

Why: d6aa74fd is the first word of K1 in FIPS-197, and the same value used in AddRoundKey for round 1.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-g-how

35. Your turn: g on w7, for K2

Faded example

w7 = d6 ab 76 fe. Its rotated bytes run through the S-box as S[ab] = 62, S[76] = 38, S[fe] = bb, S[d6] = f6. K2 uses round constant 02 00 00 00.

Fill in the blanks

rotate: d6 ab 76 fe -> ab 76 fe d6
S-box: -> 62 38 bb f6
xor Rcon: 62 xor 02 = 60
g(w7) = 60 38 bb f6

Why: Rotating moves d6 to the end: ab 76 fe d6. The S-box gives 62 38 bb f6. Only the first byte meets the round constant: 62 xor 02 = 60, so g(w7) = 60 38 bb f6. Then w8 = w4 xor g(w7) = d6aa74fd xor 6038bbf6 = b692cf0b, the first word of K2.

36. Each round key gets a different Rcon

Concept

The round constant Rcon is one byte followed by 00 00 00, so it only ever changes the first byte of g. Each round key K1 to K10 has its own byte, and the bytes come from one simple rule: start at 01 and double each time, with the same 1b overflow rule as MixColumns.

round keyg input after rotate and S-boxRcon bytefirst byte of g
K1, from g(w3)d7 ab 76 fe01d7 xor 01 = d6
K2, from g(w7)62 38 bb f60262 xor 02 = 60
K8, from g(w31)d3 ba f7 2f80d3 xor 80 = 53
K9, from g(w35)08 da b5 e41b08 xor 1b = 13

The sequence is 01, 02, 04, 08, 10, 20, 40, 80, then 1b, then 36. Doubling 80 = 1000 0000 pushes the top bit out, so instead of 00 we XOR 1b, exactly as in MixColumns; doubling 1b then gives 36.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-rcon

37. Your turn: the Rcon sequence

Fill the middle

Start at 01 and double, one byte per round key. Doubling a byte whose top bit is 1 drops that bit and XORs 1b.

Fill in the blanks

K1 01, K2 02, K3 04, K4 08, K5 10, K6 20, K7 40, K8 80, K9 1b, K10 36

Why: 80 is 1000 0000. Shifting left pushes the 1 out and leaves 0000 0000, so we XOR 1b and get 1b. Doubling 1b = 0001 1011 gives 0011 0110 = 36, with no overflow. These are the ten round constants listed in the standard.

38. Why does the key schedule need g?

Socratic

Suppose we drop g and build every word with XOR alone. Alice happens to pick the all-zero key.

Discussion prompt

What would her round keys be, and what would AddRoundKey then do? Then predict what changes if g has rotate and S-box but no round constant.

Hint: What is zero XOR zero?

Answer:

With XOR alone, zero XOR zero is zero, so every round key is zero and AddRoundKey does nothing at all. More generally, every round key word would be a fixed XOR combination of the four key words, a pattern anyone can write down.

key scheduleK1K2
XOR only00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000
XOR, rotate, S-box63636363 63636363 63636363 6363636398989898 fbfbfbfb 98989898 fbfbfbfb
full g, with Rcon62636363 62636363 62636363 626363639b9898c9 f9fbfbaa 9b9898c9 f9fbfbaa

With rotate and S-box, 00 becomes 63, but every byte of each word stays identical because the key's bytes were identical: the key's symmetry survives. The round constant touches only the first byte, turning 63 into 62, and from K2 on the pattern is broken. The S-box brings non-linearity; Rcon makes every round different.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-g-why

39. Which part of g does which job?

Discrimination

Each piece of g fixes a different weakness. Sort each claim to the piece it describes.

Sort into buckets

Which piece of g is responsible?

the S-box
Without it, round keys would be XOR combinations of the key words
the round constant
Breaks the symmetry when all key bytes are equal; Makes round 2 differ from round 1 even for a symmetric key
the rotation
Changes which byte position each byte of the word lands in
sbox
The S-box is the only non-linear piece. Without it the whole schedule is linear, so every round key is a fixed XOR combination of the original key words.
rcon
The round constant is different for every round key and touches one byte, so it breaks symmetries that the S-box preserves, like four identical bytes in a word.
rot
Rotation moves each byte to a different position in the word, so bytes of the key mix across positions over the rounds.

40. All 11 round keys, and where each is used

Concept

Running the schedule to the end for the key 000102...0f gives these round keys, exactly as printed in the standard's appendix.

keywordsbytesRconused in
K0w0-w300010203 04050607 08090a0b 0c0d0e0f-before round 1
K1w4-w7d6aa74fd d2af72fa daa678f1 d6ab76fe01round 1
K2w8-w11b692cf0b 643dbdf1 be9bc500 6830b3fe02round 2
K3w12-w15b6ff744e d2c2c9bf 6c590cbf 0469bf4104round 3
K4w16-w1947f7f7bc 95353e03 f96c32bc fd058dfd08round 4
K5w20-w233caaa3e8 a99f9deb 50f3af57 adf622aa10round 5
K6w24-w275e390f7d f7a69296 a7553dc1 0aa31f6b20round 6
K7w28-w3114f9701a e35fe28c 440adf4d 4ea9c02640round 7
K8w32-w3547438735 a41c65b9 e016baf4 aebf7ad280round 8
K9w36-w39549932d1 f0855768 1093ed9c be2c974e1bround 9
K10w40-w4313111d7f e3944a17 f307a78b 4d2b30c536round 10

Every round key follows from the one before it by public rules. That cuts both ways, as the next slide asks.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-keys-all

41. If one round key leaks, is the rest safe?

Counterexample

A designer argues: an attacker who learns only K10, the last round key, still knows nothing useful, because the real key is K0.

Discussion prompt

Is that right? Use the rule w[i] = w[i-4] xor w[i-1] to decide.

Hint: Can you solve the rule for w[i-4]?

Answer:

No. The rule can be run backwards: w[i-4] = w[i] xor w[i-1], with g applied where the forward rule used it. Starting from the four words of K10, you can recover K9, then K8, and so on down to K0, which is the key itself.

So in AES-128, knowing any single round key is the same as knowing the key. This is why side channels that leak the last round key, for example through power or timing measurements of the final round, are treated as complete key recovery. The defence lies in the implementation, not the schedule.

42. Part 4 — The whole cipher

Section

Ten rounds, and what they do to a single flipped bit

43. The FIPS-197 example through all ten rounds

Concept

Here is the complete encryption of our example. Round 1 is shown step by step, and every earlier slide used one piece of it. Rounds 2 to 9 repeat the same four steps with the next round key, and round 10 skips MixColumns.

plaintext      00112233445566778899aabbccddeeff
xor K0         00102030405060708090a0b0c0d0e0f0
r1 SubBytes    63cab7040953d051cd60e0e7ba70e18c
r1 ShiftRows   6353e08c0960e104cd70b751bacad0e7
r1 MixColumns  5f72641557f5bc92f7be3b291db9f91a
r1 xor K1      89d810e8855ace682d1843d8cb128fe4
r2 end         4915598f55e5d7a0daca94fa1f0a63f7
r3 end         fa636a2825b339c940668a3157244d17
r4 end         247240236966b3fa6ed2753288425b6c
r5 end         c81677bc9b7ac93b25027992b0261996
r6 end         c62fe109f75eedc3cc79395d84f9cf5d
r7 end         d1876c0f79c4300ab45594add66ff41f
r8 end         fde3bad205e5d0d73547964ef1fe37f1
r9 end         bd6e7c3df2b5779e0b61216e8b10b689
r10 (no Mix)   69c4e0d86a7b0430d8cdb78070b4c55a   # the ciphertext
linewhat produced itchecked against
xor K0the key itself, before any roundthe figure on the state slide
r1 SubBytes to r1 xor K1the four steps you computed by handthe worked examples and exercises
r2 end to r9 endnine more rounds with K2 to K9FIPS-197 appendix C.1
r10SubBytes, ShiftRows, xor K10, no MixColumnsopenssl enc -aes-128-ecb gives the same 32 hex digits

Every value was produced by a short reference implementation written for this deck and agrees with the standard's appendix and with OpenSSL. Writing such an implementation, about 60 lines of Python, is an excellent way to make each box concrete.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-trace

44. Why can round 10 skip MixColumns?

Prediction

The last round runs SubBytes, ShiftRows and AddRoundKey, but no MixColumns.

Predict first

Why does dropping MixColumns from the final round cost no security?

  • It does cost security; it was dropped only for speed
  • A final MixColumns after the last key would be a public step anyone could undo, so it adds nothing
  • Round 10 uses a stronger round key that makes up for it
  • MixColumns would make the ciphertext longer

Correct: A final MixColumns after the last key would be a public step anyone could undo, so it adds nothing

Why: MixColumns is fixed and public. If it came after the last key XOR, anyone could simply apply the inverse to the ciphertext. Mixing only protects anything when a secret key is added after it, so the designers removed it from the last round, which also makes decryption line up neatly with encryption.

45. One flipped bit, followed through two rounds

Concept

Encrypt our plaintext twice with the same key, the second time with its lowest bit flipped, so 00 becomes 01. At each stage, XOR the two states: red bytes are where the states differ.

Figure (svg): Five difference grids: start with 1 differing bit, 5 bits after SubBytes, 17 bits in one column after MixColumns, 16 bits in four columns after round 2 ShiftRows, 64 bits in all 16 bytes after round 2 MixColumns

stagedifferencebits that differ
start01 in byte 01
round 1 SubBytes1f in byte 05
round 1 MixColumns3e 1f 1f 21 in column 017
round 2 ShiftRowsfour bytes, now in four different columns16
round 2 MixColumnsall 16 bytes differ64

SubBytes turns one flipped bit into five inside the same byte. MixColumns spreads that byte to its whole column: the differences are 21f, 1f, 1f and 31f, using the byte tools. ShiftRows sends those four bytes into four different columns, and the next MixColumns fills the grid. Two rounds give full diffusion.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-avalanche

46. Where is AddRoundKey in that picture?

Prediction

The difference grids skipped every AddRoundKey.

Predict first

Why can the AddRoundKey steps be left out when tracking the difference between two encryptions under the same key?

  • Because AddRoundKey is skipped in the first two rounds
  • Because XORing the same round key into both states leaves their XOR unchanged
  • Because AddRoundKey only changes the key, not the state
  • Because the difference is always zero after AddRoundKey

Correct: Because XORing the same round key into both states leaves their XOR unchanged

Why: If the states are A and B, then (A xor K) xor (B xor K) = A xor B, because K cancels. AddRoundKey hides the states themselves, but it never changes how two states under the same key differ. The spreading of a difference comes entirely from the other three steps.

47. Ten thousand flips: the count is a coin toss

Picture it

The lecture repeated the experiment with a random key, a random plaintext and one random bit flipped, ten thousand times, counting how many of the 128 ciphertext bits changed. We reran it 3,000 times with our reference AES and recorded the count after every round.

Figure (svg): Average number of differing bits after each round with one-standard-deviation bars: about 16 after round 1, about 64 from round 2 on, with the spread settling to about 5.7 from round 3

Round 1 changes about 16 bits, one column's worth. Round 2 already averages 64 but with a wider spread, about 8.2, because the bits are not yet independent. From round 3 on, every round looks the same: an average of 64 with a standard deviation of about 5.7, which is exactly what 128 fair coin tosses would give. Ten rounds is a wide safety margin over the two that diffusion needs.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-avalanche-count

48. Is 71 changed bits suspicious?

Estimation

For 128 fair coins the average number of heads is 64 and the standard deviation is the square root of 128 times one quarter, which is the square root of 32, about 5.66.

Predict first

One run flips a plaintext bit and sees 71 ciphertext bits change. What should you conclude?

  • AES is leaking: more than half the bits changed
  • Nothing: 71 is about 1.2 standard deviations above 64, well within normal variation
  • The key was weak
  • The implementation has a bug, because exactly 64 should change

Correct: Nothing: 71 is about 1.2 standard deviations above 64, well within normal variation

Why: 71 minus 64 is 7, and 7 divided by 5.66 is about 1.24. Roughly a fifth of runs land at least that far above or below the mean. Exactly 64 every time would actually be the suspicious result, since real coin tosses vary. In our 3,000 runs the round-10 counts ranged from 44 to 90.

49. Part 5 — Remove one step, and AES breaks

Section

Every step has exactly one job

50. What if we drop one step?

Prediction

Each of the four steps looks simple. Imagine removing one of them from all ten rounds, keeping everything else.

Predict first

Which removals leave AES secure?

  • Removing ShiftRows, since MixColumns already mixes
  • Removing MixColumns, since ten rounds of S-boxes are plenty
  • Removing SubBytes, since AddRoundKey still adds the key
  • None: every single removal breaks AES, each in a different way

Correct: None: every single removal breaks AES, each in a different way

Why: Without SubBytes AES becomes linear. Without ShiftRows it splits into four 32-bit ciphers. Without MixColumns it splits into sixteen 1-byte ciphers. Without AddRoundKey it has no key at all. The next slides take each case in turn and name the property that is lost.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-remove

51. Without SubBytes, the keys pile up at the end

Concept

Suppose SubBytes is removed. What is left in each round is ShiftRows and MixColumns, call them L, followed by a key XOR. Both of those steps are linear: applying L to an XOR gives the XOR of the separate results, L(x xor k) = L(x) xor L(k).

That one property lets every key XOR be pushed past every L to the end of the cipher. The whole encryption collapses to a public scrambling of the plaintext, followed by one constant that depends only on the key.

what it isdepends on the key?
LShiftRows and MixColumns of all ten rounds, composedno, it is public
c_Kall eleven round keys, pushed through to the end and combinedyes, but it is one fixed 16-byte value
E(P)L(P) xor c_Konly through that single constant

A cipher of the form public function XOR constant is a disguised one-time pad that reuses its pad for every message. SubBytes is exactly what prevents this, because the S-box of an XOR is not the XOR of the S-boxes. That is what the lecture means by calling it the only non-linear step.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-sub-attack

52. Without SubBytes: two keys, the same leak

Anomaly

Here is real output from AES with SubBytes removed. The same two messages are encrypted under two completely different keys, and the two ciphertexts of each pair are XORed.

# AES with SubBytes removed; P0 = "meet me at noon!", P1 = "attack at dawn!!"
key 000102...0f   C0 xor C1 = 562ff5622065925679fa82f449ccb6ad
key 2b7e15...3c   C0 xor C1 = 562ff5622065925679fa82f449ccb6ad
observationwhat it means
the two XORs are identicalthe key constant c_K cancels, so C0 xor C1 depends only on the plaintexts
C0 xor C1 is L applied to P0 xor P1L is public, so the relation between the two plaintexts is exposed
it happens for every pair of messagesworse than a reused one-time pad, which leaks only when a key is reused

Predict first

Which earlier failure does this resemble most closely?

  • The reused one-time pad, where C1 xor C2 = P1 xor P2
  • DES's short key
  • A hash collision
  • A replayed MAC tag

Correct: The reused one-time pad, where C1 xor C2 = P1 xor P2

Why: With a reused pad, XORing two ciphertexts cancels the key and leaves the XOR of the plaintexts. AES without SubBytes behaves the same way after a public, undoable scrambling, and it does so for every pair of messages ever encrypted under the key.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-sub

53. Without ShiftRows, the four columns never meet

Concept

MixColumns mixes inside a column, and SubBytes and AddRoundKey work byte by byte. So without ShiftRows, nothing ever moves a byte into a different column. A change in column 0 spreads through column 0 in round 1 and stays there for all ten rounds.

Figure (svg): Three ciphertext grids for a one-bit plaintext change: without ShiftRows only column 0 changes; without MixColumns only byte 0 changes; with full AES every byte changes

AES then splits into four separate ciphers, each on a 32-bit column. A 32-bit block is far too small: it has only about 4.3 billion possible inputs, so the complete input-output table of each column could be collected and stored. That is the opposite of what a 128-bit block is for.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-shift

54. How big is a complete table for a 32-bit block?

Estimation

Without ShiftRows each column is an independent 32-bit cipher. A complete table lists the output for every possible input.

Predict first

There are 2 to the power 32 possible inputs, and one 16-byte AES block carries one input for each of the four columns at once. Roughly how much ciphertext is a full table?

  • About 64 kilobytes
  • About 64 megabytes
  • About 64 gigabytes
  • About 64 petabytes

Correct: About 64 gigabytes

Why: 2 to the power 32 blocks of 16 bytes is 2 to the power 36 bytes, which is 64 GiB: a single ordinary disk. Compare that with the 2 to the power 128 work that full AES demands. Splitting a big block into small independent pieces destroys the security the block size was supposed to provide.

55. Without MixColumns, every byte is on its own

Concept

Without MixColumns no step ever combines two bytes. SubBytes and AddRoundKey act on one byte at a time, and ShiftRows only moves bytes around. So every output byte depends on exactly one input byte, through all ten rounds.

varianta one-bit change reachesAES splits into
full AESall 16 bytes after two roundsone 128-bit cipher
no ShiftRowsthe 4 bytes of one columnfour 32-bit ciphers
no MixColumns1 bytesixteen 8-bit ciphers

A cipher on one byte has only 256 possible inputs, so its whole table is tiny: 256 blocks, about 4 kilobytes, would cover every position at once. In the figure on the previous slide only byte 0 of the ciphertext changed, because byte 0 sits in row 0, which ShiftRows never moves.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-mix

56. Without AddRoundKey, there is no key at all

Concept

The cleanest failure. The key schedule still runs, but nothing uses its output, because AddRoundKey is the only step where round keys enter.

# AES with AddRoundKey removed, plaintext 00112233...ff
key 000102...0f   C  = 8c34c7e2358383edd3da9b3d23cca3b3
key 2b7e15...3c   C  = 8c34c7e2358383edd3da9b3d23cca3b3
flip one bit      C' = ecff072a6f4d848a928f8c62a4a88602
observationwhat it means
two different keys, the same ciphertextthe output does not depend on the key
one flipped bit changes all 16 bytesthe avalanche is still perfect
every step left is public and invertibleanyone can run the inverse steps and read every message

Notice the second row. The scrambling is as thorough as ever, yet there is no secrecy whatsoever. Scrambling is not encryption: a cipher is secure only because its output depends on a secret, and here nothing does.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-ark

57. Which removal causes which failure?

Matching

Summarise the four experiments. Match each removed step to what goes wrong.

Match the pairs

  • sb. no SubBytes
  • sr. no ShiftRows
  • mc. no MixColumns
  • ar. no AddRoundKey
  • lin. the cipher becomes linear, so ciphertext XORs leak plaintext XORs
  • col. four independent 32-bit ciphers
  • byte. sixteen independent 1-byte ciphers
  • none. a fixed public permutation with no secret

Why: Each step has one job: SubBytes for non-linearity, ShiftRows to carry bytes between columns, MixColumns to combine the bytes of a column, and AddRoundKey to make everything depend on the key. Remove any one and a different kind of structure appears.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-remove

58. Trap: “the output looks random, so the cipher is secure”

Trap

The trap

A tempting test: flip input bits, check that about half the output bits change, and declare the cipher strong.

variantavalanchesecure?
full AESperfectyes
no AddRoundKeyperfectno: there is no key at all
no SubBytesspreads across the blockno: it is linear

Random-looking output is necessary but nowhere near sufficient.

The fix

Security is about what someone without the key can work out, not about how scrambled the output looks. The checks that matter are structural: is there a non-linear step, does every part of the block affect every other part, and does the output depend on the key everywhere?

This is also why nobody should design their own cipher. AES earned trust from years of public cryptanalysis looking for exactly these hidden structures, not from passing a randomness test.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-no-ark

59. The lecture's challenge: explain before you code

Explain it

The lecture ends this part with a take-home challenge: a Python AES that can skip any one of the four steps, with one variant per challenge. Before touching any code, the reasoning is what counts.

Discussion prompt

For each variant, explain to a partner in two sentences: which property of AES is lost, and what an outsider could observe about ciphertexts that they could not observe with full AES?

Hint: Look back at what each step's job was on the matching slide.

Answer:

variantproperty lostwhat an outsider can observe
no SubBytesnon-linearityC0 xor C1 is the same under every key
no ShiftRowsmovement between columnsa change never leaves its column
no MixColumnsmixing within a columna change never leaves its byte
no AddRoundKeyany dependence on the keythe same plaintext gives the same ciphertext under every key

If you can fill in this table without looking, you understand why each step is in AES. The design lesson generalises to any block cipher: it needs a non-linear layer, a diffusion layer that reaches the whole block, and a key mixed in every round.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-challenge

60. Part 6 — Decryption, and AES in practice

Section

Undo every box, and where the real failures are

61. Decryption runs the same picture backwards

Concept

Decryption starts from the ciphertext and undoes each box in reverse order, using the round keys from K10 down to K0. XOR with a round key undoes itself. The other three steps each need a real inverse step.

Figure (svg): Two columns: encryption top down from plaintext through XOR K0, the round steps and XOR K10 to ciphertext; decryption bottom up through XOR K10, InvShiftRows, InvSubBytes, XOR Kr, InvMixColumns and finally XOR K0

encryption stepits inverse
SubBytesInvSubBytes: look up the inverse S-box
ShiftRowsInvShiftRows: rotate row r right by r
MixColumnsInvMixColumns: multiply by the matrix with rows 0e 0b 0d 09; it turns 5f 72 64 15 back into 63 53 e0 8c
AddRoundKeythe same XOR with the same round key

Unlike DES, where the Feistel structure only ever recomputes the round function F, AES has to invert every step. That is why each step was chosen to be one-to-one, and why the S-box and the MixColumns arithmetic had to be reversible.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-dec

62. Order the start of decryption

Ranking

Decryption begins at the ciphertext and works back through round 10, then into round 9. Order the first five operations.

Put in order

  1. XOR K10
  2. InvShiftRows
  3. InvSubBytes
  4. XOR K9
  5. InvMixColumns

Why: Round 10 ended with XOR K10, after ShiftRows, after SubBytes, so those are undone first in reverse order. Round 9 ended with MixColumns then XOR K9, so the next undo is XOR K9 followed by InvMixColumns. InvShiftRows and InvSubBytes may swap with each other, since one moves bytes and the other changes them in place, but the standard's order is the one shown.

63. Checkpoint: why AES must invert every step

Check

Solve it on paper before you click.

Check your understanding

DES decryption never inverts its round function F, but AES decryption must invert SubBytes and MixColumns. Why?

  • A. AES is not a Feistel cipher: each step transforms the whole state, so it must be undone directly (correct)
  • B. AES has more rounds than DES
  • C. AES keys are longer, so the steps must be inverted
  • D. DES decryption does invert F; both ciphers invert every step

Answer: A

Why: A Feistel round XORs F of one half into the other half, so running it again with the same key cancels it, whatever F is. AES rounds apply SubBytes, ShiftRows and MixColumns to the entire state, so decryption needs a true inverse of each, which is why every step was designed to be one-to-one.

Why B tempts people
The number of rounds does not affect whether a step must be inverted; it only affects how many inverse rounds run.
Why C tempts people
Key length has nothing to do with how decryption is structured.
Why D tempts people
In DES, F is only recomputed in decryption, never inverted. F does not even need to be one-to-one.

64. AES in practice is fast and unbroken

Concept

Twenty-five years after standardisation, AES is both everywhere and unbroken. Its practical failures come from how it is implemented and used, not from the mathematics.

$ openssl speed -evp aes-128-gcm -bytes 16384
AES-128-GCM   5387100.16k      # on the lecturer's laptop: about 5.4 GB per second, one core
questionanswer today
how fast?since about 2010, CPUs have AES instructions that run a whole round in one instruction; gigabytes per second per core
best attack on the maths?about 2 to the power 126 work for AES-128 instead of 2 to the power 128 (biclique attack, 2011): unbroken in practice
how is it really broken?software AES using lookup tables can leak the key through cache timing (2005); hardware AES instructions avoid this
quantum computers?Grover's algorithm needs about 2 to the power 64 steps for AES-128, so AES-256 keeps a comfortable margin

The lesson for practitioners: use the hardware-accelerated AES in your platform's standard library, never a hand-written one, and spend your attention on the mode of operation and on key management, where real systems actually fail.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-aes-practice

65. Where do real AES deployments fail?

Sorting

Sort each item by whether it is a realistic way AES-based systems fail today.

Sort into buckets

Realistic failure, or not a practical concern?

realistic failure
A table-based software AES leaking timing through the CPU cache; Encrypting long messages in a bad mode of operation; Hard-coding the key in an app anyone can download
not a practical concern
Brute-forcing all AES-128 keys; The 2011 biclique attack on full AES-128
real
Side channels, bad modes and poor key management are where AES systems actually break. None of them is a weakness in the cipher itself.
not
Brute force needs about 2 to the power 128 work and the best known attack about 2 to the power 126; both are far beyond any computer that exists or is planned.

66. Where you already use AES

Real world

AES runs many times a second on almost every device you own.

Discussion prompt

Name three places AES protects your data today, and for each one say what the key is shared between.

Hint: Think about your browser, your router and your laptop's disk.

Answer:

HTTPS: TLS sessions are usually encrypted with AES-GCM, using a session key your browser and the server agree on during the handshake. Wi-Fi: WPA2 and WPA3 encrypt each frame with AES, keyed from the network password and a handshake. Disk encryption: BitLocker, FileVault and LUKS encrypt the disk with AES under a key unlocked by your password or hardware chip.

Notice the pattern: AES itself is never the hard part. Each system's security depends on how the key is agreed and protected, and on the mode used to encrypt data longer than one block.

67. Housekeeping from the lecture

Concept

The original lecture pauses here for two course announcements. They are specific to that class, but the practices behind them apply to any course.

account set-up — students had to send a code-hosting account name for the course platform before the first graded round, with no late days; set up course accounts as soon as they are requested

two standing channels — an anonymous feedback poll for pace and clarity, and a discussion board for questions during and after class

If something in this lesson did not land, the equivalent move is the same: say so early, anonymously if you prefer, and bring questions to whatever discussion space your course uses.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-wanted

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-channels

68. Recap: the AES pipeline

Concept

The whole cipher on one page again, now with the job of each step, which is what the removal experiments showed.

Figure (svg): The AES pipeline: plaintext, XOR K0, ten rounds of SubBytes, ShiftRows, MixColumns and AddRoundKey with round 10 skipping MixColumns, and the key schedule supplying K0 to K10

stepits jobwithout it
SubBytesthe only non-linear stepAES is linear
ShiftRowsmoves bytes between columnsfour 32-bit ciphers
MixColumnsmixes the 4 bytes of a column (not in round 10)sixteen 1-byte ciphers
AddRoundKeythe only place the key entersno secret at all

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-recap-aes

69. Checkpoint: the pipeline

Check

Solve it on paper before you click.

Check your understanding

Which list is the correct order of operations in round 10 of AES-128?

  • A. SubBytes, ShiftRows, MixColumns, AddRoundKey
  • B. SubBytes, ShiftRows, AddRoundKey (correct)
  • C. AddRoundKey, SubBytes, ShiftRows
  • D. ShiftRows, MixColumns, AddRoundKey

Answer: B

Why: Round 10 is a normal round without MixColumns: SubBytes, ShiftRows, then AddRoundKey with K10. A MixColumns after the last key would be a public step anyone could undo.

Why A tempts people
That is rounds 1 to 9. The last round drops MixColumns.
Why C tempts people
The extra key XOR, with K0, happens once before round 1, not at the start of round 10.
Why D tempts people
SubBytes runs in every round, including the last; it is the only non-linear step.

70. Recap: where the round keys come from

Concept

One rule, applied forty times, turns the 16-byte key into 44 words, 176 bytes, the eleven round keys.

round keywordsfor the key 000102...0f
K0w0-w300010203 04050607 08090a0b 0c0d0e0f
K1w4-w7d6aa74fd d2af72fa daa678f1 d6ab76fe
K2w8-w11b692cf0b 643dbdf1 be9bc500 6830b3fe
K10w40-w4313111d7f e3944a17 f307a78b 4d2b30c5

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-recap-keys

71. One problem is left

Socratic

AES encrypts exactly one 16-byte block: 16 bytes in, 16 bytes out. A 1 MB file is 65,536 blocks, and a web page, a photo or an email is also far more than one block.

Discussion prompt

How would you encrypt a message longer than one block with AES? Propose a method, then think about what could go wrong with it.

Hint: What happens to two identical 16-byte chunks of the message?

Answer:

The obvious idea is to cut the message into 16-byte blocks and encrypt each one separately with the same key. But then identical plaintext blocks give identical ciphertext blocks, and patterns in the data show straight through the encryption.

The way a one-block cipher is used over a long message is called the mode of operation, and with it comes padding for the last partial block. The next lecture part shows that the mode and its initialisation vector break long before the cipher does: that is where most real failures live.

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-recap-bridge

72. Draw AES from memory

Connect it up

Close the slides and rebuild the whole cipher.

Draw it

Draw the AES-128 pipeline from plaintext to ciphertext. Label the XOR with K0, the four steps of a round with one phrase each for its job, the missing step in round 10, and the key schedule with the rule for making a new word and the three moves of g. Then mark which boxes use the key.

Check against the recap slides. If you could not say what g does or why round 10 drops MixColumns, revisit Part 3 or the start of Part 4.

73. Exit ticket

Exit ticket

One question to check the central idea of the lesson.

Predict first

A designer proposes a faster AES that drops SubBytes but keeps the other three steps and all ten rounds. What is the strongest objection?

  • It would be slower, not faster
  • Without the only non-linear step the cipher becomes linear, so ciphertext XORs reveal plaintext XORs under any key
  • The key schedule would stop working
  • The ciphertext would no longer be 16 bytes

Correct: Without the only non-linear step the cipher becomes linear, so ciphertext XORs reveal plaintext XORs under any key

Why: With SubBytes gone, all the round keys can be pushed to the end, leaving a public linear map XOR one key-dependent constant. The XOR of two ciphertexts then depends only on the XOR of the plaintexts, the same leak as a reused one-time pad. The key schedule would still use the S-box internally, but that does not save the cipher.

74. What you can do now

Recap

You have taken AES apart one box at a time with the standard's own numbers.

ideaone line
state4 by 4 grid of bytes, filled column by column
roundSubBytes, ShiftRows, MixColumns (not in round 10), AddRoundKey
key schedulew[i] = w[i-4] xor w[i-1], with g every fourth word
diffusiontwo rounds spread one bit to all 128
nexta mode of operation, to encrypt more than one block

Security I, Lecture 2: Cryptography, symmetric ciphers (AES) slide s-recap-aes

Sources

  1. Security I, Lecture 2: Cryptography, symmetric ciphers (AES)
  2. FIPS 197 — Advanced Encryption Standard (AES), NIST 2001, updated 2023
  3. Daemen and Rijmen, The Design of Rijndael (Springer, 2002) — J. Daemen and V. Rijmen, The Design of Rijndael: AES, the Advanced Encryption Standard. Springer, 2002.
  4. Bogdanov, Khovratovich and Rechberger, Biclique Cryptanalysis of the Full AES (ASIACRYPT 2011)
  5. Bernstein, Cache-timing attacks on AES (2005)

Want this taught 1-on-1? Alexander tutors Computer Security — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108