xref: /xnu-10002.81.5/bsd/man/man4/random.4 (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions.Dd September 6, 2001
2*5e3eaea3SApple OSS Distributions.Dt RANDOM 4
3*5e3eaea3SApple OSS Distributions.Os Darwin
4*5e3eaea3SApple OSS Distributions.Sh NAME
5*5e3eaea3SApple OSS Distributions.Nm random
6*5e3eaea3SApple OSS Distributions,
7*5e3eaea3SApple OSS Distributions.Nm urandom
8*5e3eaea3SApple OSS Distributions.Nd random data source devices.
9*5e3eaea3SApple OSS Distributions.Sh SYNOPSIS
10*5e3eaea3SApple OSS Distributions.Cd "pseudo-device random"
11*5e3eaea3SApple OSS Distributions.Sh DESCRIPTION
12*5e3eaea3SApple OSS DistributionsThe
13*5e3eaea3SApple OSS Distributions.Nm
14*5e3eaea3SApple OSS Distributionsdevice produces uniformly distributed random byte values
15*5e3eaea3SApple OSS Distributionsof potentially high quality.
16*5e3eaea3SApple OSS Distributions.Pp
17*5e3eaea3SApple OSS DistributionsTo obtain random bytes, open
18*5e3eaea3SApple OSS Distributions.Nm /dev/random
19*5e3eaea3SApple OSS Distributionsfor reading and read from it.
20*5e3eaea3SApple OSS Distributions.Pp
21*5e3eaea3SApple OSS DistributionsThe same random data is also available from
22*5e3eaea3SApple OSS Distributions.Xr getentropy 2 .
23*5e3eaea3SApple OSS DistributionsUsing the
24*5e3eaea3SApple OSS Distributions.Xr getentropy 2
25*5e3eaea3SApple OSS Distributionssystem call interface will provide resiliency to file descriptor exhaustion, chroot, or sandboxing which can make
26*5e3eaea3SApple OSS Distributions.Nm /dev/random
27*5e3eaea3SApple OSS Distributionsunavailable.  Additionally, the
28*5e3eaea3SApple OSS Distributions.Xr arc4random 3
29*5e3eaea3SApple OSS DistributionsAPI provides a fast userspace random number generator built on the
30*5e3eaea3SApple OSS Distributions.Nm
31*5e3eaea3SApple OSS Distributionsdata source and is preferred over directly accessing the system's random device.
32*5e3eaea3SApple OSS Distributions.Pp
33*5e3eaea3SApple OSS Distributions.Nm /dev/urandom
34*5e3eaea3SApple OSS Distributionsis a compatibility nod to Linux. On Linux,
35*5e3eaea3SApple OSS Distributions.Nm /dev/urandom
36*5e3eaea3SApple OSS Distributionswill produce lower quality output if the entropy pool drains, while
37*5e3eaea3SApple OSS Distributions.Nm /dev/random
38*5e3eaea3SApple OSS Distributionswill prefer to block and wait for additional entropy to be collected.
39*5e3eaea3SApple OSS DistributionsWith Fortuna, this choice and distinction is not necessary, and
40*5e3eaea3SApple OSS Distributionsthe two devices behave identically. You may use either.
41*5e3eaea3SApple OSS Distributions.Pp
42*5e3eaea3SApple OSS DistributionsThe
43*5e3eaea3SApple OSS Distributions.Nm
44*5e3eaea3SApple OSS Distributionsdevice implements the
45*5e3eaea3SApple OSS Distributions.Nm Fortuna
46*5e3eaea3SApple OSS Distributionspseudo random number generator algorithm and maintains its entropy pool.
47*5e3eaea3SApple OSS DistributionsThe kernel automatically seeds the algorithm with additional entropy during normal execution.
48*5e3eaea3SApple OSS Distributions.Sh FILES
49*5e3eaea3SApple OSS Distributions.Bl -tag -width /dev/urandom -compact
50*5e3eaea3SApple OSS Distributions.It Pa /dev/random
51*5e3eaea3SApple OSS Distributions.It Pa /dev/urandom
52*5e3eaea3SApple OSS Distributions.El
53*5e3eaea3SApple OSS Distributions.Sh HISTORY
54*5e3eaea3SApple OSS DistributionsA
55*5e3eaea3SApple OSS Distributions.Nm
56*5e3eaea3SApple OSS Distributionsdevice appeared in the Linux operating system.
57