Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 1 | ========================================================== |
| 2 | Linux support for random number generator in i8xx chipsets |
| 3 | ========================================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 5 | Introduction |
| 6 | ============ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 8 | The hw_random framework is software that makes use of a |
| 9 | special hardware feature on your CPU or motherboard, |
| 10 | a Random Number Generator (RNG). The software has two parts: |
| 11 | a core providing the /dev/hwrng character device and its |
| 12 | sysfs support, plus a hardware-specific driver that plugs |
| 13 | into that core. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 15 | To make the most effective use of these mechanisms, you |
| 16 | should download the support software as well. Download the |
| 17 | latest version of the "rng-tools" package from the |
| 18 | hw_random driver's official Web site: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 20 | http://sourceforge.net/projects/gkernel/ |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 21 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 22 | Those tools use /dev/hwrng to fill the kernel entropy pool, |
| 23 | which is used internally and exported by the /dev/urandom and |
| 24 | /dev/random special files. |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 25 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 26 | Theory of operation |
| 27 | =================== |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 28 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 29 | CHARACTER DEVICE. Using the standard open() |
| 30 | and read() system calls, you can read random data from |
| 31 | the hardware RNG device. This data is NOT CHECKED by any |
| 32 | fitness tests, and could potentially be bogus (if the |
| 33 | hardware is faulty or has been tampered with). Data is only |
| 34 | output if the hardware "has-data" flag is set, but nevertheless |
| 35 | a security-conscious person would run fitness tests on the |
| 36 | data before assuming it is truly random. |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 37 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 38 | The rng-tools package uses such tests in "rngd", and lets you |
| 39 | run them by hand with a "rngtest" utility. |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 40 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 41 | /dev/hwrng is char device major 10, minor 183. |
| 42 | |
| 43 | CLASS DEVICE. There is a /sys/class/misc/hw_random node with |
| 44 | two unique attributes, "rng_available" and "rng_current". The |
| 45 | "rng_available" attribute lists the hardware-specific drivers |
| 46 | available, while "rng_current" lists the one which is currently |
| 47 | connected to /dev/hwrng. If your system has more than one |
| 48 | RNG available, you may change the one used by writing a name from |
| 49 | the list in "rng_available" into "rng_current". |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 50 | |
| 51 | ========================================================================== |
| 52 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 53 | |
| 54 | Hardware driver for Intel/AMD/VIA Random Number Generators (RNG) |
| 55 | - Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com> |
| 56 | - Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com> |
David Brownell | 537878d | 2008-03-24 12:29:51 -0700 | [diff] [blame] | 57 | |
| 58 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 59 | About the Intel RNG hardware, from the firmware hub datasheet |
| 60 | ============================================================= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 62 | The Firmware Hub integrates a Random Number Generator (RNG) |
| 63 | using thermal noise generated from inherently random quantum |
| 64 | mechanical properties of silicon. When not generating new random |
| 65 | bits the RNG circuitry will enter a low power state. Intel will |
| 66 | provide a binary software driver to give third party software |
| 67 | access to our RNG for use as a security feature. At this time, |
| 68 | the RNG is only to be used with a system in an OS-present state. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 70 | Intel RNG Driver notes |
| 71 | ====================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 73 | FIXME: support poll(2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 75 | .. note:: |
| 76 | |
| 77 | request_mem_region was removed, for three reasons: |
| 78 | |
| 79 | 1) Only one RNG is supported by this driver; |
| 80 | 2) The location used by the RNG is a fixed location in |
| 81 | MMIO-addressable memory; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | 3) users with properly working BIOS e820 handling will always |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 83 | have the region in which the RNG is located reserved, so |
| 84 | request_mem_region calls always fail for proper setups. |
| 85 | However, for people who use mem=XX, BIOS e820 information is |
| 86 | **not** in /proc/iomem, and request_mem_region(RNG_ADDR) can |
| 87 | succeed. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 89 | Driver details |
| 90 | ============== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 92 | Based on: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | Intel 82802AB/82802AC Firmware Hub (FWH) Datasheet |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 94 | May 1999 Order Number: 290658-002 R |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 96 | Intel 82802 Firmware Hub: |
| 97 | Random Number Generator |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | Programmer's Reference Manual |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 99 | December 1999 Order Number: 298029-001 R |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 101 | Intel 82802 Firmware HUB Random Number Generator Driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | Copyright (c) 2000 Matt Sottek <msottek@quiknet.com> |
| 103 | |
Mauro Carvalho Chehab | 440e4f6 | 2017-05-14 13:59:18 -0300 | [diff] [blame^] | 104 | Special thanks to Matt Sottek. I did the "guts", he |
| 105 | did the "brains" and all the testing. |