Use SetMark to avoid unneeded zeroization in Rijndael
parent
ebcd91a0ac
commit
6e436427fb
|
|
@ -316,6 +316,9 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c
|
||||||
|
|
||||||
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
|
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86
|
||||||
m_aliasBlock.New(s_sizeToAllocate);
|
m_aliasBlock.New(s_sizeToAllocate);
|
||||||
|
// The alias block is only used on IA-32 when unaligned data access is in effect.
|
||||||
|
// Setting the low water mark to 0 avoids zeroization when m_aliasBlock is unused.
|
||||||
|
m_aliasBlock.SetMark(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_rounds = keyLen/4 + 6;
|
m_rounds = keyLen/4 + 6;
|
||||||
|
|
@ -1146,6 +1149,7 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo
|
||||||
return length;
|
return length;
|
||||||
|
|
||||||
static const byte *zeros = (const byte*)(Te+256);
|
static const byte *zeros = (const byte*)(Te+256);
|
||||||
|
m_aliasBlock.SetMark(m_aliasBlock.size());
|
||||||
byte *space = NULLPTR, *originalSpace = const_cast<byte*>(m_aliasBlock.data());
|
byte *space = NULLPTR, *originalSpace = const_cast<byte*>(m_aliasBlock.data());
|
||||||
|
|
||||||
// round up to nearest 256 byte boundary
|
// round up to nearest 256 byte boundary
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat
|
||||||
|
|
||||||
unsigned int m_rounds;
|
unsigned int m_rounds;
|
||||||
FixedSizeAlignedSecBlock<word32, 4*15> m_key;
|
FixedSizeAlignedSecBlock<word32, 4*15> m_key;
|
||||||
SecByteBlock m_aliasBlock;
|
mutable SecByteBlock m_aliasBlock;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Provides implementation for encryption transformation
|
//! \brief Provides implementation for encryption transformation
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue