mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 17:14:51 -04:00
crypto: make secret_key automatically mlock
This commit is contained in:
parent
70271fa788
commit
ab74dc277a
5 changed files with 12 additions and 10 deletions
|
@ -67,7 +67,7 @@ DISABLE_VS_WARNINGS(4244 4345)
|
|||
static void derive_key(const crypto::chacha_key &base_key, crypto::chacha_key &key)
|
||||
{
|
||||
static_assert(sizeof(base_key) == sizeof(crypto::hash), "chacha key and hash should be the same size");
|
||||
tools::scrubbed_arr<char, sizeof(base_key)+1> data;
|
||||
epee::mlocked<tools::scrubbed_arr<char, sizeof(base_key)+1>> data;
|
||||
memcpy(data.data(), &base_key, sizeof(base_key));
|
||||
data[sizeof(base_key)] = KEYS_ENCRYPTION_SALT;
|
||||
crypto::generate_chacha_key(data.data(), sizeof(data), key, 1);
|
||||
|
@ -223,7 +223,7 @@ DISABLE_VS_WARNINGS(4244 4345)
|
|||
void account_base::create_from_viewkey(const cryptonote::account_public_address& address, const crypto::secret_key& viewkey)
|
||||
{
|
||||
crypto::secret_key fake;
|
||||
memset(&unwrap(fake), 0, sizeof(fake));
|
||||
memset(&unwrap(unwrap(fake)), 0, sizeof(fake));
|
||||
create_from_keys(address, fake, viewkey);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue