diff options
author | Theodore Ts'o <tytso@mit.edu> | 2012-07-05 10:35:23 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-07-14 20:17:47 -0400 |
commit | c2557a303ab6712bb6e09447df828c557c710ac9 (patch) | |
tree | 6459a604fa95e7cabdf78a30b1a5fa203e3252bb /include/linux/random.h | |
parent | e6d4947b12e8ad947add1032dd754803c6004824 (diff) |
random: add new get_random_bytes_arch() function
Create a new function, get_random_bytes_arch() which will use the
architecture-specific hardware random number generator if it is
present. Change get_random_bytes() to not use the HW RNG, even if it
is avaiable.
The reason for this is that the hw random number generator is fast (if
it is present), but it requires that we trust the hardware
manufacturer to have not put in a back door. (For example, an
increasing counter encrypted by an AES key known to the NSA.)
It's unlikely that Intel (for example) was paid off by the US
Government to do this, but it's impossible for them to prove otherwise
--- especially since Bull Mountain is documented to use AES as a
whitener. Hence, the output of an evil, trojan-horse version of
RDRAND is statistically indistinguishable from an RDRAND implemented
to the specifications claimed by Intel. Short of using a tunnelling
electronic microscope to reverse engineer an Ivy Bridge chip and
disassembling and analyzing the CPU microcode, there's no way for us
to tell for sure.
Since users of get_random_bytes() in the Linux kernel need to be able
to support hardware systems where the HW RNG is not present, most
time-sensitive users of this interface have already created their own
cryptographic RNG interface which uses get_random_bytes() as a seed.
So it's much better to use the HW RNG to improve the existing random
number generator, by mixing in any entropy returned by the HW RNG into
/dev/random's entropy pool, but to always _use_ /dev/random's entropy
pool.
This way we get almost of the benefits of the HW RNG without any
potential liabilities. The only benefits we forgo is the
speed/performance enhancements --- and generic kernel code can't
depend on depend on get_random_bytes() having the speed of a HW RNG
anyway.
For those places that really want access to the arch-specific HW RNG,
if it is available, we provide get_random_bytes_arch().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
Diffstat (limited to 'include/linux/random.h')
-rw-r--r-- | include/linux/random.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/random.h b/include/linux/random.h index e14b4387354a..29e217a7e6d0 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
@@ -56,6 +56,7 @@ extern void add_input_randomness(unsigned int type, unsigned int code, | |||
56 | extern void add_interrupt_randomness(int irq, int irq_flags); | 56 | extern void add_interrupt_randomness(int irq, int irq_flags); |
57 | 57 | ||
58 | extern void get_random_bytes(void *buf, int nbytes); | 58 | extern void get_random_bytes(void *buf, int nbytes); |
59 | extern void get_random_bytes_arch(void *buf, int nbytes); | ||
59 | void generate_random_uuid(unsigned char uuid_out[16]); | 60 | void generate_random_uuid(unsigned char uuid_out[16]); |
60 | 61 | ||
61 | #ifndef MODULE | 62 | #ifndef MODULE |