aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2015-01-20 19:23:25 -0500
committerCory Fields <cory-nospam-@coryfields.com>2015-02-15 11:34:02 -0500
commit1630219d906f592c9258bfe2a0e0c4923df35782 (patch)
tree02b0ed9574290873f88bd0ebc1bd0a224c98e5b1 /src/random.cpp
parenta9565863e09a32729bd6ce33f31889099b3d75cb (diff)
openssl: abstract out OPENSSL_cleanse
This makes it easier for us to replace it if desired, since it's now only in one spot. Also, it avoids the openssl include from allocators.h, which essentially forced openssl to be included from every compilation unit.
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/random.cpp b/src/random.cpp
index 663456e962..ae25bee1b7 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -5,6 +5,7 @@
#include "random.h"
+#include "support/cleanse.h"
#ifdef WIN32
#include "compat.h" // for Windows API
#endif
@@ -18,7 +19,6 @@
#include <sys/time.h>
#endif
-#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
@@ -40,7 +40,7 @@ void RandAddSeed()
// Seed with CPU performance counter
int64_t nCounter = GetPerformanceCounter();
RAND_add(&nCounter, sizeof(nCounter), 1.5);
- OPENSSL_cleanse((void*)&nCounter, sizeof(nCounter));
+ memory_cleanse((void*)&nCounter, sizeof(nCounter));
}
void RandAddSeedPerfmon()
@@ -70,7 +70,7 @@ void RandAddSeedPerfmon()
RegCloseKey(HKEY_PERFORMANCE_DATA);
if (ret == ERROR_SUCCESS) {
RAND_add(begin_ptr(vData), nSize, nSize / 100.0);
- OPENSSL_cleanse(begin_ptr(vData), nSize);
+ memory_cleanse(begin_ptr(vData), nSize);
LogPrint("rand", "%s: %lu bytes\n", __func__, nSize);
} else {
static bool warned = false; // Warn only once