Break AES, one missing step at a time
Security I, Fall 2026. A coding challenge that goes with the AES lecture.
We break four weak versions of AES-128. Each weak version removes one of the four steps from every round. For each one we get some ciphertexts, and we must recover a secret plaintext without the key.
The code we use
Download aes.py. It is the AES from the lecture, for one 16-byte block, in plain Python. We do not need to write AES ourselves.
encrypt_block(pt, key, skip)anddecrypt_block(ct, key, skip)take an optionalskip: one of"SubBytes","ShiftRows","MixColumns","AddRoundKey". That step is removed from all ten rounds.- Skipping AddRoundKey also removes the first XOR with K0. Round 10 never has MixColumns, as in real AES.
- The single steps are there too:
sub_bytes,shift_rows,mix_columns, their inverses, andkey_expansion.
Run python3 aes.py once. It prints these values, for key 00 01 02 ... 0f and plaintext 00 11 22 ... ff:
skip ciphertext none 69c4e0d86a7b0430d8cdb78070b4c55a (FIPS-197, appendix C.1) SubBytes b60c4e707d338ca91e252895a5914de4 ShiftRows 5300bda29c7e35fbca37eb5f48c9fbef MixColumns 5cec2b6ff8595c257f0cc5620b901e90 AddRoundKey 8c34c7e2358383edd3da9b3d23cca3b3
The four challenges
Each challenge uses its own secret random key, which we never see. Each secret plaintext is 16 ASCII characters of the form flag{...}. Each page can check our answer.
| Challenge | Step removed | What we get |
|---|---|---|
| 1 | SubBytes | One known pair, one target ciphertext |
| 2 | ShiftRows | A log of eight known pairs, one target ciphertext |
| 3 | MixColumns | One known pair, 256 chosen plaintexts, one target ciphertext |
| 4 | AddRoundKey | One known pair, one target ciphertext |
Rules
- Do not guess the flag. Recover it with code, and keep the code. We may ask to see it.
- Brute force over the key is not a solution. Each break takes well under a second on a laptop.
encrypt_blockwith a key we choose is a good tool to test ideas. We write the attack ourselves.