aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/chacha8.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-08-24 19:20:33 +0200
committerRiccardo Spagni <ric@spagni.net>2015-08-24 19:20:36 +0200
commitc24a7e8fc0ff92c8ddab8907f574ea0fe3048c3f (patch)
treeda4922f74780b9a04dd51ae16418c5c9f1bf161a /src/crypto/chacha8.h
parentMerge pull request #380 (diff)
parentwallet: encrypt the cache file (diff)
downloadmonero-c24a7e8fc0ff92c8ddab8907f574ea0fe3048c3f.tar.xz
Merge pull request #381
f197599 wallet: encrypt the cache file (moneromooo-monero) 98c76a3 chacha8: add a key generation variant that take a pointer and size (moneromooo-monero)
Diffstat (limited to 'src/crypto/chacha8.h')
-rw-r--r--src/crypto/chacha8.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/crypto/chacha8.h b/src/crypto/chacha8.h
index 9527e4016..8e58f42a2 100644
--- a/src/crypto/chacha8.h
+++ b/src/crypto/chacha8.h
@@ -70,13 +70,17 @@ namespace crypto {
chacha8(data, length, reinterpret_cast<const uint8_t*>(&key), reinterpret_cast<const uint8_t*>(&iv), cipher);
}
- inline void generate_chacha8_key(std::string password, chacha8_key& key) {
+ inline void generate_chacha8_key(const void *data, size_t size, chacha8_key& key) {
static_assert(sizeof(chacha8_key) <= sizeof(hash), "Size of hash must be at least that of chacha8_key");
char pwd_hash[HASH_SIZE];
- crypto::cn_slow_hash(password.data(), password.size(), pwd_hash);
+ crypto::cn_slow_hash(data, size, pwd_hash);
memcpy(&key, pwd_hash, sizeof(key));
memset(pwd_hash, 0, sizeof(pwd_hash));
}
+
+ inline void generate_chacha8_key(std::string password, chacha8_key& key) {
+ return generate_chacha8_key(password.data(), password.size(), key);
+ }
}
#endif