From 1dc3b1a516332f12a4bd8fd8dd80695a003d1d98 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 6 Jun 2019 09:50:56 +0000 Subject: wallet: add --extra-entropy command line flag It lets the user add custom entropy to the PRNG. It does this by hashing the new data and xoring the resulting hash with the PRNG state. --- src/crypto/crypto.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/crypto/crypto.cpp') diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index 3f06c4f3f..6d3c4ed35 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -88,13 +88,24 @@ namespace crypto { return &reinterpret_cast(scalar); } - void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes) + boost::mutex &get_random_lock() { static boost::mutex random_lock; - boost::lock_guard lock(random_lock); + return random_lock; + } + + void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes) + { + boost::lock_guard lock(get_random_lock()); generate_random_bytes_not_thread_safe(N, bytes); } + void add_extra_entropy_thread_safe(const void *ptr, size_t bytes) + { + boost::lock_guard lock(get_random_lock()); + add_extra_entropy_not_thread_safe(ptr, bytes); + } + static inline bool less32(const unsigned char *k0, const unsigned char *k1) { for (int n = 31; n >= 0; --n) -- cgit v1.2.3