mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Use aligned buffer for CMAC
This commit is contained in:
parent
d0eefdf32a
commit
a2223356b0
18
cmac.cpp
18
cmac.cpp
@ -77,7 +77,8 @@ void CMAC_Base::Update(const byte *input, size_t length)
|
||||
return;
|
||||
|
||||
BlockCipher &cipher = AccessCipher();
|
||||
unsigned int blockSize = cipher.BlockSize();
|
||||
const unsigned int blockSize = cipher.BlockSize();
|
||||
const unsigned int alignment = cipher.OptimalDataAlignment();
|
||||
|
||||
if (m_counter > 0)
|
||||
{
|
||||
@ -100,7 +101,20 @@ void CMAC_Base::Update(const byte *input, size_t length)
|
||||
if (length > blockSize)
|
||||
{
|
||||
CRYPTOPP_ASSERT(m_counter == 0);
|
||||
size_t leftOver = 1 + cipher.AdvancedProcessBlocks(m_reg, input, m_reg, length-1, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
|
||||
const byte* is = input; // m_reg is always aligned
|
||||
|
||||
AlignedSecByteBlock i;
|
||||
if (!IsAlignedOn(input, alignment))
|
||||
{
|
||||
i.Assign(input, length);
|
||||
is = i.begin();
|
||||
}
|
||||
|
||||
// size_t leftOver = 1 + cipher.AdvancedProcessBlocks(m_reg, input, m_reg, length-1,
|
||||
// BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
|
||||
const int flags = BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput;
|
||||
size_t leftOver = 1 + cipher.AdvancedProcessBlocks(m_reg, is, m_reg, length-1, flags);
|
||||
|
||||
input += (length - leftOver);
|
||||
length = leftOver;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user