How it works · 13 of 34 Advanced
Why does bad randomness make weak encryption keys?
A key anyone could guess
Randomness & weak keys: A key is only as strong as the randomness used to make it; a broken random-number source produces keys that are short, repeated or shared, and then the strongest algorithm can be undone in seconds.
Loading the animation…
Say it like this A key is only as strong as the randomness that made it: a broken random source gives repeated or tiny keys, and then the strongest algorithm can be undone in seconds.
Under the hood — for builders
- Real example: the loaded die, in code
- Two cameras that seed an ordinary random generator with the second they booted get the same key. The operating system's source gives each its own:
- A key that was the number 4, cracked here
- We made an elliptic-curve (P-256) key whose secret is 4, then, from its public key alone, tried 1, 2, 3 …:
- How common it was: the 2012 internet scan
- Researchers collected the public keys of every reachable https and SSH server and compared them all:
- eMudhra, from bug to fakes
- A certificate authority (B5) whose key-making went wrong, on a timeline:
- How many guesses each mistake leaves
- Each broken source shrinks the keys a thief must try. Candidates on a log scale, and the time to try them all on one CPU core:
- Reused randomness
- Sony PS3, 2010: the same random number in every signature gave away the private signing key.
- What to use
- The operating system's source (getrandom, /dev/urandom, BCryptGenRandom); never Math.random or Python's random.
- Measure it
- Collect your devices' public keys and look for duplicates; test first-boot randomness before shipping.
- Sources
- Heninger et al., USENIX Security 2012 · our eMudhra paper · Debian DSA-1571 / CVE-2008-0166 · fail0verflow, 27C3 (2010).
What happens in the randomness & weak keys animation, step by step?
- Keys are cut from random numbers. A fair die: every key different, and too many possibilities to guess.
- A loaded die: the random source is broken. The machine starts repeating itself.
- In 2012 researchers found keys sharing parts across the internet and worked out the private keys of 0.50% of the https servers they scanned.
- Your turn: fix the die. Only then does the needle fall to zero.
- 30 April 2025: a bug turned eight of eMudhra's 24 new keys into numbers no bigger than 255. One was 4. For 17 months nobody tried.
- Within two days of the report, people made 107,107 fake padlocks. Weak keys fail today; the next threat breaks even strong ones. Next: quantum.
What everyday example explains randomness & weak keys?
A combination lock left on 1-2-3-4. The lock's design is fine; the number chosen for it isn't.
Why should a team care about randomness & weak keys?
If your products generate keys (routers, cameras, apps on first boot), test the randomness and check that no two devices share a key before shipping; if a supplier's key is weak, you inherit it.