aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-11-07 13:42:52 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-11-07 13:49:25 +0100
commit65e3a1e76202b9a695fc6319dbd527ac563e0895 (patch)
tree4346296f76f3f17b5f3c0120c79f166da64c489f /src/random.cpp
parent9ea87f9e187da41964c3cafdadf54b2f767c3450 (diff)
Make sure that GetRandomBytes never fails
We're using GetRandomBytes in several contexts where it's either unwieldy to return an error, or an error would mean a fatal exception anyhow. @gmaxwell checked OpenSSL a while ago and discovered that it never actually fails, but it can't hurt to be a bit paranoid here.
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/random.cpp b/src/random.cpp
index 998e7dfb08..fc9505ae73 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -82,13 +82,12 @@ void RandAddSeedPerfmon()
#endif
}
-bool GetRandBytes(unsigned char* buf, int num)
+void GetRandBytes(unsigned char* buf, int 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));
- return false;
+ assert(false);
}
- return true;
}
uint64_t GetRand(uint64_t nMax)