diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2019-01-24 18:40:02 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2019-02-03 17:34:26 -0800 |
commit | 1435fabc19d2143187efb493cbe23225eaf851ae (patch) | |
tree | 618b087accfdca7c0d5e9f7a3eeda51ce5c8b1f9 /src/random.h | |
parent | 72bd4ab867e3be0d8410403d9641c08288d343e3 (diff) |
Use RdSeed when available, and reduce RdRand load
This introduces support for autodetecting and using the RdSeed instruction.
In addition:
* In SeedFast, only 64 bits of entropy are generated through RdRand (256 was relatively slow).
* In SeedStartup, 256 bits of entropy are generated, using RdSeed (preferably) or RdRand (otherwise).
Diffstat (limited to 'src/random.h')
-rw-r--r-- | src/random.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/random.h b/src/random.h index 4c73f3822a..1c035f87ba 100644 --- a/src/random.h +++ b/src/random.h @@ -24,7 +24,7 @@ * perform 'fast' seeding, consisting of mixing in: * - A stack pointer (indirectly committing to calling thread and call stack) * - A high-precision timestamp (rdtsc when available, c++ high_resolution_clock otherwise) - * - Hardware RNG (rdrand) when available. + * - 64 bits from the hardware RNG (rdrand) when available. * These entropy sources are very fast, and only designed to protect against situations * where a VM state restore/copy results in multiple systems with the same randomness. * FastRandomContext on the other hand does not protect against this once created, but @@ -48,6 +48,7 @@ * * On first use of the RNG (regardless of what function is called first), all entropy * sources used in the 'slow' seeder are included, but also: + * - 256 bits from the hardware RNG (rdseed or rdrand) when available. * - (On Windows) Performance monitoring data from the OS. * - (On Windows) Through OpenSSL, the screen contents. * |