Skip to content

Commit

Permalink
Report amount of data gathered from environment
Browse files Browse the repository at this point in the history
Cherry-picked from: d1c0277
  • Loading branch information
sipa authored and xanimo committed May 6, 2024
1 parent 27ba585 commit 65f16db
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 @@ -24,6 +24,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; }
};

void detect_sha512_hardware(void);
Expand Down
4 changes: 4 additions & 0 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,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 @@ -460,10 +462,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 65f16db

Please sign in to comment.