Skip to content

Commit

Permalink
Report amount of data gathered from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Nov 12, 2019
1 parent 64e1e02 commit d1c0277
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/crypto/sha512.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CSHA512
CSHA512& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
CSHA512& Reset();
uint64_t Size() const { return bytes; }
};

#endif // BITCOIN_CRYPTO_SHA512_H
4 changes: 4 additions & 0 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ static void SeedPeriodic(CSHA512& hasher, RNGState& rng)
SeedTimestamp(hasher);

// Dynamic environment data (performance monitoring, ...)
auto old_size = hasher.Size();
RandAddDynamicEnv(hasher);
LogPrintf("Feeding %i bytes of dynamic environment data into RNG\n", hasher.Size() - old_size);

// Strengthen for 10 ms
SeedStrengthen(hasher, rng, 10000);
Expand All @@ -540,10 +542,12 @@ static void SeedStartup(CSHA512& hasher, RNGState& rng) noexcept
SeedSlow(hasher);

// Dynamic environment data (performance monitoring, ...)
auto old_size = hasher.Size();
RandAddDynamicEnv(hasher);

// Static environment data
RandAddStaticEnv(hasher);
LogPrintf("Feeding %i bytes of environment data into RNG\n", hasher.Size() - old_size);

// Strengthen for 100 ms
SeedStrengthen(hasher, rng, 100000);
Expand Down

0 comments on commit d1c0277

Please sign in to comment.