Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115632
D6242.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D6242.diff
View Options
diff --git a/src/random.cpp b/src/random.cpp
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -18,10 +18,6 @@
#include <sync.h> // for Mutex
#include <util/time.h> // for GetTime()
-#include <openssl/conf.h>
-#include <openssl/err.h>
-#include <openssl/rand.h>
-
#include <chrono>
#include <cstdlib>
#include <memory>
@@ -392,8 +388,6 @@
#endif
}
-void LockingCallbackOpenSSL(int mode, int i, const char *file, int line);
-
namespace {
class RNGState {
@@ -410,32 +404,11 @@
uint8_t m_state[32] GUARDED_BY(m_mutex) = {0};
uint64_t m_counter GUARDED_BY(m_mutex) = 0;
bool m_strongly_seeded GUARDED_BY(m_mutex) = false;
- std::unique_ptr<Mutex[]> m_mutex_openssl;
public:
- RNGState() noexcept {
- InitHardwareRand();
-
- // Init OpenSSL library multithreading support
- m_mutex_openssl.reset(new Mutex[CRYPTO_num_locks()]);
- CRYPTO_set_locking_callback(LockingCallbackOpenSSL);
-
- // OpenSSL can optionally load a config file which lists optional
- // loadable modules and engines. We don't use them so we don't require
- // the config. However some of our libs may call functions which attempt
- // to load the config file, possibly resulting in an exit() or crash if
- // it is missing or corrupt. Explicitly tell OpenSSL not to try to load
- // the file. The result for our libs will be that the config appears to
- // have been loaded and there are no modules/engines available.
- OPENSSL_no_config();
- }
+ RNGState() noexcept { InitHardwareRand(); }
- ~RNGState() {
- // Securely erase the memory used by the OpenSSL PRNG
- RAND_cleanup();
- // Shutdown OpenSSL library multithreading support
- CRYPTO_set_locking_callback(nullptr);
- }
+ ~RNGState() {}
/**
* Extract up to 32 bytes of entropy from the RNG state, mixing in new
@@ -475,8 +448,6 @@
memory_cleanse(buf, 64);
return ret;
}
-
- Mutex &GetOpenSSLMutex(int i) { return m_mutex_openssl[i]; }
};
RNGState &GetRNGState() noexcept {
@@ -488,17 +459,6 @@
}
} // namespace
-void LockingCallbackOpenSSL(int mode, int i, const char *file,
- int line) NO_THREAD_SAFETY_ANALYSIS {
- RNGState &rng = GetRNGState();
-
- if (mode & CRYPTO_LOCK) {
- rng.GetOpenSSLMutex(i).lock();
- } else {
- rng.GetOpenSSLMutex(i).unlock();
- }
-}
-
/**
* A note on the use of noexcept in the seeding functions below:
*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:36 (3 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187643
Default Alt Text
D6242.diff (2 KB)
Attached To
D6242: random: Remove remaining OpenSSL calls and locking infrastructure
Event Timeline
Log In to Comment