162306a36Sopenharmony_ci=================================
262306a36Sopenharmony_ciHardware random number generators
362306a36Sopenharmony_ci=================================
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciIntroduction
662306a36Sopenharmony_ci============
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciThe hw_random framework is software that makes use of a
962306a36Sopenharmony_cispecial hardware feature on your CPU or motherboard,
1062306a36Sopenharmony_cia Random Number Generator (RNG).  The software has two parts:
1162306a36Sopenharmony_cia core providing the /dev/hwrng character device and its
1262306a36Sopenharmony_cisysfs support, plus a hardware-specific driver that plugs
1362306a36Sopenharmony_ciinto that core.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciTo make the most effective use of these mechanisms, you
1662306a36Sopenharmony_cishould download the support software as well.  Download the
1762306a36Sopenharmony_cilatest version of the "rng-tools" package from the
1862306a36Sopenharmony_cihw_random driver's official Web site:
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci	http://sourceforge.net/projects/gkernel/
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciThose tools use /dev/hwrng to fill the kernel entropy pool,
2362306a36Sopenharmony_ciwhich is used internally and exported by the /dev/urandom and
2462306a36Sopenharmony_ci/dev/random special files.
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciTheory of operation
2762306a36Sopenharmony_ci===================
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciCHARACTER DEVICE.  Using the standard open()
3062306a36Sopenharmony_ciand read() system calls, you can read random data from
3162306a36Sopenharmony_cithe hardware RNG device.  This data is NOT CHECKED by any
3262306a36Sopenharmony_cifitness tests, and could potentially be bogus (if the
3362306a36Sopenharmony_cihardware is faulty or has been tampered with).  Data is only
3462306a36Sopenharmony_cioutput if the hardware "has-data" flag is set, but nevertheless
3562306a36Sopenharmony_cia security-conscious person would run fitness tests on the
3662306a36Sopenharmony_cidata before assuming it is truly random.
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciThe rng-tools package uses such tests in "rngd", and lets you
3962306a36Sopenharmony_cirun them by hand with a "rngtest" utility.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/dev/hwrng is char device major 10, minor 183.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciCLASS DEVICE.  There is a /sys/class/misc/hw_random node with
4462306a36Sopenharmony_citwo unique attributes, "rng_available" and "rng_current".  The
4562306a36Sopenharmony_ci"rng_available" attribute lists the hardware-specific drivers
4662306a36Sopenharmony_ciavailable, while "rng_current" lists the one which is currently
4762306a36Sopenharmony_ciconnected to /dev/hwrng.  If your system has more than one
4862306a36Sopenharmony_ciRNG available, you may change the one used by writing a name from
4962306a36Sopenharmony_cithe list in "rng_available" into "rng_current".
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci==========================================================================
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciHardware driver for Intel/AMD/VIA Random Number Generators (RNG)
5562306a36Sopenharmony_ci	- Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
5662306a36Sopenharmony_ci	- Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciAbout the Intel RNG hardware, from the firmware hub datasheet
6062306a36Sopenharmony_ci=============================================================
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciThe Firmware Hub integrates a Random Number Generator (RNG)
6362306a36Sopenharmony_ciusing thermal noise generated from inherently random quantum
6462306a36Sopenharmony_cimechanical properties of silicon. When not generating new random
6562306a36Sopenharmony_cibits the RNG circuitry will enter a low power state. Intel will
6662306a36Sopenharmony_ciprovide a binary software driver to give third party software
6762306a36Sopenharmony_ciaccess to our RNG for use as a security feature. At this time,
6862306a36Sopenharmony_cithe RNG is only to be used with a system in an OS-present state.
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ciIntel RNG Driver notes
7162306a36Sopenharmony_ci======================
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciFIXME: support poll(2)
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci.. note::
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	request_mem_region was removed, for three reasons:
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	1) Only one RNG is supported by this driver;
8062306a36Sopenharmony_ci	2) The location used by the RNG is a fixed location in
8162306a36Sopenharmony_ci	   MMIO-addressable memory;
8262306a36Sopenharmony_ci	3) users with properly working BIOS e820 handling will always
8362306a36Sopenharmony_ci	   have the region in which the RNG is located reserved, so
8462306a36Sopenharmony_ci	   request_mem_region calls always fail for proper setups.
8562306a36Sopenharmony_ci	   However, for people who use mem=XX, BIOS e820 information is
8662306a36Sopenharmony_ci	   **not** in /proc/iomem, and request_mem_region(RNG_ADDR) can
8762306a36Sopenharmony_ci	   succeed.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciDriver details
9062306a36Sopenharmony_ci==============
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ciBased on:
9362306a36Sopenharmony_ci	Intel 82802AB/82802AC Firmware Hub (FWH) Datasheet
9462306a36Sopenharmony_ci	May 1999 Order Number: 290658-002 R
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciIntel 82802 Firmware Hub:
9762306a36Sopenharmony_ci	Random Number Generator
9862306a36Sopenharmony_ci	Programmer's Reference Manual
9962306a36Sopenharmony_ci	December 1999 Order Number: 298029-001 R
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ciIntel 82802 Firmware HUB Random Number Generator Driver
10262306a36Sopenharmony_ci	Copyright (c) 2000 Matt Sottek <msottek@quiknet.com>
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciSpecial thanks to Matt Sottek.  I did the "guts", he
10562306a36Sopenharmony_cidid the "brains" and all the testing.
106