mirror of
https://github.com/monero-project/monero.git
synced 2025-08-23 08:15:11 -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
|
@ -146,3 +146,18 @@ void generate_random_bytes_not_thread_safe(size_t n, void *result) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void add_extra_entropy_not_thread_safe(const void *ptr, size_t bytes)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
while (bytes > 0)
|
||||
{
|
||||
hash_permutation(&state);
|
||||
const size_t round_bytes = bytes > HASH_DATA_AREA ? HASH_DATA_AREA : bytes;
|
||||
for (i = 0; i < round_bytes; ++i)
|
||||
state.b[i] ^= ((const uint8_t*)ptr)[i];
|
||||
bytes -= round_bytes;
|
||||
ptr = cpadd(ptr, round_bytes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue