1 |
1275 |
phoenix |
Hardware driver for Intel/AMD/VIA Random Number Generators (RNG)
|
2 |
|
|
Copyright 2000,2001 Jeff Garzik
|
3 |
|
|
Copyright 2000,2001 Philipp Rumpf
|
4 |
|
|
|
5 |
|
|
Introduction:
|
6 |
|
|
|
7 |
|
|
The hw_random device driver is software that makes use of a
|
8 |
|
|
special hardware feature on your CPU or motherboard,
|
9 |
|
|
a Random Number Generator (RNG).
|
10 |
|
|
|
11 |
|
|
In order to make effective use of this device driver, you
|
12 |
|
|
should download the support software as well. Download the
|
13 |
|
|
latest version of the "rng-tools" package from the
|
14 |
|
|
hw_random driver's official Web site:
|
15 |
|
|
|
16 |
|
|
http://sourceforge.net/projects/gkernel/
|
17 |
|
|
|
18 |
|
|
About the Intel RNG hardware, from the firmware hub datasheet:
|
19 |
|
|
|
20 |
|
|
The Firmware Hub integrates a Random Number Generator (RNG)
|
21 |
|
|
using thermal noise generated from inherently random quantum
|
22 |
|
|
mechanical properties of silicon. When not generating new random
|
23 |
|
|
bits the RNG circuitry will enter a low power state. Intel will
|
24 |
|
|
provide a binary software driver to give third party software
|
25 |
|
|
access to our RNG for use as a security feature. At this time,
|
26 |
|
|
the RNG is only to be used with a system in an OS-present state.
|
27 |
|
|
|
28 |
|
|
Theory of operation:
|
29 |
|
|
|
30 |
|
|
Character driver. Using the standard open()
|
31 |
|
|
and read() system calls, you can read random data from
|
32 |
|
|
the hardware RNG device. This data is NOT CHECKED by any
|
33 |
|
|
fitness tests, and could potentially be bogus (if the
|
34 |
|
|
hardware is faulty or has been tampered with). Data is only
|
35 |
|
|
output if the hardware "has-data" flag is set, but nevertheless
|
36 |
|
|
a security-conscious person would run fitness tests on the
|
37 |
|
|
data before assuming it is truly random.
|
38 |
|
|
|
39 |
|
|
/dev/hwrandom is char device major 10, minor 183.
|
40 |
|
|
|
41 |
|
|
Driver notes:
|
42 |
|
|
|
43 |
|
|
* FIXME: support poll(2)
|
44 |
|
|
|
45 |
|
|
NOTE: request_mem_region was removed, for two reasons:
|
46 |
|
|
1) Only one RNG is supported by this driver, 2) The location
|
47 |
|
|
used by the RNG is a fixed location in MMIO-addressable memory,
|
48 |
|
|
3) users with properly working BIOS e820 handling will always
|
49 |
|
|
have the region in which the RNG is located reserved, so
|
50 |
|
|
request_mem_region calls always fail for proper setups.
|
51 |
|
|
However, for people who use mem=XX, BIOS e820 information is
|
52 |
|
|
-not- in /proc/iomem, and request_mem_region(RNG_ADDR) can
|
53 |
|
|
succeed.
|
54 |
|
|
|
55 |
|
|
Driver details:
|
56 |
|
|
|
57 |
|
|
Based on:
|
58 |
|
|
Intel 82802AB/82802AC Firmware Hub (FWH) Datasheet
|
59 |
|
|
May 1999 Order Number: 290658-002 R
|
60 |
|
|
|
61 |
|
|
Intel 82802 Firmware Hub: Random Number Generator
|
62 |
|
|
Programmer's Reference Manual
|
63 |
|
|
December 1999 Order Number: 298029-001 R
|
64 |
|
|
|
65 |
|
|
Intel 82802 Firmware HUB Random Number Generator Driver
|
66 |
|
|
Copyright (c) 2000 Matt Sottek
|
67 |
|
|
|
68 |
|
|
Special thanks to Matt Sottek. I did the "guts", he
|
69 |
|
|
did the "brains" and all the testing.
|
70 |
|
|
|
71 |
|
|
Change history:
|
72 |
|
|
|
73 |
|
|
Version 1.0.0:
|
74 |
|
|
* Merge Intel, AMD, VIA RNG drivers into one.
|
75 |
|
|
Further changelog in BitKeeper.
|
76 |
|
|
|
77 |
|
|
Version 0.9.8:
|
78 |
|
|
* Support other i8xx chipsets by adding 82801E detection
|
79 |
|
|
* 82801DB detection is the same as for 82801CA.
|
80 |
|
|
|
81 |
|
|
Version 0.9.7:
|
82 |
|
|
* Support other i8xx chipsets too (by adding 82801BA(M) and
|
83 |
|
|
82801CA(M) detection)
|
84 |
|
|
|
85 |
|
|
Version 0.9.6:
|
86 |
|
|
* Internal driver cleanups, prep for 1.0.0 release.
|
87 |
|
|
|
88 |
|
|
Version 0.9.5:
|
89 |
|
|
* Rip out entropy injection via timer. It never ever worked,
|
90 |
|
|
and a better solution (rngd) is now available.
|
91 |
|
|
|
92 |
|
|
Version 0.9.4:
|
93 |
|
|
* Fix: Remove request_mem_region
|
94 |
|
|
* Fix: Horrible bugs in FIPS calculation and test execution
|
95 |
|
|
|
96 |
|
|
Version 0.9.3:
|
97 |
|
|
* Clean up rng_read a bit.
|
98 |
|
|
* Update i810_rng driver Web site URL.
|
99 |
|
|
* Increase default timer interval to 4 samples per second.
|
100 |
|
|
* Abort if mem region is not available.
|
101 |
|
|
* BSS zero-initialization cleanup.
|
102 |
|
|
* Call misc_register() from rng_init_one.
|
103 |
|
|
* Fix O_NONBLOCK to occur before we schedule.
|
104 |
|
|
|
105 |
|
|
Version 0.9.2:
|
106 |
|
|
* Simplify open blocking logic
|
107 |
|
|
|
108 |
|
|
Version 0.9.1:
|
109 |
|
|
* Support i815 chipsets too (Matt Sottek)
|
110 |
|
|
* Fix reference counting when statically compiled (prumpf)
|
111 |
|
|
* Rewrite rng_dev_read (prumpf)
|
112 |
|
|
* Make module races less likely (prumpf)
|
113 |
|
|
* Small miscellaneous bug fixes (prumpf)
|
114 |
|
|
* Use pci table for PCI id list
|
115 |
|
|
|
116 |
|
|
Version 0.9.0:
|
117 |
|
|
* Don't register a pci_driver, because we are really
|
118 |
|
|
using PCI bridge vendor/device ids, and someone
|
119 |
|
|
may want to register a driver for the bridge. (bug fix)
|
120 |
|
|
* Don't let the usage count go negative (bug fix)
|
121 |
|
|
* Clean up spinlocks (bug fix)
|
122 |
|
|
* Enable PCI device, if necessary (bug fix)
|
123 |
|
|
* iounmap on module unload (bug fix)
|
124 |
|
|
* If RNG chrdev is already in use when open(2) is called,
|
125 |
|
|
sleep until it is available.
|
126 |
|
|
* Remove redundant globals rng_allocated, rng_use_count
|
127 |
|
|
* Convert numeric globals to unsigned
|
128 |
|
|
* Module unload cleanup
|
129 |
|
|
|
130 |
|
|
Version 0.6.2:
|
131 |
|
|
* Clean up spinlocks. Since we don't have any interrupts
|
132 |
|
|
to worry about, but we do have a timer to worry about,
|
133 |
|
|
we use spin_lock_bh everywhere except the timer function
|
134 |
|
|
itself.
|
135 |
|
|
* Fix module load/unload.
|
136 |
|
|
* Fix timer function and h/w enable/disable logic
|
137 |
|
|
* New timer interval sysctl
|
138 |
|
|
* Clean up sysctl names
|