Change from NDEBUG to CRYPTOPP_DEBUG in source files to ensure all debug behavior pivots on CRYPTOPP_DEBUG, and not NDEBUG (Issue 277, CVE-2016-7420)

pull/286/head
Jeffrey Walton 2016-09-16 14:51:48 -04:00
parent 6847978f0a
commit 91ca6c117d
24 changed files with 32 additions and 32 deletions

View File

@ -7,7 +7,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ThreeWay_TestInstantiations() void ThreeWay_TestInstantiations()
{ {
ThreeWay::Encryption x1; ThreeWay::Encryption x1;

View File

@ -13,7 +13,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
namespace Weak1 { namespace Weak1 {
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ARC4_TestInstantiations() void ARC4_TestInstantiations()
{ {
ARC4 x; ARC4 x;

View File

@ -18,7 +18,7 @@ NAMESPACE_BEGIN(CryptoPP)
a += b; d ^= a; d = rotlFixed<word32>(d, 8); \ a += b; d ^= a; d = rotlFixed<word32>(d, 8); \
c += d; b ^= c; b = rotlFixed<word32>(b, 7); c += d; b ^= c; b = rotlFixed<word32>(b, 7);
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ChaCha_TestInstantiations() void ChaCha_TestInstantiations()
{ {
ChaCha8::Encryption x1; ChaCha8::Encryption x1;

2
dh.cpp
View File

@ -8,7 +8,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void DH_TestInstantiations() void DH_TestInstantiations()
{ {
DH dh1; DH dh1;

View File

@ -5,7 +5,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void DH2_TestInstantiations() void DH2_TestInstantiations()
{ {
DH2 dh(*(SimpleKeyAgreementDomain*)NULL); DH2 dh(*(SimpleKeyAgreementDomain*)NULL);

View File

@ -31,7 +31,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if 0 #if 0
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
static void ECDSA_TestInstantiations() static void ECDSA_TestInstantiations()
{ {
ECDSA<EC2N>::Signer t1; ECDSA<EC2N>::Signer t1;

View File

@ -7,7 +7,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ElGamal_TestInstantiations() void ElGamal_TestInstantiations()
{ {
ElGamalEncryptor test1(1, 1, 1); ElGamalEncryptor test1(1, 1, 1);

View File

@ -18,7 +18,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ESIGN_TestInstantiations() void ESIGN_TestInstantiations()
{ {
ESIGN<SHA>::Verifier x1(1, 1); ESIGN<SHA>::Verifier x1(1, 1);

View File

@ -10,7 +10,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void Files_TestInstantiations() void Files_TestInstantiations()
{ {
FileStore f0; FileStore f0;

View File

@ -325,7 +325,7 @@ PolynomialMod2 PolynomialMod2::Modulo(const PolynomialMod2 &b) const
PolynomialMod2& PolynomialMod2::operator<<=(unsigned int n) PolynomialMod2& PolynomialMod2::operator<<=(unsigned int n)
{ {
#if !defined(NDEBUG) #if CRYPTOPP_DEBUG
int x; CRYPTOPP_UNUSED(x); int x; CRYPTOPP_UNUSED(x);
CRYPTOPP_ASSERT(SafeConvert(n,x)); CRYPTOPP_ASSERT(SafeConvert(n,x));
#endif #endif

View File

@ -20,7 +20,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void TestInstantiations_gfpcrypt() void TestInstantiations_gfpcrypt()
{ {
GDSA<SHA>::Signer test; GDSA<SHA>::Signer test;

View File

@ -206,10 +206,10 @@ class DWord
public: public:
// Converity finding on default ctor. We've isntrumented the code, // Converity finding on default ctor. We've isntrumented the code,
// and cannot uncover a case where it affects a result. // and cannot uncover a case where it affects a result.
#if (defined(__COVERITY__) || !defined(NDEBUG)) && defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) #if (defined(__COVERITY__) || CRYPTOPP_DEBUG) && defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE)
// Repeating pattern of 1010 for debug builds to break things... // Repeating pattern of 1010 for debug builds to break things...
DWord() : m_whole(0) {memset(&m_whole, 0xa, sizeof(m_whole));} DWord() : m_whole(0) {memset(&m_whole, 0xa, sizeof(m_whole));}
#elif (defined(__COVERITY__) || !defined(NDEBUG)) && !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) #elif (defined(__COVERITY__) || CRYPTOPP_DEBUG) && !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE)
// Repeating pattern of 1010 for debug builds to break things... // Repeating pattern of 1010 for debug builds to break things...
DWord() : m_halfs() {memset(&m_halfs, 0xaa, sizeof(m_halfs));} DWord() : m_halfs() {memset(&m_halfs, 0xaa, sizeof(m_halfs));}
#else #else
@ -346,7 +346,7 @@ public:
// and cannot uncover a case where it affects a result. // and cannot uncover a case where it affects a result.
#if defined(__COVERITY__) #if defined(__COVERITY__)
Word() : m_whole(0) {} Word() : m_whole(0) {}
#elif !defined(NDEBUG) #elif CRYPTOPP_DEBUG
// Repeating pattern of 1010 for debug builds to break things... // Repeating pattern of 1010 for debug builds to break things...
Word() : m_whole(0) {memset(&m_whole, 0xaa, sizeof(m_whole));} Word() : m_whole(0) {memset(&m_whole, 0xaa, sizeof(m_whole));}
#else #else
@ -2076,7 +2076,7 @@ static void SetFunctionPointers()
#if CRYPTOPP_INTEGER_SSE2 #if CRYPTOPP_INTEGER_SSE2
if (HasSSE2()) if (HasSSE2())
{ {
#if _MSC_VER != 1200 || defined(NDEBUG) #if _MSC_VER != 1200 || !(CRYPTOPP_DEBUG)
if (IsP4()) if (IsP4())
{ {
s_pAdd = &SSE2_Add; s_pAdd = &SSE2_Add;
@ -2614,7 +2614,7 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B)
Q[1] = SubatomicDivide(T+1, B[0], B[1]); Q[1] = SubatomicDivide(T+1, B[0], B[1]);
Q[0] = SubatomicDivide(T, B[0], B[1]); Q[0] = SubatomicDivide(T, B[0], B[1]);
#ifndef NDEBUG #if CRYPTOPP_DEBUG
// multiply quotient and divisor and add remainder, make sure it equals dividend // multiply quotient and divisor and add remainder, make sure it equals dividend
CRYPTOPP_ASSERT(!T[2] && !T[3] && (T[1] < B[1] || (T[1]==B[1] && T[0]<B[0]))); CRYPTOPP_ASSERT(!T[2] && !T[3] && (T[1] < B[1] || (T[1]==B[1] && T[0]<B[0])));
word P[4]; word P[4];
@ -2633,7 +2633,7 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B)
Q[0] = q.GetLowHalf(); Q[0] = q.GetLowHalf();
Q[1] = q.GetHighHalf(); Q[1] = q.GetHighHalf();
#ifndef NDEBUG #if CRYPTOPP_DEBUG
if (B[0] || B[1]) if (B[0] || B[1])
{ {
// multiply quotient and divisor and add remainder, make sure it equals dividend // multiply quotient and divisor and add remainder, make sure it equals dividend

View File

@ -10,7 +10,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void LUC_TestInstantiations() void LUC_TestInstantiations()
{ {
LUC_HMP<SHA>::Signer t1; LUC_HMP<SHA>::Signer t1;

View File

@ -9,7 +9,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
namespace Weak1 { namespace Weak1 {
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void MD5_TestInstantiations() void MD5_TestInstantiations()
{ {
MD5 x; MD5 x;

View File

@ -7,13 +7,13 @@
#include "modes.h" #include "modes.h"
#include "misc.h" #include "misc.h"
//#ifndef NDEBUG //#if CRYPTOPP_DEBUG
#include "des.h" #include "des.h"
//#endif //#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void Modes_TestInstantiations() void Modes_TestInstantiations()
{ {
CFB_Mode<DES>::Encryption m0; CFB_Mode<DES>::Encryption m0;

View File

@ -9,7 +9,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void TestInstantiations_MQV() void TestInstantiations_MQV()
{ {
MQV mqv; MQV mqv;

View File

@ -10,7 +10,7 @@
#include "algparam.h" #include "algparam.h"
#include "fips140.h" #include "fips140.h"
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) && !defined(CRYPTOPP_IS_DLL) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING) && !defined(CRYPTOPP_IS_DLL)
#include "pssr.h" #include "pssr.h"
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
void RSA_TestInstantiations() void RSA_TestInstantiations()

View File

@ -32,7 +32,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void Salsa20_TestInstantiations() void Salsa20_TestInstantiations()
{ {
Salsa20::Encryption x1; Salsa20::Encryption x1;

View File

@ -10,7 +10,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void SEAL_TestInstantiations() void SEAL_TestInstantiations()
{ {
SEAL<>::Encryption x; SEAL<>::Encryption x;

View File

@ -82,7 +82,7 @@ bool ValidateAll(bool thorough)
pass=TestRDSEED() && pass; pass=TestRDSEED() && pass;
#endif #endif
#if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_IMPORTS)
// http://github.com/weidai11/cryptopp/issues/92 // http://github.com/weidai11/cryptopp/issues/92
pass=TestSecBlock() && pass; pass=TestSecBlock() && pass;
// http://github.com/weidai11/cryptopp/issues/64 // http://github.com/weidai11/cryptopp/issues/64
@ -334,7 +334,7 @@ bool TestSettings()
return pass; return pass;
} }
#if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_IMPORTS)
bool TestSecBlock() bool TestSecBlock()
{ {
cout << "\nTesting SecBlock...\n\n"; cout << "\nTesting SecBlock...\n\n";
@ -1268,7 +1268,7 @@ bool TestSecBlock()
} }
#endif #endif
#if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_IMPORTS)
bool TestHuffmanCodes() bool TestHuffmanCodes()
{ {
cout << "\nTesting Huffman codes...\n\n"; cout << "\nTesting Huffman codes...\n\n";

View File

@ -799,7 +799,7 @@ bool ValidateBlumGoldwasser()
} }
*/ */
#if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_IMPORTS)
// Issue 64: "PolynomialMod2::operator<<=", http://github.com/weidai11/cryptopp/issues/64 // Issue 64: "PolynomialMod2::operator<<=", http://github.com/weidai11/cryptopp/issues/64
bool TestPolynomialMod2() bool TestPolynomialMod2()
{ {

View File

@ -90,7 +90,7 @@ bool ValidateEC2N();
bool ValidateECDSA(); bool ValidateECDSA();
bool ValidateESIGN(); bool ValidateESIGN();
#if !defined(NDEBUG) #if CRYPTOPP_DEBUG
bool TestSecBlock(); bool TestSecBlock();
bool TestPolynomialMod2(); bool TestPolynomialMod2();
bool TestHuffmanCodes(); bool TestHuffmanCodes();

View File

@ -7,7 +7,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void WAKE_TestInstantiations() void WAKE_TestInstantiations()
{ {
WAKE_OFB<>::Encryption x2; WAKE_OFB<>::Encryption x2;

View File

@ -85,7 +85,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void Whirlpool_TestInstantiations() void Whirlpool_TestInstantiations()
{ {
Whirlpool x; Whirlpool x;