aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/chacha.h
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-03-05 18:24:11 +0900
committerstoffu <stoffu@protonmail.ch>2018-03-14 21:00:17 +0900
commit7dfa5e9e6e05fb2b8bb346d92f2a22229ef495c8 (patch)
tree16d206dd1cc720babdfafa10e511e490badb1d6c /src/crypto/chacha.h
parentcrypto: revert odd namespace changes made in #3303 (diff)
downloadmonero-7dfa5e9e6e05fb2b8bb346d92f2a22229ef495c8.tar.xz
chacha: call prehashed version explicitly as generate_chacha_key_prehashed
hash: add prehashed version cn_slow_hash_prehashed slow-hash: let cn_slow_hash take 4th parameter for deciding prehashed or not slow-hash: add support for prehashed version for the other 3 platforms
Diffstat (limited to '')
-rw-r--r--src/crypto/chacha.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/crypto/chacha.h b/src/crypto/chacha.h
index 22da53bd0..7a120931a 100644
--- a/src/crypto/chacha.h
+++ b/src/crypto/chacha.h
@@ -69,10 +69,17 @@ namespace crypto {
chacha20(data, length, key.data(), reinterpret_cast<const uint8_t*>(&iv), cipher);
}
- inline void generate_chacha_key(const void *data, size_t size, chacha_key& key, int cn_variant = 0, bool prehashed=false) {
+ inline void generate_chacha_key(const void *data, size_t size, chacha_key& key) {
static_assert(sizeof(chacha_key) <= sizeof(hash), "Size of hash must be at least that of chacha_key");
tools::scrubbed_arr<char, HASH_SIZE> pwd_hash;
- crypto::cn_slow_hash_pre(data, size, pwd_hash.data(), cn_variant, prehashed);
+ crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 0/*prehashed*/);
+ memcpy(&key, pwd_hash.data(), sizeof(key));
+ }
+
+ inline void generate_chacha_key_prehashed(const void *data, size_t size, chacha_key& key) {
+ static_assert(sizeof(chacha_key) <= sizeof(hash), "Size of hash must be at least that of chacha_key");
+ tools::scrubbed_arr<char, HASH_SIZE> pwd_hash;
+ crypto::cn_slow_hash(data, size, pwd_hash.data(), 0/*variant*/, 1/*prehashed*/);
memcpy(&key, pwd_hash.data(), sizeof(key));
}