MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AddDataToRng

Function AddDataToRng

src/random.cpp:302–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300static uint64_t rng_counter = 0;
301
302static void AddDataToRng(void* data, size_t len) {
303 CSHA512 hasher;
304 hasher.Write((const unsigned char*)&len, sizeof(len));
305 hasher.Write((const unsigned char*)data, len);
306 unsigned char buf[64];
307 {
308 std::unique_lock<std::mutex> lock(cs_rng_state);
309 hasher.Write(rng_state, sizeof(rng_state));
310 hasher.Write((const unsigned char*)&rng_counter, sizeof(rng_counter));
311 ++rng_counter;
312 hasher.Finalize(buf);
313 memcpy(rng_state, buf + 32, 32);
314 }
315 memory_cleanse(buf, 64);
316}
317
318void GetStrongRandBytes(unsigned char* out, int num)
319{

Callers 1

RandAddSeedSleepFunction · 0.85

Calls 4

memcpyFunction · 0.85
memory_cleanseFunction · 0.85
WriteMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected