Pcornel
Security · Cryptography

Random Number Generation

Cheat sheet · https://pcornel.dk/topic.php?topic=4681

Back to the Topic

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.

Remember

  • Random ≠ unique.
  • Unique identifier ≠ cryptographically unpredictable token.
  • PRNG output ≠ secure without entropy, state protection and suitable construction.
  • Health test pass ≠ entropy source uncompromised forever.

First 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

Verify in this order

entropy sources → CSPRNG → keys/nonces/tokens

Where it usually breaks

First mismatch in key/secret generation → storage/rotation → trust/certificate validation → protocol negotiation → cryptographic operation → peer/application verification; preserve identity/policy/pre-state before mutation.

Cryptography → Random Number Generation proof map

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

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4681

Confirmation

Confirm action

Continue?