Use aligned buffer for Poly1305 nonce

pull/489/head
Jeffrey Walton 2017-09-04 19:28:19 -04:00
parent fe0a5ee8e8
commit d0eefdf32a
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 3 additions and 1 deletions

View File

@ -34,7 +34,9 @@ void Poly1305_Base<T>::UncheckedSetKey(const byte *key, unsigned int length, con
if (params.GetValue(Name::IV(), t) && t.begin() && t.size()) if (params.GetValue(Name::IV(), t) && t.begin() && t.size())
{ {
// Nonce key is a class member to avoid the zeroizer on a temporary // Nonce key is a class member to avoid the zeroizer on a temporary
m_cipher.ProcessBlock(t.begin(), m_nk.begin()); CRYPTOPP_ASSERT(t.size() == m_nk.size());
std::memcpy(m_nk.begin(), t.begin(), t.size());
m_cipher.ProcessBlock(m_nk.begin(), m_nk.begin());
m_n[0] = GetWord<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 0); m_n[0] = GetWord<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 0);
m_n[1] = GetWord<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 4); m_n[1] = GetWord<word32>(false, LITTLE_ENDIAN_ORDER, m_nk + 4);