Use it when configuring, checking or troubleshooting Random Number Generation in Cryptography.
Random Number Generation
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.
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.
entropy sources → CSPRNG → keys/nonces/tokens
Context & applicabilityCommon mistakes · platform/version boundaries
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.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
- Random ≠ unique.
- Unique identifier ≠ cryptographically unpredictable token.
- PRNG output ≠ secure without entropy, state protection and suitable construction.
- Health test pass ≠ entropy source uncompromised forever.
cat /proc/sys/kernel/random/entropy_avail— entropy (informational)openssl rand -hex 32— CSPRNG outputpython3 -c 'import secrets;print(secrets.token_hex(32))'— language CSPRNG
ReferenceWhat it is1 section · depth on demand
Using secure randomness
| Language / OS | Use |
|---|---|
| Linux | getrandom(), /dev/urandom |
| Windows | BCryptGenRandom |
| Python | secrets module |
| Java | SecureRandom |
| Node.js | crypto.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.
| Use | Correct source |
|---|---|
| Linux | getrandom(), /dev/urandom |
| Windows | BCryptGenRandom |
| Python | secrets module (not random) |
| Java | SecureRandom |
| Node.js | crypto.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.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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.
Quick lookup tables
Cryptography → Random Number Generation proof map
Fast scope, effective cryptographic state, verification and closure boundaries for Cryptography → Random Number Generation.
| Boundary | Establish | Does not establish |
|---|---|---|
| Scope and intent | Asset/data/peer, security property, identity/name, protocol and time | Does not prove algorithm, key, trust or endpoint correctness |
| Effective cryptographic state | Exact version, algorithm/mode/parameters, key/certificate/path and negotiated result | Configuration or object presence does not prove correct use |
| Verification outcome | Positive, negative, tamper, expiry/revoke and failure tests correlated with evidence | One success does not prove every peer, client, path or lifecycle stage |
| Closure | Original operation succeeds; old/unsafe state is retired and regression checks pass | Administrative workflow completion alone is not closure |