Rev | Author | # | Line |
---|---|---|---|
1 | perry | 1 | RANDOM |
2 | !!!RANDOM | ||
3 | NAME | ||
4 | DESCRIPTION | ||
5 | CONFIGURING | ||
6 | FILES | ||
7 | AUTHOR | ||
8 | SEE ALSO | ||
9 | ---- | ||
10 | !!NAME | ||
11 | |||
12 | |||
13 | random, urandom - kernel random number source devices | ||
14 | !!DESCRIPTION | ||
15 | |||
16 | |||
17 | The character special files __/dev/random__ and | ||
2 | StuartYeates | 18 | __/dev/urandom__ (present since [Linux] 1.3.30) provide an |
1 | perry | 19 | interface to the kernel's random number generator. File |
20 | __/dev/random__ has major device number 1 and minor | ||
21 | device number 8. File __/dev/urandom__ has major device | ||
22 | number 1 and minor device number 9. | ||
23 | |||
24 | |||
25 | The random number generator gathers environmental noise from | ||
26 | device drivers and other sources into an entropy pool. The | ||
27 | generator also keeps an estimate of the number of bit of the | ||
28 | noise in the entropy pool. From this entropy pool random | ||
29 | numbers are created. | ||
30 | |||
31 | |||
32 | When read, the __/dev/random__ device will only return | ||
33 | random bytes within the estimated number of bits of noise in | ||
34 | the entropy pool. __/dev/random__ should be suitable for | ||
35 | uses that need very high quality randomness such as one-time | ||
36 | pad or key generation. When the entropy pool is empty, reads | ||
37 | to __/dev/random__ will block until additional | ||
38 | environmental noise is gathered. | ||
39 | |||
40 | |||
41 | When read, __/dev/urandom__ device will return as many | ||
42 | bytes as are requested. As a result, if there is not | ||
43 | sufficient entropy in the entropy pool, the returned values | ||
44 | are theoretically vulnerable to a cryptographic attack on | ||
45 | the algorithms used by the driver. Knowledge of how to do | ||
46 | this is not available in the current non-classified | ||
47 | literature, but it is theoretically possible that such an | ||
48 | attack may exist. If this is a concern in your application, | ||
49 | use __/dev/random__ instead. | ||
50 | !!CONFIGURING | ||
51 | |||
52 | |||
53 | If your system does not have __/dev/random__ and | ||
54 | __/dev/urandom__ created already, they can be created | ||
55 | with the following commands: | ||
56 | |||
57 | |||
58 | mknod -m 644 /dev/random c 1 8 | ||
2 | StuartYeates | 59 | mknod -m 644 /dev/urandom c 1 9 |
60 | chown root:root /dev/random /dev/urandom | ||
61 | |||
1 | perry | 62 | 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 below the estimate. In order to counteract this effect, it helps to carry entropy pool information across shut-downs and start-ups. To do this, add the following lines to an appropriate script which is run during the Linux system start-up sequence: |
63 | |||
2 | StuartYeates | 64 | echo "Initializing kernel random number generator..." |
65 | # Initialize kernel random number generator with random seed | ||
66 | # from last shut-down (or start-up) to this start-up. Load and | ||
67 | # then save 512 bytes, which is the size of the entropy pool. | ||
68 | if [[ -f /var/random-seed ]; then | ||
69 | cat /var/random-seed >/dev/urandom | ||
70 | fi | ||
71 | dd if=/dev/urandom of=/var/random-seed count=1 | ||
72 | |||
73 | Also, add the following lines in an appropriate script which is run during the Linux system shutdown: | ||
1 | perry | 74 | |
2 | StuartYeates | 75 | # Carry a random seed from shut-down to start-up for the random |
76 | # number generator. Save 512 bytes, which is the size of the | ||
77 | # random number generator's entropy pool. | ||
78 | echo "Saving random seed..." | ||
79 | dd if=/dev/urandom of=/var/random-seed count=1 | ||
1 | perry | 80 | |
81 | |||
82 | !!FILES | ||
83 | |||
84 | |||
85 | /dev/random | ||
86 | /dev/urandom | ||
87 | !!AUTHOR | ||
88 | |||
89 | |||
2 | StuartYeates | 90 | The kernel's RandomNumberGenerator was written by Theodore |
1 | perry | 91 | Ts'o (tytso@athena.mit.edu). |
92 | !!SEE ALSO | ||
93 | |||
94 | |||
2 | StuartYeates | 95 | mknod(1) |
1 | perry | 96 | RFC 1750, |
97 | ---- |
lib/blame.php:177: Warning: Invalid argument supplied for foreach()