Changeset View
Changeset View
Standalone View
Standalone View
src/random.cpp
Show First 20 Lines • Show All 570 Lines • ▼ Show 20 Lines | |||||
static void SeedPeriodic(CSHA512 &hasher, RNGState &rng) { | static void SeedPeriodic(CSHA512 &hasher, RNGState &rng) { | ||||
// Everything that the 'fast' seeder includes | // Everything that the 'fast' seeder includes | ||||
SeedFast(hasher); | SeedFast(hasher); | ||||
// High-precision timestamp | // High-precision timestamp | ||||
SeedTimestamp(hasher); | SeedTimestamp(hasher); | ||||
// Dynamic environment data (performance monitoring, ...) | // Dynamic environment data (performance monitoring, ...) | ||||
auto old_size = hasher.Size(); | |||||
RandAddDynamicEnv(hasher); | RandAddDynamicEnv(hasher); | ||||
LogPrintf("Feeding %i bytes of dynamic environment data into RNG\n", | |||||
hasher.Size() - old_size); | |||||
// Strengthen for 10ms | // Strengthen for 10ms | ||||
SeedStrengthen(hasher, rng, 10000); | SeedStrengthen(hasher, rng, 10000); | ||||
} | } | ||||
static void SeedStartup(CSHA512 &hasher, RNGState &rng) noexcept { | static void SeedStartup(CSHA512 &hasher, RNGState &rng) noexcept { | ||||
// Gather 256 bits of hardware randomness, if available | // Gather 256 bits of hardware randomness, if available | ||||
SeedHardwareSlow(hasher); | SeedHardwareSlow(hasher); | ||||
// Everything that the 'slow' seeder includes. | // Everything that the 'slow' seeder includes. | ||||
SeedSlow(hasher); | SeedSlow(hasher); | ||||
// Dynamic environment data (performance monitoring, ...) | // Dynamic environment data (performance monitoring, ...) | ||||
auto old_size = hasher.Size(); | |||||
RandAddDynamicEnv(hasher); | RandAddDynamicEnv(hasher); | ||||
// Static environment data | // Static environment data | ||||
RandAddStaticEnv(hasher); | RandAddStaticEnv(hasher); | ||||
LogPrintf("Feeding %i bytes of environment data into RNG\n", | |||||
hasher.Size() - old_size); | |||||
// Strengthen for 100ms | // Strengthen for 100ms | ||||
SeedStrengthen(hasher, rng, 100000); | SeedStrengthen(hasher, rng, 100000); | ||||
} | } | ||||
enum class RNGLevel { | enum class RNGLevel { | ||||
FAST, //!< Automatically called by GetRandBytes | FAST, //!< Automatically called by GetRandBytes | ||||
SLOW, //!< Automatically called by GetStrongRandBytes | SLOW, //!< Automatically called by GetStrongRandBytes | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |