aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/crypto.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-04-10 12:20:31 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-04-10 12:30:48 +0100
commit90a16b119f3f35900d0bfc304e8cae2dad20a84b (patch)
tree5e949a254bd77ef845e495d9b0084dde913b5b51 /src/crypto/crypto.h
parentMerge pull request #3434 (diff)
downloadmonero-90a16b119f3f35900d0bfc304e8cae2dad20a84b.tar.xz
crypto: fix initialization order issue with random mutex
Diffstat (limited to '')
-rw-r--r--src/crypto/crypto.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index 81ebfb9e2..9ea0f2ec0 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -53,8 +53,6 @@ namespace crypto {
#include "random.h"
}
- extern boost::mutex random_lock;
-
#pragma pack(push, 1)
POD_CLASS ec_point {
char data[32];
@@ -149,11 +147,12 @@ namespace crypto {
const public_key *const *, std::size_t, const signature *);
};
+ void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes);
+
/* Generate N random bytes
*/
inline void rand(size_t N, uint8_t *bytes) {
- boost::lock_guard<boost::mutex> lock(random_lock);
- generate_random_bytes_not_thread_safe(N, bytes);
+ generate_random_bytes_thread_safe(N, bytes);
}
/* Generate a value filled with random bytes.
@@ -161,8 +160,7 @@ namespace crypto {
template<typename T>
typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
typename std::remove_cv<T>::type res;
- boost::lock_guard<boost::mutex> lock(random_lock);
- generate_random_bytes_not_thread_safe(sizeof(T), &res);
+ generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
return res;
}