From 31062675757d4b743ca808cfb8f54d3f719f5fc1 Mon Sep 17 00:00:00 2001 From: "Paragon Initiative Enterprises, LLC" Date: Fri, 28 Oct 2016 22:03:55 -0400 Subject: [PATCH] Use libsodium's CSPRNG instead of OpenSSL's --- src/random.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index 4f197fcac..52b9c7cb9 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -21,6 +21,7 @@ #include #include +#include "sodium.h" static inline int64_t GetPerformanceCounter() { @@ -83,12 +84,9 @@ void RandAddSeedPerfmon() #endif } -void GetRandBytes(unsigned char* buf, int num) +void GetRandBytes(unsigned char* buf, size_t num) { - if (RAND_bytes(buf, num) != 1) { - LogPrintf("%s: OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL)); - assert(false); - } + randombytes_buf(buf, (size_t) num); } uint64_t GetRand(uint64_t nMax)