Lion Cipher Lab

Break textbook RSA from scratch (implement it, then defeat it -- and see why padding exists)

Why it matters

RSA underpins the certificates, signatures, and key exchange that still run large parts of the internet -- and it is one of the most misused primitives in existence. 'Textbook' RSA, the version everyone first learns (c = m^e mod n with nothing else), is not a cipher: it is deterministic, malleable, and with a small public exponent it can leak the plaintext to anyone holding only the public key and a pocket calculator. Once you have implemented RSA yourself and then broken your own implementation four different ways, you will never again confuse 'the RSA math' with 'a secure encryption…

What you'll learn

Steps in this lab

  1. What textbook RSA is, in one breath
  2. The maths you actually need (kept minimal)
  3. Set up a clean workspace
  4. Implement RSA from scratch
  5. Flaw 1: textbook RSA is deterministic (no semantic security)
  6. Flaw 2: the multiplicative homomorphism makes RSA malleable
  7. Attack: recover the plaintext with an e=3 integer cube root
  8. Attack: Hastad's broadcast (same message, three e=3 recipients)
  9. The defence: switch to RSA-OAEP + RSA-PSS and watch the attack fail
  10. The judgment call: when raw modexp shows up, and what to use instead

Open the full interactive lab →