aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/account.h
diff options
context:
space:
mode:
authorSarang Noether <32460187+SarangNoether@users.noreply.github.com>2020-08-09 19:11:54 -0400
committerSarang Noether <32460187+SarangNoether@users.noreply.github.com>2020-08-09 19:11:54 -0400
commit921dd8dde5d381052d0aa2936304a3541a230c55 (patch)
treeb6e5c12201cc934b17aa61f06861c2199ba99dc1 /src/cryptonote_basic/account.h
parentMerge pull request #6586 (diff)
downloadmonero-921dd8dde5d381052d0aa2936304a3541a230c55.tar.xz
Use domain-separated ChaCha20 for in-memory key encryption
Diffstat (limited to '')
-rw-r--r--src/cryptonote_basic/account.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h
index 5288b9b04..c71c06edd 100644
--- a/src/cryptonote_basic/account.h
+++ b/src/cryptonote_basic/account.h
@@ -57,16 +57,15 @@ namespace cryptonote
account_keys& operator=(account_keys const&) = default;
- void encrypt(const crypto::chacha_key &key);
- void decrypt(const crypto::chacha_key &key);
- void encrypt_viewkey(const crypto::chacha_key &key);
- void decrypt_viewkey(const crypto::chacha_key &key);
+ void encrypt_wrapper(const crypto::chacha_key &key, const bool all_keys);
+ void decrypt_wrapper(const crypto::chacha_key &key, const bool all_keys);
+ void decrypt_legacy(const crypto::chacha_key &key);
hw::device& get_device() const ;
void set_device( hw::device &hwdev) ;
private:
- void xor_with_key_stream(const crypto::chacha_key &key);
+ void chacha_wrapper(const crypto::chacha_key &key, const bool all_keys);
};
/************************************************************************/
@@ -100,10 +99,12 @@ namespace cryptonote
void forget_spend_key();
const std::vector<crypto::secret_key> &get_multisig_keys() const { return m_keys.m_multisig_keys; }
- void encrypt_keys(const crypto::chacha_key &key) { m_keys.encrypt(key); }
- void decrypt_keys(const crypto::chacha_key &key) { m_keys.decrypt(key); }
- void encrypt_viewkey(const crypto::chacha_key &key) { m_keys.encrypt_viewkey(key); }
- void decrypt_viewkey(const crypto::chacha_key &key) { m_keys.decrypt_viewkey(key); }
+ void encrypt_keys(const crypto::chacha_key &key) { m_keys.encrypt_wrapper(key, true); }
+ void encrypt_keys_same_iv(const crypto::chacha_key &key) { m_keys.decrypt_wrapper(key, true); } // encryption with the same IV is the same as decryption due to symmetry
+ void decrypt_keys(const crypto::chacha_key &key) { m_keys.decrypt_wrapper(key, true); }
+ void encrypt_viewkey(const crypto::chacha_key &key) { m_keys.encrypt_wrapper(key, false); }
+ void decrypt_viewkey(const crypto::chacha_key &key) { m_keys.decrypt_wrapper(key, false); }
+ void decrypt_legacy(const crypto::chacha_key &key) { m_keys.decrypt_legacy(key); }
template <class t_archive>
inline void serialize(t_archive &a, const unsigned int /*ver*/)