/dev/random

Uses your system voice; voice and rate in settings.

Snapshot

≈ 5 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

of In Unix-like operating systems, and are special files that provide random numbers from a cryptographically secure pseudorandom number generator (CSPRNG). The CSPRNG is seeded with entropy (a value that provides randomness) from environmental noise, collected from device drivers and other sources. Users can obtain random numbers from the CSPRNG simply by reading the file. Not all operating systems implement the same methods for and . When entropy available is low, will block; on newer systems, this typically happens at program startup until entropy is sufficient, before permanently unblocking. The device typically was never a blocking device, even if the pseudorandom number generator seed was not fully initialized with entropy since boot. This special file originated in Linux in 1994. It was quickly adopted by other Unix-like operating systems.

of ]] In Unix-like operating systems, and are special files that provide random numbers from a cryptographically secure pseudorandom number generator (CSPRNG). The CSPRNG is seeded with entropy (a value that provides randomness) from environmental noise, collected from device drivers and other sources. Users can obtain random numbers from the CSPRNG simply by reading the file. Not all operating systems implement the same methods for and . When entropy available is low, will block; on newer systems, this typically happens at program startup until entropy is sufficient, before permanently unblocking. The device typically was never a blocking device, even if the pseudorandom number generator seed was not fully initialized with entropy since boot. This special file originated in Linux in 1994. It was quickly adopted by other Unix-like operating systems. ==Linux== The Linux kernel provides the separate device files and . Since kernel version 5.6 of 2020, only blocks when the CSPRNG hasn't initialized. Once initialized, and behave the same. In October 2016, with the release of Linux kernel version 4.8, the kernel's was switched over to a ChaCha20-based cryptographic pseudorandom number generator (CPRNG) implementation by Theodore Ts'o, based on Bernstein's well-regarded stream cipher ChaCha20. Since version 5.17 of the Linux kernel, the random number generator switched from using the SHA-1 cryptographic hash function in the entropy collector to BLAKE2s, a newer, faster and more secure hash function. ==BSD systems== The FreeBSD operating system provides a link to . Both block only until properly seeded. FreeBSD's PRNG (Fortuna) reseeds regularly, and does not attempt to estimate entropy. On a system with small amount of network and disk activity, reseeding is done after a fraction of a second. DragonFly BSD inherited FreeBSD's random device files when it was forked. Since OpenBSD 5.1 (May 1, 2012) and uses arc4random, a CSPRNG function based on RC4. The function was changed to use the stronger ChaCha20 with OpenBSD 5.5 (May 1, 2014). The system automatically uses hardware random number generators (such as those provided on some Intel PCI hubs) if they are available, through the OpenBSD Cryptographic Framework. was removed in OpenBSD 6.3 (April 15, 2018). NetBSD's implementation of the legacy API has been switched over to ChaCha20 as well. ==macOS, iOS and other Apple OSes== All Apple OSes have moved to Fortuna since at least December 2019, possibly earlier. It is based on SHA-256. Multiple entropy sources such as the secure enclave RNG, boot phase timing jitter, hardware interrupt (timing assumed) are used. RDSEED/RDRAND is used on Intel-based Macs that support it. Seed (entropy) data is also stored for subsequent reboots. Prior to the change, macOS and iOS used 160-bit Yarrow based on SHA-1. There is no difference between and ; both behave identically. ==Other operating systems== and are also available on Solaris, NetBSD, Tru64 UNIX 5.1B, AIX 5.2 and HP-UX 11i v2. As with FreeBSD, AIX implements its own Yarrow-based design, however AIX uses considerably fewer entropy sources than the standard implementation and stops refilling the pool when it thinks it contains enough entropy. In Windows NT, similar functionality is delivered by , but reading the special file does not work as in UNIX. The documented methods to generate cryptographically random bytes are CryptGenRandom and RtlGenRandom. Windows PowerShell provides access to a cryptographically secure pseudorandom number generator via the cmdlet. ==See also== CryptGenRandom – The Microsoft Windows API's CSPRNG Entropy-supplying system calls Fortuna algorithm Hardware random number generator Standard streams ==References== ==External links== – describes the Linux 4.8 /dev/random infrastructure and the futility of counting "spent" entropy. Includes quotes from cryptographers. (Counting of "spent" entropy is removed in kernel 5.17.)

Text derived from https://en.wikipedia.org/w/index.php?oldid=1371153380 under CC BY-SA 4.0; modifications have been made.