diff options
author | stoffu <stoffu@protonmail.ch> | 2017-06-20 08:27:31 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2017-06-22 18:11:15 +0900 |
commit | 8da82256d475656a8a4932b9e2d623f80c7e62e6 (patch) | |
tree | b0da633f40618ad4d199861138e70fd9dd082afb /src/crypto | |
parent | Signature proving payment to destination by only revealing key derivation, no... (diff) | |
download | monero-8da82256d475656a8a4932b9e2d623f80c7e62e6.tar.xz |
crypto: moved boost::lock_guard into a smaller scope
Diffstat (limited to '')
-rw-r--r-- | src/crypto/crypto.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index 6ae7e5f24..1c7adff3b 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -81,12 +81,16 @@ namespace crypto { } /* generate a random 32-byte (256-bit) integer and copy it to res */ - static inline void random_scalar(ec_scalar &res) { + static inline void random_scalar_not_thread_safe(ec_scalar &res) { unsigned char tmp[64]; generate_random_bytes_not_thread_safe(64, tmp); sc_reduce(tmp); memcpy(&res, tmp, 32); } + static inline void random_scalar(ec_scalar &res) { + boost::lock_guard<boost::mutex> lock(random_lock); + random_scalar_not_thread_safe(res); + } static inline void hash_to_scalar(const void *data, size_t length, ec_scalar &res) { cn_fast_hash(data, length, reinterpret_cast<hash &>(res)); @@ -99,7 +103,6 @@ namespace crypto { * */ secret_key crypto_ops::generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key, bool recover) { - boost::lock_guard<boost::mutex> lock(random_lock); ge_p3 point; secret_key rng; @@ -205,7 +208,6 @@ namespace crypto { }; void crypto_ops::generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig) { - boost::lock_guard<boost::mutex> lock(random_lock); ge_p3 tmp3; ec_scalar k; s_comm buf; @@ -405,7 +407,6 @@ POP_WARNINGS const public_key *const *pubs, size_t pubs_count, const secret_key &sec, size_t sec_index, signature *sig) { - boost::lock_guard<boost::mutex> lock(random_lock); size_t i; ge_p3 image_unp; ge_dsmp image_pre; |