liveBook · Manning

True random number generator

As explained in Hacking Cryptography

A hardware random number generator, or true random number generator, samples nondeterministic physical phenomena to produce unpredictable random values.

A true random number generator (TRNG), also called a hardware random number generator (HRNG), samples nondeterministic physical phenomena to produce values that are practically unpredictable. Its security value is not merely that its output looks random: it roots cryptographic randomness in an attacker-unguessable physical process rather than in a deterministic algorithm and seed. section 2.2 section 2.2.1

This distinguishes a TRNG from a pseudorandom number generator (PRNG) and a cryptographically secure PRNG (CSPRNG). PRNGs and CSPRNGs deterministically expand a seed; if that seed becomes known, their later output can lose its intended randomness. A TRNG is therefore commonly used to supply a good seed, while a faster CSPRNG supplies the large volume of random bytes cryptographic operations need. section 2.2 section 2.3

A usable TRNG needs more than a physical noise source:

  • Sample a phenomenon with useful entropy and a known generation rate. Possible sources range from radioactive decay to electrical-circuit noise; their quality and speed differ. section 2.2.1 section 2.3
  • Resist physical attempts to predict or influence the source, including through tamper protection where appropriate. section 2.2.1
  • Use a physical model to estimate entropy and output rate without claiming to predict the individual generated bits. section 2.2.1
  • Run health tests on raw output and stop operation when the source is faulty. Without health testing, even all-zero or all-one output can pass unnoticed. section 2.2.1 section 10.2

Slow rain versus fast generation

Rain can serve as an intuition for a physical source: it may help decide whether to carry an umbrella, but its state does not change every millisecond. Likewise, a TRNG’s output rate is bounded by the phenomenon it samples and by how quickly underlying conditions change. This slowness is why a TRNG should feed a faster CSPRNG instead of directly providing all cryptographic random bytes. section 2.2.1 section 10.2

Figure 10.2 The recommended setup for using randomness for cryptographic applications: health tests should ensure the correct operation of the TRNG, which should periodically reseed a CSPRNG.
figure

The recommended construction puts health tests before use of TRNG output, then uses that entropy to seed and periodically reseed a CSPRNG. The CSPRNG provides speed; continuous reseeding limits dependence on one seed or internal state over time. section 10.2 section 10.9

Treat a TRNG as the root of a cryptographic randomness pipeline, not as an excuse to use any hardware labeled “random.” Some designs, including avalanche- and Zener-diode constructions, can be attacked and may not offer a good way to assess health. For critical work, prefer a dedicated hardware RNG or HSM that uses a high-quality entropy source and follows modeled health-testing practices. Less-critical systems may instead collect operating-system entropy such as timing and input jitter, but those sources are suboptimal because their expected entropy is not modeled by equivalent health tests. section 2.3 section 10.2

The operational rule is direct: use a CSPRNG for cryptographic applications, seed it from a good-quality TRNG, and reseed it periodically. Do not substitute a weak default PRNG merely because it emits values that appear random; deterministic generators can be compromised through seed guessing or recovery of internal state. section 2.3 section 10.9

How Hacking Cryptography covers it

How deep it goes
Explains physical sources, rate and entropy models, tamper resistance, health tests, and reseeding; defers detailed construction mechanics.
Examples
Uses rain, radioactive decay, electrical noise, diode designs, HSMs, and Linux entropy devices as concrete examples.
What you can do after
Evaluate/understand it by distinguishing a modeled, health-tested entropy source from an untested or deterministic random generator.
How it connects
Connects TRNGs to entropy, uniform distribution, PRNGs, CSPRNGs, seeds, health tests, and state extension attacks.

Also explained in

Compare how 2 books explain true random number generator →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.