Skip to content
Entropy Sources
step 1/5

Reading — step 1 of 5

Read

~1 min readEntropy Sources

Entropy Sources

A CSPRNG starts with true entropy from physical sources, then EXPANDS it deterministically.

OS entropy sources:

  • Hardware RNG (Intel RDRAND, ARM TRNG): chip-level noise. Suspicious people don't trust them alone.
  • Interrupt timing: CPU jitter, disk arrivals, network packets — microsecond-level noise.
  • /dev/random (Linux, OpenBSD): pool fed by entropy events. Blocks if pool is "low".
  • /dev/urandom: same pool, NEVER blocks. Modern wisdom: use this.
  • Mouse/keyboard movements: only matters during early boot; quickly negligible.

Entropy estimation: how many UNPREDICTABLE bits you've collected. Linux's pool tracks entropy_avail. If too low, /dev/random blocks.

Modern CPUs (post-2012) have hardware RNG, so entropy is usually plentiful. Embedded devices and VMs at boot are weak — that's why some systems hang on ssh-keygen shortly after boot.

Best practice: use getrandom() (Linux 3.17+, glibc 2.25+):

unsigned char buf[32];
ssize_t n = getrandom(buf, 32, 0);   // blocks until pool initialized

After that point, urandom is fine. The "blocks until initialized" matters because /dev/urandom (the file) was historically OK to read EVEN IF the pool was empty — that's been fixed but the wisdom is to use the syscall.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…