@@ -295,14 +295,14 @@ static void SeedHardwareSlow(CSHA512& hasher) noexcept {
295295}
296296
297297/* * Use repeated SHA512 to strengthen the randomness in seed32, and feed into hasher. */
298- static void Strengthen (const unsigned char (&seed)[32], int microseconds , CSHA512& hasher) noexcept
298+ static void Strengthen (const unsigned char (&seed)[32], SteadyClock::duration dur , CSHA512& hasher) noexcept
299299{
300300 CSHA512 inner_hasher;
301301 inner_hasher.Write (seed, sizeof (seed));
302302
303303 // Hash loop
304304 unsigned char buffer[64 ];
305- int64_t stop = GetTimeMicros () + microseconds ;
305+ const auto stop{ SteadyClock::now () + dur} ;
306306 do {
307307 for (int i = 0 ; i < 1000 ; ++i) {
308308 inner_hasher.Finalize (buffer);
@@ -312,7 +312,7 @@ static void Strengthen(const unsigned char (&seed)[32], int microseconds, CSHA51
312312 // Benchmark operation and feed it into outer hasher.
313313 int64_t perf = GetPerformanceCounter ();
314314 hasher.Write ((const unsigned char *)&perf, sizeof (perf));
315- } while (GetTimeMicros () < stop);
315+ } while (SteadyClock::now () < stop);
316316
317317 // Produce output from inner state and feed it to outer hasher.
318318 inner_hasher.Finalize (buffer);
@@ -566,13 +566,13 @@ static void SeedSlow(CSHA512& hasher, RNGState& rng) noexcept
566566}
567567
568568/* * Extract entropy from rng, strengthen it, and feed it into hasher. */
569- static void SeedStrengthen (CSHA512& hasher, RNGState& rng, int microseconds ) noexcept
569+ static void SeedStrengthen (CSHA512& hasher, RNGState& rng, SteadyClock::duration dur ) noexcept
570570{
571571 // Generate 32 bytes of entropy from the RNG, and a copy of the entropy already in hasher.
572572 unsigned char strengthen_seed[32 ];
573573 rng.MixExtract (strengthen_seed, sizeof (strengthen_seed), CSHA512 (hasher), false );
574574 // Strengthen the seed, and feed it into hasher.
575- Strengthen (strengthen_seed, microseconds , hasher);
575+ Strengthen (strengthen_seed, dur , hasher);
576576}
577577
578578static void SeedPeriodic (CSHA512& hasher, RNGState& rng) noexcept
@@ -592,7 +592,7 @@ static void SeedPeriodic(CSHA512& hasher, RNGState& rng) noexcept
592592 LogPrint (BCLog::RANDOM, " Feeding %i bytes of dynamic environment data into RNG\n " , hasher.Size () - old_size);
593593
594594 // Strengthen for 10 ms
595- SeedStrengthen (hasher, rng, 10000 );
595+ SeedStrengthen (hasher, rng, 10ms );
596596}
597597
598598static void SeedStartup (CSHA512& hasher, RNGState& rng) noexcept
@@ -612,7 +612,7 @@ static void SeedStartup(CSHA512& hasher, RNGState& rng) noexcept
612612 LogPrint (BCLog::RANDOM, " Feeding %i bytes of environment data into RNG\n " , hasher.Size () - old_size);
613613
614614 // Strengthen for 100 ms
615- SeedStrengthen (hasher, rng, 100000 );
615+ SeedStrengthen (hasher, rng, 100ms );
616616}
617617
618618enum class RNGLevel {
0 commit comments