From f78a5b2eb8c08c9559cce730b28fc2f0c6b92de4 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 27 Jan 2019 09:08:02 -0500 Subject: Avoid extra memcpy in Poly1305 Resynchronize --- poly1305.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'poly1305.cpp') diff --git a/poly1305.cpp b/poly1305.cpp index d1ddba87..c478d131 100644 --- a/poly1305.cpp +++ b/poly1305.cpp @@ -230,8 +230,7 @@ void Poly1305_Base::Update(const byte *input, size_t length) // Process memcpy_s(m_acc + num, BLOCKSIZE - num, input, rem); Poly1305_HashBlocks(m_h, m_r, m_acc, BLOCKSIZE, 1); - input += rem; - length -= rem; + input += rem; length -= rem; } else { @@ -286,8 +285,8 @@ void Poly1305_Base::Resynchronize(const byte *nonce, int nonceLength) CRYPTOPP_ASSERT(nonceLength == -1 || nonceLength == (int)BLOCKSIZE); nonceLength == -1 ? nonceLength = BLOCKSIZE : nonceLength; - std::memcpy(m_nk.begin(), nonce, nonceLength); - m_cipher.ProcessBlock(m_nk.begin()); + // Encrypt the nonce, stash in m_nk + m_cipher.ProcessBlock(nonce, m_nk.begin()); m_n[0] = GetWord(false, LITTLE_ENDIAN_ORDER, m_nk + 0); m_n[1] = GetWord(false, LITTLE_ENDIAN_ORDER, m_nk + 4); -- cgit v1.2.1