2017-04-14 01:45:21 +00:00
|
|
|
// regtest1.cpp - originally written and placed in the public domain by Wei Dai
|
|
|
|
// regtest.cpp split into 3 files due to OOM kills by JW in April 2017
|
|
|
|
|
|
|
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
|
|
|
|
|
|
|
|
#include "cryptlib.h"
|
|
|
|
#include "factory.h"
|
|
|
|
#include "bench.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
#include "crc.h"
|
|
|
|
#include "adler32.h"
|
|
|
|
#include "md2.h"
|
|
|
|
#include "md5.h"
|
|
|
|
#include "keccak.h"
|
|
|
|
#include "sha3.h"
|
|
|
|
#include "blake2.h"
|
|
|
|
#include "sha.h"
|
2017-11-24 04:19:09 +00:00
|
|
|
#include "sha3.h"
|
|
|
|
#include "sm3.h"
|
2017-04-14 01:45:21 +00:00
|
|
|
#include "tiger.h"
|
|
|
|
#include "ripemd.h"
|
|
|
|
#include "panama.h"
|
|
|
|
#include "whrlpool.h"
|
|
|
|
|
|
|
|
#include "osrng.h"
|
|
|
|
#include "drbg.h"
|
|
|
|
#include "mersenne.h"
|
|
|
|
#include "rdrand.h"
|
2017-08-19 19:41:45 +00:00
|
|
|
#include "padlkrng.h"
|
2017-04-14 01:45:21 +00:00
|
|
|
|
|
|
|
#include "modes.h"
|
|
|
|
#include "aes.h"
|
|
|
|
|
|
|
|
// Aggressive stack checking with VS2005 SP1 and above.
|
2017-05-11 16:05:57 +00:00
|
|
|
#if (_MSC_FULL_VER >= 140050727)
|
2017-04-14 01:45:21 +00:00
|
|
|
# pragma strict_gs_check (on)
|
|
|
|
#endif
|
|
|
|
|
2017-06-02 09:18:52 +00:00
|
|
|
#if CRYPTOPP_MSC_VERSION
|
|
|
|
# pragma warning(disable: 4505 4355)
|
|
|
|
#endif
|
|
|
|
|
2017-04-14 01:45:21 +00:00
|
|
|
USING_NAMESPACE(CryptoPP)
|
|
|
|
|
|
|
|
// Unkeyed ciphers
|
|
|
|
void RegisterFactories1();
|
|
|
|
// Shared key ciphers
|
|
|
|
void RegisterFactories2();
|
|
|
|
// Public key ciphers
|
|
|
|
void RegisterFactories3();
|
|
|
|
|
|
|
|
void RegisterFactories(Test::TestClass suites)
|
|
|
|
{
|
|
|
|
static bool s_registered = false;
|
|
|
|
if (s_registered)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((suites & Test::Unkeyed) == Test::Unkeyed)
|
|
|
|
RegisterFactories1();
|
|
|
|
|
2017-05-20 03:29:59 +00:00
|
|
|
if ((suites & Test::SharedKeyMAC) == Test::SharedKeyMAC ||
|
2017-08-18 08:52:20 +00:00
|
|
|
(suites & Test::SharedKeyStream) == Test::SharedKeyStream ||
|
|
|
|
(suites & Test::SharedKeyBlock) == Test::SharedKeyBlock)
|
2017-04-14 01:45:21 +00:00
|
|
|
RegisterFactories2();
|
|
|
|
|
|
|
|
if ((suites & Test::PublicKey) == Test::PublicKey)
|
|
|
|
RegisterFactories3();
|
|
|
|
|
|
|
|
s_registered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unkeyed ciphers
|
|
|
|
void RegisterFactories1()
|
|
|
|
{
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, CRC32>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, CRC32C>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Adler32>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Weak::MD5>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA1>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA224>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA256>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA384>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA512>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Whirlpool>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Tiger>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, RIPEMD160>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, RIPEMD320>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, RIPEMD128>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, RIPEMD256>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<LittleEndian> >();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<BigEndian> >();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Keccak_224>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Keccak_256>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Keccak_384>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, Keccak_512>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA3_224>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA3_256>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA3_384>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SHA3_512>();
|
2017-11-24 04:19:09 +00:00
|
|
|
RegisterDefaultFactoryFor<HashTransformation, SM3>();
|
2017-04-14 01:45:21 +00:00
|
|
|
RegisterDefaultFactoryFor<HashTransformation, BLAKE2s>();
|
|
|
|
RegisterDefaultFactoryFor<HashTransformation, BLAKE2b>();
|
|
|
|
|
|
|
|
#ifdef BLOCKING_RNG_AVAILABLE
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, BlockingRng>();
|
|
|
|
#endif
|
|
|
|
#ifdef NONBLOCKING_RNG_AVAILABLE
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, NonblockingRng>();
|
|
|
|
#endif
|
|
|
|
#ifdef OS_RNG_AVAILABLE
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, AutoSeededRandomPool>();
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, AutoSeededX917RNG<AES> >();
|
|
|
|
#endif
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, MT19937>();
|
2017-08-19 19:41:45 +00:00
|
|
|
#if (CRYPTOPP_BOOL_X86)
|
|
|
|
if (HasPadlockRNG())
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, PadlockRNG>();
|
|
|
|
#endif
|
2017-04-14 01:45:21 +00:00
|
|
|
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
|
|
|
|
if (HasRDRAND())
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, RDRAND>();
|
|
|
|
if (HasRDSEED())
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, RDSEED>();
|
|
|
|
#endif
|
|
|
|
RegisterDefaultFactoryFor<RandomNumberGenerator, OFB_Mode<AES>::Encryption >("AES/OFB RNG");
|
|
|
|
RegisterDefaultFactoryFor<NIST_DRBG, Hash_DRBG<SHA1> >("Hash_DRBG(SHA1)");
|
|
|
|
RegisterDefaultFactoryFor<NIST_DRBG, Hash_DRBG<SHA256> >("Hash_DRBG(SHA256)");
|
|
|
|
RegisterDefaultFactoryFor<NIST_DRBG, HMAC_DRBG<SHA1> >("HMAC_DRBG(SHA1)");
|
|
|
|
RegisterDefaultFactoryFor<NIST_DRBG, HMAC_DRBG<SHA256> >("HMAC_DRBG(SHA256)");
|
|
|
|
}
|