mirror of
https://github.com/monero-project/monero.git
synced 2025-08-11 18:20:16 -04:00
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.
This commit is contained in:
parent
8adde33e01
commit
1dc3b1a516
5 changed files with 41 additions and 2 deletions
|
@ -88,13 +88,24 @@ namespace crypto {
|
|||
return &reinterpret_cast<const unsigned char &>(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<boost::mutex> lock(random_lock);
|
||||
return random_lock;
|
||||
}
|
||||
|
||||
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> 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<boost::mutex> 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue