0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

crypto: make ChaCha20::SetKey wipe buffer

This commit is contained in:
Pieter Wuille 2023-08-17 15:37:41 -04:00
parent da0ec62e34
commit 57cc136282
2 changed files with 8 additions and 5 deletions

View file

@ -335,6 +335,13 @@ ChaCha20::~ChaCha20()
memory_cleanse(m_buffer.data(), m_buffer.size());
}
void ChaCha20::SetKey(Span<const std::byte> key) noexcept
{
m_aligned.SetKey(key);
m_bufleft = 0;
memory_cleanse(m_buffer.data(), m_buffer.size());
}
FSChaCha20::FSChaCha20(Span<const std::byte> key, uint32_t rekey_interval) noexcept :
m_chacha20(key), m_rekey_interval(rekey_interval)
{

View file

@ -95,11 +95,7 @@ public:
~ChaCha20();
/** Set 32-byte key, and seek to nonce 0 and block position 0. */
void SetKey(Span<const std::byte> key) noexcept
{
m_aligned.SetKey(key);
m_bufleft = 0;
}
void SetKey(Span<const std::byte> key) noexcept;
/** 96-bit nonce type. */
using Nonce96 = ChaCha20Aligned::Nonce96;