Aligned buffers in AuthenticatedSymmetricCipherBase

pull/489/head
Jeffrey Walton 2017-09-04 20:36:43 -04:00
parent b18f74130b
commit b0f3b8ce17
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 14 additions and 1 deletions

View File

@ -36,7 +36,20 @@ void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_
// now process the input data in blocks of blockSize bytes and save the leftovers to m_data
if (len >= blockSize)
{
size_t leftOver = AuthenticateBlocks(input, len);
// size_t leftOver = AuthenticateBlocks(input, len);
size_t leftOver = 0;
const unsigned int alignment = GetSymmetricCipher().OptimalDataAlignment();
if (IsAlignedOn(input, alignment))
{
leftOver = AuthenticateBlocks(input, len);
}
else
{
AlignedSecByteBlock block(input, len);
leftOver = AuthenticateBlocks(block, len);
}
input += (len - leftOver);
len = leftOver;
}