summaryrefslogtreecommitdiff
path: root/poly1305.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-01-27 09:08:02 -0500
committerJeffrey Walton <noloader@gmail.com>2019-01-27 09:08:02 -0500
commitf78a5b2eb8c08c9559cce730b28fc2f0c6b92de4 (patch)
treec4c87e6144ba62f83840f08a02276708be5816a1 /poly1305.cpp
parentd2c030638d9882ff24235471d5dff913189771b3 (diff)
downloadcryptopp-git-f78a5b2eb8c08c9559cce730b28fc2f0c6b92de4.tar.gz
Avoid extra memcpy in Poly1305 Resynchronize
Diffstat (limited to 'poly1305.cpp')
-rw-r--r--poly1305.cpp7
1 files changed, 3 insertions, 4 deletions
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<T>::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<T>::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<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 0);
m_n[1] = GetWord<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 4);