Align buffers for Poly1305 and VMAC

pull/489/head
Jeffrey Walton 2017-09-05 16:43:29 -04:00
parent 37e02f9e0e
commit 09023bf45e
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 5 additions and 3 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())
{
// 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(), m_nk.size());
m_cipher.ProcessBlock(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);

View File

@ -69,8 +69,8 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con
cipher.SetKey(userKey, keylength, params);
const unsigned int blockSize = cipher.BlockSize();
const unsigned int blockSizeInWords = blockSize / sizeof(word64);
SecBlock<word64> out(blockSizeInWords);
SecByteBlock in;
SecBlock<word64, AllocatorWithCleanup<word64, true> > out(blockSizeInWords);
AlignedSecByteBlock in;
in.CleanNew(blockSize);
size_t i;