Warn of under-aligned buffers when using AES in debug mode
This commit supports the upcoming AltiVec and Power8 processor. This commit affects a number of classes due to the ubiquitous use of AES. The commit adds debug asserts to warn of under-aligned and misaligned buffers in debug builds.pull/489/head
parent
75aef9bded
commit
fe0a5ee8e8
20
rijndael.cpp
20
rijndael.cpp
|
|
@ -351,6 +351,11 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c
|
||||||
|
|
||||||
void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||||
{
|
{
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( m_key, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( inBlock, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(xorBlock, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlock, OptimalDataAlignment()));
|
||||||
|
|
||||||
#if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_AESNI_AVAILABLE
|
#if CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_AESNI_AVAILABLE
|
||||||
# if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
|
# if (CRYPTOPP_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM)
|
||||||
if (HasSSE2())
|
if (HasSSE2())
|
||||||
|
|
@ -441,6 +446,11 @@ void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock
|
||||||
|
|
||||||
void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||||
{
|
{
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( m_key, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( inBlock, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(xorBlock, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlock, OptimalDataAlignment()));
|
||||||
|
|
||||||
#if CRYPTOPP_AESNI_AVAILABLE
|
#if CRYPTOPP_AESNI_AVAILABLE
|
||||||
if (HasAESNI())
|
if (HasAESNI())
|
||||||
{
|
{
|
||||||
|
|
@ -1088,6 +1098,11 @@ Rijndael::Enc::Enc() { }
|
||||||
#if CRYPTOPP_ENABLE_ADVANCED_PROCESS_BLOCKS
|
#if CRYPTOPP_ENABLE_ADVANCED_PROCESS_BLOCKS
|
||||||
size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
||||||
{
|
{
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( m_key, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( inBlocks, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(xorBlocks, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlocks, OptimalDataAlignment()));
|
||||||
|
|
||||||
#if CRYPTOPP_AESNI_AVAILABLE
|
#if CRYPTOPP_AESNI_AVAILABLE
|
||||||
if (HasAESNI())
|
if (HasAESNI())
|
||||||
return Rijndael_Enc_AdvancedProcessBlocks_AESNI(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
return Rijndael_Enc_AdvancedProcessBlocks_AESNI(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||||
|
|
@ -1151,6 +1166,11 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo
|
||||||
|
|
||||||
size_t Rijndael::Dec::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
size_t Rijndael::Dec::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
||||||
{
|
{
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( m_key, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn( inBlocks, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(xorBlocks, OptimalDataAlignment()));
|
||||||
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlocks, OptimalDataAlignment()));
|
||||||
|
|
||||||
#if CRYPTOPP_AESNI_AVAILABLE
|
#if CRYPTOPP_AESNI_AVAILABLE
|
||||||
if (HasAESNI())
|
if (HasAESNI())
|
||||||
return Rijndael_Dec_AdvancedProcessBlocks_AESNI(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
return Rijndael_Dec_AdvancedProcessBlocks_AESNI(m_key, m_rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue