Table of Contents >> Show >> Hide
- Randomness: The Thing Computers Fake for a Living
- Entropy, Explained Like You’re Not in a Graduate Seminar
- What Counts as a TRNG (and What’s Just Vibes)?
- Standards (Yes, They Matter): NIST’s RNG “Trilogy”
- Your OS Is Already an RNG Engineer (Let It Do Its Job)
- Hardware RNGs: RDRAND, RDSEED, TPMs, and the Trust Question
- “True Hacker” Threat Modeling for Randomness
- Testing Randomness: Because “It Looks Random” Isn’t a Test
- Practical Recipes (Safe, Boring, and Correct)
- Common RNG Faceplants (Seen in the Wild)
- So… Do You Need a “True” RNG Device?
- Conclusion: The Real Hacker Flex Is Predictability Resistance
- Field Notes: of Experience With “Real” Randomness
- Sources Consulted (No Links)
“True hacker” gets used for everything from hoodie aesthetics to keyboard clacks in coffee shops. But if we’re being honest, the
most hacker-coded hobby is arguing about randomness at 2:13 a.m.because the security of keys, tokens, nonces, salts, and sessions
all quietly depends on one question:
Can an attacker predict what you think is random?
This guide walks through what a true random number generator (TRNG) actually is, why most secure systems rely on a hybrid approach,
how modern operating systems generate cryptographic randomness, and what “extra paranoid” setups look like when done responsibly.
Expect real-world examples, a little humor, and zero “just roll your own crypto” energy.
Randomness: The Thing Computers Fake for a Living
Computers are deterministic machines. If you give them the same input state, you get the same outputevery time. So when your laptop
“generates random numbers,” it’s usually doing one of three things:
1) PRNG: Pseudorandom Number Generator
A PRNG is an algorithm that stretches a small internal state into a long sequence that looks random. It’s great for simulations,
games, and anything where “random-ish” is fine. But basic PRNGs can be predictable if someone can guess or recover the state.
2) CSPRNG / DRBG: Cryptographically Secure PRNG
A cryptographically secure PRNG (often implemented as a DRBGDeterministic Random Bit Generator) is designed so that even if an attacker
sees a bunch of outputs, they can’t feasibly predict past or future outputs (assuming proper design and secrecy of state).
This is what you want for cryptography.
3) TRNG: True Random Number Generator
A TRNG uses a physical processsomething noisy and unpredictable in the real worldto produce entropy (unpredictable bits). Think thermal
noise, oscillator jitter, or quantum phenomena. TRNG output often needs conditioning (like hashing) because raw physical noise can be biased.
Here’s the plot twist: in modern secure systems, the “best” answer is typically a well-engineered hybrid:
a TRNG (or multiple entropy sources) feeding a CSPRNG/DRBG that produces fast, high-quality random bytes on demand.
Entropy, Explained Like You’re Not in a Graduate Seminar
Entropy is just a fancy word for “how hard it is to guess.” If your “random” seed is the current timestamp, that’s not entropythat’s a
countdown for an attacker. Real entropy comes from processes that are difficult to model or observe precisely.
Operating systems maintain an entropy pool (conceptually) by collecting unpredictable events: timing jitter, device noise,
hardware RNG inputs, and other environmental signals. Then they use a secure construction to produce the random bytes your apps request.
If you take nothing else away: your goal is not “looks random.” Your goal is “not predictable to the attacker you care about.”
What Counts as a TRNG (and What’s Just Vibes)?
A TRNG is only as “true” as its physical entropy source and the engineering around it. Common TRNG sources include:
- Thermal noise from resistors or electronic components
- Avalanche noise from reverse-biased diodes (used in some hardware designs)
- Ring oscillator jitter (timing variations in oscillators)
- Metastability in circuits (unpredictable resolution timing)
- Radioactive decay (yes, it’s a thingoften in research or specialized devices)
- Quantum processes (commercial “quantum RNG” devices exist)
But raw noise is messy: it can be biased, correlated, or influenced by temperature, voltage, aging, or EMI. That’s why serious RNG designs
add conditioning (often via cryptographic hashing) and health tests to detect failure modes.
The hacker takeaway: TRNG isn’t a magical box that spits out perfect randomness. It’s an input stream that must be treated like a sensor:
sampled, sanity-checked, and processed.
Standards (Yes, They Matter): NIST’s RNG “Trilogy”
If you want to talk about RNGs without accidentally reinventing a weak wheel, it helps to know the core U.S. standards ecosystem:
- SP 800-90A: DRBG mechanisms (deterministic generators built from approved cryptographic primitives)
- SP 800-90B: requirements and validation guidance for entropy sources (the “true” part)
- SP 800-90C: constructions that combine entropy sources + DRBGs into complete Random Bit Generators (RBGs)
Translated into normal-person terms: use a proven deterministic generator, seed it with real entropy, reseed appropriately, and continuously
watch for entropy source failure. “True hacker” mode isn’t ignoring standardsit’s understanding why they exist and where they’re brittle.
Your OS Is Already an RNG Engineer (Let It Do Its Job)
Most people trying to be “extra secure” accidentally downgrade themselves by bypassing the operating system’s RNG and doing something clever
(read: fragile). Modern OSes provide CSPRNG interfaces specifically designed for crypto.
Linux: getrandom(), /dev/urandom, and the “/dev/random panic”
On modern Linux, the kernel provides a cryptographic RNG and exposes it via system calls and devices. The practical advice for applications:
use getrandom() (directly or indirectly through your language/runtime) or a crypto library that does. Avoid reading
/dev/random as a default “because it sounds more random”blocking behavior can create self-inflicted outages.
In other words: if your authentication service freezes because the entropy pool is “low,” you didn’t build a fortressyou built a denial-of-service button.
Windows: BCryptGenRandom
On Windows, use BCryptGenRandom (or a high-level crypto API that uses it). It’s designed for cryptographic randomness and is the
modern interface applications should reach for.
macOS/iOS: SecRandomCopyBytes
On Apple platforms, SecRandomCopyBytes provides cryptographically secure random bytes. It’s the standard building block used by
higher-level APIs and frameworks.
If you’re writing in a mainstream language, the correct move is usually: use the language’s crypto RNG wrapper (which calls the OS),
not a “random()” meant for dice rolls.
Hardware RNGs: RDRAND, RDSEED, TPMs, and the Trust Question
Modern CPUs and platforms often include hardware RNG features. Two well-known x86 instructions are:
- RDRAND: returns random data generated by the CPU’s hardware RNG system
- RDSEED: returns conditioned entropy intended specifically for seeding other generators
Vendors publish guidance emphasizing that hardware RNG output is meant for cryptographic use, and that seeding and reseeding strategies matter.
RDSEED is generally positioned as “seed material,” while RDRAND is used for generating random values directly.
But here’s the hacker-grade nuance: hardware can fail, and failures can be subtle. Robust systems treat hardware RNG as
one input among several, not as a single point of faith. Many security teams prefer designs that mix entropy sources
so that a flaw in one component doesn’t collapse the whole randomness story.
If you’re building high-assurance systems, consider this mindset:
Trust the OS CSPRNG as the primary interface, and view hardware RNG as an internal contributornot a replacement.
“True Hacker” Threat Modeling for Randomness
Whether you need a TRNG device, extra entropy sources, or just the OS CSPRNG depends on the attacker model. Ask:
- Remote attacker? OS CSPRNG is typically the right answer for keys/tokens/nonces.
- Local attacker with system access? Worry about RNG state exposure, VM snapshots, container cloning, and compromised kernels.
- Supply-chain or nation-state paranoia? Diversify entropy sources and prefer designs with independent inputs.
- Embedded/IoT? Boot-time entropy scarcity is a real risk; plan for it explicitly.
“True hacker” isn’t always “most complicated.” It’s “most appropriate for the risk.”
Testing Randomness: Because “It Looks Random” Isn’t a Test
Statistical test suites (like NIST’s SP 800-22 suite) can detect certain biases and non-random patterns in output sequences. Tools in this space
include classic batteries like Diehard-style tests and more advanced academic suites.
Two important warnings:
- Passing tests doesn’t prove unpredictability. A cleverly broken generator can still pass statistical tests.
- Failing tests is a red alert. It can indicate bias, correlation, hardware drift, or bad conditioning.
In professional TRNG design, you’ll see “health tests” that run continuously and shut down or degrade output if the entropy source behaves oddly.
This is the difference between “a gadget” and “an entropy subsystem.”
Practical Recipes (Safe, Boring, and Correct)
If your goal is secure keys, tokens, salts, and nonces, use high-level crypto APIs that draw from the OS CSPRNG. Here are examples that are
simple enough to be hard to mess up.
Python: use secrets for tokens and IDs
Go: crypto/rand for bytes (and avoid modulo bias)
Node.js: crypto.randomBytes
Command line: OpenSSL for quick randomness
Notice the theme: you’re not “creating” randomnessyou’re requesting random bytes from a subsystem designed for cryptography.
That’s not laziness. That’s maturity.
Common RNG Faceplants (Seen in the Wild)
- Seeding with time: “It was random, I used the current timestamp.” Attackers love you for this.
-
Using
math.randomfor tokens: Great for shuffling playlists, terrible for sessions. -
Modulo bias: Using
rand % nfor non-power-of-two ranges without rejection sampling. - Nonce reuse: A single repeated nonce can wreck modern encryption modes and signatures.
-
Blocking on
/dev/random: Turning “security” into an outage is a classic. - VM snapshot weirdness: Restoring snapshots can roll RNG state back in time if the stack isn’t designed for it.
A true hacker doesn’t just generate random numbersthey avoid predictable mistakes.
So… Do You Need a “True” RNG Device?
Most of the time, no. For typical web apps, APIs, and services, the operating system CSPRNG is the right tool and is engineered
to provide cryptographically secure output at scale.
You might consider additional entropy sources or specialized hardware if you’re:
- Operating in constrained embedded environments with weak entropy at boot
- Building high-assurance systems that must withstand deep compromise scenarios
- Designing infrastructure where you want independent entropy inputs for defense-in-depth
- Meeting strict compliance or validation requirements that mandate specific constructions
Even then, the winning pattern is usually: TRNG inputs + conditioning + CSPRNG output.
“True” randomness is the seed corn; the CSPRNG is the harvest.
Conclusion: The Real Hacker Flex Is Predictability Resistance
A “True Random Number Generator for a true hacker” isn’t a single device or a mysterious command. It’s a mindset:
understand entropy, use proven cryptographic randomness interfaces, avoid DIY pitfalls, and design for failure.
If you want the short checklist:
- Use OS-backed crypto RNG APIs (directly or via your language’s crypto library).
- Don’t confuse “blocking” with “better.”
- Assume entropy sources can fail and prefer designs that mix inputs.
- Test and monitor if you own the entropy source.
Because the only thing worse than a predictable attacker is a predictable “random” number generator.
Field Notes: of Experience With “Real” Randomness
The first time you ship something security-sensitive, randomness feels like the easiest box to check. “We used secure random. Done.”
Then reality shows up with a clipboard and a smirk.
One lesson you learn quickly: entropy is a lifecycle problem, not a function call. Early-boot environments can be
surprisingly starvedespecially on minimal cloud images, embedded Linux devices, or freshly provisioned VMs that haven’t had time to
accumulate unpredictable events. I’ve seen systems generate cryptographic material “too early,” before the randomness subsystem was ready.
The code was correct. The timing was not.
Another lesson: the most dangerous bugs are the quiet ones. A randomness failure might not crash your service. It might
just make certain values slightly more predictable, or occasionally repeat. That’s the kind of defect that can sit undetected until someone
does incident response and realizes multiple “unique” tokens share suspicious structure. It’s why good RNG designs include health tests and
why high-level OS APIs exist in the first place: they let you outsource years of paranoia to people whose whole job is paranoia.
Then there’s the “security theater outage,” a classic move where someone insists on reading from the most ominous-sounding interface
because it “must be more secure.” When you attach the fate of a production service to an entropy-estimation mechanism that can block,
you are effectively letting the weather decide whether authentication works. That’s not stronger securityit’s an availability vulnerability
you hand-delivered to yourself.
Hardware RNGs add another layer of “fun.” They’re powerful, fast, and often extremely well-engineeredbut they’re still hardware, which means
you have to respect the possibility of failure modes, firmware quirks, and platform-specific bugs. In mature systems, the right posture is
rarely “trust hardware blindly.” It’s “treat hardware as a valuable ingredient” and still rely on the OS CSPRNG as the stable interface.
Defense-in-depth means your randomness story survives a surprise.
My favorite real-world takeaway is this: secure randomness is mostly about humility. The humble approach is to use battle-tested
APIs, follow best practices, and avoid clever shortcuts. The “true hacker” move isn’t building a DIY TRNG out of spare partsthough that can be
a fun educational project. The real flex is knowing when not to do the cool thing, because the boring thing is the thing that keeps keys
unguessable at 3 a.m. during an incident.
