Changeset View
Changeset View
Standalone View
Standalone View
src/random.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
* all the previous sources). These entropy sources are slower, but designed to | * all the previous sources). These entropy sources are slower, but designed to | ||||
* make sure the RNG state contains fresh data that is unpredictable to | * make sure the RNG state contains fresh data that is unpredictable to | ||||
* attackers. | * attackers. | ||||
* | * | ||||
* - RandAddSeedSleep() seeds everything that fast seeding includes, but | * - RandAddSeedSleep() seeds everything that fast seeding includes, but | ||||
* additionally: | * additionally: | ||||
* - A high-precision timestamp before and after sleeping 1ms. | * - A high-precision timestamp before and after sleeping 1ms. | ||||
* - (On Windows) Once every 10 minutes, performance monitoring data from the | * - (On Windows) Once every 10 minutes, performance monitoring data from the | ||||
* OS. These just exploit the fact the system is idle to improve the quality of | * OS. | ||||
* the RNG slightly. | * - Once every minute, strengthen the entropy for 10 ms using repeated | ||||
* SHA512. | |||||
* These just exploit the fact the system is idle to improve the quality | |||||
* of the RNG slightly. | |||||
* | * | ||||
* On first use of the RNG (regardless of what function is called first), all | * 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: | * entropy sources used in the 'slow' seeder are included, but also: | ||||
* - 256 bits from the hardware RNG (rdseed or rdrand) when available. | * - 256 bits from the hardware RNG (rdseed or rdrand) when available. | ||||
* - (On Windows) Performance monitoring data from the OS. | * - (On Windows) Performance monitoring data from the OS. | ||||
* - (On Windows) Through OpenSSL, the screen contents. | * - (On Windows) Through OpenSSL, the screen contents. | ||||
* - Strengthen the entropy for 100 ms using repeated SHA512. | |||||
* | * | ||||
* When mixing in new entropy, H = SHA512(entropy || old_rng_state) is computed, | * When mixing in new entropy, H = SHA512(entropy || old_rng_state) is computed, | ||||
* and (up to) the first 32 bytes of H are produced as output, while the last 32 | * and (up to) the first 32 bytes of H are produced as output, while the last 32 | ||||
* bytes become the new RNG state. | * bytes become the new RNG state. | ||||
*/ | */ | ||||
/** | /** | ||||
* Generate random data via the internal PRNG. | * Generate random data via the internal PRNG. | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |