Linux support for random number generator in i8xx chipsets¶
Introduction¶
The hw_random framework is software that makes use of aspecial hardware feature on your CPU or motherboard,a Random Number Generator (RNG). The software has two parts:a core providing the /dev/hwrng character device and itssysfs support, plus a hardware-specific driver that plugsinto that core.
To make the most effective use of these mechanisms, youshould download the support software as well. Download thelatest version of the “rng-tools” package from thehw_random driver’s official Web site:
Those tools use /dev/hwrng to fill the kernel entropy pool,which is used internally and exported by the /dev/urandom and/dev/random special files.
Theory of operation¶
CHARACTER DEVICE. Using the standard open()and read() system calls, you can read random data fromthe hardware RNG device. This data is NOT CHECKED by anyfitness tests, and could potentially be bogus (if thehardware is faulty or has been tampered with). Data is onlyoutput if the hardware “has-data” flag is set, but neverthelessa security-conscious person would run fitness tests on thedata before assuming it is truly random.
The rng-tools package uses such tests in “rngd”, and lets yourun them by hand with a “rngtest” utility.
/dev/hwrng is char device major 10, minor 183.
CLASS DEVICE. There is a /sys/class/misc/hw_random node withtwo unique attributes, “rng_available” and “rng_current”. The“rng_available” attribute lists the hardware-specific driversavailable, while “rng_current” lists the one which is currentlyconnected to /dev/hwrng. If your system has more than oneRNG available, you may change the one used by writing a name fromthe list in “rng_available” into “rng_current”.
- Hardware driver for Intel/AMD/VIA Random Number Generators (RNG)
- Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
- Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
About the Intel RNG hardware, from the firmware hub datasheet¶
The Firmware Hub integrates a Random Number Generator (RNG)using thermal noise generated from inherently random quantummechanical properties of silicon. When not generating new randombits the RNG circuitry will enter a low power state. Intel willprovide a binary software driver to give third party softwareaccess to our RNG for use as a security feature. At this time,the RNG is only to be used with a system in an OS-present state.
Intel RNG Driver notes¶
FIXME: support poll(2)
Note
request_mem_region was removed, for three reasons:
- Only one RNG is supported by this driver;
- The location used by the RNG is a fixed location inMMIO-addressable memory;
- users with properly working BIOS e820 handling will alwayshave the region in which the RNG is located reserved, sorequest_mem_region calls always fail for proper setups.However, for people who use mem=XX, BIOS e820 information isnot in /proc/iomem, and request_mem_region(RNG_ADDR) cansucceed.
Driver details¶
- Based on:
- Intel 82802AB/82802AC Firmware Hub (FWH) DatasheetMay 1999 Order Number: 290658-002 R
- Intel 82802 Firmware Hub:
- Random Number GeneratorProgrammer’s Reference ManualDecember 1999 Order Number: 298029-001 R
- Intel 82802 Firmware HUB Random Number Generator Driver
- Copyright (c) 2000 Matt Sottek <msottek@quiknet.com>
Special thanks to Matt Sottek. I did the “guts”, hedid the “brains” and all the testing.