Lion Cipher Lab

Implement AES-128 from scratch, and verify it against the FIPS 197 vectors

Why it matters

AES is the cipher that protects almost everything: HTTPS, Wi-Fi, disk encryption, VPNs, messaging apps. Most people only ever call it from a library. This lab opens it up. You build AES-128 yourself in about 150 lines of plain Python, following the official US standard (FIPS 197), and you compute its famous S-box from first principles instead of copying a table. Then you prove it is right the way professionals do: NIST's worked examples, NIST's validation test vectors, and thousands of random blocks compared against OpenSSL. You also measure the ideas behind the design. You watch one flipped…

What you'll learn

Steps in this lab

  1. What you are building, and the words you need
  2. Set up: a terminal, Python, OpenSSL and a lab folder
  3. Write AES-128: the field, the S-box, the key schedule, the rounds
  4. Check the S-box you derived against FIPS 197, and measure it
  5. Verify against the FIPS 197 examples and the NIST AESAVS vectors
  6. Differential test against OpenSSL on 2,000 random blocks
  7. Plant a bug: the round-trip test passes, the first vector catches it
  8. Measure diffusion round by round, with and without MixColumns
  9. Break AES without MixColumns with 256 chosen blocks
  10. A correct block cipher is still not encryption: ECB leaks, CTR is malleable
  11. Why your AES must never ship: speed, AES-NI and cache timing
  12. Do it better: how a professional uses and tests AES

Open the full interactive lab →