OS-Entropy
The kernel's cryptographically secure random number generator, the right default
About OS-Entropy
OS-Entropy is a system random number source from the Operating system RNG family. It is also known as os-rng and getrandom. NextSSL lists it in the safe tier and exposes it through the safe API.
Overview
The operating system RNG provides cryptographically secure random bytes seeded from hardware and environmental entropy. It is the correct source for keys, nonces, salts and tokens, and the recommended seed for any user-space DRBG.
Modern kernels collect entropy from interrupt timing, hardware random number instructions such as RDRAND and RDSEED, boot-time seeds and other sources, and feed it into a cryptographic generator. Linux uses a ChaCha20-based design behind getrandom(2) and /dev/urandom; Windows exposes BCryptGenRandom; macOS and the BSDs provide getentropy and arc4random. These interfaces are designed to block only until the generator is initially seeded and then never run out.
Calling the OS RNG directly avoids most failure modes of user-space generators: state duplication after fork, poor seeding at boot and implementation bugs. NextSSL's os-entropy wraps the platform interface, preferring system calls such as getrandom over device files. On Linux, getrandom blocks only until the generator is first seeded, while on Windows, BCryptGenRandom is available from boot. Where a platform cannot provide secure randomness, the correct behaviour is to fail loudly rather than return weak output.
History
1994–2014Linux /dev/random introduced by Theodore Ts'o
getrandom() system call added to Linux 3.17
How it works
- The kernel gathers entropy from hardware and system events into a pool.
- Once adequately seeded, a cryptographic generator (for example ChaCha20 on Linux) produces output.
- Applications request bytes through getrandom, getentropy or BCryptGenRandom.
- The kernel reseeds periodically and on events such as VM resume, where supported.
Security notes
Considered the safest default. Early-boot or freshly cloned virtual machines can have reduced entropy on some platforms; avoid reading device files that may be unavailable in sandboxes, and check for errors rather than falling back to weak sources.
Typical uses
Sizes
The registry declares no fixed sizes for this algorithm.
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
buf = ns.call("rng_fill", "os-entropy", None, 32)[0]
nextssl_rng_fill("os-entropy", NULL, 32, out);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_rng_in(reg::all(), Policy::Safe, "os-entropy", &Params::new())?;
let mut buf = [0u8; 32];
alg.fill(&mut buf)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Frequently asked questions
What is OS-Entropy?
OS-Entropy is a RNG in the Operating system RNG family. The operating system RNG provides cryptographically secure random bytes seeded from hardware and environmental entropy. It is also known as os-rng, getrandom.
Is OS-Entropy safe to use?
OS-Entropy is in the safe tier. Modern and recommended. The default choice for new designs. It can be called from the safe API.
Related families
ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
HMAC_DRBGNIST SP 800-90A deterministic random bit generator built on HMAC
ML-KEMNIST's primary post-quantum key encapsulation mechanism, standardised in FIPS 203
HMACThe standard way to build a MAC from a cryptographic hash (RFC 2104, FIPS 198-1)
EdDSADeterministic Edwards-curve signatures: Ed25519 and Ed448
ChaChaBernstein's ARX stream cipher; ChaCha20 secures much of today's TLS, SSH and VPN traffic