Skip to content

What is a random number generator?

A random number generator is any system that produces values an attacker cannot predict. In practice there are two broad kinds: deterministic generators that stretch a seed, and physical generators that extract unpredictability from a measurable process. Nearly every real system uses both together.

The two halves of every real generator

Production systems almost never use one generator. They use a physical source to produce a seed, and a deterministic algorithm to expand that seed into as many bits as the application needs. NIST calls the first an entropy source and the second a DRBG, a deterministic random bit generator. Both halves have to be right.

This matters because the two halves fail in opposite ways. A deterministic generator fails silently and completely: given the same seed it produces the same stream forever, and nothing about the output looks wrong. A physical source fails gradually and detectably, if you are measuring it.

The four terms, briefly

  • PRNG — expands a seed by a deterministic rule. Fast, reproducible, and not safe for keys unless it is also cryptographically secure.
  • CSPRNG — a PRNG built so that seeing output does not let you compute past or future output. The construction is worth understanding.
  • TRNG — derives bits from a physical process such as thermal noise or jitter.
  • QRNG — a TRNG whose randomness comes from a quantum process, which is what makes a physical entropy model possible rather than merely plausible.

Which one you need

If you are generating long-lived keys, you need a physical source somewhere in the chain and evidence about it. If you are producing large volumes of random data from a well-seeded CSPRNG, you may need nothing more. The honest version of this question is worth reading before you specify hardware.

What is not a real answer is "the operating system handles it". Modern kernels do a competent job of pooling entropy, but the guarantees they can offer depend entirely on what the underlying hardware gave them, and on most platforms that is not something you can inspect.