aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/crypto.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-05-17 19:09:56 +0200
committerRiccardo Spagni <ric@spagni.net>2016-05-17 19:09:57 +0200
commita837c9cb0feeb7c8c4e616df64cbf650e38355f7 (patch)
tree504e043cc8156e1ec27d0c9c34bcefb0beb271f4 /src/crypto/crypto.h
parentMerge pull request #840 (diff)
parentcrypto: make clear generate_random_bytes is not thread safe (diff)
downloadmonero-a837c9cb0feeb7c8c4e616df64cbf650e38355f7.tar.xz
Merge pull request #842
d539be3 crypto: make clear generate_random_bytes is not thread safe (moneromooo-monero)
Diffstat (limited to 'src/crypto/crypto.h')
-rw-r--r--src/crypto/crypto.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index 883aa521a..fa55c2aab 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -117,13 +117,20 @@ namespace crypto {
const public_key *const *, std::size_t, const signature *);
};
+ /* 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 a value filled with random bytes.
*/
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(sizeof(T), &res);
+ generate_random_bytes_not_thread_safe(sizeof(T), &res);
return res;
}