diff --git a/src/random.h b/src/random.h --- a/src/random.h +++ b/src/random.h @@ -44,20 +44,18 @@ * make sure the RNG state contains fresh data that is unpredictable to * attackers. * - * - RandAddSeedSleep() seeds everything that fast seeding includes, but + * - RandAddPeriodic() seeds everything that fast seeding includes, but * additionally: - * - A high-precision timestamp before and after sleeping 1ms. - * - (On Windows) Once every 10 minutes, performance monitoring data from the - * OS. - * - 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. + * - A high-precision timestamp + * - Dynamic environment data (performance monitoring, ...) + * - Strengthen the entropy for 10 ms using repeated SHA512. + * This is run once every minute. * * 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. + * - Dynamic environment data (performance monitoring, ...) + * - Static environment data * - Strengthen the entropy for 100 ms using repeated SHA512. * * When mixing in new entropy, H = SHA512(entropy || old_rng_state) is computed, @@ -96,7 +94,7 @@ * * Thread-safe. */ -void RandAddPeriodic(); +void RandAddPeriodic() noexcept; /** * Fast randomness source. This is seeded once with secure random data, but diff --git a/src/random.cpp b/src/random.cpp --- a/src/random.cpp +++ b/src/random.cpp @@ -212,7 +212,7 @@ * Access to other hardware random number generators could be added here later, * assuming it is sufficiently fast (in the order of a few hundred CPU cycles). * Slower sources should probably be invoked separately, and/or only from - * RandAddSeedSleep (which is called during idle background operation). + * RandAddPeriodic (which is called once a minute). */ static void InitHardwareRand() {} static void ReportHardwareRand() {} @@ -502,17 +502,7 @@ /** * A note on the use of noexcept in the seeding functions below: * - * None of the RNG code should ever throw any exception, with the sole exception - * of MilliSleep in SeedSleep, which can (and does) support interruptions which - * cause a boost::thread_interrupted to be thrown. - * - * This means that SeedSleep, and all functions that invoke it are throwing. - * However, we know that GetRandBytes() and GetStrongRandBytes() never trigger - * this sleeping logic, so they are noexcept. The same is true for all the - * GetRand*() functions that use GetRandBytes() indirectly. - * - * TODO: After moving away from interruptible boost-based thread management, - * everything can become noexcept here. + * None of the RNG code should ever throw any exception. */ static void SeedTimestamp(CSHA512 &hasher) noexcept { @@ -568,7 +558,7 @@ Strengthen(strengthen_seed, microseconds, hasher); } -static void SeedPeriodic(CSHA512 &hasher, RNGState &rng) { +static void SeedPeriodic(CSHA512 &hasher, RNGState &rng) noexcept { // Everything that the 'fast' seeder includes SeedFast(hasher); @@ -655,7 +645,7 @@ void GetStrongRandBytes(uint8_t *buf, int num) noexcept { ProcRand(buf, num, RNGLevel::SLOW); } -void RandAddPeriodic() { +void RandAddPeriodic() noexcept { ProcRand(nullptr, 0, RNGLevel::PERIODIC); }