From aecc77a0af80fdcebc71570a5e9a46c1b645aa7f Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 8 Dec 2019 12:03:52 -0500 Subject: Minor optimization for Blake2b::final_result Avoids some needless memsets --- src/lib/hash/blake2/blake2b.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/hash/blake2/blake2b.cpp b/src/lib/hash/blake2/blake2b.cpp index 9617fb4fb..0280d0c8b 100644 --- a/src/lib/hash/blake2/blake2b.cpp +++ b/src/lib/hash/blake2/blake2b.cpp @@ -51,6 +51,7 @@ void BLAKE2b::state_init() m_H[0] ^= 0x01010000 ^ static_cast(output_length()); m_T[0] = m_T[1] = 0; m_F[0] = m_F[1] = 0; + m_bufpos = 0; } namespace { @@ -177,7 +178,7 @@ void BLAKE2b::final_result(uint8_t output[]) m_F[0] = 0xFFFFFFFFFFFFFFFF; compress(m_buffer.data(), 1, m_bufpos); copy_out_vec_le(output, output_length(), m_H); - clear(); + state_init(); } std::string BLAKE2b::name() const -- cgit v1.2.3