Pcornel
Browse topics
Options
Recent
Favorites
Security · Technical reference

Random Number Generation

Direct answer

Cryptographic Random Number Generation combines sufficient entropy with a vetted deterministic random bit generator and lifecycle controls to produce unpredictable keys, nonces, tokens and challenges.

When to use this

Use it when configuring, checking or troubleshooting Random Number Generation in Cryptography.

First 30 seconds

1. Use the OS CSPRNG (getrandom, /dev/urandom, secrets).

2. Never Math.random/rand() for security.

3. VMs/containers at boot: ensure seeding.

4. Hardware RNG feeds the pool.

5. Test libraries' use.

Operational verification

entropy sources → CSPRNG → keys/nonces/tokens

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common traps

Output that passes statistical tests is not evidence of unpredictability; security depends on entropy, generator design, state secrecy and correct lifecycle under real deployment events.

Suspicious evidence: timestamp seed, predictable language PRNG, cloned state, ignored RNG failure, modulo bias, insufficient token bits, shared seed image, entropy source unavailable or state rollback.

Platform / version applicability
Cryptography, PKI and secrets
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCryptography, PKI and secrets
Scope / prerequisiteUse it when configuring, checking or troubleshooting Random Number Generation in Cryptography.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

physical/system entropy → conditioning and seed → vetted DRBG state → purpose-specific output → state update/reseed → consumer key/nonce/token

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Random ≠ unique.
  • Unique identifier ≠ cryptographically unpredictable token.
  • PRNG output ≠ secure without entropy, state protection and suitable construction.
  • Health test pass ≠ entropy source uncompromised forever.
Key checks
  • cat /proc/sys/kernel/random/entropy_avail — entropy (informational)
  • openssl rand -hex 32 — CSPRNG output
  • python3 -c 'import secrets;print(secrets.token_hex(32))' — language CSPRNG
ReferenceWhat it is1 section · depth on demand

Using secure randomness

Language / OSUse
Linuxgetrandom(), /dev/urandom
WindowsBCryptGenRandom
Pythonsecrets module
JavaSecureRandom
Node.jscrypto.randomBytes

Never use rand(), Math.random() or Python random for keys, tokens or passwords. Watch VM clones and embedded devices at first boot, which can have low entropy.

ReferenceImportant terms & boundaries2 sections · depth on demand

What this shows and what it does not

Output that passes statistical tests is not evidence of unpredictability; security depends on entropy, generator design, state secrecy and correct lifecycle under real deployment events.

In depth

Random number generation underpins all cryptography: keys, nonces, salts, session IDs and tokens must be unpredictable. Weak randomness has broken real systems — predictable keys on embedded devices, guessable session tokens.

UseCorrect source
Linuxgetrandom(), /dev/urandom
WindowsBCryptGenRandom
Pythonsecrets module (not random)
JavaSecureRandom
Node.jscrypto.randomBytes, crypto.randomUUID
import secrets
token = secrets.token_urlsafe(32)

General-purpose random functions (random, Math.random) are predictable and must never be used for security. Virtual machines and embedded devices at first boot may have little entropy — modern kernels handle this, but keys generated in golden images must not be shared across clones.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCryptography, PKI and secrets current

Authoritative/upstream documentation reviewed for bounded claims in Cryptography → Random Number Generation. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://csrc.nist.gov/pubs/fips/197/final · confidence 94%
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
CSPRNGcryptographic randomnesssecure random generation
Embedded reference data

Quick lookup tables

Cryptography → Random Number Generation proof map

Fast scope, effective cryptographic state, verification and closure boundaries for Cryptography → Random Number Generation.

BoundaryEstablishDoes not establish
Scope and intentAsset/data/peer, security property, identity/name, protocol and timeDoes not prove algorithm, key, trust or endpoint correctness
Effective cryptographic stateExact version, algorithm/mode/parameters, key/certificate/path and negotiated resultConfiguration or object presence does not prove correct use
Verification outcomePositive, negative, tamper, expiry/revoke and failure tests correlated with evidenceOne success does not prove every peer, client, path or lifecycle stage
ClosureOriginal operation succeeds; old/unsafe state is retired and regression checks passAdministrative workflow completion alone is not closure
Confirmation

Confirm action

Continue?