Use libsodium's CSPRNG instead of OpenSSL's
This commit is contained in:
committed by
Jack Grigg
parent
ee6d993561
commit
3106267575
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
#include "sodium.h"
|
||||||
|
|
||||||
static inline int64_t GetPerformanceCounter()
|
static inline int64_t GetPerformanceCounter()
|
||||||
{
|
{
|
||||||
@@ -83,12 +84,9 @@ void RandAddSeedPerfmon()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetRandBytes(unsigned char* buf, int num)
|
void GetRandBytes(unsigned char* buf, size_t num)
|
||||||
{
|
{
|
||||||
if (RAND_bytes(buf, num) != 1) {
|
randombytes_buf(buf, (size_t) num);
|
||||||
LogPrintf("%s: OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL));
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetRand(uint64_t nMax)
|
uint64_t GetRand(uint64_t nMax)
|
||||||
|
|||||||
Reference in New Issue
Block a user