diff options
Diffstat (limited to 'man4/random.4')
-rw-r--r-- | man4/random.4 | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/man4/random.4 b/man4/random.4 index 0f0eb21..7a1d15d 100644 --- a/man4/random.4 +++ b/man4/random.4 @@ -9,13 +9,13 @@ .\" 2008-06-20, George Spelvin <linux@horizon.com>, .\" Matt Mackall <mpm@selenic.com> .\" -.TH random 4 2023-04-18 "Linux man-pages 6.05.01" +.TH random 4 2023-10-31 "Linux man-pages 6.7" .SH NAME random, urandom \- kernel random number source devices .SH SYNOPSIS .nf #include <linux/random.h> -.PP +.P .BI "int ioctl(" fd ", RND" request ", " param ");" .fi .SH DESCRIPTION @@ -28,27 +28,27 @@ has major device number 1 and minor device number 8. The file .I /dev/urandom has major device number 1 and minor device number 9. -.PP +.P The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. The generator also keeps an estimate of the number of bits of noise in the entropy pool. From this entropy pool, random numbers are created. -.PP +.P Linux 3.17 and later provides the simpler and safer .BR getrandom (2) interface which requires no special files; see the .BR getrandom (2) manual page for details. -.PP +.P When read, the .I /dev/urandom device returns random bytes using a pseudorandom number generator seeded from the entropy pool. Reads from this device do not block (i.e., the CPU is not yielded), but can incur an appreciable delay when requesting large amounts of data. -.PP +.P When read during early boot time, .I /dev/urandom may return data prior to the entropy pool being initialized. @@ -57,7 +57,7 @@ may return data prior to the entropy pool being initialized. If this is of concern in your application, use .BR getrandom (2) or \fI/dev/random\fP instead. -.PP +.P The \fI/dev/random\fP device is a legacy interface which dates back to a time where the cryptographic primitives used in the implementation of \fI/dev/urandom\fP were not widely trusted. @@ -65,7 +65,7 @@ It will return random bytes only within the estimated number of bits of fresh noise in the entropy pool, blocking if necessary. \fI/dev/random\fP is suitable for applications that need high quality randomness, and can afford indeterminate delays. -.PP +.P When the entropy pool is empty, reads from \fI/dev/random\fP will block until additional environmental noise is gathered. Since Linux 5.6, the @@ -89,7 +89,7 @@ will return \-1 and .I errno will be set to .BR EAGAIN . -.PP +.P The .B O_NONBLOCK flag has no effect when opening @@ -104,7 +104,7 @@ Reads with a buffer over this limit may return less than the requested number of bytes or fail with the error .BR EINTR , if interrupted by a signal handler. -.PP +.P Since Linux 3.16, .\" commit 79a8468747c5f95ed3d5ce8376a3e82e0c5857fc a @@ -119,7 +119,7 @@ from will return at most 512 bytes .\" SEC_XFER_SIZE in drivers/char/random.c (340 bytes before Linux 2.6.12). -.PP +.P Writing to \fI/dev/random\fP or \fI/dev/urandom\fP will update the entropy pool with the data written, but this will not result in a higher entropy count. @@ -137,7 +137,7 @@ these applications, .BR getrandom (2) must be used instead, because it will block until the entropy pool is initialized. -.PP +.P If a seed file is saved across reboots as recommended below, the output is cryptographically secure against attackers without local root access as @@ -156,7 +156,7 @@ entropy is not immediately available. If your system does not have \fI/dev/random\fP and \fI/dev/urandom\fP created already, they can be created with the following commands: -.PP +.P .in +4n .EX mknod \-m 666 /dev/random c 1 8 @@ -164,7 +164,7 @@ mknod \-m 666 /dev/urandom c 1 9 chown root:root /dev/random /dev/urandom .EE .in -.PP +.P When a Linux system starts up without much operator interaction, the entropy pool may be in a fairly predictable state. This reduces the actual amount of noise in the entropy pool @@ -173,7 +173,7 @@ In order to counteract this effect, it helps to carry entropy pool information across shut-downs and start-ups. To do this, add the lines to an appropriate script which is run during the Linux system start-up sequence: -.PP +.P .in +4n .EX echo "Initializing random number generator..." @@ -192,10 +192,10 @@ bytes=$(expr $bits / 8) dd if=/dev/urandom of=$random_seed count=1 bs=$bytes .EE .in -.PP +.P Also, add the following lines in an appropriate script which is run during the Linux system shutdown: -.PP +.P .in +4n .EX # Carry a random seed from shut\-down to start\-up @@ -210,7 +210,7 @@ bytes=$(expr $bits / 8) dd if=/dev/urandom of=$random_seed count=1 bs=$bytes .EE .in -.PP +.P In the above examples, we assume Linux 2.6.0 or later, where .I /proc/sys/kernel/random/poolsize returns the size of the entropy pool in bits (see below). @@ -321,7 +321,9 @@ is the buffer of size .I buf_size which gets added to the entropy pool. .TP -.BR RNDZAPENTCNT ", " RNDCLEARPOOL +.B RNDZAPENTCNT +.TQ +.B RNDCLEARPOOL Zero the entropy count of all pools and add some system data (such as wall clock) to the pools. .SH FILES @@ -343,5 +345,5 @@ may return data prior to the entropy pool being initialized. .BR mknod (1), .BR getrandom (2), .BR random (7) -.PP +.P RFC\ 1750, "Randomness Recommendations for Security" |