From 5624ab0b4f844dc7c17aeb1b009f002c33c38fb3 Mon Sep 17 00:00:00 2001 From: fanquake Date: Sat, 26 Oct 2019 08:15:43 -0400 Subject: [PATCH] random: stop feeding RNG output back into OpenSSL On the ::SLOW or ::SLEEP paths, we would feed our RNG output back into OpenSSL using RAND_add. This commit removes that functionality. RAND_add(): https://www.openssl.org/docs/manmaster/man3/RAND_add.html RAND_add() mixes the num bytes at buf into the internal state of the random generator. This function will not normally be needed, as mentioned above. The randomness argument is an estimate of how much randomness is contained in buf, in bytes, and should be a number between zero and num. --- src/random.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index 3e6398f7b4..8bdf45ef67 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -586,14 +586,6 @@ static void ProcRand(unsigned char* out, int num, RNGLevel level) SeedStartup(startup_hasher, rng); rng.MixExtract(out, num, std::move(startup_hasher), true); } - - // For anything but the 'fast' level, feed the resulting RNG output (after an additional hashing step) back into OpenSSL. - if (level != RNGLevel::FAST) { - unsigned char buf[64]; - CSHA512().Write(out, num).Finalize(buf); - RAND_add(buf, sizeof(buf), num); - memory_cleanse(buf, 64); - } } void GetRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::FAST); }