summaryrefslogtreecommitdiff
path: root/modes.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-09-16 11:27:15 -0400
committerJeffrey Walton <noloader@gmail.com>2016-09-16 11:27:15 -0400
commit399a1546de71f41598c15edada28e7f0d616f541 (patch)
tree530160789358a3303be180df2d8529c82782156b /modes.cpp
parentfca5fbb36169a7522e6c533df9c322d47e3dc6bb (diff)
downloadcryptopp-git-399a1546de71f41598c15edada28e7f0d616f541.tar.gz
Add CRYPTOPP_ASSERT (Issue 277, CVE-2016-7420)
trap.h and CRYPTOPP_ASSERT has existed for over a year in Master. We deferred on the cut-over waiting for a minor version bump (5.7). We have to use it now due to CVE-2016-7420
Diffstat (limited to 'modes.cpp')
-rw-r--r--modes.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/modes.cpp b/modes.cpp
index ed2b3224..09d6fd13 100644
--- a/modes.cpp
+++ b/modes.cpp
@@ -35,10 +35,10 @@ void CipherModeBase::ResizeBuffers()
void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount)
{
- assert(input);
- assert(output);
- assert(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
- assert(m_feedbackSize == BlockSize());
+ CRYPTOPP_ASSERT(input);
+ CRYPTOPP_ASSERT(output);
+ CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
+ CRYPTOPP_ASSERT(m_feedbackSize == BlockSize());
const unsigned int s = BlockSize();
if (dir == ENCRYPTION)
@@ -60,7 +60,7 @@ void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, siz
void CFB_ModePolicy::TransformRegister()
{
- assert(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
+ CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
m_cipher->ProcessBlock(m_register, m_temp);
unsigned int updateSize = BlockSize()-m_feedbackSize;
memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize);
@@ -69,7 +69,7 @@ void CFB_ModePolicy::TransformRegister()
void CFB_ModePolicy::CipherResynchronize(const byte *iv, size_t length)
{
- assert(length == BlockSize());
+ CRYPTOPP_ASSERT(length == BlockSize());
CopyOrZero(m_register, iv, length);
TransformRegister();
}
@@ -89,7 +89,7 @@ void CFB_ModePolicy::ResizeBuffers()
void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount)
{
- assert(m_cipher->IsForwardTransformation()); // OFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
+ CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // OFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
unsigned int s = BlockSize();
m_cipher->ProcessBlock(m_register, keystreamBuffer);
if (iterationCount > 1)
@@ -100,7 +100,7 @@ void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount
void OFB_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
{
CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length);
- assert(length == BlockSize());
+ CRYPTOPP_ASSERT(length == BlockSize());
CopyOrZero(m_register, iv, length);
}
@@ -124,7 +124,7 @@ void CTR_ModePolicy::IncrementCounterBy256()
void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *output, const byte *input, size_t iterationCount)
{
- assert(m_cipher->IsForwardTransformation()); // CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
+ CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
unsigned int s = BlockSize();
unsigned int inputIncrement = input ? s : 0;
@@ -145,7 +145,7 @@ void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *ou
void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
{
CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length);
- assert(length == BlockSize());
+ CRYPTOPP_ASSERT(length == BlockSize());
CopyOrZero(m_register, iv, length);
m_counterArray = m_register;
@@ -174,7 +174,7 @@ void BlockOrientedCipherModeBase::ResizeBuffers()
void ECB_OneWay::ProcessData(byte *outString, const byte *inString, size_t length)
{
- assert(length%BlockSize()==0);
+ CRYPTOPP_ASSERT(length%BlockSize()==0);
m_cipher->AdvancedProcessBlocks(inString, NULL, outString, length, BlockTransformation::BT_AllowParallel);
}
@@ -182,7 +182,7 @@ void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t l
{
if (!length)
return;
- assert(length%BlockSize()==0);
+ CRYPTOPP_ASSERT(length%BlockSize()==0);
unsigned int blockSize = BlockSize();
m_cipher->AdvancedProcessBlocks(inString, m_register, outString, blockSize, BlockTransformation::BT_XorInput);
@@ -231,7 +231,7 @@ void CBC_Decryption::ProcessData(byte *outString, const byte *inString, size_t l
{
if (!length)
return;
- assert(length%BlockSize()==0);
+ CRYPTOPP_ASSERT(length%BlockSize()==0);
unsigned int blockSize = BlockSize();
memcpy(m_temp, inString+length-blockSize, blockSize); // save copy now in case of in-place decryption