Lion Cipher Lab

Implement PBKDF2 from scratch, and measure what each iteration buys you

Why it matters

Almost every security checklist says 'hash passwords with a slow, salted function', and PBKDF2 is the one that ships everywhere: in Python's standard library, in FIPS-validated crypto modules, in Wi-Fi WPA2 and in Kerberos. But 'slow' is a number, and most people who set that number copied it. In this lab you build PBKDF2 yourself from its RFC, on top of an HMAC you also build, and prove both against published test vectors you did not produce. Then you measure what the iteration count actually buys. Each iteration adds the same cost to the defender's single login and to every one of the…

What you'll learn

Steps in this lab

  1. What you are building, and the words you need
  2. Set up: a terminal, Python, and a lab folder
  3. Write HMAC, then PBKDF2, straight from the RFCs
  4. Prove it against numbers you did not produce
  5. Plant a bug: what single-block tests miss
  6. Measure what each iteration costs, for the defender and the attacker
  7. Check your number against OWASP and NIST, and see how it aged
  8. Show that the salt matters, with two users and one password
  9. Honest negative 1: PBKDF2 is not memory-hard
  10. Honest negative 2: the long-password quirk, and the long-password cost trap
  11. Honest negative 3: your iteration count is a lever on your own login endpoint
  12. Do it better: what to ship, and when PBKDF2 is the wrong choice

Open the full interactive lab →