From c17734c56b9ddfb9a9ce5274f70d5bd576f5cabe Mon Sep 17 00:00:00 2001 From: Wyatt O'Day Date: Thu, 31 Aug 2017 09:41:55 -0400 Subject: [PATCH] Make the debug build more closely behave like the release build if `CRYPTOPP_NO_TESTS` is defined. --- 3way.cpp | 2 +- arc4.cpp | 2 +- chacha.cpp | 2 +- config.h | 6 ++++++ dh.cpp | 2 +- dh2.cpp | 2 +- eccrypto.cpp | 2 +- elgamal.cpp | 2 +- esign.cpp | 2 +- files.cpp | 2 +- gfpcrypt.cpp | 2 +- integer.cpp | 4 ++-- luc.cpp | 2 +- md5.cpp | 2 +- modes.cpp | 4 ++-- mqv.cpp | 2 +- rsa.cpp | 2 +- salsa.cpp | 2 +- seal.cpp | 2 +- wake.cpp | 2 +- whrlpool.cpp | 2 +- 21 files changed, 28 insertions(+), 22 deletions(-) diff --git a/3way.cpp b/3way.cpp index 60bd0e13..b3a9bea0 100644 --- a/3way.cpp +++ b/3way.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void ThreeWay_TestInstantiations() { ThreeWay::Encryption x1; diff --git a/arc4.cpp b/arc4.cpp index 7046b727..ba7bfdd4 100644 --- a/arc4.cpp +++ b/arc4.cpp @@ -13,7 +13,7 @@ NAMESPACE_BEGIN(CryptoPP) namespace Weak1 { -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void ARC4_TestInstantiations() { ARC4 x; diff --git a/chacha.cpp b/chacha.cpp index 4aeed40b..8b662932 100644 --- a/chacha.cpp +++ b/chacha.cpp @@ -17,7 +17,7 @@ NAMESPACE_BEGIN(CryptoPP) a += b; d ^= a; d = rotlFixed(d, 8); \ c += d; b ^= c; b = rotlFixed(b, 7); -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void ChaCha_TestInstantiations() { ChaCha8::Encryption x1; diff --git a/config.h b/config.h index e7b66798..5075d283 100644 --- a/config.h +++ b/config.h @@ -137,6 +137,12 @@ # define CRYPTOPP_DEBUG 1 #endif +// CRYPTOPP_TEST_INSTANTIATIONS enables the class instantiation tests +// in each encryption source. For example, RSA_TestInstantiations(). +#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) && !defined(CRYPTOPP_NO_TESTS) +# define CRYPTOPP_TEST_INSTANTIATIONS 1 +#endif + // ***************** Important Settings Again ******************** // But the defaults should be ok. diff --git a/dh.cpp b/dh.cpp index 5a0e7d1d..80eedf78 100644 --- a/dh.cpp +++ b/dh.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void DH_TestInstantiations() { DH dh1; diff --git a/dh2.cpp b/dh2.cpp index 4c062d4e..33dbb760 100644 --- a/dh2.cpp +++ b/dh2.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) struct NullCryptoParameters : public CryptoParameters { void AssignFrom(const NameValuePairs &source) { diff --git a/eccrypto.cpp b/eccrypto.cpp index 92106052..222de200 100644 --- a/eccrypto.cpp +++ b/eccrypto.cpp @@ -31,7 +31,7 @@ NAMESPACE_BEGIN(CryptoPP) #if 0 -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) static void ECDSA_TestInstantiations() { ECDSA::Signer t1; diff --git a/elgamal.cpp b/elgamal.cpp index 13c2a9be..f4cf6ac2 100644 --- a/elgamal.cpp +++ b/elgamal.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void ElGamal_TestInstantiations() { ElGamalEncryptor test1(1, 1, 1); diff --git a/esign.cpp b/esign.cpp index 7c69a684..8ba5dd23 100644 --- a/esign.cpp +++ b/esign.cpp @@ -18,7 +18,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void ESIGN_TestInstantiations() { ESIGN::Verifier x1(1, 1); diff --git a/files.cpp b/files.cpp index c200e9e7..00967a22 100644 --- a/files.cpp +++ b/files.cpp @@ -10,7 +10,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void Files_TestInstantiations() { FileStore f0; diff --git a/gfpcrypt.cpp b/gfpcrypt.cpp index 6494b084..05d20bc7 100644 --- a/gfpcrypt.cpp +++ b/gfpcrypt.cpp @@ -20,7 +20,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void TestInstantiations_gfpcrypt() { GDSA::Signer test; diff --git a/integer.cpp b/integer.cpp index 732c7962..f4c81d89 100644 --- a/integer.cpp +++ b/integer.cpp @@ -2712,7 +2712,7 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B) Q[1] = SubatomicDivide(T+1, B[0], B[1]); Q[0] = SubatomicDivide(T, B[0], B[1]); -#if defined(CRYPTOPP_DEBUG) +#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_NO_TESTS) // 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]::Signer t1; diff --git a/md5.cpp b/md5.cpp index 3bdc7379..91564c80 100644 --- a/md5.cpp +++ b/md5.cpp @@ -9,7 +9,7 @@ NAMESPACE_BEGIN(CryptoPP) namespace Weak1 { -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void MD5_TestInstantiations() { MD5 x; diff --git a/modes.cpp b/modes.cpp index 0d9849ce..83e58f99 100644 --- a/modes.cpp +++ b/modes.cpp @@ -7,13 +7,13 @@ #include "modes.h" #include "misc.h" -#if defined(CRYPTOPP_DEBUG) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) #include "des.h" #endif NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void Modes_TestInstantiations() { CFB_Mode::Encryption m0; diff --git a/mqv.cpp b/mqv.cpp index 5602eb05..2c712f41 100644 --- a/mqv.cpp +++ b/mqv.cpp @@ -9,7 +9,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void TestInstantiations_MQV() { MQV mqv; diff --git a/rsa.cpp b/rsa.cpp index 095a99dd..3f3f0eb0 100644 --- a/rsa.cpp +++ b/rsa.cpp @@ -11,7 +11,7 @@ #include "fips140.h" #include "pkcspad.h" -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) && !defined(CRYPTOPP_IS_DLL) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) #include "pssr.h" NAMESPACE_BEGIN(CryptoPP) void RSA_TestInstantiations() diff --git a/salsa.cpp b/salsa.cpp index e0f7a085..84f9f0e3 100644 --- a/salsa.cpp +++ b/salsa.cpp @@ -30,7 +30,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void Salsa20_TestInstantiations() { Salsa20::Encryption x1; diff --git a/seal.cpp b/seal.cpp index fef2656c..b8624958 100644 --- a/seal.cpp +++ b/seal.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void SEAL_TestInstantiations() { SEAL<>::Encryption x; diff --git a/wake.cpp b/wake.cpp index 8501bcf7..1f57baee 100644 --- a/wake.cpp +++ b/wake.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void WAKE_TestInstantiations() { WAKE_OFB<>::Encryption x2; diff --git a/whrlpool.cpp b/whrlpool.cpp index 49b030e4..f6106a66 100644 --- a/whrlpool.cpp +++ b/whrlpool.cpp @@ -83,7 +83,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) +#if defined(CRYPTOPP_TEST_INSTANTIATIONS) void Whirlpool_TestInstantiations() { Whirlpool x;