aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/random.c
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-08-27 15:14:15 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-08-27 15:14:15 -0500
commit8f6f674753bae7494e1ee4569004947d47a4e983 (patch)
tree454eabd74a6fa1b9de32feafd8fedd21c0d731e9 /src/crypto/random.c
parentMerge pull request #5559 (diff)
parentwallet: add --extra-entropy command line flag (diff)
downloadmonero-8f6f674753bae7494e1ee4569004947d47a4e983.tar.xz
Merge pull request #5609
1dc3b1a wallet: add --extra-entropy command line flag (moneromooo-monero)
Diffstat (limited to 'src/crypto/random.c')
-rw-r--r--src/crypto/random.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/crypto/random.c b/src/crypto/random.c
index 74b202661..766b5f558 100644
--- a/src/crypto/random.c
+++ b/src/crypto/random.c
@@ -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);
+ }
+}