1 // regtest1.cpp - originally written and placed in the public domain by Wei Dai 2 // regtest.cpp split into 3 files due to OOM kills by JW 3 // in April 2017. A second split occurred in July 2018. 4 5 #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 6 7 #include "cryptlib.h" 8 #include "factory.h" 9 #include "bench.h" 10 #include "cpu.h" 11 12 #include "crc.h" 13 #include "adler32.h" 14 #include "md2.h" 15 #include "md5.h" 16 #include "keccak.h" 17 #include "sha3.h" 18 #include "shake.h" 19 #include "blake2.h" 20 #include "sha.h" 21 #include "sha3.h" 22 #include "sm3.h" 23 #include "hkdf.h" 24 #include "tiger.h" 25 #include "ripemd.h" 26 #include "panama.h" 27 #include "whrlpool.h" 28 29 #include "osrng.h" 30 #include "drbg.h" 31 #include "darn.h" 32 #include "mersenne.h" 33 #include "rdrand.h" 34 #include "padlkrng.h" 35 36 #include "modes.h" 37 #include "aes.h" 38 39 // Aggressive stack checking with VS2005 SP1 and above. 40 #if (_MSC_FULL_VER >= 140050727) 41 # pragma strict_gs_check (on) 42 #endif 43 44 #if CRYPTOPP_MSC_VERSION 45 # pragma warning(disable: 4505 4355) 46 #endif 47 48 USING_NAMESPACE(CryptoPP) 49 50 // Unkeyed ciphers 51 void RegisterFactories1(); 52 // MAC ciphers 53 void RegisterFactories2(); 54 // Stream ciphers 55 void RegisterFactories3(); 56 // Block ciphers 57 void RegisterFactories4(); 58 // Public key ciphers 59 void RegisterFactories5(); 60 61 void RegisterFactories(Test::TestClass suites) 62 { 63 static bool s_registered = false; 64 if (s_registered) 65 return; 66 67 if ((suites & Test::Unkeyed) == Test::Unkeyed) 68 RegisterFactories1(); 69 70 if ((suites & Test::SharedKeyMAC) == Test::SharedKeyMAC) 71 RegisterFactories2(); 72 73 if ((suites & Test::SharedKeyStream) == Test::SharedKeyStream) 74 RegisterFactories3(); 75 76 if ((suites & Test::SharedKeyBlock) == Test::SharedKeyBlock) 77 RegisterFactories4(); 78 79 if ((suites & Test::PublicKey) == Test::PublicKey) 80 RegisterFactories5(); 81 82 s_registered = true; 83 } 84 85 // Unkeyed ciphers 86 void RegisterFactories1() 87 { 88 RegisterDefaultFactoryFor<HashTransformation, CRC32>(); 89 RegisterDefaultFactoryFor<HashTransformation, CRC32C>(); 90 RegisterDefaultFactoryFor<HashTransformation, Adler32>(); 91 RegisterDefaultFactoryFor<HashTransformation, Weak::MD5>(); 92 RegisterDefaultFactoryFor<HashTransformation, SHA1>(); 93 RegisterDefaultFactoryFor<HashTransformation, SHA224>(); 94 RegisterDefaultFactoryFor<HashTransformation, SHA256>(); 95 RegisterDefaultFactoryFor<HashTransformation, SHA384>(); 96 RegisterDefaultFactoryFor<HashTransformation, SHA512>(); 97 RegisterDefaultFactoryFor<HashTransformation, Whirlpool>(); 98 RegisterDefaultFactoryFor<HashTransformation, Tiger>(); 99 RegisterDefaultFactoryFor<HashTransformation, RIPEMD160>(); 100 RegisterDefaultFactoryFor<HashTransformation, RIPEMD320>(); 101 RegisterDefaultFactoryFor<HashTransformation, RIPEMD128>(); 102 RegisterDefaultFactoryFor<HashTransformation, RIPEMD256>(); 103 RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<LittleEndian> >(); 104 RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<BigEndian> >(); 105 RegisterDefaultFactoryFor<HashTransformation, Keccak_224>(); 106 RegisterDefaultFactoryFor<HashTransformation, Keccak_256>(); 107 RegisterDefaultFactoryFor<HashTransformation, Keccak_384>(); 108 RegisterDefaultFactoryFor<HashTransformation, Keccak_512>(); 109 RegisterDefaultFactoryFor<HashTransformation, SHA3_224>(); 110 RegisterDefaultFactoryFor<HashTransformation, SHA3_256>(); 111 RegisterDefaultFactoryFor<HashTransformation, SHA3_384>(); 112 RegisterDefaultFactoryFor<HashTransformation, SHA3_512>(); 113 RegisterDefaultFactoryFor<HashTransformation, SHAKE128>(); 114 RegisterDefaultFactoryFor<HashTransformation, SHAKE256>(); 115 RegisterDefaultFactoryFor<HashTransformation, SM3>(); 116 RegisterDefaultFactoryFor<HashTransformation, BLAKE2s>(); 117 RegisterDefaultFactoryFor<HashTransformation, BLAKE2b>(); 118 119 #ifdef BLOCKING_RNG_AVAILABLE 120 RegisterDefaultFactoryFor<RandomNumberGenerator, BlockingRng>(); 121 #endif 122 #ifdef NONBLOCKING_RNG_AVAILABLE 123 RegisterDefaultFactoryFor<RandomNumberGenerator, NonblockingRng>(); 124 #endif 125 #ifdef OS_RNG_AVAILABLE 126 RegisterDefaultFactoryFor<RandomNumberGenerator, AutoSeededRandomPool>(); 127 RegisterDefaultFactoryFor<RandomNumberGenerator, AutoSeededX917RNG<AES> >(); 128 #endif 129 RegisterDefaultFactoryFor<RandomNumberGenerator, MT19937>(); 130 #if (CRYPTOPP_BOOL_X86) 131 if (HasPadlockRNG()) 132 RegisterDefaultFactoryFor<RandomNumberGenerator, PadlockRNG>(); 133 #endif 134 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 135 if (HasRDRAND()) 136 RegisterDefaultFactoryFor<RandomNumberGenerator, RDRAND>(); 137 if (HasRDSEED()) 138 RegisterDefaultFactoryFor<RandomNumberGenerator, RDSEED>(); 139 #endif 140 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) 141 if (HasDARN()) 142 RegisterDefaultFactoryFor<RandomNumberGenerator, DARN>(); 143 #endif 144 RegisterDefaultFactoryFor<RandomNumberGenerator, OFB_Mode<AES>::Encryption >("AES/OFB RNG"); 145 RegisterDefaultFactoryFor<NIST_DRBG, Hash_DRBG<SHA1> >("Hash_DRBG(SHA1)"); 146 RegisterDefaultFactoryFor<NIST_DRBG, Hash_DRBG<SHA256> >("Hash_DRBG(SHA256)"); 147 RegisterDefaultFactoryFor<NIST_DRBG, HMAC_DRBG<SHA1> >("HMAC_DRBG(SHA1)"); 148 RegisterDefaultFactoryFor<NIST_DRBG, HMAC_DRBG<SHA256> >("HMAC_DRBG(SHA256)"); 149 150 RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA1> >(); 151 RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA256> >(); 152 RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA512> >(); 153 RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<Whirlpool> >(); 154 } 155