From 63976542803d22116a9c8469936c71e8e4c2ad0d Mon Sep 17 00:00:00 2001 From: Dutchman101 Date: Sat, 22 Jun 2024 03:40:40 +0200 Subject: [PATCH] Fix failed cryptopp tests in debug builds; partially revert 7ba2a4c (Accidentally added files that were always in cryptopp but not in use by MTA) --- vendor/cryptopp/bench.h | 105 -- vendor/cryptopp/bench1.cpp | 520 -------- vendor/cryptopp/bench2.cpp | 267 ---- vendor/cryptopp/bench3.cpp | 480 ------- vendor/cryptopp/datatest.cpp | 1443 --------------------- vendor/cryptopp/dlltest.cpp | 212 ---- vendor/cryptopp/fipsalgt.cpp | 1293 ------------------- vendor/cryptopp/fipstest.cpp | 652 ---------- vendor/cryptopp/regtest1.cpp | 160 --- vendor/cryptopp/regtest2.cpp | 105 -- vendor/cryptopp/regtest3.cpp | 156 --- vendor/cryptopp/regtest4.cpp | 58 - vendor/cryptopp/test.cpp | 1098 ---------------- vendor/cryptopp/validat0.cpp | 1672 ------------------------- vendor/cryptopp/validat1.cpp | 1225 ------------------ vendor/cryptopp/validat10.cpp | 535 -------- vendor/cryptopp/validat2.cpp | 1328 -------------------- vendor/cryptopp/validat3.cpp | 1367 -------------------- vendor/cryptopp/validat4.cpp | 1813 --------------------------- vendor/cryptopp/validat5.cpp | 2224 --------------------------------- vendor/cryptopp/validat6.cpp | 408 ------ vendor/cryptopp/validat7.cpp | 705 ----------- vendor/cryptopp/validat8.cpp | 631 ---------- vendor/cryptopp/validat9.cpp | 735 ----------- vendor/cryptopp/validate.h | 395 ------ 25 files changed, 19587 deletions(-) delete mode 100644 vendor/cryptopp/bench.h delete mode 100644 vendor/cryptopp/bench1.cpp delete mode 100644 vendor/cryptopp/bench2.cpp delete mode 100644 vendor/cryptopp/bench3.cpp delete mode 100644 vendor/cryptopp/datatest.cpp delete mode 100644 vendor/cryptopp/dlltest.cpp delete mode 100644 vendor/cryptopp/fipsalgt.cpp delete mode 100644 vendor/cryptopp/fipstest.cpp delete mode 100644 vendor/cryptopp/regtest1.cpp delete mode 100644 vendor/cryptopp/regtest2.cpp delete mode 100644 vendor/cryptopp/regtest3.cpp delete mode 100644 vendor/cryptopp/regtest4.cpp delete mode 100644 vendor/cryptopp/test.cpp delete mode 100644 vendor/cryptopp/validat0.cpp delete mode 100644 vendor/cryptopp/validat1.cpp delete mode 100644 vendor/cryptopp/validat10.cpp delete mode 100644 vendor/cryptopp/validat2.cpp delete mode 100644 vendor/cryptopp/validat3.cpp delete mode 100644 vendor/cryptopp/validat4.cpp delete mode 100644 vendor/cryptopp/validat5.cpp delete mode 100644 vendor/cryptopp/validat6.cpp delete mode 100644 vendor/cryptopp/validat7.cpp delete mode 100644 vendor/cryptopp/validat8.cpp delete mode 100644 vendor/cryptopp/validat9.cpp delete mode 100644 vendor/cryptopp/validate.h diff --git a/vendor/cryptopp/bench.h b/vendor/cryptopp/bench.h deleted file mode 100644 index 561b657874..0000000000 --- a/vendor/cryptopp/bench.h +++ /dev/null @@ -1,105 +0,0 @@ -// bench.h - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#ifndef CRYPTOPP_BENCH_H -#define CRYPTOPP_BENCH_H - -#include "cryptlib.h" - -#include -#include -#include -#include - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -// More granular control over benchmarks -enum TestClass { - /// \brief Random number generators - UnkeyedRNG=(1<<0), - /// \brief Message digests - UnkeyedHash=(1<<1), - /// \brief Other unkeyed algorithms - UnkeyedOther=(1<<2), - - /// \brief Message authentication codes - SharedKeyMAC=(1<<3), - /// \brief Stream ciphers - SharedKeyStream=(1<<4), - /// \brief Block ciphers ciphers - SharedKeyBlock=(1<<5), - /// \brief Other shared key algorithms - SharedKeyOther=(1<<6), - - /// \brief Key agreement algorithms over integers - PublicKeyAgreement=(1<<7), - /// \brief Encryption algorithms over integers - PublicKeyEncryption=(1<<8), - /// \brief Signature algorithms over integers - PublicKeySignature=(1<<9), - /// \brief Other public key algorithms over integers - PublicKeyOther=(1<<10), - - /// \brief Key agreement algorithms over EC - PublicKeyAgreementEC=(1<<11), - /// \brief Encryption algorithms over EC - PublicKeyEncryptionEC=(1<<12), - /// \brief Signature algorithms over EC - PublicKeySignatureEC=(1<<13), - /// \brief Other public key algorithms over EC - PublicKeyOtherEC=(1<<14), - - Unkeyed=UnkeyedRNG|UnkeyedHash|UnkeyedOther, - SharedKey=SharedKeyMAC|SharedKeyStream|SharedKeyBlock|SharedKeyOther, - PublicKey=PublicKeyAgreement|PublicKeyEncryption|PublicKeySignature|PublicKeyOther, - PublicKeyEC=PublicKeyAgreementEC|PublicKeyEncryptionEC|PublicKeySignatureEC|PublicKeyOtherEC, - - All=Unkeyed|SharedKey|PublicKey|PublicKeyEC, - - TestFirst=(0), TestLast=(1<<15) -}; - -extern const double CLOCK_TICKS_PER_SECOND; -extern double g_allocatedTime; -extern double g_hertz; -extern double g_logTotal; -extern unsigned int g_logCount; -extern const byte defaultKey[]; - -// Test book keeping -extern time_t g_testBegin; -extern time_t g_testEnd; - -// Benchmark command handler -void BenchmarkWithCommand(int argc, const char* const argv[]); -// Top level, prints preamble and postamble -void Benchmark(Test::TestClass suites, double t, double hertz); -// Unkeyed systems -void BenchmarkUnkeyedAlgorithms(double t, double hertz); -// Shared key systems -void BenchmarkSharedKeyedAlgorithms(double t, double hertz); -// Public key systems over integers -void BenchmarkPublicKeyAlgorithms(double t, double hertz); -// Public key systems over elliptic curves -void BenchmarkEllipticCurveAlgorithms(double t, double hertz); - -// These are defined in bench1.cpp -extern void OutputResultKeying(double iterations, double timeTaken); -extern void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken); -extern void OutputResultOperations(const char *name, const char *provider, const char *operation, bool pc, unsigned long iterations, double timeTaken); - -// These are defined in bench1.cpp -extern void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal); -extern void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal); -extern void BenchMark(const char *name, HashTransformation &ht, double timeTotal); -extern void BenchMark(const char *name, RandomNumberGenerator &rng, double timeTotal); - -// These are defined in bench2.cpp -extern void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs ¶ms); -extern void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal); - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP - -#endif diff --git a/vendor/cryptopp/bench1.cpp b/vendor/cryptopp/bench1.cpp deleted file mode 100644 index 24c9a3b7e5..0000000000 --- a/vendor/cryptopp/bench1.cpp +++ /dev/null @@ -1,520 +0,0 @@ -// bench1.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#include "cryptlib.h" -#include "bench.h" -#include "validate.h" - -#include "cpu.h" -#include "factory.h" -#include "algparam.h" -#include "argnames.h" -#include "smartptr.h" -#include "stdcpp.h" - -#include "osrng.h" -#include "drbg.h" -#include "darn.h" -#include "mersenne.h" -#include "rdrand.h" -#include "padlkrng.h" - -#include -#include -#include - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4355) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -#ifdef CLOCKS_PER_SEC -const double CLOCK_TICKS_PER_SECOND = (double)CLOCKS_PER_SEC; -#elif defined(CLK_TCK) -const double CLOCK_TICKS_PER_SECOND = (double)CLK_TCK; -#else -const double CLOCK_TICKS_PER_SECOND = 1000000.0; -#endif - -extern const byte defaultKey[] = "0123456789" // 168 + NULL - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "00000000000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000"; - -double g_allocatedTime = 0.0, g_hertz = 0.0, g_logTotal = 0.0; -unsigned int g_logCount = 0; -time_t g_testBegin, g_testEnd; - -inline std::string HertzToString(double hertz) -{ - std::ostringstream oss; - oss.precision(3); - - if (hertz >= 0.999e+9) - oss << hertz / 1e+9 << " GHz"; - else if (hertz >= 0.999e+6) - oss << hertz / 1e+6 << " MHz"; - else if (hertz >= 0.999e+3) - oss << hertz / 1e+3 << " KHz"; - else - oss << hertz << " Hz"; - - return oss.str(); -} - -void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken) -{ - std::ostringstream oss; - - // Coverity finding - if (length < 0.000001f) length = 0.000001f; - if (timeTaken < 0.000001f) timeTaken = 0.000001f; - - double mbs = length / timeTaken / (1024*1024); - oss << "\n" << name << "" << provider; - oss << std::setiosflags(std::ios::fixed); - oss << "" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << mbs; - if (g_hertz > 1.0f) - { - const double cpb = timeTaken * g_hertz / length; - if (cpb < 24.0f) - oss << "" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << cpb; - else - oss << "" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << cpb; - } - g_logTotal += log(mbs); - g_logCount++; - - std::cout << oss.str(); -} - -void OutputResultKeying(double iterations, double timeTaken) -{ - std::ostringstream oss; - - // Coverity finding - if (iterations < 0.000001f) iterations = 0.000001f; - if (timeTaken < 0.000001f) timeTaken = 0.000001f; - - oss << "" << std::setprecision(3) << std::setiosflags(std::ios::fixed) << (1000*1000*timeTaken/iterations); - - // Coverity finding - if (g_hertz > 1.0f) - oss << "" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / iterations; - - std::cout << oss.str(); -} - -void OutputResultOperations(const char *name, const char *provider, const char *operation, bool pc, unsigned long iterations, double timeTaken) -{ - CRYPTOPP_UNUSED(provider); - std::ostringstream oss; - - // Coverity finding - if (!iterations) iterations++; - if (timeTaken < 0.000001f) timeTaken = 0.000001f; - - oss << "\n" << name << " " << operation << (pc ? " with precomputation" : ""); - //oss << "" << provider; - oss << "" << std::setprecision(3) << std::setiosflags(std::ios::fixed) << (1000*timeTaken/iterations); - - // Coverity finding - if (g_hertz > 1.0f) - { - const double t = timeTaken * g_hertz / iterations / 1000000; - oss << "" << std::setprecision(3) << std::setiosflags(std::ios::fixed) << t; - } - - g_logTotal += log(iterations/timeTaken); - g_logCount++; - - std::cout << oss.str(); -} - -/* -void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal) -{ - const int BUF_SIZE = RoundUpToMultipleOf(2048U, cipher.OptimalNumberOfParallelBlocks() * cipher.BlockSize()); - AlignedSecByteBlock buf(BUF_SIZE); - buf.SetMark(16); - - const int nBlocks = BUF_SIZE / cipher.BlockSize(); - unsigned long i=0, blocks=1; - double timeTaken; - - clock_t start = ::clock(); - do - { - blocks *= 2; - for (; i(&rng); - if (cipher != NULLPTR) - { - const size_t size = cipher->DefaultKeyLength(); - if (cipher->IsResynchronizable()) - cipher->SetKeyWithIV(buf, size, buf+size); - else - cipher->SetKey(buf, size); - } - - unsigned long long blocks = 1; - double timeTaken; - - clock_t start = ::clock(); - do - { - rng.GenerateBlock(buf, buf.size()); - blocks++; - timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND; - } while (timeTaken < timeTotal); - - std::string provider = rng.AlgorithmProvider(); - OutputResultBytes(name, provider.c_str(), double(blocks) * BUF_SIZE, timeTaken); -} - -// Hack, but we probably need a KeyedRandomNumberGenerator interface -// and a few methods to generalize keying a RNG. X917RNG, Hash_DRBG, -// HMAC_DRBG, AES/CFB RNG and a few others could use it. "A few others" -// includes BLAKE2, ChaCha and Poly1305 when used as a RNG. -void BenchMark(const char *name, NIST_DRBG &rng, double timeTotal) -{ - const int BUF_SIZE = 2048U; - AlignedSecByteBlock buf(BUF_SIZE); - Test::GlobalRNG().GenerateBlock(buf, BUF_SIZE); - buf.SetMark(16); - - rng.IncorporateEntropy(buf, rng.MinEntropyLength()); - unsigned long long blocks = 1; - double timeTaken; - - clock_t start = ::clock(); - do - { - rng.GenerateBlock(buf, buf.size()); - blocks++; - timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND; - } while (timeTaken < timeTotal); - - std::string provider = rng.AlgorithmProvider(); - OutputResultBytes(name, provider.c_str(), double(blocks) * BUF_SIZE, timeTaken); -} - -template -void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName = NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) -{ - CRYPTOPP_UNUSED(params); - std::string name = factoryName; - if (displayName) - name = displayName; - - member_ptr obj(ObjectFactoryRegistry::Registry().CreateObject(factoryName)); - BenchMark(name.c_str(), *obj, g_allocatedTime); -} - -void AddHtmlHeader() -{ - std::ostringstream oss; - - // HTML5 - oss << ""; - oss << "\n"; - - oss << "\n"; - oss << "\n"; - oss << "\nSpeed Comparison of Popular Crypto Algorithms"; - oss << "\n"; - oss << "\n"; - - oss << "\n"; - - oss << "\n

Crypto++ " << CRYPTOPP_VERSION / 100; - oss << '.' << (CRYPTOPP_VERSION % 100) / 10 << '.' << CRYPTOPP_VERSION % 10 << " Benchmarks

"; - - oss << "\n

Here are speed benchmarks for some commonly used cryptographic algorithms.

"; - - if (g_hertz > 1.0f) - oss << "\n

CPU frequency of the test platform is " << HertzToString(g_hertz) << ".

"; - else - oss << "\n

CPU frequency of the test platform was not provided.

" << std::endl; - - std::cout << oss.str(); -} - -void AddHtmlFooter() -{ - std::ostringstream oss; - oss << "\n\n\n"; - std::cout << oss.str(); -} - -void BenchmarkWithCommand(int argc, const char* const argv[]) -{ - std::string command(argv[1]); - float runningTime(argc >= 3 ? Test::StringToValue(argv[2]) : 1.0f); - float cpuFreq(argc >= 4 ? Test::StringToValue(argv[3])*float(1e9) : 0.0f); - std::string algoName(argc >= 5 ? argv[4] : ""); - - // https://github.com/weidai11/cryptopp/issues/983 - if (runningTime > 10.0f) - runningTime = 10.0f; - - if (command == "b") // All benchmarks - Benchmark(Test::All, runningTime, cpuFreq); - else if (command == "b4") // Public key algorithms over EC - Test::Benchmark(Test::PublicKeyEC, runningTime, cpuFreq); - else if (command == "b3") // Public key algorithms - Test::Benchmark(Test::PublicKey, runningTime, cpuFreq); - else if (command == "b2") // Shared key algorithms - Test::Benchmark(Test::SharedKey, runningTime, cpuFreq); - else if (command == "b1") // Unkeyed algorithms - Test::Benchmark(Test::Unkeyed, runningTime, cpuFreq); -} - -void Benchmark(Test::TestClass suites, double t, double hertz) -{ - g_allocatedTime = t; - g_hertz = hertz; - - // Add
in between tables - size_t count_breaks = 0; - - AddHtmlHeader(); - - g_testBegin = ::time(NULLPTR); - - if (static_cast(suites) == 0 || static_cast(suites) > TestLast) - suites = Test::All; - - // Unkeyed algorithms - if (suites & Test::Unkeyed) - { - if (count_breaks) - std::cout << "\n
"; - count_breaks++; - - BenchmarkUnkeyedAlgorithms(t, hertz); - } - - // Shared key algorithms - if (suites & Test::SharedKey) - { - if (count_breaks) - std::cout << "\n
"; - count_breaks++; - - BenchmarkSharedKeyedAlgorithms(t, hertz); - } - - // Public key algorithms - if (suites & Test::PublicKey) - { - if (count_breaks) - std::cout << "\n
"; - count_breaks++; - - BenchmarkPublicKeyAlgorithms(t, hertz); - } - - // Public key algorithms over EC - if (suites & Test::PublicKeyEC) - { - if (count_breaks) - std::cout << "\n
"; - count_breaks++; - - BenchmarkEllipticCurveAlgorithms(t, hertz); - } - - g_testEnd = ::time(NULLPTR); - - std::ostringstream oss; - oss << "\n

Throughput Geometric Average: " << std::setiosflags(std::ios::fixed); - oss << std::exp(g_logTotal/(g_logCount > 0.0f ? g_logCount : 1.0f)) << std::endl; - - oss << "\n

Test started at " << TimeToString(g_testBegin); - oss << "\n
Test ended at " << TimeToString(g_testEnd); - oss << "\n"; - std::cout << oss.str(); - - AddHtmlFooter(); -} - -void BenchmarkUnkeyedAlgorithms(double t, double hertz) -{ - g_allocatedTime = t; - g_hertz = hertz; - - const char *cpb; - if (g_hertz > 1.0f) - cpb = "Cycles/Byte"; - else - cpb = ""; - - std::cout << "\n"; - - std::cout << "\n"; - std::cout << ""; - std::cout << "\n"; - std::cout << "\n"; - { -#ifdef NONBLOCKING_RNG_AVAILABLE - BenchMarkByNameKeyLess("NonblockingRng"); -#endif -#ifdef OS_RNG_AVAILABLE - BenchMarkByNameKeyLess("AutoSeededRandomPool"); - BenchMarkByNameKeyLess("AutoSeededX917RNG(AES)"); -#endif - BenchMarkByNameKeyLess("MT19937"); -#if (CRYPTOPP_BOOL_X86) && !defined(CRYPTOPP_DISABLE_ASM) - if (HasPadlockRNG()) - BenchMarkByNameKeyLess("PadlockRNG"); -#endif -#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_ASM) - if (HasRDRAND()) - BenchMarkByNameKeyLess("RDRAND"); - if (HasRDSEED()) - BenchMarkByNameKeyLess("RDSEED"); -#endif -#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) && !defined(CRYPTOPP_DISABLE_ASM) - if (HasDARN()) - BenchMarkByNameKeyLess("DARN"); -#endif - BenchMarkByNameKeyLess("AES/OFB RNG"); - BenchMarkByNameKeyLess("Hash_DRBG(SHA1)"); - BenchMarkByNameKeyLess("Hash_DRBG(SHA256)"); - BenchMarkByNameKeyLess("HMAC_DRBG(SHA1)"); - BenchMarkByNameKeyLess("HMAC_DRBG(SHA256)"); - } - - std::cout << "\n"; - { - BenchMarkByNameKeyLess("CRC32"); - BenchMarkByNameKeyLess("CRC32C"); - BenchMarkByNameKeyLess("Adler32"); - BenchMarkByNameKeyLess("MD5"); - BenchMarkByNameKeyLess("SHA-1"); - BenchMarkByNameKeyLess("SHA-256"); - BenchMarkByNameKeyLess("SHA-512"); - BenchMarkByNameKeyLess("SHA3-224"); - BenchMarkByNameKeyLess("SHA3-256"); - BenchMarkByNameKeyLess("SHA3-384"); - BenchMarkByNameKeyLess("SHA3-512"); - BenchMarkByNameKeyLess("Keccak-224"); - BenchMarkByNameKeyLess("Keccak-256"); - BenchMarkByNameKeyLess("Keccak-384"); - BenchMarkByNameKeyLess("Keccak-512"); - BenchMarkByNameKeyLess("Tiger"); - BenchMarkByNameKeyLess("Whirlpool"); - BenchMarkByNameKeyLess("RIPEMD-160"); - BenchMarkByNameKeyLess("RIPEMD-320"); - BenchMarkByNameKeyLess("RIPEMD-128"); - BenchMarkByNameKeyLess("RIPEMD-256"); - BenchMarkByNameKeyLess("SM3"); - BenchMarkByNameKeyLess("BLAKE2s"); - BenchMarkByNameKeyLess("BLAKE2b"); - BenchMarkByNameKeyLess("LSH-256"); - BenchMarkByNameKeyLess("LSH-512"); - } - - std::cout << "\n
AlgorithmProviderMiB/Second" << cpb; - - std::cout << "\n
" << std::endl; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/bench2.cpp b/vendor/cryptopp/bench2.cpp deleted file mode 100644 index 0bd2d0a4b2..0000000000 --- a/vendor/cryptopp/bench2.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// bench2.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#include "cryptlib.h" -#include "bench.h" -#include "validate.h" - -#include "cpu.h" -#include "factory.h" -#include "algparam.h" -#include "argnames.h" -#include "smartptr.h" -#include "stdcpp.h" - -#include "vmac.h" -#include "hmac.h" -#include "ttmac.h" -#include "cmac.h" -#include "dmac.h" - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4355) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs ¶ms) -{ - unsigned long iterations = 0; - double timeTaken; - - clock_t start = ::clock(); - do - { - for (unsigned int i=0; i<1024; i++) - c.SetKey(defaultKey, keyLength, params); - timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND; - iterations += 1024; - } - while (timeTaken < g_allocatedTime); - - OutputResultKeying(iterations, timeTaken); -} - -void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal) -{ - if (cipher.NeedsPrespecifiedDataLengths()) - cipher.SpecifyDataLengths(0, cipher.MaxMessageLength(), 0); - - BenchMark(name, static_cast(cipher), timeTotal); -} - -template -void BenchMarkByName2(const char *factoryName, size_t keyLength=0, const char *displayName=NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) -{ - std::string name(factoryName ? factoryName : ""); - member_ptr obj(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - - if (keyLength == 0) - keyLength = obj->DefaultKeyLength(); - - if (displayName != NULLPTR) - name = displayName; - else if (keyLength != 0) - name += " (" + IntToString(keyLength * 8) + "-bit key)"; - - obj->SetKey(defaultKey, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, obj->IVSize()), false))); - BenchMark(name.c_str(), *static_cast(obj.get()), g_allocatedTime); - BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, obj->IVSize()), false))); -} - -template -void BenchMarkByName(const char *factoryName, size_t keyLength=0, const char *displayName=NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) -{ - BenchMarkByName2(factoryName, keyLength, displayName, params); -} - -void BenchmarkSharedKeyedAlgorithms(double t, double hertz) -{ - g_allocatedTime = t; - g_hertz = hertz; - - const char *cpb, *cpk; - if (g_hertz > 1.0f) - { - cpb = "Cycles/Byte"; - cpk = "Cycles to
Setup Key and IV"; - } - else - { - cpb = cpk = ""; - } - - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - { -#if CRYPTOPP_AESNI_AVAILABLE - if (HasCLMUL()) - BenchMarkByName2("AES/GCM", 0, "GMAC(AES)"); - else -#elif CRYPTOPP_ARM_PMULL_AVAILABLE - if (HasPMULL()) - BenchMarkByName2("AES/GCM", 0, "GMAC(AES)"); - else -#elif CRYPTOPP_POWER8_VMULL_AVAILABLE - if (HasPMULL()) - BenchMarkByName2("AES/GCM", 0, "GMAC(AES)"); - else -#endif - { - BenchMarkByName2("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048)); - BenchMarkByName2("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64 * 1024)); - } - - BenchMarkByName("VMAC(AES)-64"); - BenchMarkByName("VMAC(AES)-128"); - BenchMarkByName("HMAC(SHA-1)"); - BenchMarkByName("HMAC(SHA-256)"); - BenchMarkByName("Two-Track-MAC"); - BenchMarkByName("CMAC(AES)"); - BenchMarkByName("DMAC(AES)"); - BenchMarkByName("Poly1305(AES)"); - BenchMarkByName("Poly1305TLS"); - BenchMarkByName("BLAKE2s"); - BenchMarkByName("BLAKE2b"); - BenchMarkByName("SipHash-2-4"); - BenchMarkByName("SipHash-4-8"); - } - - std::cout << "\n"; - { - BenchMarkByName("Panama-LE"); - BenchMarkByName("Panama-BE"); - BenchMarkByName("Salsa20", 0, "Salsa20"); - BenchMarkByName("Salsa20", 0, "Salsa20/12", MakeParameters(Name::Rounds(), 12)); - BenchMarkByName("Salsa20", 0, "Salsa20/8", MakeParameters(Name::Rounds(), 8)); - BenchMarkByName("ChaCha", 0, "ChaCha20"); - BenchMarkByName("ChaCha", 0, "ChaCha12", MakeParameters(Name::Rounds(), 12)); - BenchMarkByName("ChaCha", 0, "ChaCha8", MakeParameters(Name::Rounds(), 8)); - BenchMarkByName("ChaChaTLS"); - BenchMarkByName("Sosemanuk"); - BenchMarkByName("Rabbit"); - BenchMarkByName("RabbitWithIV"); - BenchMarkByName("HC-128"); - BenchMarkByName("HC-256"); - BenchMarkByName("MARC4"); - BenchMarkByName("SEAL-3.0-LE"); - BenchMarkByName("WAKE-OFB-LE"); - } - - std::cout << "\n"; - { - BenchMarkByName("AES/CTR", 16); - BenchMarkByName("AES/CTR", 24); - BenchMarkByName("AES/CTR", 32); - BenchMarkByName("AES/CBC", 16); - BenchMarkByName("AES/CBC", 24); - BenchMarkByName("AES/CBC", 32); - BenchMarkByName("AES/XTS", 32); - BenchMarkByName("AES/XTS", 48); - BenchMarkByName("AES/XTS", 64); - BenchMarkByName("AES/OFB", 16); - BenchMarkByName("AES/CFB", 16); - BenchMarkByName("AES/ECB", 16); - BenchMarkByName("ARIA/CTR", 16); - BenchMarkByName("ARIA/CTR", 32); - BenchMarkByName("HIGHT/CTR"); - BenchMarkByName("Camellia/CTR", 16); - BenchMarkByName("Camellia/CTR", 32); - BenchMarkByName("Twofish/CTR"); - BenchMarkByName("Threefish-256(256)/CTR", 32); - BenchMarkByName("Threefish-512(512)/CTR", 64); - BenchMarkByName("Threefish-1024(1024)/CTR", 128); - BenchMarkByName("Serpent/CTR"); - BenchMarkByName("CAST-128/CTR"); - BenchMarkByName("CAST-256/CTR", 32); - BenchMarkByName("RC6/CTR"); - BenchMarkByName("MARS/CTR"); - BenchMarkByName("SHACAL-2/CTR", 16); - BenchMarkByName("SHACAL-2/CTR", 64); - BenchMarkByName("DES/CTR"); - BenchMarkByName("DES-XEX3/CTR"); - BenchMarkByName("DES-EDE3/CTR"); - BenchMarkByName("IDEA/CTR"); - BenchMarkByName("RC5/CTR", 0, "RC5 (r=16)"); - BenchMarkByName("Blowfish/CTR"); - BenchMarkByName("SKIPJACK/CTR"); - BenchMarkByName("SEED/CTR", 0, "SEED/CTR (1/2 K table)"); - BenchMarkByName("SM4/CTR"); - - BenchMarkByName("Kalyna-128/CTR", 16, "Kalyna-128(128)/CTR (128-bit key)"); - BenchMarkByName("Kalyna-128/CTR", 32, "Kalyna-128(256)/CTR (256-bit key)"); - BenchMarkByName("Kalyna-256/CTR", 32, "Kalyna-256(256)/CTR (256-bit key)"); - BenchMarkByName("Kalyna-256/CTR", 64, "Kalyna-256(512)/CTR (512-bit key)"); - BenchMarkByName("Kalyna-512/CTR", 64, "Kalyna-512(512)/CTR (512-bit key)"); - } - - std::cout << "\n"; - { - BenchMarkByName("CHAM-64/CTR", 16, "CHAM-64(128)/CTR (128-bit key)"); - BenchMarkByName("CHAM-128/CTR", 16, "CHAM-128(128)/CTR (128-bit key)"); - BenchMarkByName("CHAM-128/CTR", 32, "CHAM-128(256)/CTR (256-bit key)"); - - BenchMarkByName("LEA-128/CTR", 16, "LEA-128(128)/CTR (128-bit key)"); - BenchMarkByName("LEA-128/CTR", 24, "LEA-128(192)/CTR (192-bit key)"); - BenchMarkByName("LEA-128/CTR", 32, "LEA-128(256)/CTR (256-bit key)"); - - BenchMarkByName("SIMECK-32/CTR", 8, "SIMECK-32(64)/CTR (64-bit key)"); - BenchMarkByName("SIMECK-64/CTR", 16, "SIMECK-64(128)/CTR (128-bit key)"); - - BenchMarkByName("SIMON-64/CTR", 12, "SIMON-64(96)/CTR (96-bit key)"); - BenchMarkByName("SIMON-64/CTR", 16, "SIMON-64(128)/CTR (128-bit key)"); - BenchMarkByName("SIMON-128/CTR", 16, "SIMON-128(128)/CTR (128-bit key)"); - BenchMarkByName("SIMON-128/CTR", 24, "SIMON-128(192)/CTR (192-bit key)"); - BenchMarkByName("SIMON-128/CTR", 32, "SIMON-128(256)/CTR (256-bit key)"); - - BenchMarkByName("SPECK-64/CTR", 12, "SPECK-64(96)/CTR (96-bit key)"); - BenchMarkByName("SPECK-64/CTR", 16, "SPECK-64(128)/CTR (128-bit key)"); - BenchMarkByName("SPECK-128/CTR", 16, "SPECK-128(128)/CTR (128-bit key)"); - BenchMarkByName("SPECK-128/CTR", 24, "SPECK-128(192)/CTR (192-bit key)"); - BenchMarkByName("SPECK-128/CTR", 32, "SPECK-128(256)/CTR (256-bit key)"); - - BenchMarkByName("TEA/CTR"); - BenchMarkByName("XTEA/CTR"); - } - - std::cout << "\n"; - { -#if CRYPTOPP_AESNI_AVAILABLE - if (HasCLMUL()) - BenchMarkByName2("AES/GCM", 0, "AES/GCM"); - else -#elif CRYPTOPP_ARM_PMULL_AVAILABLE - if (HasPMULL()) - BenchMarkByName2("AES/GCM", 0, "AES/GCM"); - else -#elif CRYPTOPP_POWER8_VMULL_AVAILABLE - if (HasPMULL()) - BenchMarkByName2("AES/GCM", 0, "AES/GCM"); - else -#endif - { - BenchMarkByName2("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048)); - BenchMarkByName2("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64 * 1024)); - } - BenchMarkByName2("AES/CCM"); - BenchMarkByName2("AES/EAX"); - BenchMarkByName2("ChaCha20/Poly1305"); - BenchMarkByName2("XChaCha20/Poly1305"); - } - - std::cout << "\n
AlgorithmProviderMiB/Second" << cpb; - std::cout << "Microseconds to
Setup Key and IV" << cpk; - - std::cout << "\n
" << std::endl; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/bench3.cpp b/vendor/cryptopp/bench3.cpp deleted file mode 100644 index e280a6216f..0000000000 --- a/vendor/cryptopp/bench3.cpp +++ /dev/null @@ -1,480 +0,0 @@ -// bench3.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#include "cryptlib.h" -#include "bench.h" -#include "validate.h" - -#include "cpu.h" -#include "factory.h" -#include "algparam.h" -#include "argnames.h" -#include "smartptr.h" -#include "stdcpp.h" - -#include "pubkey.h" -#include "gfpcrypt.h" -#include "eccrypto.h" -#include "pkcspad.h" - -#include "files.h" -#include "filters.h" -#include "hex.h" -#include "rsa.h" -#include "nr.h" -#include "dsa.h" -#include "luc.h" -#include "rw.h" -#include "ecp.h" -#include "ec2n.h" -#include "asn.h" -#include "dh.h" -#include "mqv.h" -#include "hmqv.h" -#include "fhmqv.h" -#include "xed25519.h" -#include "xtrcrypt.h" -#include "esign.h" -#include "pssr.h" -#include "oids.h" -#include "randpool.h" -#include "stdcpp.h" -#include "hrtimer.h" - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc = false) -{ - unsigned int len = 16; - SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len)); - Test::GlobalRNG().GenerateBlock(plaintext, len); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - key.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = key.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Encryption", pc, i, timeTaken); - - if (!pc && key.GetMaterial().SupportsPrecomputation()) - { - key.AccessMaterial().Precompute(16); - BenchMarkEncryption(name, key, timeTotal, true); - } -} - -void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal) -{ - unsigned int len = 16; - SecByteBlock ciphertext(pub.CiphertextLength(len)); - SecByteBlock plaintext(pub.MaxPlaintextLength(ciphertext.size())); - Test::GlobalRNG().GenerateBlock(plaintext, len); - pub.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - priv.Decrypt(Test::GlobalRNG(), ciphertext, ciphertext.size(), plaintext); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = priv.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Decryption", false, i, timeTaken); -} - -void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool pc=false) -{ - unsigned int len = 16; - AlignedSecByteBlock message(len), signature(key.SignatureLength()); - Test::GlobalRNG().GenerateBlock(message, len); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - (void)key.SignMessage(Test::GlobalRNG(), message, len, signature); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = key.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Signature", pc, i, timeTaken); - - if (!pc && key.GetMaterial().SupportsPrecomputation()) - { - key.AccessMaterial().Precompute(16); - BenchMarkSigning(name, key, timeTotal, true); - } -} - -void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier &pub, double timeTotal, bool pc=false) -{ - unsigned int len = 16; - AlignedSecByteBlock message(len), signature(pub.SignatureLength()); - Test::GlobalRNG().GenerateBlock(message, len); - priv.SignMessage(Test::GlobalRNG(), message, len, signature); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - (void)pub.VerifyMessage(message, len, signature, signature.size()); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = pub.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Verification", pc, i, timeTaken); - - if (!pc && pub.GetMaterial().SupportsPrecomputation()) - { - pub.AccessMaterial().Precompute(16); - BenchMarkVerification(name, priv, pub, timeTotal, true); - } -} - -void BenchMarkKeyGen(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false) -{ - SecByteBlock priv(d.PrivateKeyLength()), pub(d.PublicKeyLength()); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - d.GenerateKeyPair(Test::GlobalRNG(), priv, pub); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = d.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Key-Pair Generation", pc, i, timeTaken); - - if (!pc && d.GetMaterial().SupportsPrecomputation()) - { - d.AccessMaterial().Precompute(16); - BenchMarkKeyGen(name, d, timeTotal, true); - } -} - -void BenchMarkKeyGen(const char *name, AuthenticatedKeyAgreementDomain &d, double timeTotal, bool pc=false) -{ - SecByteBlock priv(d.EphemeralPrivateKeyLength()), pub(d.EphemeralPublicKeyLength()); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - d.GenerateEphemeralKeyPair(Test::GlobalRNG(), priv, pub); - ++i; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = d.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Key-Pair Generation", pc, i, timeTaken); - - if (!pc && d.GetMaterial().SupportsPrecomputation()) - { - d.AccessMaterial().Precompute(16); - BenchMarkKeyGen(name, d, timeTotal, true); - } -} - -void BenchMarkAgreement(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false) -{ - SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength()); - SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength()); - d.GenerateKeyPair(Test::GlobalRNG(), priv1, pub1); - d.GenerateKeyPair(Test::GlobalRNG(), priv2, pub2); - SecByteBlock val(d.AgreedValueLength()); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - d.Agree(val, priv1, pub2); - d.Agree(val, priv2, pub1); - i+=2; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = d.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Key Agreement", pc, i, timeTaken); -} - -void BenchMarkAgreement(const char *name, AuthenticatedKeyAgreementDomain &d, double timeTotal, bool pc=false) -{ - SecByteBlock spriv1(d.StaticPrivateKeyLength()), spriv2(d.StaticPrivateKeyLength()); - SecByteBlock epriv1(d.EphemeralPrivateKeyLength()), epriv2(d.EphemeralPrivateKeyLength()); - SecByteBlock spub1(d.StaticPublicKeyLength()), spub2(d.StaticPublicKeyLength()); - SecByteBlock epub1(d.EphemeralPublicKeyLength()), epub2(d.EphemeralPublicKeyLength()); - d.GenerateStaticKeyPair(Test::GlobalRNG(), spriv1, spub1); - d.GenerateStaticKeyPair(Test::GlobalRNG(), spriv2, spub2); - d.GenerateEphemeralKeyPair(Test::GlobalRNG(), epriv1, epub1); - d.GenerateEphemeralKeyPair(Test::GlobalRNG(), epriv2, epub2); - SecByteBlock val(d.AgreedValueLength()); - - unsigned int i = 0; - double timeTaken; - - ThreadUserTimer timer; - timer.StartTimer(); - - do - { - d.Agree(val, spriv1, epriv1, spub2, epub2); - d.Agree(val, spriv2, epriv2, spub1, epub1); - i+=2; timeTaken = timer.ElapsedTimeAsDouble(); - } - while (timeTaken < timeTotal); - - std::string provider = d.AlgorithmProvider(); - OutputResultOperations(name, provider.c_str(), "Key Agreement", pc, i, timeTaken); -} - -template -void BenchMarkCrypto(const char *filename, const char *name, double timeTotal) -{ - FileSource f(DataDir(filename).c_str(), true, new HexDecoder); - typename SCHEME::Decryptor priv(f); - typename SCHEME::Encryptor pub(priv); - BenchMarkEncryption(name, pub, timeTotal); - BenchMarkDecryption(name, priv, pub, timeTotal); -} - -template -void BenchMarkSignature(const char *filename, const char *name, double timeTotal) -{ - FileSource f(DataDir(filename).c_str(), true, new HexDecoder); - typename SCHEME::Signer priv(f); - typename SCHEME::Verifier pub(priv); - BenchMarkSigning(name, priv, timeTotal); - BenchMarkVerification(name, priv, pub, timeTotal); -} - -template -void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal) -{ - FileSource f(DataDir(filename).c_str(), true, new HexDecoder); - D d(f); - BenchMarkKeyGen(name, d, timeTotal); - BenchMarkAgreement(name, d, timeTotal); -} - -void BenchmarkPublicKeyAlgorithms(double t, double hertz) -{ - g_allocatedTime = t; - g_hertz = hertz; - - const char *mco; - if (g_hertz > 1.0f) - mco = "Megacycles/Operation"; - else - mco = ""; - - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - { - BenchMarkCrypto > >("TestData/rsa1024.dat", "RSA 1024", t); - BenchMarkCrypto > >("TestData/luc1024.dat", "LUC 1024", t); - BenchMarkCrypto >("TestData/dlie1024.dat", "DLIES 1024", t); - BenchMarkCrypto >("TestData/lucc512.dat", "LUCELG 512", t); - } - - std::cout << "\n"; - { - BenchMarkCrypto > >("TestData/rsa2048.dat", "RSA 2048", t); - BenchMarkCrypto > >("TestData/luc2048.dat", "LUC 2048", t); - BenchMarkCrypto >("TestData/dlie2048.dat", "DLIES 2048", t); - BenchMarkCrypto >("TestData/lucc1024.dat", "LUCELG 1024", t); - } - - std::cout << "\n"; - { - BenchMarkSignature >("TestData/rsa1024.dat", "RSA 1024", t); - BenchMarkSignature >("TestData/rw1024.dat", "RW 1024", t); - BenchMarkSignature >("TestData/luc1024.dat", "LUC 1024", t); - BenchMarkSignature >("TestData/nr1024.dat", "NR 1024", t); - BenchMarkSignature("TestData/dsa1024.dat", "DSA 1024", t); - BenchMarkSignature >("TestData/lucs512.dat", "LUC-HMP 512", t); - BenchMarkSignature >("TestData/esig1023.dat", "ESIGN 1023", t); - BenchMarkSignature >("TestData/esig1536.dat", "ESIGN 1536", t); - } - - std::cout << "\n"; - { - BenchMarkSignature >("TestData/rsa2048.dat", "RSA 2048", t); - BenchMarkSignature >("TestData/rw2048.dat", "RW 2048", t); - BenchMarkSignature >("TestData/luc2048.dat", "LUC 2048", t); - BenchMarkSignature >("TestData/nr2048.dat", "NR 2048", t); - BenchMarkSignature >("TestData/lucs1024.dat", "LUC-HMP 1024", t); - BenchMarkSignature >("TestData/esig2046.dat", "ESIGN 2046", t); - } - - std::cout << "\n"; - { - BenchMarkKeyAgreement("TestData/xtrdh171.dat", "XTR-DH 171", t); - BenchMarkKeyAgreement("TestData/xtrdh342.dat", "XTR-DH 342", t); - BenchMarkKeyAgreement("TestData/dh1024.dat", "DH 1024", t); - BenchMarkKeyAgreement("TestData/dh2048.dat", "DH 2048", t); - BenchMarkKeyAgreement("TestData/lucd512.dat", "LUCDIF 512", t); - BenchMarkKeyAgreement("TestData/lucd1024.dat", "LUCDIF 1024", t); - BenchMarkKeyAgreement("TestData/mqv1024.dat", "MQV 1024", t); - BenchMarkKeyAgreement("TestData/mqv2048.dat", "MQV 2048", t); - } - - std::cout << "\n
OperationMilliseconds/Operation" << mco; - - std::cout << "\n
" << std::endl; -} - -void BenchmarkEllipticCurveAlgorithms(double t, double hertz) -{ - g_allocatedTime = t; - g_hertz = hertz; - - const char *mco; - if (g_hertz > 1.0f) - mco = "Megacycles/Operation"; - else - mco = ""; - - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - std::cout << "\n"; - { - ed25519::Signer sign(Test::GlobalRNG()); - ed25519::Verifier verify(sign); - x25519 agree(Test::GlobalRNG()); - - BenchMarkSigning("ed25519", sign, t); - BenchMarkVerification("ed25519", sign, verify, t); - BenchMarkKeyGen("x25519", agree, t); - BenchMarkAgreement("x25519", agree, t); - } - -#if 0 - std::cout << "\n"; - { - BenchMarkKeyAgreement("TestData/mqv160.dat", "MQV P-160", t); - BenchMarkKeyAgreement("TestData/mqv256.dat", "MQV P-256", t); - BenchMarkKeyAgreement("TestData/mqv384.dat", "MQV P-384", t); - BenchMarkKeyAgreement("TestData/mqv512.dat", "MQV P-521", t); - - BenchMarkKeyAgreement("TestData/hmqv160.dat", "HMQV P-160", t); - BenchMarkKeyAgreement("TestData/hmqv256.dat", "HMQV P-256", t); - BenchMarkKeyAgreement("TestData/hmqv384.dat", "HMQV P-384", t); - BenchMarkKeyAgreement("TestData/hmqv512.dat", "HMQV P-521", t); - - BenchMarkKeyAgreement("TestData/fhmqv160.dat", "FHMQV P-160", t); - BenchMarkKeyAgreement("TestData/fhmqv256.dat", "FHMQV P-256", t); - BenchMarkKeyAgreement("TestData/fhmqv384.dat", "FHMQV P-384", t); - BenchMarkKeyAgreement("TestData/fhmqv512.dat", "FHMQV P-521", t); - } -#endif - - std::cout << "\n"; - { - ECIES::Decryptor cpriv(Test::GlobalRNG(), ASN1::secp256k1()); - ECIES::Encryptor cpub(cpriv); - ECDSA::Signer spriv(cpriv); - ECDSA::Verifier spub(spriv); - ECDSA_RFC6979::Signer spriv2(cpriv); - ECDSA_RFC6979::Verifier spub2(spriv2); - ECGDSA::Signer spriv3(Test::GlobalRNG(), ASN1::secp256k1()); - ECGDSA::Verifier spub3(spriv3); - ECDH::Domain ecdhc(ASN1::secp256k1()); - ECMQV::Domain ecmqvc(ASN1::secp256k1()); - - BenchMarkEncryption("ECIES over GF(p) 256", cpub, t); - BenchMarkDecryption("ECIES over GF(p) 256", cpriv, cpub, t); - BenchMarkSigning("ECDSA over GF(p) 256", spriv, t); - BenchMarkVerification("ECDSA over GF(p) 256", spriv, spub, t); - BenchMarkSigning("ECDSA-RFC6979 over GF(p) 256", spriv2, t); - BenchMarkVerification("ECDSA-RFC6979 over GF(p) 256", spriv2, spub2, t); - BenchMarkSigning("ECGDSA over GF(p) 256", spriv3, t); - BenchMarkVerification("ECGDSA over GF(p) 256", spriv3, spub3, t); - BenchMarkKeyGen("ECDHC over GF(p) 256", ecdhc, t); - BenchMarkAgreement("ECDHC over GF(p) 256", ecdhc, t); - BenchMarkKeyGen("ECMQVC over GF(p) 256", ecmqvc, t); - BenchMarkAgreement("ECMQVC over GF(p) 256", ecmqvc, t); - } - - std::cout << "\n"; - { - ECIES::Decryptor cpriv(Test::GlobalRNG(), ASN1::sect233r1()); - ECIES::Encryptor cpub(cpriv); - ECDSA::Signer spriv(cpriv); - ECDSA::Verifier spub(spriv); - ECDSA_RFC6979::Signer spriv2(cpriv); - ECDSA_RFC6979::Verifier spub2(spriv2); - ECGDSA::Signer spriv3(Test::GlobalRNG(), ASN1::sect233r1()); - ECGDSA::Verifier spub3(spriv3); - ECDH::Domain ecdhc(ASN1::sect233r1()); - ECMQV::Domain ecmqvc(ASN1::sect233r1()); - - BenchMarkEncryption("ECIES over GF(2^n) 233", cpub, t); - BenchMarkDecryption("ECIES over GF(2^n) 233", cpriv, cpub, t); - BenchMarkSigning("ECDSA over GF(2^n) 233", spriv, t); - BenchMarkVerification("ECDSA over GF(2^n) 233", spriv, spub, t); - BenchMarkSigning("ECDSA-RFC6979 over GF(2^n) 233", spriv2, t); - BenchMarkVerification("ECDSA-RFC6979 over GF(2^n) 233", spriv2, spub2, t); - BenchMarkSigning("ECGDSA over GF(2^n) 233", spriv3, t); - BenchMarkVerification("ECGDSA over GF(2^n) 233", spriv3, spub3, t); - BenchMarkKeyGen("ECDHC over GF(2^n) 233", ecdhc, t); - BenchMarkAgreement("ECDHC over GF(2^n) 233", ecdhc, t); - BenchMarkKeyGen("ECMQVC over GF(2^n) 233", ecmqvc, t); - BenchMarkAgreement("ECMQVC over GF(2^n) 233", ecmqvc, t); - } - - std::cout << "\n
OperationMilliseconds/Operation" << mco; - - std::cout << "\n
" << std::endl; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/datatest.cpp b/vendor/cryptopp/datatest.cpp deleted file mode 100644 index ac82d5181b..0000000000 --- a/vendor/cryptopp/datatest.cpp +++ /dev/null @@ -1,1443 +0,0 @@ -// datatest.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#define CRYPTOPP_DEFAULT_NO_DLL -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "factory.h" -#include "integer.h" -#include "filters.h" -#include "randpool.h" -#include "files.h" -#include "trunhash.h" -#include "queue.h" -#include "smartptr.h" -#include "validate.h" -#include "stdcpp.h" -#include "misc.h" -#include "hex.h" -#include "trap.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -#ifdef CRYPTOPP_MSC_VERSION -# define STRTOUL64 _strtoui64 -#else -# define STRTOUL64 strtoull -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -ANONYMOUS_NAMESPACE_BEGIN - -bool s_thorough = false; -typedef std::map TestData; -const TestData *s_currentTestData = NULLPTR; -const std::string testDataFilename = "cryptest.dat"; - -// Handles CR, LF, and CRLF properly. Early RFC's used '\r\0' on occasion. -// For istream.fail() see https://stackoverflow.com/q/34395801/608639. -bool Readline(std::istream& stream, std::string& line) -{ - // Ensure old data is cleared - line.clear(); - - std::string temp; - temp.reserve(64); - - while (!stream.fail()) - { - int ch = stream.get(); - if (ch == '\r') - { - int next = stream.peek(); - if (next == '\n') - (void)stream.get(); - else if (next == '\0') - (void)stream.get(); - - break; - } - else if (ch == '\n') - { - break; - } - - temp.push_back(static_cast(ch)); - } - -#if defined(CRYPTOPP_CXX11) - temp.shrink_to_fit(); -#else - // Non-binding shrink to fit - temp.reserve(0); -#endif - - std::swap(line, temp); - - return !stream.fail(); -} - -std::string TrimSpace(const std::string& str) -{ - if (str.empty()) return ""; - - const std::string whitespace(" \r\t\n"); - std::string::size_type beg = str.find_first_not_of(whitespace); - std::string::size_type end = str.find_last_not_of(whitespace); - - if (beg != std::string::npos && end != std::string::npos) - return str.substr(beg, end+1); - else if (beg != std::string::npos) - return str.substr(beg); - else - return ""; -} - -std::string TrimComment(const std::string& str) -{ - if (str.empty()) return ""; - - std::string::size_type first = str.find("#"); - - if (first != std::string::npos) - return TrimSpace(str.substr(0, first)); - else - return TrimSpace(str); -} - -class TestFailure : public Exception -{ -public: - TestFailure() : Exception(OTHER_ERROR, "Validation test failed") {} -}; - -void OutputTestData(const TestData &v) -{ - std::cerr << "\n"; - for (TestData::const_iterator i = v.begin(); i != v.end(); ++i) - { - std::cerr << i->first << ": " << i->second << std::endl; - } -} - -void SignalTestFailure() -{ - OutputTestData(*s_currentTestData); - throw TestFailure(); -} - -void SignalUnknownAlgorithmError(const std::string& algType) -{ - OutputTestData(*s_currentTestData); - throw Exception(Exception::OTHER_ERROR, "Unknown algorithm " + algType + " during validation test"); -} - -void SignalTestError(const char* msg = NULLPTR) -{ - OutputTestData(*s_currentTestData); - - if (msg) - throw Exception(Exception::OTHER_ERROR, msg); - else - throw Exception(Exception::OTHER_ERROR, "Unexpected error during validation test"); -} - -bool DataExists(const TestData &data, const char *name) -{ - TestData::const_iterator i = data.find(name); - return (i != data.end()); -} - -const std::string & GetRequiredDatum(const TestData &data, const char *name) -{ - TestData::const_iterator i = data.find(name); - if (i == data.end()) - { - std::string msg("Required datum \"" + std::string(name) + "\" missing"); - SignalTestError(msg.c_str()); - } - return i->second; -} - -void RandomizedTransfer(BufferedTransformation &source, BufferedTransformation &target, bool finish, const std::string &channel=DEFAULT_CHANNEL) -{ - while (source.MaxRetrievable() > (finish ? 0 : 4096)) - { - byte buf[4096+64]; - size_t start = Test::GlobalRNG().GenerateWord32(0, 63); - size_t len = Test::GlobalRNG().GenerateWord32(1, UnsignedMin(4096U, 3*source.MaxRetrievable()/2)); - len = source.Get(buf+start, len); - target.ChannelPut(channel, buf+start, len); - } -} - -void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransformation &target) -{ - std::string s1 = GetRequiredDatum(data, name), s2; - ByteQueue q; - - while (!s1.empty()) - { - std::string::size_type pos = s1.find_first_not_of(" "); - if (pos != std::string::npos) - s1.erase(0, pos); - - if (s1.empty()) - goto end; - - int repeat = 1; - if (s1[0] == 'r') - { - s1 = s1.erase(0, 1); - repeat = std::atoi(s1.c_str()); - s1 = s1.substr(s1.find(' ')+1); - } - - // Convert word32 or word64 to little endian order. Some algorithm test vectors are - // presented in the format. We probably should have named them word32le and word64le. - if (s1.length() >= 6 && (s1.substr(0,6) == "word32" || s1.substr(0,6) == "word64")) - { - std::istringstream iss(s1.substr(6)); - if (s1.substr(0,6) == "word64") - { - word64 value; - while (iss >> std::skipws >> std::hex >> value) - { - value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value); - q.Put(reinterpret_cast(&value), 8); - } - } - else - { - word32 value; - while (iss >> std::skipws >> std::hex >> value) - { - value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value); - q.Put(reinterpret_cast(&value), 4); - } - } - goto end; - } - - s2.clear(); - if (s1[0] == '\"') - { - s2 = s1.substr(1, s1.find('\"', 1)-1); - s1 = s1.substr(s2.length() + 2); - } - else if (s1.substr(0, 2) == "0x") - { - std::string::size_type n = s1.find(' '); - StringSource(s1.substr(2, n), true, new HexDecoder(new StringSink(s2))); - s1 = s1.substr(STDMIN(n, s1.length())); - } - else - { - std::string::size_type n = s1.find(' '); - StringSource(s1.substr(0, n), true, new HexDecoder(new StringSink(s2))); - s1 = s1.substr(STDMIN(n, s1.length())); - } - - while (repeat--) - { - q.Put(ConstBytePtr(s2), BytePtrSize(s2)); - RandomizedTransfer(q, target, false); - } - } - -end: - RandomizedTransfer(q, target, true); -} - -std::string GetDecodedDatum(const TestData &data, const char *name) -{ - std::string s; - PutDecodedDatumInto(data, name, StringSink(s).Ref()); - return s; -} - -std::string GetOptionalDecodedDatum(const TestData &data, const char *name) -{ - std::string s; - if (DataExists(data, name)) - PutDecodedDatumInto(data, name, StringSink(s).Ref()); - return s; -} - -class TestDataNameValuePairs : public NameValuePairs -{ -public: - TestDataNameValuePairs(const TestData &data) : m_data(data) {} - - virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const - { - TestData::const_iterator i = m_data.find(name); - if (i == m_data.end()) - { - if (std::string(name) == Name::DigestSize() && valueType == typeid(int)) - { - i = m_data.find("MAC"); - if (i == m_data.end()) - i = m_data.find("Digest"); - if (i == m_data.end()) - return false; - - m_temp.clear(); - PutDecodedDatumInto(m_data, i->first.c_str(), StringSink(m_temp).Ref()); - *reinterpret_cast(pValue) = (int)m_temp.size(); - return true; - } - else - return false; - } - - const std::string &value = i->second; - - if (valueType == typeid(int)) - *reinterpret_cast(pValue) = atoi(value.c_str()); - else if (valueType == typeid(word64)) - { - std::string x(value.empty() ? "0" : value); - const char* beg = &x[0]; - char* end = &x[0] + value.size(); - - errno = 0; - *reinterpret_cast(pValue) = STRTOUL64(beg, &end, 0); - if (errno != 0) - return false; - } - else if (valueType == typeid(Integer)) - *reinterpret_cast(pValue) = Integer((std::string(value) + "h").c_str()); - else if (valueType == typeid(ConstByteArrayParameter)) - { - m_temp.clear(); - PutDecodedDatumInto(m_data, name, StringSink(m_temp).Ref()); - reinterpret_cast(pValue)->Assign(ConstBytePtr(m_temp), BytePtrSize(m_temp), false); - } - else - throw ValueTypeMismatch(name, typeid(std::string), valueType); - - return true; - } - -private: - const TestData &m_data; - mutable std::string m_temp; -}; - -void TestKeyPairValidAndConsistent(CryptoMaterial &pub, const CryptoMaterial &priv, unsigned int &totalTests) -{ - totalTests++; - - if (!pub.Validate(Test::GlobalRNG(), 2U+!!s_thorough)) - SignalTestFailure(); - if (!priv.Validate(Test::GlobalRNG(), 2U+!!s_thorough)) - SignalTestFailure(); - - ByteQueue bq1, bq2; - pub.Save(bq1); - pub.AssignFrom(priv); - pub.Save(bq2); - if (bq1 != bq2) - SignalTestFailure(); -} - -void TestSignatureScheme(TestData &v, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - static member_ptr signer; - static member_ptr verifier; - static std::string lastName; - - if (name != lastName) - { - signer.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - verifier.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - lastName = name; - - // Code coverage - (void)signer->AlgorithmName(); - (void)verifier->AlgorithmName(); - (void)signer->AlgorithmProvider(); - (void)verifier->AlgorithmProvider(); - } - - TestDataNameValuePairs pairs(v); - - if (test == "GenerateKey") - { - totalTests++; - - signer->AccessPrivateKey().GenerateRandom(Test::GlobalRNG(), pairs); - verifier->AccessPublicKey().AssignFrom(signer->AccessPrivateKey()); - } - else - { - std::string keyFormat = GetRequiredDatum(v, "KeyFormat"); - - totalTests++; // key format - if (keyFormat == "DER") - verifier->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PublicKey")).Ref()); - else if (keyFormat == "Component") - verifier->AccessMaterial().AssignFrom(pairs); - - if (test == "Verify" || test == "NotVerify") - { - totalTests++; - - SignatureVerificationFilter verifierFilter(*verifier, NULLPTR, SignatureVerificationFilter::SIGNATURE_AT_BEGIN); - PutDecodedDatumInto(v, "Signature", verifierFilter); - PutDecodedDatumInto(v, "Message", verifierFilter); - verifierFilter.MessageEnd(); - if (verifierFilter.GetLastResult() == (test == "NotVerify")) - SignalTestFailure(); - return; - } - else if (test == "PublicKeyValid") - { - totalTests++; - - if (!verifier->GetMaterial().Validate(Test::GlobalRNG(), 3)) - SignalTestFailure(); - return; - } - - totalTests++; // key format - if (keyFormat == "DER") - signer->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PrivateKey")).Ref()); - else if (keyFormat == "Component") - signer->AccessMaterial().AssignFrom(pairs); - } - - if (test == "GenerateKey" || test == "KeyPairValidAndConsistent") - { - totalTests++; - - TestKeyPairValidAndConsistent(verifier->AccessMaterial(), signer->GetMaterial(),totalTests); - SignatureVerificationFilter verifierFilter(*verifier, NULLPTR, SignatureVerificationFilter::THROW_EXCEPTION); - const byte msg[3] = {'a', 'b', 'c'}; - verifierFilter.Put(msg, sizeof(msg)); - StringSource ss(msg, sizeof(msg), true, new SignerFilter(Test::GlobalRNG(), *signer, new Redirector(verifierFilter))); - } - else if (test == "Sign") - { - totalTests++; - - SignerFilter f(Test::GlobalRNG(), *signer, new HexEncoder(new FileSink(std::cout))); - StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f)); - SignalTestFailure(); - } - else if (test == "DeterministicSign") - { - totalTests++; - - // This test is specialized for RFC 6979. The RFC is a drop-in replacement - // for DSA and ECDSA, and access to the seed or secret is not needed. If - // additional deterministic signatures are added, then the test harness will - // likely need to be extended. - std::string signature; - SignerFilter f(Test::GlobalRNG(), *signer, new StringSink(signature)); - StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f)); - - if (GetDecodedDatum(v, "Signature") != signature) - SignalTestFailure(); - } - else - { - std::string msg("Unknown signature test \"" + test + "\""); - SignalTestError(msg.c_str()); - CRYPTOPP_ASSERT(false); - } -} - -// Subset of TestSignatureScheme. We picked the tests that have data that is easy to write to a file. -// Also see https://github.com/weidai11/cryptopp/issues/1010, where HIGHT broke when using FileSource. -void TestSignatureSchemeWithFileSource(TestData &v, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - if (test != "Sign" && test != "DeterministicSign") { return; } - - static member_ptr signer; - static member_ptr verifier; - static std::string lastName; - - if (name != lastName) - { - signer.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - verifier.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - name = lastName; - - // Code coverage - (void)signer->AlgorithmName(); - (void)verifier->AlgorithmName(); - (void)signer->AlgorithmProvider(); - (void)verifier->AlgorithmProvider(); - } - - TestDataNameValuePairs pairs(v); - - std::string keyFormat = GetRequiredDatum(v, "KeyFormat"); - - totalTests++; // key format - if (keyFormat == "DER") - verifier->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PublicKey")).Ref()); - else if (keyFormat == "Component") - verifier->AccessMaterial().AssignFrom(pairs); - - totalTests++; // key format - if (keyFormat == "DER") - signer->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PrivateKey")).Ref()); - else if (keyFormat == "Component") - signer->AccessMaterial().AssignFrom(pairs); - - if (test == "Sign") - { - totalTests++; - - SignerFilter f(Test::GlobalRNG(), *signer, new HexEncoder(new FileSink(std::cout))); - StringSource ss(GetDecodedDatum(v, "Message"), true, new FileSink(testDataFilename.c_str())); - FileSource fs(testDataFilename.c_str(), true, new Redirector(f)); - SignalTestFailure(); - } - else if (test == "DeterministicSign") - { - totalTests++; - - // This test is specialized for RFC 6979. The RFC is a drop-in replacement - // for DSA and ECDSA, and access to the seed or secret is not needed. If - // additional deterministic signatures are added, then the test harness will - // likely need to be extended. - std::string signature; - SignerFilter f(Test::GlobalRNG(), *signer, new StringSink(signature)); - StringSource ss(GetDecodedDatum(v, "Message"), true, new FileSink(testDataFilename.c_str())); - FileSource fs(testDataFilename.c_str(), true, new Redirector(f)); - - if (GetDecodedDatum(v, "Signature") != signature) - SignalTestFailure(); - } -} - -void TestAsymmetricCipher(TestData &v, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - static member_ptr encryptor; - static member_ptr decryptor; - static std::string lastName; - - if (name != lastName) - { - encryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - decryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - lastName = name; - - // Code coverage - (void)encryptor->AlgorithmName(); - (void)decryptor->AlgorithmName(); - (void)encryptor->AlgorithmProvider(); - (void)decryptor->AlgorithmProvider(); - } - - std::string keyFormat = GetRequiredDatum(v, "KeyFormat"); - - if (keyFormat == "DER") - { - totalTests++; - - decryptor->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PrivateKey")).Ref()); - encryptor->AccessMaterial().Load(StringStore(GetDecodedDatum(v, "PublicKey")).Ref()); - } - else if (keyFormat == "Component") - { - totalTests++; - - TestDataNameValuePairs pairs(v); - decryptor->AccessMaterial().AssignFrom(pairs); - encryptor->AccessMaterial().AssignFrom(pairs); - } - - if (test == "DecryptMatch") - { - totalTests++; - - std::string decrypted, expected = GetDecodedDatum(v, "Plaintext"); - StringSource ss(GetDecodedDatum(v, "Ciphertext"), true, new PK_DecryptorFilter(Test::GlobalRNG(), *decryptor, new StringSink(decrypted))); - if (decrypted != expected) - SignalTestFailure(); - } - else if (test == "KeyPairValidAndConsistent") - { - totalTests++; - - TestKeyPairValidAndConsistent(encryptor->AccessMaterial(), decryptor->GetMaterial(), totalTests); - } - else - { - std::string msg("Unknown asymmetric cipher test \"" + test + "\""); - SignalTestError(msg.c_str()); - CRYPTOPP_ASSERT(false); - } -} - -void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - std::string key = GetDecodedDatum(v, "Key"); - std::string plaintext = GetDecodedDatum(v, "Plaintext"); - - TestDataNameValuePairs testDataPairs(v); - CombinedNameValuePairs pairs(overrideParameters, testDataPairs); - - if (test == "Encrypt" || test == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT") - { - static member_ptr encryptor, decryptor; - static std::string lastName; - - totalTests++; - - if (name != lastName) - { - encryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - decryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - lastName = name; - - // Code coverage - (void)encryptor->AlgorithmName(); - (void)decryptor->AlgorithmName(); - (void)encryptor->AlgorithmProvider(); - (void)decryptor->AlgorithmProvider(); - (void)encryptor->IsRandomAccess(); - (void)decryptor->IsRandomAccess(); - (void)encryptor->MinKeyLength(); - (void)decryptor->MinKeyLength(); - (void)encryptor->MaxKeyLength(); - (void)decryptor->MaxKeyLength(); - (void)encryptor->DefaultKeyLength(); - (void)decryptor->DefaultKeyLength(); - } - - ConstByteArrayParameter iv; - if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize()) - SignalTestFailure(); - - if (test == "Resync") - { - encryptor->Resynchronize(iv.begin(), (int)iv.size()); - decryptor->Resynchronize(iv.begin(), (int)iv.size()); - } - else - { - encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - } - - word64 seek64 = pairs.GetWord64ValueWithDefault("Seek64", 0); - if (seek64) - { - encryptor->Seek(seek64); - decryptor->Seek(seek64); - } - else - { - int seek = pairs.GetIntValueWithDefault("Seek", 0); - if (seek) - { - encryptor->Seek(seek); - decryptor->Seek(seek); - } - } - - // Most block ciphers don't specify BlockPaddingScheme. Kalyna uses it - // in test vectors. 0 is NoPadding, 1 is ZerosPadding, 2 is PkcsPadding, - // 3 is OneAndZerosPadding, etc. Note: The machinery is wired such that - // paddingScheme is effectively latched. An old paddingScheme may be - // unintentionally used in a subsequent test. - int paddingScheme = pairs.GetIntValueWithDefault(Name::BlockPaddingScheme(), 0); - - std::string encrypted, xorDigest, ciphertext, ciphertextXorDigest; - if (test == "EncryptionMCT" || test == "DecryptionMCT") - { - SymmetricCipher *cipher = encryptor.get(); - std::string buf(plaintext), keybuf(key); - - if (test == "DecryptionMCT") - { - cipher = decryptor.get(); - ciphertext = GetDecodedDatum(v, "Ciphertext"); - buf.assign(ciphertext.begin(), ciphertext.end()); - } - - for (int i=0; i<400; i++) - { - encrypted.reserve(10000 * plaintext.size()); - for (int j=0; j<10000; j++) - { - cipher->ProcessString(BytePtr(buf), BytePtrSize(buf)); - encrypted.append(buf.begin(), buf.end()); - } - - encrypted.erase(0, encrypted.size() - keybuf.size()); - xorbuf(BytePtr(keybuf), BytePtr(encrypted), BytePtrSize(keybuf)); - cipher->SetKey(BytePtr(keybuf), BytePtrSize(keybuf)); - } - - encrypted.assign(buf.begin(), buf.end()); - ciphertext = GetDecodedDatum(v, test == "EncryptionMCT" ? "Ciphertext" : "Plaintext"); - if (encrypted != ciphertext) - { - std::cout << "\nincorrectly encrypted: "; - StringSource ss(encrypted, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(256); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - return; - } - - StreamTransformationFilter encFilter(*encryptor, new StringSink(encrypted), - static_cast(paddingScheme)); - - StringStore pstore(plaintext); - RandomizedTransfer(pstore, encFilter, true); - encFilter.MessageEnd(); - - if (test != "EncryptXorDigest") - { - ciphertext = GetDecodedDatum(v, "Ciphertext"); - } - else - { - ciphertextXorDigest = GetDecodedDatum(v, "CiphertextXorDigest"); - xorDigest.append(encrypted, 0, 64); - for (size_t i=64; i(xorDigest[i%64] ^ encrypted[i]); - } - if (test != "EncryptXorDigest" ? encrypted != ciphertext : xorDigest != ciphertextXorDigest) - { - std::cout << "\nincorrectly encrypted: "; - StringSource ss(encrypted, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(2048); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - - std::string decrypted; - StreamTransformationFilter decFilter(*decryptor, new StringSink(decrypted), - static_cast(paddingScheme)); - - StringStore cstore(encrypted); - RandomizedTransfer(cstore, decFilter, true); - decFilter.MessageEnd(); - - if (decrypted != plaintext) - { - std::cout << "\nincorrectly decrypted: "; - StringSource ss(decrypted, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(256); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - } - else - { - std::string msg("Unknown symmetric cipher test \"" + test + "\""); - SignalTestError(msg.c_str()); - } -} - -// Subset of TestSymmetricCipher. The test suite lacked tests for in-place encryption, -// where inString == outString. Also see https://github.com/weidai11/cryptopp/issues/1231. -void TestSymmetricCipherWithInplaceEncryption(TestData &v, const NameValuePairs &overrideParameters, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - std::string key = GetDecodedDatum(v, "Key"); - std::string plaintext = GetDecodedDatum(v, "Plaintext"); - - TestDataNameValuePairs testDataPairs(v); - CombinedNameValuePairs pairs(overrideParameters, testDataPairs); - - if (test != "Encrypt" ) { return; } - - static member_ptr encryptor, decryptor; - static std::string lastName; - - if (name != lastName) - { - encryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - decryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - lastName = name; - } - - // Only test stream ciphers at the moment - if (encryptor->MandatoryBlockSize() != 1) { return; } - - totalTests++; - - ConstByteArrayParameter iv; - if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize()) - SignalTestFailure(); - - encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - - word64 seek64 = pairs.GetWord64ValueWithDefault("Seek64", 0); - if (seek64) - { - encryptor->Seek(seek64); - decryptor->Seek(seek64); - } - else - { - int seek = pairs.GetIntValueWithDefault("Seek", 0); - if (seek) - { - encryptor->Seek(seek); - decryptor->Seek(seek); - } - } - - const std::string plainText = GetDecodedDatum(v, "Plaintext"); - const std::string cipherText = GetDecodedDatum(v, "Ciphertext"); - - // Use buffer for in-place encryption and decryption - std::string buffer(plainText); - - // Test in-place encryption - encryptor->ProcessString(BytePtr(buffer), BytePtrSize(buffer)); - - if (buffer != cipherText) - { - std::cout << "\nincorrectly encrypted: "; - StringSource ss(buffer, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(256); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - - // Test in-place decryption - decryptor->ProcessString(BytePtr(buffer), BytePtrSize(buffer)); - - if (buffer != plainText) - { - std::cout << "\nincorrectly decrypted: "; - StringSource ss(buffer, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(256); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } -} - -// Subset of TestSymmetricCipher. We picked the tests that have data that is easy to write to a file. -// Also see https://github.com/weidai11/cryptopp/issues/1010, where HIGHT broke when using FileSource. -void TestSymmetricCipherWithFileSource(TestData &v, const NameValuePairs &overrideParameters, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - // Limit FileSource tests to Encrypt only. - if (test != "Encrypt") { return; } - - totalTests++; - - std::string key = GetDecodedDatum(v, "Key"); - std::string plaintext = GetDecodedDatum(v, "Plaintext"); - - TestDataNameValuePairs testDataPairs(v); - CombinedNameValuePairs pairs(overrideParameters, testDataPairs); - - static member_ptr encryptor, decryptor; - static std::string lastName; - - if (name != lastName) - { - encryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - decryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - lastName = name; - - // Code coverage - (void)encryptor->AlgorithmName(); - (void)decryptor->AlgorithmName(); - (void)encryptor->AlgorithmProvider(); - (void)decryptor->AlgorithmProvider(); - (void)encryptor->MinKeyLength(); - (void)decryptor->MinKeyLength(); - (void)encryptor->MaxKeyLength(); - (void)decryptor->MaxKeyLength(); - (void)encryptor->DefaultKeyLength(); - (void)decryptor->DefaultKeyLength(); - } - - ConstByteArrayParameter iv; - if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize()) - SignalTestFailure(); - - encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - - word64 seek64 = pairs.GetWord64ValueWithDefault("Seek64", 0); - if (seek64) - { - encryptor->Seek(seek64); - decryptor->Seek(seek64); - } - else - { - int seek = pairs.GetIntValueWithDefault("Seek", 0); - if (seek) - { - encryptor->Seek(seek); - decryptor->Seek(seek); - } - } - - // Most block ciphers don't specify BlockPaddingScheme. Kalyna uses it - // in test vectors. 0 is NoPadding, 1 is ZerosPadding, 2 is PkcsPadding, - // 3 is OneAndZerosPadding, etc. Note: The machinery is wired such that - // paddingScheme is effectively latched. An old paddingScheme may be - // unintentionally used in a subsequent test. - int paddingScheme = pairs.GetIntValueWithDefault(Name::BlockPaddingScheme(), 0); - - std::string encrypted, ciphertext; - StreamTransformationFilter encFilter(*encryptor, new StringSink(encrypted), - static_cast(paddingScheme)); - - StringSource ss(plaintext, true, new FileSink(testDataFilename.c_str())); - FileSource pstore(testDataFilename.c_str(), true); - RandomizedTransfer(pstore, encFilter, true); - encFilter.MessageEnd(); - - ciphertext = GetDecodedDatum(v, "Ciphertext"); - - if (encrypted != ciphertext) - { - std::cout << "\nincorrectly encrypted: "; - StringSource sss(encrypted, false, new HexEncoder(new FileSink(std::cout))); - sss.Pump(2048); sss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - - std::string decrypted; - StreamTransformationFilter decFilter(*decryptor, new StringSink(decrypted), - static_cast(paddingScheme)); - - StringStore cstore(encrypted); - RandomizedTransfer(cstore, decFilter, true); - decFilter.MessageEnd(); - - if (decrypted != plaintext) - { - std::cout << "\nincorrectly decrypted: "; - StringSource sss(decrypted, false, new HexEncoder(new FileSink(std::cout))); - sss.Pump(256); sss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } -} - -void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters, unsigned int &totalTests) -{ - std::string type = GetRequiredDatum(v, "AlgorithmType"); - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - std::string key = GetDecodedDatum(v, "Key"); - - std::string plaintext = GetOptionalDecodedDatum(v, "Plaintext"); - std::string ciphertext = GetOptionalDecodedDatum(v, "Ciphertext"); - std::string header = GetOptionalDecodedDatum(v, "Header"); - std::string footer = GetOptionalDecodedDatum(v, "Footer"); - std::string mac = GetOptionalDecodedDatum(v, "MAC"); - - TestDataNameValuePairs testDataPairs(v); - CombinedNameValuePairs pairs(overrideParameters, testDataPairs); - - if (test == "Encrypt" || test == "EncryptXorDigest" || test == "NotVerify") - { - totalTests++; - - static member_ptr encryptor; - static member_ptr decryptor; - static std::string lastName; - - if (name != lastName) - { - encryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - decryptor.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - name = lastName; - - // Code coverage - (void)encryptor->AlgorithmName(); - (void)decryptor->AlgorithmName(); - (void)encryptor->AlgorithmProvider(); - (void)decryptor->AlgorithmProvider(); - (void)encryptor->MinKeyLength(); - (void)decryptor->MinKeyLength(); - (void)encryptor->MaxKeyLength(); - (void)decryptor->MaxKeyLength(); - (void)encryptor->DefaultKeyLength(); - (void)decryptor->DefaultKeyLength(); - (void)encryptor->IsRandomAccess(); - (void)decryptor->IsRandomAccess(); - (void)encryptor->IsSelfInverting(); - (void)decryptor->IsSelfInverting(); - (void)encryptor->MaxHeaderLength(); - (void)decryptor->MaxHeaderLength(); - (void)encryptor->MaxMessageLength(); - (void)decryptor->MaxMessageLength(); - (void)encryptor->MaxFooterLength(); - (void)decryptor->MaxFooterLength(); - (void)encryptor->NeedsPrespecifiedDataLengths(); - (void)decryptor->NeedsPrespecifiedDataLengths(); - } - - encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - - std::string encrypted, decrypted; - AuthenticatedEncryptionFilter ef(*encryptor, new StringSink(encrypted)); - bool macAtBegin = !mac.empty() && !Test::GlobalRNG().GenerateBit(); // test both ways randomly - AuthenticatedDecryptionFilter df(*decryptor, new StringSink(decrypted), macAtBegin ? AuthenticatedDecryptionFilter::MAC_AT_BEGIN : 0); - - if (encryptor->NeedsPrespecifiedDataLengths()) - { - encryptor->SpecifyDataLengths(header.size(), plaintext.size(), footer.size()); - decryptor->SpecifyDataLengths(header.size(), plaintext.size(), footer.size()); - } - - StringStore sh(header), sp(plaintext), sc(ciphertext), sf(footer), sm(mac); - - if (macAtBegin) - RandomizedTransfer(sm, df, true); - sh.CopyTo(df, LWORD_MAX, AAD_CHANNEL); - RandomizedTransfer(sc, df, true); - sf.CopyTo(df, LWORD_MAX, AAD_CHANNEL); - if (!macAtBegin) - RandomizedTransfer(sm, df, true); - df.MessageEnd(); - - RandomizedTransfer(sh, ef, true, AAD_CHANNEL); - RandomizedTransfer(sp, ef, true); - RandomizedTransfer(sf, ef, true, AAD_CHANNEL); - ef.MessageEnd(); - - if (test == "Encrypt" && encrypted != ciphertext+mac) - { - std::cout << "\nincorrectly encrypted: "; - StringSource ss(encrypted, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(2048); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - if (test == "Encrypt" && decrypted != plaintext) - { - std::cout << "\nincorrectly decrypted: "; - StringSource ss(decrypted, false, new HexEncoder(new FileSink(std::cout))); - ss.Pump(256); ss.Flush(false); - std::cout << "\n"; - SignalTestFailure(); - } - - if (ciphertext.size()+mac.size()-plaintext.size() != encryptor->DigestSize()) - { - std::cout << "\nbad MAC size\n"; - SignalTestFailure(); - } - if (df.GetLastResult() != (test == "Encrypt")) - { - std::cout << "\nMAC incorrectly verified\n"; - SignalTestFailure(); - } - } - else - { - std::string msg("Unknown authenticated symmetric cipher test \"" + test + "\""); - SignalTestError(msg.c_str()); - } -} - -void TestDigestOrMAC(TestData &v, bool testDigest, unsigned int &totalTests) -{ - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - const char *digestName = testDigest ? "Digest" : "MAC"; - - member_ptr mac; - member_ptr hash; - HashTransformation *pHash = NULLPTR; - - TestDataNameValuePairs pairs(v); - - if (testDigest) - { - hash.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - pHash = hash.get(); - - // Code coverage - (void)hash->AlgorithmName(); - (void)hash->AlgorithmProvider(); - (void)hash->TagSize(); - (void)hash->DigestSize(); - (void)hash->Restart(); - } - else - { - mac.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - pHash = mac.get(); - std::string key = GetDecodedDatum(v, "Key"); - mac->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs); - - // Code coverage - (void)mac->AlgorithmName(); - (void)mac->AlgorithmProvider(); - (void)mac->TagSize(); - (void)mac->DigestSize(); - (void)mac->Restart(); - (void)mac->MinKeyLength(); - (void)mac->MaxKeyLength(); - (void)mac->DefaultKeyLength(); - } - - if (test == "Verify" || test == "VerifyTruncated" || test == "NotVerify") - { - totalTests++; - - int digestSize = -1; - if (test == "VerifyTruncated") - digestSize = pairs.GetIntValueWithDefault(Name::DigestSize(), digestSize); - HashVerificationFilter verifierFilter(*pHash, NULLPTR, HashVerificationFilter::HASH_AT_BEGIN, digestSize); - PutDecodedDatumInto(v, digestName, verifierFilter); - PutDecodedDatumInto(v, "Message", verifierFilter); - verifierFilter.MessageEnd(); - if (verifierFilter.GetLastResult() == (test == "NotVerify")) - SignalTestFailure(); - } - else - { - std::string msg("Unknown digest or mac test \"" + test + "\""); - SignalTestError(msg.c_str()); - } -} - -void TestKeyDerivationFunction(TestData &v, unsigned int &totalTests) -{ - totalTests++; - - std::string name = GetRequiredDatum(v, "Name"); - std::string test = GetRequiredDatum(v, "Test"); - - if(test == "Skip") return; - - std::string secret = GetDecodedDatum(v, "Secret"); - std::string expected = GetDecodedDatum(v, "DerivedKey"); - - TestDataNameValuePairs pairs(v); - - static member_ptr kdf; - static std::string lastName; - - if (name != lastName) - { - kdf.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - name = lastName; - - // Code coverage - (void)kdf->AlgorithmName(); - (void)kdf->AlgorithmProvider(); - (void)kdf->MinDerivedKeyLength(); - (void)kdf->MaxDerivedKeyLength(); - } - - std::string calculated; calculated.resize(expected.size()); - kdf->DeriveKey(BytePtr(calculated), BytePtrSize(calculated), BytePtr(secret), BytePtrSize(secret), pairs); - - if(calculated != expected) - { - std::cerr << "Calculated: "; - StringSource(calculated, true, new HexEncoder(new FileSink(std::cerr))); - std::cerr << std::endl; - - SignalTestFailure(); - } -} - -inline char FirstChar(const std::string& str) { - if (str.empty()) return 0; - return str[0]; -} - -inline char LastChar(const std::string& str) { - if (str.empty()) return 0; - return str[str.length()-1]; -} - -// GetField parses the name/value pairs. If this function is modified, -// then run 'cryptest.exe tv all' to ensure parsing still works. -bool GetField(std::istream &is, std::string &name, std::string &value) -{ - std::string line; - name.clear(); value.clear(); - - // ***** Name ***** - while (Readline(is, line)) - { - // Eat empty lines and comments gracefully - line = TrimSpace(line); - if (line.empty() || line[0] == '#') - continue; - - std::string::size_type pos = line.find(':'); - if (pos == std::string::npos) - SignalTestError("Unable to parse name/value pair"); - - name = TrimSpace(line.substr(0, pos)); - line = TrimSpace(line.substr(pos +1)); - - // Empty name is bad - if (name.empty()) - return false; - - // Empty value is ok - if (line.empty()) - return true; - - break; - } - - // ***** Value ***** - bool continueLine = true; - - do - { - continueLine = false; - - // Trim leading and trailing whitespace. Don't parse comments - // here because there may be a line continuation at the end. - line = TrimSpace(line); - - if (line.empty()) - continue; - - // Check for continuation. The slash must be the last character. - if (LastChar(line) == '\\') { - continueLine = true; - line.erase(line.end()-1); - } - - // Re-trim after parsing - line = TrimComment(line); - line = TrimSpace(line); - - if (line.empty()) - continue; - - // Finally... the value - value += line; - - if (continueLine) - value += ' '; - } - while (continueLine && Readline(is, line)); - - return true; -} - -void OutputPair(const NameValuePairs &v, const char *name) -{ - Integer x; - bool b = v.GetValue(name, x); - CRYPTOPP_UNUSED(b); CRYPTOPP_ASSERT(b); - std::cout << name << ": \\\n "; - x.Encode(HexEncoder(new FileSink(std::cout), false, 64, "\\\n ").Ref(), x.MinEncodedSize()); - std::cout << std::endl; -} - -void OutputNameValuePairs(const NameValuePairs &v) -{ - std::string names = v.GetValueNames(); - std::string::size_type i = 0; - while (i < names.size()) - { - std::string::size_type j = names.find_first_of (';', i); - - if (j == std::string::npos) - return; - else - { - std::string name = names.substr(i, j-i); - if (name.find(':') == std::string::npos) - OutputPair(v, name.c_str()); - } - - i = j + 1; - } -} - -void TestDataFile(std::string filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests) -{ - std::ifstream file(DataDir(filename).c_str()); - if (!file.good()) - throw Exception(Exception::OTHER_ERROR, "Can not open file " + DataDir(filename) + " for reading"); - - TestData v; - s_currentTestData = &v; - std::string name, value, lastAlgName; - - while (file) - { - if (!GetField(file, name, value)) - break; - - if (name == "AlgorithmType") - v.clear(); - - // Can't assert value. Plaintext is sometimes empty. - // CRYPTOPP_ASSERT(!value.empty()); - v[name] = value; - - // The name "Test" is special. It tells the framework - // to run the test. Otherwise, name/value pairs are - // parsed and added to TestData 'v'. - if (name == "Test" && (s_thorough || v["SlowTest"] != "1")) - { - bool failed = false; - std::string algType = GetRequiredDatum(v, "AlgorithmType"); - std::string algName = GetRequiredDatum(v, "Name"); - - if (lastAlgName != algName) - { - std::cout << "\nTesting " << algType << " algorithm " << algName << ".\n"; - lastAlgName = algName; - } - - // In the old days each loop ran one test. Later, things were modified to run the - // the same test twice. Some tests are run with both a StringSource and a FileSource - // to catch FileSource specific errors. currentTests and deltaTests (below) keep - // the book keeping in order. - unsigned int currentTests = totalTests; - - try - { - if (algType == "Signature") - { - TestSignatureScheme(v, totalTests); - TestSignatureSchemeWithFileSource(v, totalTests); - } - else if (algType == "SymmetricCipher") - { - TestSymmetricCipher(v, overrideParameters, totalTests); - TestSymmetricCipherWithInplaceEncryption(v, overrideParameters, totalTests); - TestSymmetricCipherWithFileSource(v, overrideParameters, totalTests); - } - else if (algType == "AuthenticatedSymmetricCipher") - TestAuthenticatedSymmetricCipher(v, overrideParameters, totalTests); - else if (algType == "AsymmetricCipher") - TestAsymmetricCipher(v, totalTests); - else if (algType == "MessageDigest") - TestDigestOrMAC(v, true, totalTests); - else if (algType == "MAC") - TestDigestOrMAC(v, false, totalTests); - else if (algType == "KDF") - TestKeyDerivationFunction(v, totalTests); - else if (algType == "FileList") - TestDataFile(GetRequiredDatum(v, "Test"), g_nullNameValuePairs, totalTests, failedTests); - else - SignalUnknownAlgorithmError(algType); - } - catch (const TestFailure &) - { - failed = true; - std::cout << "\nTest FAILED.\n"; - } - catch (const Exception &e) - { - failed = true; - std::cout << "\nCryptoPP::Exception caught: " << e.what() << std::endl; - } - catch (const std::exception &e) - { - failed = true; - std::cout << "\nstd::exception caught: " << e.what() << std::endl; - } - - if (failed) - { - std::cout << "Skipping to next test." << std::endl; - failedTests++; - } - else - { - if (algType != "FileList") - { - unsigned int deltaTests = totalTests-currentTests; - if (deltaTests) - { - std::string progress(deltaTests, '.'); - std::cout << progress; - if (currentTests % 4 == 0) - std::cout << std::flush; - } - } - } - - // Most tests fully specify parameters, like key and iv. Each test gets - // its own unique value. Since each test gets a new value for each test - // case, latching a value in 'TestData v' does not matter. The old key - // or iv will get overwritten on the next test. - // - // If a per-test vector parameter was set for a test, like BlockPadding, - // BlockSize or Tweak, then it becomes latched in 'TestData v'. The old - // value is used in subsequent tests, and it could cause a self test - // failure in the next test. The behavior surfaced under Kalyna and - // Threefish. The Kalyna test vectors use NO_PADDING for all tests except - // one. Threefish occasionally uses a Tweak. - // - // Unlatch BlockPadding, BlockSize and Tweak now, after the test has been - // run. Also note we only unlatch from 'TestData v'. If overrideParameters - // are specified, the caller is responsible for managing the parameter. - v.erase("Tweak"); v.erase("InitialBlock"); - v.erase("BlockSize"); v.erase("BlockPaddingScheme"); - } - } -} - -ANONYMOUS_NAMESPACE_END - -bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParameters, bool thorough) -{ - s_thorough = thorough; - unsigned int totalTests = 0, failedTests = 0; - TestDataFile((filename ? filename : ""), overrideParameters, totalTests, failedTests); - - std::cout << std::dec << "\nTests complete. Total tests = " << totalTests << ". Failed tests = " << failedTests << "." << std::endl; - if (failedTests != 0) - std::cout << "SOME TESTS FAILED!\n"; - - CRYPTOPP_ASSERT(failedTests == 0); - return failedTests == 0; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/dlltest.cpp b/vendor/cryptopp/dlltest.cpp deleted file mode 100644 index 2ad8f2fec2..0000000000 --- a/vendor/cryptopp/dlltest.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef CRYPTOPP_DLL_ONLY -# define CRYPTOPP_DEFAULT_NO_DLL -#endif - -#include "dll.h" -#include "cryptlib.h" -#include "filters.h" -#include "pkcspad.h" - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -USING_NAMESPACE(CryptoPP) - -void FIPS140_SampleApplication() -{ - if (!FIPS_140_2_ComplianceEnabled()) - { - std::cerr << "FIPS 140-2 compliance was turned off at compile time.\n"; - abort(); - } - - // check self test status - if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED) - { - std::cerr << "Automatic power-up self test failed.\n"; - abort(); - } - std::cout << "0. Automatic power-up self test passed.\n"; - - // simulate a power-up self test error - SimulatePowerUpSelfTestFailure(); - try - { - // trying to use a crypto algorithm after power-up self test error will result in an exception - AES::Encryption aes; - - // should not be here - std::cerr << "Use of AES failed to cause an exception after power-up self test error.\n"; - abort(); - } - catch (SelfTestFailure &e) - { - std::cout << "1. Caught expected exception when simulating self test failure. Exception message follows: "; - std::cout << e.what() << std::endl; - } - - // clear the self test error state and redo power-up self test - DoDllPowerUpSelfTest(); - if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED) - { - std::cerr << "Re-do power-up self test failed.\n"; - abort(); - } - std::cout << "2. Re-do power-up self test passed.\n"; - - // encrypt and decrypt - const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; - const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; - const byte plaintext[] = { // "Now is the time for all " without tailing 0 - 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74, - 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20, - 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20}; - byte ciphertext[24]; - byte decrypted[24]; - - CFB_FIPS_Mode::Encryption encryption_DES_EDE3_CFB; - encryption_DES_EDE3_CFB.SetKeyWithIV(key, sizeof(key), iv); - encryption_DES_EDE3_CFB.ProcessString(ciphertext, plaintext, 24); - - CFB_FIPS_Mode::Decryption decryption_DES_EDE3_CFB; - decryption_DES_EDE3_CFB.SetKeyWithIV(key, sizeof(key), iv); - decryption_DES_EDE3_CFB.ProcessString(decrypted, ciphertext, 24); - - if (std::memcmp(plaintext, decrypted, 24) != 0) - { - std::cerr << "DES-EDE3-CFB Encryption/decryption failed.\n"; - abort(); - } - std::cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n"; - - // hash - const byte message[] = {'a', 'b', 'c'}; - const byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D}; - byte digest[20]; - - SHA1 sha; - sha.Update(message, 3); - sha.Final(digest); - - if (std::memcmp(digest, expectedDigest, 20) != 0) - { - std::cerr << "SHA-1 hash failed.\n"; - abort(); - } - std::cout << "4. SHA-1 hash succeeded.\n"; - - // create auto-seeded X9.17 RNG object, if available -#ifdef OS_RNG_AVAILABLE - AutoSeededX917RNG rng; -#else - // this is used to allow this function to compile on platforms that don't have auto-seeded RNGs - RandomNumberGenerator &rng(NullRNG()); -#endif - - // generate DSA key - DSA::PrivateKey dsaPrivateKey; - dsaPrivateKey.GenerateRandomWithKeySize(rng, 1024); - DSA::PublicKey dsaPublicKey; - dsaPublicKey.AssignFrom(dsaPrivateKey); - if (!dsaPrivateKey.Validate(rng, 3) || !dsaPublicKey.Validate(rng, 3)) - { - std::cerr << "DSA key generation failed.\n"; - abort(); - } - std::cout << "5. DSA key generation succeeded.\n"; - - // encode DSA key - std::string encodedDsaPublicKey, encodedDsaPrivateKey; - dsaPublicKey.DEREncode(StringSink(encodedDsaPublicKey).Ref()); - dsaPrivateKey.DEREncode(StringSink(encodedDsaPrivateKey).Ref()); - - // decode DSA key - DSA::PrivateKey decodedDsaPrivateKey; - decodedDsaPrivateKey.BERDecode(StringStore(encodedDsaPrivateKey).Ref()); - DSA::PublicKey decodedDsaPublicKey; - decodedDsaPublicKey.BERDecode(StringStore(encodedDsaPublicKey).Ref()); - - if (!decodedDsaPrivateKey.Validate(rng, 3) || !decodedDsaPublicKey.Validate(rng, 3)) - { - std::cerr << "DSA key encode/decode failed.\n"; - abort(); - } - std::cout << "6. DSA key encode/decode succeeded.\n"; - - // sign and verify - byte signature[40]; - DSA::Signer signer(dsaPrivateKey); - CRYPTOPP_ASSERT(signer.SignatureLength() == 40); - signer.SignMessage(rng, message, 3, signature); - - DSA::Verifier verifier(dsaPublicKey); - if (!verifier.VerifyMessage(message, 3, signature, sizeof(signature))) - { - std::cerr << "DSA signature and verification failed.\n"; - abort(); - } - std::cout << "7. DSA signature and verification succeeded.\n"; - - - // try to verify an invalid signature - signature[0] ^= 1; - if (verifier.VerifyMessage(message, 3, signature, sizeof(signature))) - { - std::cerr << "DSA signature verification failed to detect bad signature.\n"; - abort(); - } - std::cout << "8. DSA signature verification successfully detected bad signature.\n"; - - // try to use an invalid key length - try - { - ECB_Mode::Encryption encryption_DES_EDE3_ECB; - encryption_DES_EDE3_ECB.SetKey(key, 5); - - // should not be here - std::cerr << "DES-EDE3 implementation did not detect use of invalid key length.\n"; - abort(); - } - catch (InvalidArgument &e) - { - std::cout << "9. Caught expected exception when using invalid key length. Exception message follows: "; - std::cout << e.what() << std::endl; - } - - std::cout << "\nFIPS 140-2 Sample Application completed normally.\n"; -} - -#ifdef CRYPTOPP_IMPORTS - -static PNew s_pNew = NULLPTR; -static PDelete s_pDelete = NULLPTR; - -extern "C" __declspec(dllexport) void __cdecl SetNewAndDeleteFromCryptoPP(PNew pNew, PDelete pDelete, PSetNewHandler pSetNewHandler) -{ - (void)(pSetNewHandler); - s_pNew = pNew; - s_pDelete = pDelete; -} - -void * __cdecl operator new (size_t size) -{ - return s_pNew(size); -} - -void __cdecl operator delete (void * p) -{ - s_pDelete(p); -} - -#endif - -#ifdef CRYPTOPP_DLL_ONLY - -int __cdecl main() -{ - FIPS140_SampleApplication(); - return 0; -} - -#endif diff --git a/vendor/cryptopp/fipsalgt.cpp b/vendor/cryptopp/fipsalgt.cpp deleted file mode 100644 index 1f2061bdd1..0000000000 --- a/vendor/cryptopp/fipsalgt.cpp +++ /dev/null @@ -1,1293 +0,0 @@ -// fipsalgt.cpp - originally written and placed in the public domain by Wei Dai - -// This file implements the various algorithm tests needed to pass FIPS 140 validation. -// They're preserved here (commented out) in case Crypto++ needs to be revalidated. - -#if 0 -#ifndef CRYPTOPP_IMPORTS -#define CRYPTOPP_DEFAULT_NO_DLL -#endif - -#include "dll.h" -#include "cryptlib.h" -#include "smartptr.h" -#include "filters.h" -#include "oids.h" - -USING_NAMESPACE(CryptoPP) - -class LineBreakParser : public AutoSignaling > -{ -public: - LineBreakParser(BufferedTransformation *attachment=NULLPTR, byte lineEnd='\n') - : m_lineEnd(lineEnd) {Detach(attachment);} - - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking) - { - if (!blocking) - throw BlockingInputOnly("LineBreakParser"); - - unsigned int i, last = 0; - for (i=0; iPut2(begin+last, i-last, GetAutoSignalPropagation(), blocking); - last = i+1; - } - } - if (last != i) - AttachedTransformation()->Put2(begin+last, i-last, 0, blocking); - - if (messageEnd && GetAutoSignalPropagation()) - { - AttachedTransformation()->MessageEnd(GetAutoSignalPropagation()-1, blocking); - AttachedTransformation()->MessageSeriesEnd(GetAutoSignalPropagation()-1, blocking); - } - - return 0; - } - -private: - byte m_lineEnd; -}; - -class TestDataParser : public Unflushable -{ -public: - enum DataType {OTHER, COUNT, KEY_T, IV, INPUT, OUTPUT}; - - TestDataParser(std::string algorithm, std::string test, std::string mode, unsigned int feedbackSize, bool encrypt, BufferedTransformation *attachment) - : m_algorithm(algorithm), m_test(test), m_mode(mode), m_feedbackSize(feedbackSize) - , m_firstLine(true), m_blankLineTransition(0) - { - Detach(attachment); - - m_typeToName[COUNT] = "COUNT"; - - m_nameToType["COUNT"] = COUNT; - m_nameToType["KEY"] = KEY_T; - m_nameToType["KEYs"] = KEY_T; - m_nameToType["key"] = KEY_T; - m_nameToType["Key"] = KEY_T; - m_nameToType["IV"] = IV; - m_nameToType["IV1"] = IV; - m_nameToType["CV"] = IV; - m_nameToType["CV1"] = IV; - m_nameToType["IB"] = IV; - m_nameToType["TEXT"] = INPUT; - m_nameToType["RESULT"] = OUTPUT; - m_nameToType["Msg"] = INPUT; - m_nameToType["Seed"] = INPUT; - m_nameToType["V"] = INPUT; - m_nameToType["DT"] = IV; - SetEncrypt(encrypt); - - if (m_algorithm == "DSA" || m_algorithm == "ECDSA") - { - if (m_test == "PKV") - m_trigger = "Qy"; - else if (m_test == "KeyPair") - m_trigger = "N"; - else if (m_test == "SigGen") - m_trigger = "Msg"; - else if (m_test == "SigVer") - m_trigger = "S"; - else if (m_test == "PQGGen") - m_trigger = "N"; - else if (m_test == "PQGVer") - m_trigger = "H"; - } - else if (m_algorithm == "HMAC") - m_trigger = "Msg"; - else if (m_algorithm == "SHA") - m_trigger = (m_test == "MONTE") ? "Seed" : "Msg"; - else if (m_algorithm == "RNG") - m_trigger = "V"; - else if (m_algorithm == "RSA") - m_trigger = (m_test == "Ver") ? "S" : "Msg"; - } - - void SetEncrypt(bool encrypt) - { - m_encrypt = encrypt; - if (encrypt) - { - m_nameToType["PLAINTEXT"] = INPUT; - m_nameToType["CIPHERTEXT"] = OUTPUT; - m_nameToType["PT"] = INPUT; - m_nameToType["CT"] = OUTPUT; - } - else - { - m_nameToType["PLAINTEXT"] = OUTPUT; - m_nameToType["CIPHERTEXT"] = INPUT; - m_nameToType["PT"] = OUTPUT; - m_nameToType["CT"] = INPUT; - } - - if (m_algorithm == "AES" || m_algorithm == "TDES") - { - if (encrypt) - { - m_trigger = "PLAINTEXT"; - m_typeToName[OUTPUT] = "CIPHERTEXT"; - } - else - { - m_trigger = "CIPHERTEXT"; - m_typeToName[OUTPUT] = "PLAINTEXT"; - } - m_count = 0; - } - } - -protected: - void OutputData(std::string &output, const std::string &key, const std::string &data) - { - output += key; - output += "= "; - output += data; - output += "\n"; - } - - void OutputData(std::string &output, const std::string &key, int data) - { - OutputData(output, key, IntToString(data)); - } - - void OutputData(std::string &output, const std::string &key, const SecByteBlock &data) - { - output += key; - output += "= "; - HexEncoder(new StringSink(output), false).Put(data, data.size()); - output += "\n"; - } - - void OutputData(std::string &output, const std::string &key, const Integer &data, int size=-1) - { - SecByteBlock s(size < 0 ? data.MinEncodedSize() : size); - data.Encode(s, s.size()); - OutputData(output, key, s); - } - - void OutputData(std::string &output, const std::string &key, const PolynomialMod2 &data, int size=-1) - { - SecByteBlock s(size < 0 ? data.MinEncodedSize() : size); - data.Encode(s, s.size()); - OutputData(output, key, s); - } - - void OutputData(std::string &output, DataType t, const std::string &data) - { - if (m_algorithm == "SKIPJACK") - { - if (m_test == "KAT") - { - if (t == OUTPUT) - output = m_line + data + "\n"; - } - else - { - if (t != COUNT) - { - output += m_typeToName[t]; - output += "="; - } - output += data; - output += t == OUTPUT ? "\n" : " "; - } - } - else if (m_algorithm == "TDES" && t == KEY_T && m_typeToName[KEY_T].empty()) - { - output += "KEY1 = "; - output += data.substr(0, 16); - output += "\nKEY2 = "; - output += data.size() > 16 ? data.substr(16, 16) : data.substr(0, 16); - output += "\nKEY3 = "; - output += data.size() > 32 ? data.substr(32, 16) : data.substr(0, 16); - output += "\n"; - } - else - { - output += m_typeToName[t]; - output += " = "; - output += data; - output += "\n"; - } - } - - void OutputData(std::string &output, DataType t, int i) - { - OutputData(output, t, IntToString(i)); - } - - void OutputData(std::string &output, DataType t, const SecByteBlock &data) - { - std::string hexData; - StringSource(data.begin(), data.size(), true, new HexEncoder(new StringSink(hexData), false)); - OutputData(output, t, hexData); - } - - void OutputGivenData(std::string &output, DataType t, bool optional = false) - { - if (m_data.find(m_typeToName[t]) == m_data.end()) - { - if (optional) - return; - throw Exception(Exception::OTHER_ERROR, "TestDataParser: key not found: " + m_typeToName[t]); - } - - OutputData(output, t, m_data[m_typeToName[t]]); - } - - template - BlockCipher * NewBT(T *) - { - if (!m_encrypt && (m_mode == "ECB" || m_mode == "CBC")) - return new typename T::Decryption; - else - return new typename T::Encryption; - } - - template - SymmetricCipher * NewMode(T *, BlockCipher &bt, const byte *iv) - { - if (!m_encrypt) - return new typename T::Decryption(bt, iv, m_feedbackSize/8); - else - return new typename T::Encryption(bt, iv, m_feedbackSize/8); - } - - static inline void Xor(SecByteBlock &z, const SecByteBlock &x, const SecByteBlock &y) - { - CRYPTOPP_ASSERT(x.size() == y.size()); - z.resize(x.size()); - xorbuf(z, x, y, x.size()); - } - - SecByteBlock UpdateKey(SecByteBlock key, const SecByteBlock *text) - { - unsigned int innerCount = (m_algorithm == "AES") ? 1000 : 10000; - int keySize = key.size(), blockSize = text[0].size(); - SecByteBlock x(keySize); - for (int k=0; k - void EC_KeyPair(string &output, int n, const OID &oid) - { - DL_GroupParameters_EC params(oid); - for (int i=0; i priv; - DL_PublicKey_EC pub; - priv.Initialize(m_rng, params); - priv.MakePublicKey(pub); - - OutputData(output, "d ", priv.GetPrivateExponent()); - OutputData(output, "Qx ", pub.GetPublicElement().x, params.GetCurve().GetField().MaxElementByteLength()); - OutputData(output, "Qy ", pub.GetPublicElement().y, params.GetCurve().GetField().MaxElementByteLength()); - } - } - - template - void EC_SigGen(string &output, const OID &oid) - { - DL_GroupParameters_EC params(oid); - typename ECDSA::PrivateKey priv; - typename ECDSA::PublicKey pub; - priv.Initialize(m_rng, params); - priv.MakePublicKey(pub); - - typename ECDSA::Signer signer(priv); - SecByteBlock sig(signer.SignatureLength()); - StringSource(m_data["Msg"], true, new HexDecoder(new SignerFilter(m_rng, signer, new ArraySink(sig, sig.size())))); - SecByteBlock R(sig, sig.size()/2), S(sig+sig.size()/2, sig.size()/2); - - OutputData(output, "Qx ", pub.GetPublicElement().x, params.GetCurve().GetField().MaxElementByteLength()); - OutputData(output, "Qy ", pub.GetPublicElement().y, params.GetCurve().GetField().MaxElementByteLength()); - OutputData(output, "R ", R); - OutputData(output, "S ", S); - } - - template - void EC_SigVer(string &output, const OID &oid) - { - SecByteBlock x(DecodeHex(m_data["Qx"])); - SecByteBlock y(DecodeHex(m_data["Qy"])); - Integer r((m_data["R"]+"h").c_str()); - Integer s((m_data["S"]+"h").c_str()); - - typename EC::FieldElement Qx(x, x.size()); - typename EC::FieldElement Qy(y, y.size()); - typename EC::Element Q(Qx, Qy); - - DL_GroupParameters_EC params(oid); - typename ECDSA::PublicKey pub; - pub.Initialize(params, Q); - typename ECDSA::Verifier verifier(pub); - - SecByteBlock sig(verifier.SignatureLength()); - r.Encode(sig, sig.size()/2); - s.Encode(sig+sig.size()/2, sig.size()/2); - - SignatureVerificationFilter filter(verifier); - filter.Put(sig, sig.size()); - StringSource(m_data["Msg"], true, new HexDecoder(new Redirector(filter, Redirector::DATA_ONLY))); - filter.MessageEnd(); - byte b; - filter.Get(b); - OutputData(output, "Result ", b ? "P" : "F"); - } - - template - static bool EC_PKV(RandomNumberGenerator &rng, const SecByteBlock &x, const SecByteBlock &y, const OID &oid) - { - typename EC::FieldElement Qx(x, x.size()); - typename EC::FieldElement Qy(y, y.size()); - typename EC::Element Q(Qx, Qy); - - DL_GroupParameters_EC params(oid); - typename ECDSA::PublicKey pub; - pub.Initialize(params, Q); - return pub.Validate(rng, 3); - } - - template - Result * CreateRSA2(const std::string &standard) - { - if (typeid(Result) == typeid(PK_Verifier)) - { - if (standard == "R") - return (Result *) new typename RSASS_ISO::Verifier; - else if (standard == "P") - return (Result *) new typename RSASS::Verifier; - else if (standard == "1") - return (Result *) new typename RSASS::Verifier; - } - else if (typeid(Result) == typeid(PK_Signer)) - { - if (standard == "R") - return (Result *) new typename RSASS_ISO::Signer; - else if (standard == "P") - return (Result *) new typename RSASS::Signer; - else if (standard == "1") - return (Result *) new typename RSASS::Signer; - } - - return NULLPTR; - } - - template - Result * CreateRSA(const std::string &standard, const std::string &hash) - { - if (hash == "1") - return CreateRSA2(standard); - else if (hash == "224") - return CreateRSA2(standard); - else if (hash == "256") - return CreateRSA2(standard); - else if (hash == "384") - return CreateRSA2(standard); - else if (hash == "512") - return CreateRSA2(standard); - else - return NULLPTR; - } - - virtual void DoTest() - { - std::string output; - - if (m_algorithm == "DSA") - { - if (m_test == "KeyPair") - { - DL_GroupParameters_DSA pqg; - int modLen = atol(m_bracketString.substr(6).c_str()); - pqg.GenerateRandomWithKeySize(m_rng, modLen); - - OutputData(output, "P ", pqg.GetModulus()); - OutputData(output, "Q ", pqg.GetSubgroupOrder()); - OutputData(output, "G ", pqg.GetSubgroupGenerator()); - - int n = atol(m_data["N"].c_str()); - for (int i=0; iPut((byte *)output.data(), output.size()); - output.resize(0); - } - } - else if (m_test == "PQGGen") - { - int n = atol(m_data["N"].c_str()); - for (int i=0; iPut((byte *)output.data(), output.size()); - output.resize(0); - } - } - else if (m_test == "SigGen") - { - std::string &encodedKey = m_data["PrivKey"]; - int modLen = atol(m_bracketString.substr(6).c_str()); - DSA::PrivateKey priv; - - if (!encodedKey.empty()) - { - StringStore s(encodedKey); - priv.BERDecode(s); - if (priv.GetGroupParameters().GetModulus().BitCount() != modLen) - encodedKey.clear(); - } - - if (encodedKey.empty()) - { - priv.Initialize(m_rng, modLen); - StringSink s(encodedKey); - priv.DEREncode(s); - OutputData(output, "P ", priv.GetGroupParameters().GetModulus()); - OutputData(output, "Q ", priv.GetGroupParameters().GetSubgroupOrder()); - OutputData(output, "G ", priv.GetGroupParameters().GetSubgroupGenerator()); - } - - DSA::Signer signer(priv); - DSA::Verifier pub(signer); - OutputData(output, "Msg ", m_data["Msg"]); - OutputData(output, "Y ", pub.GetKey().GetPublicElement()); - - SecByteBlock sig(signer.SignatureLength()); - StringSource(m_data["Msg"], true, new HexDecoder(new SignerFilter(m_rng, signer, new ArraySink(sig, sig.size())))); - SecByteBlock R(sig, sig.size()/2), S(sig+sig.size()/2, sig.size()/2); - OutputData(output, "R ", R); - OutputData(output, "S ", S); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - else if (m_test == "SigVer") - { - Integer p((m_data["P"] + "h").c_str()); - Integer q((m_data["Q"] + "h").c_str()); - Integer g((m_data["G"] + "h").c_str()); - Integer y((m_data["Y"] + "h").c_str()); - DSA::Verifier verifier(p, q, g, y); - - HexDecoder filter(new SignatureVerificationFilter(verifier)); - StringSource(m_data["R"], true, new Redirector(filter, Redirector::DATA_ONLY)); - StringSource(m_data["S"], true, new Redirector(filter, Redirector::DATA_ONLY)); - StringSource(m_data["Msg"], true, new Redirector(filter, Redirector::DATA_ONLY)); - filter.MessageEnd(); - byte b; - filter.Get(b); - OutputData(output, "Result ", b ? "P" : "F"); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - else if (m_test == "PQGVer") - { - Integer p((m_data["P"] + "h").c_str()); - Integer q((m_data["Q"] + "h").c_str()); - Integer g((m_data["G"] + "h").c_str()); - Integer h((m_data["H"] + "h").c_str()); - int c = atol(m_data["c"].c_str()); - SecByteBlock seed(m_data["Seed"].size()/2); - StringSource(m_data["Seed"], true, new HexDecoder(new ArraySink(seed, seed.size()))); - - Integer p1, q1; - bool result = DSA::GeneratePrimes(seed, seed.size()*8, c, p1, 1024, q1, true); - result = result && (p1 == p && q1 == q); - result = result && g == a_exp_b_mod_c(h, (p-1)/q, p); - - OutputData(output, "Result ", result ? "P" : "F"); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - - return; - } - - if (m_algorithm == "ECDSA") - { - std::map name2oid; - name2oid["P-192"] = ASN1::secp192r1(); - name2oid["P-224"] = ASN1::secp224r1(); - name2oid["P-256"] = ASN1::secp256r1(); - name2oid["P-384"] = ASN1::secp384r1(); - name2oid["P-521"] = ASN1::secp521r1(); - name2oid["K-163"] = ASN1::sect163k1(); - name2oid["K-233"] = ASN1::sect233k1(); - name2oid["K-283"] = ASN1::sect283k1(); - name2oid["K-409"] = ASN1::sect409k1(); - name2oid["K-571"] = ASN1::sect571k1(); - name2oid["B-163"] = ASN1::sect163r2(); - name2oid["B-233"] = ASN1::sect233r1(); - name2oid["B-283"] = ASN1::sect283r1(); - name2oid["B-409"] = ASN1::sect409r1(); - name2oid["B-571"] = ASN1::sect571r1(); - - if (m_test == "PKV") - { - bool pass; - if (m_bracketString[0] == 'P') - pass = EC_PKV(m_rng, DecodeHex(m_data["Qx"]), DecodeHex(m_data["Qy"]), name2oid[m_bracketString]); - else - pass = EC_PKV(m_rng, DecodeHex(m_data["Qx"]), DecodeHex(m_data["Qy"]), name2oid[m_bracketString]); - - OutputData(output, "Result ", pass ? "P" : "F"); - } - else if (m_test == "KeyPair") - { - if (m_bracketString[0] == 'P') - EC_KeyPair(output, atol(m_data["N"].c_str()), name2oid[m_bracketString]); - else - EC_KeyPair(output, atol(m_data["N"].c_str()), name2oid[m_bracketString]); - } - else if (m_test == "SigGen") - { - if (m_bracketString[0] == 'P') - EC_SigGen(output, name2oid[m_bracketString]); - else - EC_SigGen(output, name2oid[m_bracketString]); - } - else if (m_test == "SigVer") - { - if (m_bracketString[0] == 'P') - EC_SigVer(output, name2oid[m_bracketString]); - else - EC_SigVer(output, name2oid[m_bracketString]); - } - - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - return; - } - - if (m_algorithm == "RSA") - { - std::string shaAlg = m_data["SHAAlg"].substr(3); - - if (m_test == "Ver") - { - Integer n((m_data["n"] + "h").c_str()); - Integer e((m_data["e"] + "h").c_str()); - RSA::PublicKey pub; - pub.Initialize(n, e); - - member_ptr pV(CreateRSA(m_mode, shaAlg)); - pV->AccessMaterial().AssignFrom(pub); - - HexDecoder filter(new SignatureVerificationFilter(*pV)); - for (unsigned int i=m_data["S"].size(); iSignatureLength()*2; i++) - filter.Put('0'); - StringSource(m_data["S"], true, new Redirector(filter, Redirector::DATA_ONLY)); - StringSource(m_data["Msg"], true, new Redirector(filter, Redirector::DATA_ONLY)); - filter.MessageEnd(); - byte b; - filter.Get(b); - OutputData(output, "Result ", b ? "P" : "F"); - } - else - { - CRYPTOPP_ASSERT(m_test == "Gen"); - int modLen = atol(m_bracketString.substr(6).c_str()); - std::string &encodedKey = m_data["PrivKey"]; - RSA::PrivateKey priv; - - if (!encodedKey.empty()) - { - StringStore s(encodedKey); - priv.BERDecode(s); - if (priv.GetModulus().BitCount() != modLen) - encodedKey.clear(); - } - - if (encodedKey.empty()) - { - priv.Initialize(m_rng, modLen); - StringSink s(encodedKey); - priv.DEREncode(s); - OutputData(output, "n ", priv.GetModulus()); - OutputData(output, "e ", priv.GetPublicExponent(), modLen/8); - } - - member_ptr pS(CreateRSA(m_mode, shaAlg)); - pS->AccessMaterial().AssignFrom(priv); - - SecByteBlock sig(pS->SignatureLength()); - StringSource(m_data["Msg"], true, new HexDecoder(new SignerFilter(m_rng, *pS, new ArraySink(sig, sig.size())))); - OutputData(output, "SHAAlg ", m_data["SHAAlg"]); - OutputData(output, "Msg ", m_data["Msg"]); - OutputData(output, "S ", sig); - } - - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - return; - } - - if (m_algorithm == "SHA") - { - member_ptr pHF; - - if (m_mode == "1") - pHF.reset(new SHA1); - else if (m_mode == "224") - pHF.reset(new SHA224); - else if (m_mode == "256") - pHF.reset(new SHA256); - else if (m_mode == "384") - pHF.reset(new SHA384); - else if (m_mode == "512") - pHF.reset(new SHA512); - - if (m_test == "MONTE") - { - SecByteBlock seed = m_data2[INPUT]; - SecByteBlock MD[1003]; - int i,j; - - for (j=0; j<100; j++) - { - MD[0] = MD[1] = MD[2] = seed; - for (i=3; i<1003; i++) - { - SecByteBlock Mi = MD[i-3] + MD[i-2] + MD[i-1]; - MD[i].resize(pHF->DigestSize()); - pHF->CalculateDigest(MD[i], Mi, Mi.size()); - } - seed = MD[1002]; - OutputData(output, "COUNT ", j); - OutputData(output, "MD ", seed); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - } - else - { - SecByteBlock tag(pHF->DigestSize()); - SecByteBlock &msg(m_data2[INPUT]); - int len = atol(m_data["Len"].c_str()); - StringSource(msg.begin(), len/8, true, new HashFilter(*pHF, new ArraySink(tag, tag.size()))); - OutputData(output, "MD ", tag); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - return; - } - - SecByteBlock &key = m_data2[KEY_T]; - - if (m_algorithm == "TDES") - { - if (!m_data["KEY1"].empty()) - { - const std::string keys[3] = {m_data["KEY1"], m_data["KEY2"], m_data["KEY3"]}; - key.resize(24); - HexDecoder hexDec(new ArraySink(key, key.size())); - for (int i=0; i<3; i++) - hexDec.Put((byte *)keys[i].data(), keys[i].size()); - - if (keys[0] == keys[2]) - { - if (keys[0] == keys[1]) - key.resize(8); - else - key.resize(16); - } - else - key.resize(24); - } - } - - if (m_algorithm == "RNG") - { - key.resize(24); - StringSource(m_data["Key1"] + m_data["Key2"] + m_data["Key3"], true, new HexDecoder(new ArraySink(key, key.size()))); - - SecByteBlock seed(m_data2[INPUT]), dt(m_data2[IV]), r(8); - X917RNG rng(new DES_EDE3::Encryption(key, key.size()), seed, dt); - - if (m_test == "MCT") - { - for (int i=0; i<10000; i++) - rng.GenerateBlock(r, r.size()); - } - else - { - rng.GenerateBlock(r, r.size()); - } - - OutputData(output, "R ", r); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - return; - } - - if (m_algorithm == "HMAC") - { - member_ptr pMAC; - - if (m_bracketString == "L=20") - pMAC.reset(new HMAC); - else if (m_bracketString == "L=28") - pMAC.reset(new HMAC); - else if (m_bracketString == "L=32") - pMAC.reset(new HMAC); - else if (m_bracketString == "L=48") - pMAC.reset(new HMAC); - else if (m_bracketString == "L=64") - pMAC.reset(new HMAC); - else - throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected HMAC bracket string: " + m_bracketString); - - pMAC->SetKey(key, key.size()); - int Tlen = atol(m_data["Tlen"].c_str()); - SecByteBlock tag(Tlen); - StringSource(m_data["Msg"], true, new HexDecoder(new HashFilter(*pMAC, new ArraySink(tag, Tlen), false, Tlen))); - OutputData(output, "Mac ", tag); - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - return; - } - - member_ptr pBT; - if (m_algorithm == "DES") - pBT.reset(NewBT((DES*)0)); - else if (m_algorithm == "TDES") - { - if (key.size() == 8) - pBT.reset(NewBT((DES*)0)); - else if (key.size() == 16) - pBT.reset(NewBT((DES_EDE2*)0)); - else - pBT.reset(NewBT((DES_EDE3*)0)); - } - else if (m_algorithm == "SKIPJACK") - pBT.reset(NewBT((SKIPJACK*)0)); - else if (m_algorithm == "AES") - pBT.reset(NewBT((AES*)0)); - else - throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected algorithm: " + m_algorithm); - - if (!pBT->IsValidKeyLength(key.size())) - key.CleanNew(pBT->DefaultKeyLength()); // for Scbcvrct - pBT->SetKey(key.data(), key.size()); - - SecByteBlock &iv = m_data2[IV]; - if (iv.empty()) - iv.CleanNew(pBT->BlockSize()); - - member_ptr pCipher; - unsigned int K = m_feedbackSize; - - if (m_mode == "ECB") - pCipher.reset(NewMode((ECB_Mode_ExternalCipher*)0, *pBT, iv)); - else if (m_mode == "CBC") - pCipher.reset(NewMode((CBC_Mode_ExternalCipher*)0, *pBT, iv)); - else if (m_mode == "CFB") - pCipher.reset(NewMode((CFB_Mode_ExternalCipher*)0, *pBT, iv)); - else if (m_mode == "OFB") - pCipher.reset(NewMode((OFB_Mode_ExternalCipher*)0, *pBT, iv)); - else - throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected mode: " + m_mode); - - bool encrypt = m_encrypt; - - if (m_test == "MONTE") - { - SecByteBlock KEY[401]; - KEY[0] = key; - int keySize = key.size(); - int blockSize = pBT->BlockSize(); - - std::vector IB(10001), OB(10001), PT(10001), CT(10001), RESULT(10001), TXT(10001), CV(10001); - PT[0] = GetData("PLAINTEXT"); - CT[0] = GetData("CIPHERTEXT"); - CV[0] = IB[0] = iv; - TXT[0] = GetData("TEXT"); - - int outerCount = (m_algorithm == "AES") ? 100 : 400; - int innerCount = (m_algorithm == "AES") ? 1000 : 10000; - - for (int i=0; iSetKey(KEY[i], keySize); - - for (int j=0; jProcessBlock(IB[j], CT[j]); - PT[j+1] = CT[j]; - } - else - { - IB[j] = CT[j]; - PT[j].resize(blockSize); - pBT->ProcessBlock(IB[j], PT[j]); - CT[j+1] = PT[j]; - } - } - else if (m_mode == "OFB") - { - OB[j].resize(blockSize); - pBT->ProcessBlock(IB[j], OB[j]); - Xor(RESULT[j], OB[j], TXT[j]); - TXT[j+1] = IB[j]; - IB[j+1] = OB[j]; - } - else if (m_mode == "CBC") - { - if (encrypt) - { - Xor(IB[j], PT[j], CV[j]); - CT[j].resize(blockSize); - pBT->ProcessBlock(IB[j], CT[j]); - PT[j+1] = CV[j]; - CV[j+1] = CT[j]; - } - else - { - IB[j] = CT[j]; - OB[j].resize(blockSize); - pBT->ProcessBlock(IB[j], OB[j]); - Xor(PT[j], OB[j], CV[j]); - CV[j+1] = CT[j]; - CT[j+1] = PT[j]; - } - } - else if (m_mode == "CFB") - { - if (encrypt) - { - OB[j].resize(blockSize); - pBT->ProcessBlock(IB[j], OB[j]); - AssignLeftMostBits(CT[j], OB[j], K); - Xor(CT[j], CT[j], PT[j]); - AssignLeftMostBits(PT[j+1], IB[j], K); - IB[j+1].resize(blockSize); - std::memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8); - std::memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8); - } - else - { - OB[j].resize(blockSize); - pBT->ProcessBlock(IB[j], OB[j]); - AssignLeftMostBits(PT[j], OB[j], K); - Xor(PT[j], PT[j], CT[j]); - IB[j+1].resize(blockSize); - std::memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8); - std::memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8); - AssignLeftMostBits(CT[j+1], OB[j], K); - } - } - else - throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected mode: " + m_mode); - } - - OutputData(output, COUNT, IntToString(i)); - OutputData(output, KEY_T, KEY[i]); - if (m_mode == "CBC") - OutputData(output, IV, CV[0]); - if (m_mode == "OFB" || m_mode == "CFB") - OutputData(output, IV, IB[0]); - if (m_mode == "ECB" || m_mode == "CBC" || m_mode == "CFB") - { - if (encrypt) - { - OutputData(output, INPUT, PT[0]); - OutputData(output, OUTPUT, CT[innerCount-1]); - KEY[i+1] = UpdateKey(KEY[i], &CT[0]); - } - else - { - OutputData(output, INPUT, CT[0]); - OutputData(output, OUTPUT, PT[innerCount-1]); - KEY[i+1] = UpdateKey(KEY[i], &PT[0]); - } - PT[0] = PT[innerCount]; - IB[0] = IB[innerCount]; - CV[0] = CV[innerCount]; - CT[0] = CT[innerCount]; - } - else if (m_mode == "OFB") - { - OutputData(output, INPUT, TXT[0]); - OutputData(output, OUTPUT, RESULT[innerCount-1]); - KEY[i+1] = UpdateKey(KEY[i], &RESULT[0]); - Xor(TXT[0], TXT[0], IB[innerCount-1]); - IB[0] = OB[innerCount-1]; - } - output += "\n"; - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - } - } - else if (m_test == "MCT") - { - SecByteBlock KEY[101]; - KEY[0] = key; - int keySize = key.size(); - int blockSize = pBT->BlockSize(); - - SecByteBlock ivs[101], inputs[1001], outputs[1001]; - ivs[0] = iv; - inputs[0] = m_data2[INPUT]; - - for (int i=0; i<100; i++) - { - pCipher->SetKey(KEY[i], keySize, MakeParameters(Name::IV(), (const byte *)ivs[i])(Name::FeedbackSize(), (int)K/8, false)); - - for (int j=0; j<1000; j++) - { - outputs[j] = inputs[j]; - pCipher->ProcessString(outputs[j], outputs[j].size()); - if (K==8 && m_mode == "CFB") - { - if (j<16) - inputs[j+1].Assign(ivs[i]+j, 1); - else - inputs[j+1] = outputs[j-16]; - } - else if (m_mode == "ECB") - inputs[j+1] = outputs[j]; - else if (j == 0) - inputs[j+1] = ivs[i]; - else - inputs[j+1] = outputs[j-1]; - } - - if (m_algorithm == "AES") - OutputData(output, COUNT, m_count++); - OutputData(output, KEY_T, KEY[i]); - if (m_mode != "ECB") - OutputData(output, IV, ivs[i]); - OutputData(output, INPUT, inputs[0]); - OutputData(output, OUTPUT, outputs[999]); - output += "\n"; - AttachedTransformation()->Put((byte *)output.data(), output.size()); - output.resize(0); - - KEY[i+1] = UpdateKey(KEY[i], outputs); - ivs[i+1].CleanNew(pCipher->IVSize()); - ivs[i+1] = UpdateKey(ivs[i+1], outputs); - if (K==8 && m_mode == "CFB") - inputs[0] = outputs[999-16]; - else if (m_mode == "ECB") - inputs[0] = outputs[999]; - else - inputs[0] = outputs[998]; - } - } - else - { - CRYPTOPP_ASSERT(m_test == "KAT"); - - SecByteBlock &input = m_data2[INPUT]; - SecByteBlock result(input.size()); - member_ptr pFilter(new StreamTransformationFilter(*pCipher, new ArraySink(result, result.size()), StreamTransformationFilter::NO_PADDING)); - StringSource(input.data(), input.size(), true, pFilter.release()); - - OutputGivenData(output, COUNT, true); - OutputData(output, KEY_T, key); - OutputGivenData(output, IV, true); - OutputGivenData(output, INPUT); - OutputData(output, OUTPUT, result); - output += "\n"; - AttachedTransformation()->Put((byte *)output.data(), output.size()); - } - } - - std::vector Tokenize(const std::string &line) - { - std::vector result; - std::string s; - for (unsigned int i=0; i") - { - CRYPTOPP_ASSERT(m_test == "sha"); - m_bracketString = m_line.substr(2, m_line.size()-4); - m_line = m_line.substr(0, 13) + "Hashes") - copyLine = true; - - if (m_line == "Put((byte *)m_line.data(), m_line.size(), blocking); - return false; - } - - std::vector tokens = Tokenize(m_line); - - if (m_algorithm == "DSA" && m_test == "sha") - { - for (unsigned int i = 0; i < tokens.size(); i++) - { - if (tokens[i] == "^") - DoTest(); - else if (tokens[i] != "") - m_compactString.push_back(atol(tokens[i].c_str())); - } - } - else - { - if (!m_line.empty() && ((m_algorithm == "RSA" && m_test != "Gen") || m_algorithm == "RNG" || m_algorithm == "HMAC" || m_algorithm == "SHA" || (m_algorithm == "ECDSA" && m_test != "KeyPair") || (m_algorithm == "DSA" && (m_test == "PQGVer" || m_test == "SigVer")))) - { - // copy input to output - std::string output = m_line + '\n'; - AttachedTransformation()->Put((byte *)output.data(), output.size()); - } - - for (unsigned int i = 0; i < tokens.size(); i++) - { - if (m_firstLine && m_algorithm != "DSA") - { - if (tokens[i] == "Encrypt" || tokens[i] == "OFB") - SetEncrypt(true); - else if (tokens[i] == "Decrypt") - SetEncrypt(false); - else if (tokens[i] == "Modes") - m_test = "MONTE"; - } - else - { - if (tokens[i] != "=") - continue; - - if (i == 0) - throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected data: " + m_line); - - const std::string &key = tokens[i-1]; - std::string &data = m_data[key]; - data = (tokens.size() > i+1) ? tokens[i+1] : ""; - DataType t = m_nameToType[key]; - m_typeToName[t] = key; - m_data2[t] = DecodeHex(data); - - if (key == m_trigger || (t == OUTPUT && !m_data2[INPUT].empty() && !isspace(m_line[0]))) - DoTest(); - } - } - } - - m_firstLine = false; - - return false; - } - - inline const SecByteBlock & GetData(const std::string &key) - { - return m_data2[m_nameToType[key]]; - } - - static SecByteBlock DecodeHex(const std::string &data) - { - SecByteBlock data2(data.size() / 2); - StringSource(data, true, new HexDecoder(new ArraySink(data2, data2.size()))); - return data2; - } - - std::string m_algorithm, m_test, m_mode, m_line, m_bracketString, m_trigger; - unsigned int m_feedbackSize, m_blankLineTransition; - bool m_encrypt, m_firstLine; - - typedef std::map NameToTypeMap; - NameToTypeMap m_nameToType; - typedef std::map TypeToNameMap; - TypeToNameMap m_typeToName; - - typedef std::map Map; - Map m_data; // raw data - typedef std::map Map2; - Map2 m_data2; - int m_count; - - AutoSeededX917RNG m_rng; - std::vector m_compactString; -}; - -int FIPS_140_AlgorithmTest(int argc, char **argv) -{ - argc--; - argv++; - - std::string algorithm = argv[1]; - std::string pathname = argv[2]; - unsigned int i = pathname.find_last_of("\\/"); - std::string filename = pathname.substr(i == std::string::npos ? 0 : i+1); - std::string dirname = pathname.substr(0, i); - - if (algorithm == "auto") - { - string algTable[] = {"AES", "ECDSA", "DSA", "HMAC", "RNG", "RSA", "TDES", "SKIPJACK", "SHA"}; // order is important here - for (i=0; i 3) - { - std::string outDir = argv[3]; - - if (outDir == "auto") - { - if (dirname.substr(dirname.size()-3) == "req") - outDir = dirname.substr(0, dirname.size()-3) + "resp"; - } - - if (*outDir.rbegin() != '\\' && *outDir.rbegin() != '/') - outDir += '/'; - std::string outPathname = outDir + filename.substr(0, filename.size() - 3) + "rsp"; - pSink = new FileSink(outPathname.c_str(), false); - } - else - pSink = new FileSink(cout); - - FileSource(pathname.c_str(), true, new LineBreakParser(new TestDataParser(algorithm, test, mode, feedbackSize, encrypt, pSink)), false); - } - catch (...) - { - cout << "file: " << filename << endl; - throw; - } - return 0; -} - -extern int (*AdhocTest)(int argc, char *argv[]); -static int s_i = (AdhocTest = &FIPS_140_AlgorithmTest, 0); -#endif diff --git a/vendor/cryptopp/fipstest.cpp b/vendor/cryptopp/fipstest.cpp deleted file mode 100644 index 145f425445..0000000000 --- a/vendor/cryptopp/fipstest.cpp +++ /dev/null @@ -1,652 +0,0 @@ -// fipstest.cpp - originally written and placed in the public domain by Wei Dai - -#include "pch.h" -#include "config.h" - -#ifndef CRYPTOPP_IMPORTS - -#define CRYPTOPP_DEFAULT_NO_DLL -#include "dll.h" -#include "cryptlib.h" -#include "filters.h" -#include "smartptr.h" -#include "pkcspad.h" -#include "misc.h" - -// Simply disable CRYPTOPP_WIN32_AVAILABLE for Windows Phone and Windows Store apps -#ifdef CRYPTOPP_WIN32_AVAILABLE -# if defined(WINAPI_FAMILY) -# if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) -# undef CRYPTOPP_WIN32_AVAILABLE -# endif -# endif -#endif - -#ifdef CRYPTOPP_WIN32_AVAILABLE -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0400 -#endif - -#include - -#if defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_MSC_VERSION >= 1400 -# ifdef _M_IX86 -# define _CRT_DEBUGGER_HOOK _crt_debugger_hook -# else -# define _CRT_DEBUGGER_HOOK __crt_debugger_hook -# endif -# if CRYPTOPP_MSC_VERSION < 1900 -extern "C" {_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);} -# else -extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); } -# endif -#endif -#endif // CRYPTOPP_WIN32_AVAILABLE - -#include -#include - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4702) -#endif - -NAMESPACE_BEGIN(CryptoPP) - -extern PowerUpSelfTestStatus g_powerUpSelfTestStatus; -SecByteBlock g_actualMac; -unsigned long g_macFileLocation = 0; - -// $ grep -iIR baseaddress *.*proj -// cryptdll.vcxproj: 0x42900000 -// cryptdll.vcxproj: 0x42900000 -// cryptdll.vcxproj: 0x42900000 -// cryptdll.vcxproj: 0x42900000 -const void* g_BaseAddressOfMAC = reinterpret_cast(0x42900000); - -// use a random dummy string here, to be searched/replaced later with the real MAC -static const byte s_moduleMac[CryptoPP::HMAC::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC; -CRYPTOPP_COMPILE_ASSERT(sizeof(s_moduleMac) == CryptoPP::SHA1::DIGESTSIZE); - -#ifdef CRYPTOPP_WIN32_AVAILABLE -static HMODULE s_hModule = NULLPTR; -#endif - -const byte * CRYPTOPP_API GetActualMacAndLocation(unsigned int &macSize, unsigned int &fileLocation) -{ - macSize = (unsigned int)g_actualMac.size(); - fileLocation = g_macFileLocation; - return g_actualMac; -} - -void KnownAnswerTest(RandomNumberGenerator &rng, const char *output) -{ - EqualityComparisonFilter comparison; - - RandomNumberStore(rng, strlen(output)/2).TransferAllTo(comparison, "0"); - StringSource(output, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); - - comparison.ChannelMessageSeriesEnd("0"); - comparison.ChannelMessageSeriesEnd("1"); -} - -template -void X917RNG_KnownAnswerTest( - const char *key, - const char *seed, - const char *deterministicTimeVector, - const char *output) -{ -#ifdef OS_RNG_AVAILABLE - std::string decodedKey, decodedSeed, decodedDeterministicTimeVector; - StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); - StringSource(seed, true, new HexDecoder(new StringSink(decodedSeed))); - StringSource(deterministicTimeVector, true, new HexDecoder(new StringSink(decodedDeterministicTimeVector))); - - AutoSeededX917RNG rng(false, false); - rng.Reseed((const byte *)decodedKey.data(), decodedKey.size(), (const byte *)decodedSeed.data(), (const byte *)decodedDeterministicTimeVector.data()); - KnownAnswerTest(rng, output); -#else - throw 0; -#endif -} - -void KnownAnswerTest(StreamTransformation &encryption, StreamTransformation &decryption, const char *plaintext, const char *ciphertext) -{ - EqualityComparisonFilter comparison; - - StringSource(plaintext, true, new HexDecoder(new StreamTransformationFilter(encryption, new ChannelSwitch(comparison, "0"), StreamTransformationFilter::NO_PADDING))); - StringSource(ciphertext, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); - - StringSource(ciphertext, true, new HexDecoder(new StreamTransformationFilter(decryption, new ChannelSwitch(comparison, "0"), StreamTransformationFilter::NO_PADDING))); - StringSource(plaintext, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); - - comparison.ChannelMessageSeriesEnd("0"); - comparison.ChannelMessageSeriesEnd("1"); -} - -template -void SymmetricEncryptionKnownAnswerTest( - const char *key, - const char *hexIV, - const char *plaintext, - const char *ecb, - const char *cbc, - const char *cfb, - const char *ofb, - const char *ctr) -{ - std::string decodedKey; - StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); - - typename CIPHER::Encryption encryption((const byte *)decodedKey.data(), decodedKey.size()); - typename CIPHER::Decryption decryption((const byte *)decodedKey.data(), decodedKey.size()); - - SecByteBlock iv(encryption.BlockSize()); - StringSource(hexIV, true, new HexDecoder(new ArraySink(iv, iv.size()))); - - if (ecb) - KnownAnswerTest(ECB_Mode_ExternalCipher::Encryption(encryption).Ref(), ECB_Mode_ExternalCipher::Decryption(decryption).Ref(), plaintext, ecb); - if (cbc) - KnownAnswerTest(CBC_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CBC_Mode_ExternalCipher::Decryption(decryption, iv).Ref(), plaintext, cbc); - if (cfb) - KnownAnswerTest(CFB_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CFB_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, cfb); - if (ofb) - KnownAnswerTest(OFB_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), OFB_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, ofb); - if (ctr) - KnownAnswerTest(CTR_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CTR_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, ctr); -} - -void KnownAnswerTest(HashTransformation &hash, const char *message, const char *digest) -{ - EqualityComparisonFilter comparison; - StringSource(digest, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); - StringSource(message, true, new HashFilter(hash, new ChannelSwitch(comparison, "0"))); - - comparison.ChannelMessageSeriesEnd("0"); - comparison.ChannelMessageSeriesEnd("1"); -} - -template -void SecureHashKnownAnswerTest(const char *message, const char *digest) -{ - HASH hash; - KnownAnswerTest(hash, message, digest); -} - -template -void MAC_KnownAnswerTest(const char *key, const char *message, const char *digest) -{ - std::string decodedKey; - StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); - - MAC mac((const byte *)decodedKey.data(), decodedKey.size()); - KnownAnswerTest(mac, message, digest); -} - -template -void SignatureKnownAnswerTest(const char *key, const char *message, const char *signature) -{ - typename SCHEME::Signer signer(StringSource(key, true, new HexDecoder).Ref()); - typename SCHEME::Verifier verifier(signer); - - RandomPool rng; - EqualityComparisonFilter comparison; - - StringSource(message, true, new SignerFilter(rng, signer, new ChannelSwitch(comparison, "0"))); - StringSource(signature, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); - - comparison.ChannelMessageSeriesEnd("0"); - comparison.ChannelMessageSeriesEnd("1"); - - SignatureVerificationFilter verifierFilter(verifier, NULLPTR, SignatureVerificationFilter::SIGNATURE_AT_BEGIN | SignatureVerificationFilter::THROW_EXCEPTION); - StringSource(signature, true, new HexDecoder(new Redirector(verifierFilter, Redirector::DATA_ONLY))); - StringSource(message, true, new Redirector(verifierFilter)); -} - -void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor) -{ - try - { - RandomPool rng; - const char *testMessage ="test message"; - std::string ciphertext, decrypted; - - StringSource( - testMessage, - true, - new PK_EncryptorFilter( - rng, - encryptor, - new StringSink(ciphertext))); - - if (ciphertext == testMessage) - throw 0; - - StringSource( - ciphertext, - true, - new PK_DecryptorFilter( - rng, - decryptor, - new StringSink(decrypted))); - - if (decrypted != testMessage) - throw 0; - } - catch (...) - { - throw SelfTestFailure(encryptor.AlgorithmName() + ": pairwise consistency test failed"); - } -} - -void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier) -{ - try - { - RandomPool rng; - - StringSource( - "test message", - true, - new SignerFilter( - rng, - signer, - new SignatureVerificationFilter(verifier, NULLPTR, SignatureVerificationFilter::THROW_EXCEPTION), - true)); - } - catch (...) - { - throw SelfTestFailure(signer.AlgorithmName() + ": pairwise consistency test failed"); - } -} - -template -void SignaturePairwiseConsistencyTest(const char *key) -{ - typename SCHEME::Signer signer(StringSource(key, true, new HexDecoder).Ref()); - typename SCHEME::Verifier verifier(signer); - - SignaturePairwiseConsistencyTest(signer, verifier); -} - -MessageAuthenticationCode * NewIntegrityCheckingMAC() -{ - byte key[] = {0x47, 0x1E, 0x33, 0x96, 0x65, 0xB1, 0x6A, 0xED, 0x0B, 0xF8, 0x6B, 0xFD, 0x01, 0x65, 0x05, 0xCC}; - return new HMAC(key, sizeof(key)); -} - -bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac, unsigned long *pMacFileLocation) -{ - member_ptr mac(NewIntegrityCheckingMAC()); - unsigned int macSize = mac->DigestSize(); - - SecByteBlock tempMac; - SecByteBlock &actualMac = pActualMac ? *pActualMac : tempMac; - actualMac.resize(macSize); - - unsigned long tempLocation = 0; - unsigned long &macFileLocation = pMacFileLocation ? *pMacFileLocation : tempLocation; - macFileLocation = 0; - - MeterFilter verifier(new HashFilter(*mac, new ArraySink(actualMac, actualMac.size()))); -// MeterFilter verifier(new FileSink("c:\\dt.tmp")); - std::ifstream moduleStream; - -#ifdef CRYPTOPP_WIN32_AVAILABLE - HMODULE h = NULLPTR; - { - const size_t FIPS_MODULE_MAX_PATH = 2*MAX_PATH; - char moduleFilenameBuf[FIPS_MODULE_MAX_PATH] = ""; - if (moduleFilename == NULLPTR) - { -#if (CRYPTOPP_MSC_VERSION >= 1400 && !defined(_STLPORT_VERSION)) // ifstream doesn't support wide filename on other compilers - wchar_t wideModuleFilename[FIPS_MODULE_MAX_PATH]; - if (GetModuleFileNameW(s_hModule, wideModuleFilename, FIPS_MODULE_MAX_PATH) > 0) - { - moduleStream.open(wideModuleFilename, std::ios::in | std::ios::binary); - h = GetModuleHandleW(wideModuleFilename); - } - else -#endif - { - GetModuleFileNameA(s_hModule, moduleFilenameBuf, FIPS_MODULE_MAX_PATH); - moduleFilename = moduleFilenameBuf; - } - } -#endif - if (moduleFilename != NULLPTR) - { - moduleStream.open(moduleFilename, std::ios::in | std::ios::binary); -#ifdef CRYPTOPP_WIN32_AVAILABLE - h = GetModuleHandleA(moduleFilename); - moduleFilename = NULLPTR; - } -#endif - } - -#ifdef CRYPTOPP_WIN32_AVAILABLE - if (h == g_BaseAddressOfMAC) - { - std::ostringstream oss; - oss << "Crypto++ DLL loaded at base address " << std::hex << h << ".\n"; - OutputDebugStringA(oss.str().c_str()); - } - else - { - std::ostringstream oss; - oss << "Crypto++ DLL integrity check may fail. Expected module base address is "; - oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at " << h << ".\n"; - OutputDebugStringA(oss.str().c_str()); - } -#endif - - if (!moduleStream) - { -#ifdef CRYPTOPP_WIN32_AVAILABLE - OutputDebugStringA("Crypto++ DLL integrity check failed. Cannot open file for reading."); -#endif - return false; - } - FileStore file(moduleStream); - -#ifdef CRYPTOPP_WIN32_AVAILABLE - // try to hash from memory first - const byte *memBase = (const byte *)h; - const IMAGE_DOS_HEADER *ph = (IMAGE_DOS_HEADER *)memBase; - const IMAGE_NT_HEADERS *phnt = (IMAGE_NT_HEADERS *)(memBase + ph->e_lfanew); - const IMAGE_SECTION_HEADER *phs = IMAGE_FIRST_SECTION(phnt); - DWORD nSections = phnt->FileHeader.NumberOfSections; - size_t currentFilePos = 0; - - size_t checksumPos = (byte *)&phnt->OptionalHeader.CheckSum - memBase; - size_t checksumSize = sizeof(phnt->OptionalHeader.CheckSum); - size_t certificateTableDirectoryPos = (byte *)&phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] - memBase; - size_t certificateTableDirectorySize = sizeof(phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]); - size_t certificateTablePos = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress; - size_t certificateTableSize = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size; - - verifier.AddRangeToSkip(0, checksumPos, checksumSize); - verifier.AddRangeToSkip(0, certificateTableDirectoryPos, certificateTableDirectorySize); - verifier.AddRangeToSkip(0, certificateTablePos, certificateTableSize); - - while (nSections--) - { - switch (phs->Characteristics) - { - default: - break; - case IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ: - case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ: - unsigned int sectionSize = STDMIN(phs->SizeOfRawData, phs->Misc.VirtualSize); - const byte *sectionMemStart = memBase + phs->VirtualAddress; - unsigned int sectionFileStart = phs->PointerToRawData; - size_t subSectionStart = 0, nextSubSectionStart; - - do - { - const byte *subSectionMemStart = sectionMemStart + subSectionStart; - size_t subSectionFileStart = sectionFileStart + subSectionStart; - size_t subSectionSize = sectionSize - subSectionStart; - nextSubSectionStart = 0; - - unsigned int entriesToReadFromDisk[] = {IMAGE_DIRECTORY_ENTRY_IMPORT, IMAGE_DIRECTORY_ENTRY_IAT}; - for (unsigned int i=0; iOptionalHeader.DataDirectory[entriesToReadFromDisk[i]]; - const byte *entryMemStart = memBase + entry.VirtualAddress; - if (subSectionMemStart <= entryMemStart && entryMemStart < subSectionMemStart + subSectionSize) - { - subSectionSize = entryMemStart - subSectionMemStart; - nextSubSectionStart = entryMemStart - sectionMemStart + entry.Size; - } - } - - // Visual Studio 2019 is MSC_VER == 1920 - // https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nds -#if (CRYPTOPP_MSC_VERSION >= 1400 && CRYPTOPP_MSC_VERSION < 1920) && (defined(_M_IX86) || defined(_M_X64)) - // first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file - if (IsDebuggerPresent()) - { - if (subSectionMemStart <= (byte *)&_CRT_DEBUGGER_HOOK && (byte *)&_CRT_DEBUGGER_HOOK < subSectionMemStart + subSectionSize) - { - subSectionSize = (byte *)&_CRT_DEBUGGER_HOOK - subSectionMemStart; - nextSubSectionStart = (byte *)&_CRT_DEBUGGER_HOOK - sectionMemStart + 1; - } - } -#endif - - if (subSectionMemStart <= expectedModuleMac && expectedModuleMac < subSectionMemStart + subSectionSize) - { - // found stored MAC - macFileLocation = (unsigned long)(subSectionFileStart + (expectedModuleMac - subSectionMemStart)); - verifier.AddRangeToSkip(0, macFileLocation, macSize); - } - - file.TransferTo(verifier, subSectionFileStart - currentFilePos); - verifier.Put(subSectionMemStart, subSectionSize); - file.Skip(subSectionSize); - currentFilePos = subSectionFileStart + subSectionSize; - subSectionStart = nextSubSectionStart; - } while (nextSubSectionStart != 0); - } - phs++; - } -#endif - file.TransferAllTo(verifier); - -#ifdef CRYPTOPP_WIN32_AVAILABLE - // if that fails (could be caused by debug breakpoints or DLL base relocation modifying image in memory), - // hash from disk instead - if (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize)) - { - OutputDebugStringA("Crypto++ DLL in-memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n"); - moduleStream.clear(); - moduleStream.seekg(0); - verifier.Initialize(MakeParameters(Name::OutputBuffer(), ByteArrayParameter(actualMac, (unsigned int)actualMac.size()))); -// verifier.Initialize(MakeParameters(Name::OutputFileName(), (const char *)"c:\\dt2.tmp")); - verifier.AddRangeToSkip(0, checksumPos, checksumSize); - verifier.AddRangeToSkip(0, certificateTableDirectoryPos, certificateTableDirectorySize); - verifier.AddRangeToSkip(0, certificateTablePos, certificateTableSize); - verifier.AddRangeToSkip(0, macFileLocation, macSize); - FileStore(moduleStream).TransferAllTo(verifier); - } -#endif - - if (VerifyBufsEqual(expectedModuleMac, actualMac, macSize)) - return true; - -#ifdef CRYPTOPP_WIN32_AVAILABLE - std::string hexMac; - HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size()); - OutputDebugStringA((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str()); -#endif - return false; -} - -void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac) -{ - g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_NOT_DONE; - SetPowerUpSelfTestInProgressOnThisThread(true); - - try - { - if (FIPS_140_2_ComplianceEnabled() || expectedModuleMac != NULLPTR) - { - if (!IntegrityCheckModule(moduleFilename, expectedModuleMac, &g_actualMac, &g_macFileLocation)) - throw 0; // throw here so we break in the debugger, this will be caught right away - } - - // algorithm tests - - X917RNG_KnownAnswerTest( - "2b7e151628aed2a6abf7158809cf4f3c", // key - "000102030405060708090a0b0c0d0e0f", // seed - "00000000000000000000000000000001", // time vector - "D176EDD27493B0395F4D10546232B0693DC7061C03C3A554F09CECF6F6B46D945A"); // output - - SymmetricEncryptionKnownAnswerTest( - "385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E", - "C141B5FCCD28DC8A", - "6E1BD7C6120947A464A6AAB293A0F89A563D8D40D3461B68", - "64EAAD4ACBB9CEAD6C7615E7C7E4792FE587D91F20C7D2F4", - "6235A461AFD312973E3B4F7AA7D23E34E03371F8E8C376C9", - "E26BA806A59B0330DE40CA38E77A3E494BE2B212F6DD624B", - "E26BA806A59B03307DE2BCC25A08BA40A8BA335F5D604C62", - "E26BA806A59B03303C62C2EFF32D3ACDD5D5F35EBCC53371"); - - SymmetricEncryptionKnownAnswerTest( - "1555E5531C3A169B2D65", - "6EC9795701F49864", - "00AFA48E9621E52E8CBDA312660184EDDB1F33D9DACDA8DA", - "DBEC73562EFCAEB56204EB8AE9557EBF77473FBB52D17CD1", - "0C7B0B74E21F99B8F2C8DF37879F6C044967F42A796DCA8B", - "79FDDA9724E36CC2E023E9A5C717A8A8A7FDA465CADCBF63", - "79FDDA9724E36CC26CACBD83C1ABC06EAF5B249BE5B1E040", - "79FDDA9724E36CC211B0AEC607B95A96BCDA318440B82F49"); - - SymmetricEncryptionKnownAnswerTest( - "2b7e151628aed2a6abf7158809cf4f3c", - "000102030405060708090a0b0c0d0e0f", - "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710", // plaintext - "3ad77bb40d7a3660a89ecaf32466ef97f5d3d58503b9699de785895a96fdbaaf43b1cd7f598ece23881b00e3ed0306887b0c785e27e8ad3f8223207104725dd4", // ecb - "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7", // cbc - "3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6", // cfb - "3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e", // ofb - NULLPTR); - - SymmetricEncryptionKnownAnswerTest( - "2b7e151628aed2a6abf7158809cf4f3c", - "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", - "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710", - NULLPTR, - NULLPTR, - NULLPTR, - NULLPTR, - "874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee"); // ctr - - - SecureHashKnownAnswerTest( - "abc", - "A9993E364706816ABA3E25717850C26C9CD0D89D"); - - SecureHashKnownAnswerTest( - "abc", - "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"); - - SecureHashKnownAnswerTest( - "abc", - "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"); - - SecureHashKnownAnswerTest( - "abc", - "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"); - - SecureHashKnownAnswerTest( - "abc", - "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); - - MAC_KnownAnswerTest >( - "303132333435363738393a3b3c3d3e3f40414243", - "Sample #2", - "0922d3405faa3d194f82a45830737d5cc6c75d24"); - - const char *keyRSA1 = - "30820150020100300d06092a864886f70d01010105000482013a3082013602010002400a66791dc6988168de7ab77419bb7fb0" - "c001c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9af55d655620bbab0203010001" - "02400123c5b61ba36edb1d3679904199a89ea80c09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa" - "87d8862b75177691c11d757692df8881022033d48445c859e52340de704bcdda065fbb4058d740bd1d67d29e9c146c11cf61" - "0220335e8408866b0fd38dc7002d3f972c67389a65d5d8306566d5c4f2a5aa52628b0220045ec90071525325d3d46db79695e9af" - "acc4523964360e02b119baa366316241022015eb327360c7b60d12e5e2d16bdcd97981d17fba6b70db13b20b436e24eada590220" - "2ca6366d72781dfa24d34a9a24cbc2ae927a9958af426563ff63fb11658a461d"; - - const char *keyRSA2 = - "30820273020100300D06092A864886F70D01010105000482025D3082025902010002818100D40AF9" - "A2B713034249E5780056D70FC7DE75D76E44565AA6A6B8ED9646F3C19F9E254D72D7DE6E49DB2264" - "0C1D05AB9E2A5F901D8F3FE1F7AE02CEE2ECCE54A40ABAE55A004692752E70725AEEE7CDEA67628A" - "82A9239B4AB660C2BC56D9F01E90CBAAB9BF0FC8E17173CEFC5709A29391A7DDF3E0B758691AAF30" - "725B292F4F020111027F18C0BA087D082C45D75D3594E0767E4820818EB35612B80CEAB8C880ACA5" - "44B6876DFFEF85A576C0D45B551AFAA1FD63209CD745DF75C5A0F0B580296EA466CD0338207E4752" - "FF4E7DB724D8AE18CE5CF4153BB94C27869FBB50E64F02546E4B02997A0B8623E64017CC770759C6" - "695DB649EEFD829D688D441BCC4E7348F1024100EF86DD7AF3F32CDE8A9F6564E43A559A0C9F8BAD" - "36CC25330548B347AC158A345631FA90F7B873C36EFFAE2F7823227A3F580B5DD18304D5932751E7" - "43E9234F024100E2A039854B55688740E32A51DF4AF88613D91A371CF8DDD95D780A89D7CF2119A9" - "54F1AC0F3DCDB2F6959926E6D9D37D8BC07A4C634DE6F16315BD5F0DAC340102407ECEEDB9903572" - "1B76909F174BA6698DCA72953D957B22C0A871C8531EDE3A1BB52984A719BC010D1CA57A555DB83F" - "6DE54CBAB932AEC652F38D497A6F3F30CF024100854F30E4FF232E6DADB2CD99926855F484255AB7" - "01FBCDCB27EC426F33A7046972AA700ADBCA008763DF87440F52F4E070531AC385B55AAC1C2AE7DD" - "8F9278F1024100C313F4AF9E4A9DE1253C21080CE524251560C111550772FD08690F13FBE658342E" - "BD2D41C9DCB12374E871B1839E26CAE252E1AE3DAAD5F1EE1F42B4D0EE7581"; - - SignatureKnownAnswerTest >( - keyRSA1, - "Everyone gets Friday off.", - "0610761F95FFD1B8F29DA34212947EC2AA0E358866A722F03CC3C41487ADC604A48FF54F5C6BEDB9FB7BD59F82D6E55D8F3174BA361B2214B2D74E8825E04E81"); - - SignatureKnownAnswerTest >( - keyRSA2, - "test", - "32F6BA41C8930DE71EE67F2627172CC539EDE04267FDE03AC295E3C50311F26C3B275D3AF513AC96" - "8EE493BAB7DA3A754661D1A7C4A0D1A2B7EE8B313AACD8CB8BFBC5C15EFB0EF15C86A9334A1E87AD" - "291EB961B5CA0E84930429B28780816AA94F96FC2367B71E2D2E4866FA966795B147F00600E5207E" - "2F189C883B37477C"); - - SignaturePairwiseConsistencyTest( - "3082014A0201003082012B06072A8648CE3804013082011E02818100F468699A6F6EBCC0120D3B34C8E007F125EC7D81F763B8D0F33869AE3BD6B9F2ECCC7DF34DF84C0307449E9B85D30D57194BCCEB310F48141914DD13A077AAF9B624A6CBE666BBA1D7EBEA95B5BA6F54417FD5D4E4220C601E071D316A24EA814E8B0122DBF47EE8AEEFD319EBB01DD95683F10DBB4FEB023F8262A07EAEB7FD02150082AD4E034DA6EEACDFDAE68C36F2BAD614F9E53B02818071AAF73361A26081529F7D84078ADAFCA48E031DB54AD57FB1A833ADBD8672328AABAA0C756247998D7A5B10DACA359D231332CE8120B483A784FE07D46EEBFF0D7D374A10691F78653E6DC29E27CCB1B174923960DFE5B959B919B2C3816C19251832AFD8E35D810E598F82877ABF7D40A041565168BD7F0E21E3FE2A8D8C1C0416021426EBA66E846E755169F84A1DA981D86502405DDF"); - - SignaturePairwiseConsistencyTest >( - "302D020100301006072A8648CE3D020106052B8104000404163014020101040F0070337065E1E196980A9D00E37211"); - - SignaturePairwiseConsistencyTest >( - "3039020100301306072A8648CE3D020106082A8648CE3D030101041F301D02010104182BB8A13C8B867010BD9471D9E81FDB01ABD0538C64D6249A"); - - SignaturePairwiseConsistencyTest >(keyRSA1); - } - catch (...) - { - g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_FAILED; - goto done; - } - - g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_PASSED; - -done: - SetPowerUpSelfTestInProgressOnThisThread(false); - return; -} - -#ifdef CRYPTOPP_WIN32_AVAILABLE - -void DoDllPowerUpSelfTest() -{ - CryptoPP::DoPowerUpSelfTest(NULLPTR, s_moduleMac); -} - -#else - -void DoDllPowerUpSelfTest() -{ - throw NotImplemented("DoDllPowerUpSelfTest() only available on Windows"); -} - -#endif // #ifdef CRYPTOPP_WIN32_AVAILABLE - -NAMESPACE_END - -#ifdef CRYPTOPP_WIN32_AVAILABLE - -// DllMain needs to be in the global namespace -BOOL APIENTRY DllMain(HANDLE hModule, - DWORD dwReason, - LPVOID /*lpReserved*/) -{ - if (dwReason == DLL_PROCESS_ATTACH) - { - CryptoPP::s_hModule = (HMODULE)hModule; - CryptoPP::DoDllPowerUpSelfTest(); - } - return TRUE; -} - -#endif // #ifdef CRYPTOPP_WIN32_AVAILABLE - -#endif // #ifndef CRYPTOPP_IMPORTS diff --git a/vendor/cryptopp/regtest1.cpp b/vendor/cryptopp/regtest1.cpp deleted file mode 100644 index d5f6fec446..0000000000 --- a/vendor/cryptopp/regtest1.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// 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. A second split occurred in July 2018. - -#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 "shake.h" -#include "blake2.h" -#include "sha.h" -#include "sha3.h" -#include "sm3.h" -#include "hkdf.h" -#include "tiger.h" -#include "ripemd.h" -#include "panama.h" -#include "whrlpool.h" -#include "lsh.h" - -#include "osrng.h" -#include "drbg.h" -#include "darn.h" -#include "mersenne.h" -#include "rdrand.h" -#include "padlkrng.h" - -#include "modes.h" -#include "aes.h" - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -USING_NAMESPACE(CryptoPP) - -// Unkeyed ciphers -void RegisterFactories1(); -// MAC ciphers -void RegisterFactories2(); -// Stream ciphers -void RegisterFactories3(); -// Block ciphers -void RegisterFactories4(); -// Public key ciphers -void RegisterFactories5(); - -void RegisterFactories(Test::TestClass suites) -{ - static bool s_registered = false; - if (s_registered) - return; - - if ((suites & Test::Unkeyed) == Test::Unkeyed) - RegisterFactories1(); - - if ((suites & Test::SharedKeyMAC) == Test::SharedKeyMAC) - RegisterFactories2(); - - if ((suites & Test::SharedKeyStream) == Test::SharedKeyStream) - RegisterFactories3(); - - if ((suites & Test::SharedKeyBlock) == Test::SharedKeyBlock) - RegisterFactories4(); - - if ((suites & Test::PublicKey) == Test::PublicKey) - RegisterFactories5(); - - s_registered = true; -} - -// Unkeyed ciphers -void RegisterFactories1() -{ - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - -#ifdef BLOCKING_RNG_AVAILABLE - RegisterDefaultFactoryFor(); -#endif -#ifdef NONBLOCKING_RNG_AVAILABLE - RegisterDefaultFactoryFor(); -#endif -#ifdef OS_RNG_AVAILABLE - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor >(); -#endif - RegisterDefaultFactoryFor(); -#if (CRYPTOPP_BOOL_X86) - if (HasPadlockRNG()) - RegisterDefaultFactoryFor(); -#endif -#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) - if (HasRDRAND()) - RegisterDefaultFactoryFor(); - if (HasRDSEED()) - RegisterDefaultFactoryFor(); -#endif -#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) - if (HasDARN()) - RegisterDefaultFactoryFor(); -#endif - RegisterDefaultFactoryFor::Encryption >("AES/OFB RNG"); - RegisterDefaultFactoryFor >("Hash_DRBG(SHA1)"); - RegisterDefaultFactoryFor >("Hash_DRBG(SHA256)"); - RegisterDefaultFactoryFor >("HMAC_DRBG(SHA1)"); - RegisterDefaultFactoryFor >("HMAC_DRBG(SHA256)"); - - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); -} diff --git a/vendor/cryptopp/regtest2.cpp b/vendor/cryptopp/regtest2.cpp deleted file mode 100644 index 35b460576d..0000000000 --- a/vendor/cryptopp/regtest2.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// regtest2.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. A second split occurred in July 2018. - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "factory.h" -#include "bench.h" -#include "cpu.h" - -// For MAC's -#include "hmac.h" -#include "cmac.h" -#include "dmac.h" -#include "vmac.h" -#include "ttmac.h" - -// Ciphers -#include "md5.h" -#include "keccak.h" -#include "sha.h" -#include "sha3.h" -#include "blake2.h" -#include "ripemd.h" -#include "chacha.h" -#include "poly1305.h" -#include "siphash.h" -#include "panama.h" - -// Stream ciphers -#include "arc4.h" -#include "seal.h" -#include "wake.h" -#include "chacha.h" -#include "salsa.h" -#include "rabbit.h" -#include "hc128.h" -#include "hc256.h" -#include "panama.h" -#include "sosemanuk.h" - -// Block for CMAC -#include "aes.h" -#include "des.h" - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -USING_NAMESPACE(CryptoPP) - -// MAC ciphers -void RegisterFactories2() -{ - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor(); - RegisterDefaultFactoryFor >(); - RegisterDefaultFactoryFor >(); -} - -// Stream ciphers -void RegisterFactories3() -{ - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); - RegisterSymmetricCipherDefaultFactories(); -} diff --git a/vendor/cryptopp/regtest3.cpp b/vendor/cryptopp/regtest3.cpp deleted file mode 100644 index f1370c8e6d..0000000000 --- a/vendor/cryptopp/regtest3.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// regtest3.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. A second split occurred in July 2018. - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "factory.h" -#include "bench.h" -#include "cpu.h" - -#include "modes.h" -#include "aria.h" -#include "seed.h" -#include "hight.h" -#include "camellia.h" -#include "shacal2.h" -#include "tea.h" -#include "aes.h" -#include "tiger.h" -#include "ccm.h" -#include "gcm.h" -#include "eax.h" -#include "xts.h" -#include "twofish.h" -#include "serpent.h" -#include "cast.h" -#include "rc6.h" -#include "mars.h" -#include "kalyna.h" -#include "threefish.h" -#include "cham.h" -#include "lea.h" -#include "simeck.h" -#include "simon.h" -#include "speck.h" -#include "sm4.h" -#include "des.h" -#include "idea.h" -#include "rc5.h" -#include "skipjack.h" -#include "blowfish.h" -#include "chachapoly.h" - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -USING_NAMESPACE(CryptoPP) - -// Shared key ciphers -void RegisterFactories4() -{ - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - - RegisterAuthenticatedSymmetricCipherDefaultFactories >(); - RegisterAuthenticatedSymmetricCipherDefaultFactories >(); - RegisterAuthenticatedSymmetricCipherDefaultFactories >(); - RegisterAuthenticatedSymmetricCipherDefaultFactories(); - RegisterAuthenticatedSymmetricCipherDefaultFactories(); - - RegisterSymmetricCipherDefaultFactories >(); // For test vectors - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - RegisterSymmetricCipherDefaultFactories >(); - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks - - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Test Vectors - RegisterSymmetricCipherDefaultFactories >(); // Benchmarks -} diff --git a/vendor/cryptopp/regtest4.cpp b/vendor/cryptopp/regtest4.cpp deleted file mode 100644 index c4637f0f68..0000000000 --- a/vendor/cryptopp/regtest4.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// regtest4.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. A second split occurred in July 2018. - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "factory.h" -#include "bench.h" -#include "cpu.h" - -#include "dh.h" -#include "nr.h" -#include "rw.h" -#include "rsa.h" -#include "dsa.h" -#include "pssr.h" -#include "esign.h" - -// Hashes -#include "md2.h" -#include "md5.h" -#include "sha.h" - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -USING_NAMESPACE(CryptoPP) - -void RegisterFactories5() -{ - RegisterDefaultFactoryFor(); - RegisterAsymmetricCipherDefaultFactories > >("RSA/OAEP-MGF1(SHA-1)"); - RegisterAsymmetricCipherDefaultFactories >("DLIES(NoCofactorMultiplication, KDF2(SHA-1), XOR, HMAC(SHA-1), DHAES)"); - RegisterSignatureSchemeDefaultFactories(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >(); - RegisterSignatureSchemeDefaultFactories >("NR(1363)/EMSA1(SHA-1)"); - RegisterSignatureSchemeDefaultFactories >("DSA-1363/EMSA1(SHA-1)"); - RegisterSignatureSchemeDefaultFactories >("RSA/PKCS1-1.5(MD2)"); - RegisterSignatureSchemeDefaultFactories >("RSA/PKCS1-1.5(SHA-1)"); - RegisterSignatureSchemeDefaultFactories >("ESIGN/EMSA5-MGF1(SHA-1)"); - RegisterSignatureSchemeDefaultFactories >("RW/EMSA2(SHA-1)"); - RegisterSignatureSchemeDefaultFactories >("RSA/PSS-MGF1(SHA-1)"); -} diff --git a/vendor/cryptopp/test.cpp b/vendor/cryptopp/test.cpp deleted file mode 100644 index 22286f2e15..0000000000 --- a/vendor/cryptopp/test.cpp +++ /dev/null @@ -1,1098 +0,0 @@ -// test.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 -// scoped_main added to CryptoPP::Test namespace by JW in July 2017 -// Also see http://github.com/weidai11/cryptopp/issues/447 - -#define CRYPTOPP_DEFAULT_NO_DLL -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "dll.h" -#include "cryptlib.h" -#include "aes.h" -#include "filters.h" -#include "md5.h" -#include "ripemd.h" -#include "rng.h" -#include "gzip.h" -#include "default.h" -#include "randpool.h" -#include "ida.h" -#include "base64.h" -#include "factory.h" -#include "whrlpool.h" -#include "tiger.h" -#include "smartptr.h" -#include "pkcspad.h" -#include "stdcpp.h" -#include "osrng.h" -#include "ossig.h" -#include "trap.h" - -#include "validate.h" -#include "bench.h" - -#include -#include -#include -#include -#include - -#ifdef CRYPTOPP_WIN32_AVAILABLE -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_BSD_AVAILABLE) -#include -#include -#include -#define UNIX_PATH_FAMILY 1 -#endif - -#if defined(CRYPTOPP_OSX_AVAILABLE) -#include -#include -#include -#include -#define UNIX_PATH_FAMILY 1 -#endif - -#if (CRYPTOPP_MSC_VERSION >= 1000) -#include // for the debug heap -#endif - -#if defined(__MWERKS__) && defined(macintosh) -#include -#endif - -#ifdef _OPENMP -# include -#endif - -#ifdef __BORLANDC__ -#pragma comment(lib, "cryptlib_bds.lib") -#endif - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -// If CRYPTOPP_USE_AES_GENERATOR is 1 then AES/OFB based is used. -// Otherwise the OS random number generator is used. -#define CRYPTOPP_USE_AES_GENERATOR 1 - -// Global namespace, provided by other source files -void FIPS140_SampleApplication(); -void RegisterFactories(CryptoPP::Test::TestClass suites); -int (*AdhocTest)(int argc, char *argv[]) = NULLPTR; - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -const int MAX_PHRASE_LENGTH = 250; -const int GLOBAL_SEED_LENGTH = 16; -std::string g_argvPathHint=""; - -void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed); -std::string RSAEncryptString(const char *pubFilename, const char *seed, const char *message); -std::string RSADecryptString(const char *privFilename, const char *ciphertext); -void RSASignFile(const char *privFilename, const char *messageFilename, const char *signatureFilename); -bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const char *signatureFilename); - -void DigestFile(const char *file); -void HmacFile(const char *hexKey, const char *file); - -void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile); - -std::string EncryptString(const char *plaintext, const char *passPhrase); -std::string DecryptString(const char *ciphertext, const char *passPhrase); - -void EncryptFile(const char *in, const char *out, const char *passPhrase); -void DecryptFile(const char *in, const char *out, const char *passPhrase); - -void SecretShareFile(int threshold, int nShares, const char *filename, const char *seed); -void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames); - -void InformationDisperseFile(int threshold, int nShares, const char *filename); -void InformationRecoverFile(int threshold, const char *outFilename, char *const *inFilenames); - -void GzipFile(const char *in, const char *out, int deflate_level); -void GunzipFile(const char *in, const char *out); - -void Base64Encode(const char *infile, const char *outfile); -void Base64Decode(const char *infile, const char *outfile); -void HexEncode(const char *infile, const char *outfile); -void HexDecode(const char *infile, const char *outfile); - -void FIPS140_GenerateRandomFiles(); - -bool Validate(int, bool); -bool SetGlobalSeed(int argc, char* argv[], std::string& seed); -void SetArgvPathHint(const char* argv0, std::string& pathHint); - -ANONYMOUS_NAMESPACE_BEGIN -#if (CRYPTOPP_USE_AES_GENERATOR) -OFB_Mode::Encryption s_globalRNG; -#else -NonblockingRng s_globalRNG; -#endif -NAMESPACE_END - -RandomNumberGenerator & GlobalRNG() -{ - return dynamic_cast(s_globalRNG); -} - -// Global seed used for the self tests -std::string s_globalSeed; -void PrintSeedAndThreads(); - -// See misc.h and trap.h for comments and usage -#if defined(CRYPTOPP_DEBUG) && defined(UNIX_SIGNALS_AVAILABLE) -static const SignalHandler s_dummyHandler; -// static const DebugTrapHandler s_dummyHandler; -#endif - -int scoped_main(int argc, char *argv[]) -{ -#ifdef _CRTDBG_LEAK_CHECK_DF - // Turn on leak-checking - int tempflag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); - tempflag |= _CRTDBG_LEAK_CHECK_DF; - _CrtSetDbgFlag( tempflag ); -#endif - -#ifdef _SUNPRO_CC - // No need for thread safety for the test program - cout.set_safe_flag(stream_MT::unsafe_object); - cin.set_safe_flag(stream_MT::unsafe_object); -#endif - - try - { - RegisterFactories(All); - - // A hint to help locate TestData/ and TestVectors/ after install. - SetArgvPathHint(argv[0], g_argvPathHint); - - // Set a seed for reproducible results. If the seed is too short then - // it is padded with spaces. If the seed is missing then time() is used. - // For example: - // ./cryptest.exe v seed=abcdefg - SetGlobalSeed(argc, argv, s_globalSeed); - -#if (CRYPTOPP_USE_AES_GENERATOR) - // Fetch the SymmetricCipher interface, not the RandomNumberGenerator - // interface, to key the underlying cipher. If CRYPTOPP_USE_AES_GENERATOR is 1 - // then AES/OFB based is used. Otherwise the OS random number generator is used. - SymmetricCipher& cipher = dynamic_cast(GlobalRNG()); - cipher.SetKeyWithIV((byte *)s_globalSeed.data(), s_globalSeed.size(), (byte *)s_globalSeed.data()); -#endif - - std::string command, executableName, macFilename; - - if (argc < 2) - command = "X-help"; - else - command = argv[1]; - - if (command == "g") - { - char thisSeed[1024], privFilename[128], pubFilename[128]; - unsigned int keyLength; - - std::cout << "Key length in bits: "; - std::cin >> keyLength; - - std::cout << "\nSave private key to file: "; - std::cin >> privFilename; - - std::cout << "\nSave public key to file: "; - std::cin >> pubFilename; - - std::cout << "\nRandom Seed: "; - std::ws(std::cin); - std::cin.getline(thisSeed, 1024); - - GenerateRSAKey(keyLength, privFilename, pubFilename, thisSeed); - } - else if (command == "rs") - RSASignFile(argv[2], argv[3], argv[4]); - else if (command == "rv") - { - bool verified = RSAVerifyFile(argv[2], argv[3], argv[4]); - std::cout << (verified ? "valid signature" : "invalid signature") << std::endl; - } - else if (command == "r") - { - char privFilename[128], pubFilename[128]; - char thisSeed[1024], message[1024]; - - std::cout << "Private key file: "; - std::cin >> privFilename; - - std::cout << "\nPublic key file: "; - std::cin >> pubFilename; - - std::cout << "\nRandom Seed: "; - std::ws(std::cin); - std::cin.getline(thisSeed, 1024); - - std::cout << "\nMessage: "; - std::cin.getline(message, 1024); - - std::string ciphertext = RSAEncryptString(pubFilename, thisSeed, message); - std::cout << "\nCiphertext: " << ciphertext << std::endl; - - std::string decrypted = RSADecryptString(privFilename, ciphertext.c_str()); - std::cout << "\nDecrypted: " << decrypted << std::endl; - } - else if (command == "mt") - { - MaurerRandomnessTest mt; - FileStore fs(argv[2]); - fs.TransferAllTo(mt); - std::cout << "Maurer Test Value: " << mt.GetTestValue() << std::endl; - } - else if (command == "mac_dll") - { - std::string fname(argv[2] ? argv[2] : ""); - - // sanity check on file size - std::fstream dllFile(fname.c_str(), std::ios::in | std::ios::out | std::ios::binary); - if (!dllFile.good()) - { - std::cerr << "Failed to open file \"" << fname << "\"\n"; - return 1; - } - - std::ifstream::pos_type fileEnd = dllFile.seekg(0, std::ios_base::end).tellg(); - if (fileEnd > 20*1000*1000) - { - std::cerr << "Input file " << fname << " is too large"; - std::cerr << "(size is " << fileEnd << ").\n"; - return 1; - } - - // read file into memory - unsigned int fileSize = (unsigned int)fileEnd; - SecByteBlock buf(fileSize); - dllFile.seekg(0, std::ios_base::beg); - dllFile.read((char *)buf.begin(), fileSize); - - // find positions of relevant sections in the file, based on version 8 of documentation from http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx - word32 coffPos = *(word16 *)(void *)(buf+0x3c); - word32 optionalHeaderPos = coffPos + 24; - word16 optionalHeaderMagic = *(word16 *)(void *)(buf+optionalHeaderPos); - if (optionalHeaderMagic != 0x10b && optionalHeaderMagic != 0x20b) - { - std::cerr << "Target file is not a PE32 or PE32+ image.\n"; - return 3; - } - word32 checksumPos = optionalHeaderPos + 64; - word32 certificateTableDirectoryPos = optionalHeaderPos + (optionalHeaderMagic == 0x10b ? 128 : 144); - word32 certificateTablePos = *(word32 *)(void *)(buf+certificateTableDirectoryPos); - word32 certificateTableSize = *(word32 *)(void *)(buf+certificateTableDirectoryPos+4); - if (certificateTableSize != 0) - std::cerr << "Warning: certificate table (IMAGE_DIRECTORY_ENTRY_SECURITY) of target image is not empty.\n"; - - // find where to place computed MAC - byte mac[] = CRYPTOPP_DUMMY_DLL_MAC; - byte *found = std::search(buf.begin(), buf.end(), mac+0, mac+sizeof(mac)); - if (found == buf.end()) - { - std::cerr << "MAC placeholder not found. The MAC may already be placed.\n"; - return 2; - } - word32 macPos = (unsigned int)(found-buf.begin()); - - // compute MAC - member_ptr pMac(NewIntegrityCheckingMAC()); - CRYPTOPP_ASSERT(pMac->DigestSize() == sizeof(mac)); - MeterFilter f(new HashFilter(*pMac, new ArraySink(mac, sizeof(mac)))); - f.AddRangeToSkip(0, checksumPos, 4); - f.AddRangeToSkip(0, certificateTableDirectoryPos, 8); - f.AddRangeToSkip(0, macPos, sizeof(mac)); - f.AddRangeToSkip(0, certificateTablePos, certificateTableSize); - f.PutMessageEnd(buf.begin(), buf.size()); - - // Encode MAC - std::string hexMac; - HexEncoder encoder; - encoder.Put(mac, sizeof(mac)), encoder.MessageEnd(); - hexMac.resize(static_cast(encoder.MaxRetrievable())); - encoder.Get(reinterpret_cast(&hexMac[0]), hexMac.size()); - - // Report MAC and location - std::cout << "Placing MAC " << hexMac << " in " << fname << " at file offset " << macPos; - std::cout << " (0x" << std::hex << macPos << std::dec << ").\n"; - - // place MAC - dllFile.seekg(macPos, std::ios_base::beg); - dllFile.write((char *)mac, sizeof(mac)); - } - else if (command == "m") - DigestFile(argv[2]); - else if (command == "tv") - { - // TestDataFile() adds CRYPTOPP_DATA_DIR as required - std::string fname = (argv[2] ? argv[2] : "all"); - if (fname.find(".txt") == std::string::npos) - fname += ".txt"; - if (fname.find("TestVectors") == std::string::npos) - fname = "TestVectors/" + fname; - - PrintSeedAndThreads(); - return !RunTestDataFile(fname.c_str()); - } - else if (command == "t") - { - // VC60 workaround: use char array instead of std::string to workaround MSVC's getline bug - char passPhrase[MAX_PHRASE_LENGTH], plaintext[1024]; - - std::cout << "Passphrase: "; - std::cin.getline(passPhrase, MAX_PHRASE_LENGTH); - - std::cout << "\nPlaintext: "; - std::cin.getline(plaintext, sizeof(plaintext)); - - std::string ciphertext = EncryptString(plaintext, passPhrase); - std::cout << "\nCiphertext: " << ciphertext << std::endl; - - std::string decrypted = DecryptString(ciphertext.c_str(), passPhrase); - std::cout << "\nDecrypted: " << decrypted << std::endl; - - return 0; - } - else if (command == "e64") - Base64Encode(argv[2], argv[3]); - else if (command == "d64") - Base64Decode(argv[2], argv[3]); - else if (command == "e16") - HexEncode(argv[2], argv[3]); - else if (command == "d16") - HexDecode(argv[2], argv[3]); - else if (command == "e" || command == "d") - { - char passPhrase[MAX_PHRASE_LENGTH]; - std::cout << "Passphrase: "; - std::cin.getline(passPhrase, MAX_PHRASE_LENGTH); - if (command == "e") - EncryptFile(argv[2], argv[3], passPhrase); - else - DecryptFile(argv[2], argv[3], passPhrase); - } - else if (command == "ss") - { - char thisSeed[1024]; - std::cout << "\nRandom Seed: "; - std::ws(std::cin); - std::cin.getline(thisSeed, sizeof(thisSeed)); - SecretShareFile(StringToValue(argv[2]), StringToValue(argv[3]), argv[4], thisSeed); - } - else if (command == "sr") - SecretRecoverFile(argc-3, argv[2], argv+3); - else if (command == "id") - InformationDisperseFile(StringToValue(argv[2]), StringToValue(argv[3]), argv[4]); - else if (command == "ir") - InformationRecoverFile(argc-3, argv[2], argv+3); - else if (command == "v" || command == "vv") - { - int testNumber = argc>2 ? StringToValue(argv[2]) : 0; - return Validate(testNumber, command == "vv" /*thorough*/) ? 0 : 1; - } - else if (command.substr(0,1) == "b") // "b", "b1", "b2", ... - BenchmarkWithCommand(argc, argv); - else if (command == "z") - GzipFile(argv[3], argv[4], argv[2][0]-'0'); - else if (command == "u") - GunzipFile(argv[2], argv[3]); - else if (command == "fips") - FIPS140_SampleApplication(); - else if (command == "fips-rand") - FIPS140_GenerateRandomFiles(); - else if (command == "a") - { - if (AdhocTest) - return (*AdhocTest)(argc, argv); - else - { - std::cerr << "AdhocTest not defined.\n"; - return 1; - } - } - else if (command == "hmac") - HmacFile(argv[2], argv[3]); - else if (command == "ae") - AES_CTR_Encrypt(argv[2], argv[3], argv[4], argv[5]); - else if (command == "h" || command == "X-help") - { - FileSource usage(DataDir("TestData/usage.dat").c_str(), true, new FileSink(std::cout)); - return command == "h" ? 0 : 1; - } - else if (command == "V") - { - std::cout << CRYPTOPP_VERSION / 100 << '.' << (CRYPTOPP_VERSION % 100) / 10 << '.' << CRYPTOPP_VERSION % 10 << std::endl; - } - else - { - std::cerr << "Unrecognized command. Run \"cryptest h\" to obtain usage information.\n"; - return 1; - } - return 0; - } - catch(const Exception &e) - { - std::cout << "\nException caught: " << e.what() << std::endl; - return -1; - } - catch(const std::exception &e) - { - std::cout << "\nstd::exception caught: " << e.what() << std::endl; - return -2; - } -} // main() - -bool SetGlobalSeed(int argc, char* argv[], std::string& seed) -{ - bool ret = false; - - for (int i=0; i::Signer priv(privFile); - FileSource f(messageFilename, true, new SignerFilter(GlobalRNG(), priv, new HexEncoder(new FileSink(signatureFilename)))); -} - -bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const char *signatureFilename) -{ - FileSource pubFile(pubFilename, true, new HexDecoder); - RSASS::Verifier pub(pubFile); - - FileSource signatureFile(signatureFilename, true, new HexDecoder); - if (signatureFile.MaxRetrievable() != pub.SignatureLength()) - return false; - SecByteBlock signature(pub.SignatureLength()); - signatureFile.Get(signature, signature.size()); - - SignatureVerificationFilter *verifierFilter = new SignatureVerificationFilter(pub); - verifierFilter->Put(signature, pub.SignatureLength()); - FileSource f(messageFilename, true, verifierFilter); - - return verifierFilter->GetLastResult(); -} - -void DigestFile(const char *filename) -{ - SHA1 sha; - RIPEMD160 ripemd; - SHA256 sha256; - Tiger tiger; - SHA512 sha512; - Whirlpool whirlpool; - - vector_member_ptrs filters(6); - filters[0].reset(new HashFilter(sha)); - filters[1].reset(new HashFilter(ripemd)); - filters[2].reset(new HashFilter(tiger)); - filters[3].reset(new HashFilter(sha256)); - filters[4].reset(new HashFilter(sha512)); - filters[5].reset(new HashFilter(whirlpool)); - - member_ptr channelSwitch(new ChannelSwitch); - size_t i; - for (i=0; iAddDefaultRoute(*filters[i]); - FileSource(filename, true, channelSwitch.release()); - - HexEncoder encoder(new FileSink(std::cout), false); - for (i=0; iAlgorithmName() << ": "; - filters[i]->TransferTo(encoder); - std::cout << "\n"; - } -} - -void HmacFile(const char *hexKey, const char *file) -{ - member_ptr mac; - if (strcmp(hexKey, "selftest") == 0) - { - std::cerr << "Computing HMAC/SHA1 value for self test.\n"; - mac.reset(NewIntegrityCheckingMAC()); - } - else - { - std::string decodedKey; - StringSource(hexKey, true, new HexDecoder(new StringSink(decodedKey))); - mac.reset(new HMAC((const byte *)decodedKey.data(), decodedKey.size())); - } - FileSource(file, true, new HashFilter(*mac, new HexEncoder(new FileSink(std::cout)))); -} - -void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile) -{ - SecByteBlock key = HexDecodeString(hexKey); - SecByteBlock iv = HexDecodeString(hexIV); - CTR_Mode::Encryption aes(key, key.size(), iv); - FileSource(infile, true, new StreamTransformationFilter(aes, new FileSink(outfile))); -} - -std::string EncryptString(const char *instr, const char *passPhrase) -{ - std::string outstr; - - DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder(new StringSink(outstr))); - encryptor.Put((byte *)instr, strlen(instr)); - encryptor.MessageEnd(); - - return outstr; -} - -std::string DecryptString(const char *instr, const char *passPhrase) -{ - std::string outstr; - - HexDecoder decryptor(new DefaultDecryptorWithMAC(passPhrase, new StringSink(outstr))); - decryptor.Put((byte *)instr, strlen(instr)); - decryptor.MessageEnd(); - - return outstr; -} - -void EncryptFile(const char *in, const char *out, const char *passPhrase) -{ - FileSource f(in, true, new DefaultEncryptorWithMAC(passPhrase, new FileSink(out))); -} - -void DecryptFile(const char *in, const char *out, const char *passPhrase) -{ - FileSource f(in, true, new DefaultDecryptorWithMAC(passPhrase, new FileSink(out))); -} - -void SecretShareFile(int threshold, int nShares, const char *filename, const char *seed) -{ - CRYPTOPP_ASSERT(nShares >= 1 && nShares<=1000); - if (nShares < 1 || nShares > 1000) - throw InvalidArgument("SecretShareFile: " + IntToString(nShares) + " is not in range [1, 1000]"); - - RandomPool rng; - rng.IncorporateEntropy((byte *)seed, strlen(seed)); - - ChannelSwitch *channelSwitch = NULLPTR; - FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch)); - - // Be careful of the type of Sink used. An ArraySink will stop writing data once the array - // is full. Also see http://groups.google.com/forum/#!topic/cryptopp-users/XEKKLCEFH3Y. - vector_member_ptrs fileSinks(nShares); - std::string channel; - for (int i=0; i(i); - fileSinks[i]->Put((const byte *)channel.data(), 4); - channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL); - } - - source.PumpAll(); -} - -void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) -{ - CRYPTOPP_ASSERT(threshold >= 1 && threshold <=1000); - if (threshold < 1 || threshold > 1000) - throw InvalidArgument("SecretRecoverFile: " + IntToString(threshold) + " is not in range [1, 1000]"); - - SecretRecovery recovery(threshold, new FileSink(outFilename)); - - vector_member_ptrs fileSources(threshold); - SecByteBlock channel(4); - int i; - for (i=0; iPump(4); - fileSources[i]->Get(channel, 4); - fileSources[i]->Attach(new ChannelSwitch(recovery, std::string((char *)channel.begin(), 4))); - } - - while (fileSources[0]->Pump(256)) - for (i=1; iPump(256); - - for (i=0; iPumpAll(); -} - -void InformationDisperseFile(int threshold, int nShares, const char *filename) -{ - CRYPTOPP_ASSERT(threshold >= 1 && threshold <=1000); - if (threshold < 1 || threshold > 1000) - throw InvalidArgument("InformationDisperseFile: " + IntToString(nShares) + " is not in range [1, 1000]"); - - ChannelSwitch *channelSwitch = NULLPTR; - FileSource source(filename, false, new InformationDispersal(threshold, nShares, channelSwitch = new ChannelSwitch)); - - // Be careful of the type of Sink used. An ArraySink will stop writing data once the array - // is full. Also see http://groups.google.com/forum/#!topic/cryptopp-users/XEKKLCEFH3Y. - vector_member_ptrs fileSinks(nShares); - std::string channel; - for (int i=0; i(i); - fileSinks[i]->Put((const byte *)channel.data(), 4); - channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL); - } - - source.PumpAll(); -} - -void InformationRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) -{ - CRYPTOPP_ASSERT(threshold<=1000); - if (threshold < 1 || threshold > 1000) - throw InvalidArgument("InformationRecoverFile: " + IntToString(threshold) + " is not in range [1, 1000]"); - - InformationRecovery recovery(threshold, new FileSink(outFilename)); - - vector_member_ptrs fileSources(threshold); - SecByteBlock channel(4); - int i; - for (i=0; iPump(4); - fileSources[i]->Get(channel, 4); - fileSources[i]->Attach(new ChannelSwitch(recovery, std::string((char *)channel.begin(), 4))); - } - - while (fileSources[0]->Pump(256)) - for (i=1; iPump(256); - - for (i=0; iPumpAll(); -} - -void GzipFile(const char *in, const char *out, int deflate_level) -{ -// FileSource(in, true, new Gzip(new FileSink(out), deflate_level)); - - // use a filter graph to compare decompressed data with original - // - // Source ----> Gzip ------> Sink - // \ | - // \ Gunzip - // \ | - // \ v - // > ComparisonFilter - - EqualityComparisonFilter comparison; - - Gunzip gunzip(new ChannelSwitch(comparison, "0")); - gunzip.SetAutoSignalPropagation(0); - - FileSink sink(out); - - ChannelSwitch *cs; - Gzip gzip(cs = new ChannelSwitch(sink), deflate_level); - cs->AddDefaultRoute(gunzip); - - cs = new ChannelSwitch(gzip); - cs->AddDefaultRoute(comparison, "1"); - FileSource source(in, true, cs); - - comparison.ChannelMessageSeriesEnd("0"); - comparison.ChannelMessageSeriesEnd("1"); -} - -void GunzipFile(const char *in, const char *out) -{ - FileSource(in, true, new Gunzip(new FileSink(out))); -} - -void Base64Encode(const char *in, const char *out) -{ - FileSource(in, true, new Base64Encoder(new FileSink(out))); -} - -void Base64Decode(const char *in, const char *out) -{ - FileSource(in, true, new Base64Decoder(new FileSink(out))); -} - -void HexEncode(const char *in, const char *out) -{ - FileSource(in, true, new HexEncoder(new FileSink(out))); -} - -void HexDecode(const char *in, const char *out) -{ - FileSource(in, true, new HexDecoder(new FileSink(out))); -} - -bool Validate(int alg, bool thorough) -{ - bool result; - - g_testBegin = ::time(NULLPTR); - PrintSeedAndThreads(); - - // TODO: we need to group these tests like benchmarks... - switch (alg) - { - case 0: result = ValidateAll(thorough); break; - case 1: result = TestSettings(); break; - case 2: result = TestOS_RNG(); break; -// case 3: result = TestSecRandom(); break; - case 4: result = ValidateMD5(); break; - case 5: result = ValidateSHA(); break; - case 6: result = ValidateDES(); break; - case 7: result = ValidateIDEA(); break; - case 8: result = ValidateARC4(); break; - case 9: result = ValidateRC5(); break; - case 10: result = ValidateBlowfish(); break; -// case 11: result = ValidateDiamond2(); break; - case 12: result = ValidateThreeWay(); break; - case 13: result = ValidateBBS(); break; - case 14: result = ValidateDH(); break; - case 15: result = ValidateX25519(); break; - case 16: result = ValidateRSA(); break; - case 17: result = ValidateElGamal(); break; - case 18: result = ValidateDSA(thorough); break; -// case 18: result = ValidateHAVAL(); break; - case 19: result = ValidateSAFER(); break; - case 20: result = ValidateLUC(); break; - case 21: result = ValidateRabin(); break; -// case 22: result = ValidateBlumGoldwasser(); break; - case 23: result = ValidateECP(); break; - case 24: result = ValidateEC2N(); break; -// case 25: result = ValidateMD5MAC(); break; - case 26: result = ValidateGOST(); break; - case 27: result = ValidateTiger(); break; - case 28: result = ValidateRIPEMD(); break; - case 29: result = ValidateHMAC(); break; -// case 30: result = ValidateXMACC(); break; - case 31: result = ValidateSHARK(); break; - case 32: result = ValidateLUC_DH(); break; - case 33: result = ValidateLUC_DL(); break; - case 34: result = ValidateSEAL(); break; - case 35: result = ValidateCAST(); break; - case 36: result = ValidateSquare(); break; - case 37: result = ValidateRC2(); break; - case 38: result = ValidateRC6(); break; - case 39: result = ValidateMARS(); break; - case 40: result = ValidateRW(); break; - case 41: result = ValidateMD2(); break; - case 42: result = ValidateNR(); break; - case 43: result = ValidateMQV(); break; - case 44: result = ValidateRijndael(); break; - case 45: result = ValidateTwofish(); break; - case 46: result = ValidateSerpent(); break; - case 47: result = ValidateCipherModes(); break; - case 48: result = ValidateCRC32(); break; - case 49: result = ValidateCRC32C(); break; - case 50: result = ValidateECDSA(); break; - case 51: result = ValidateECGDSA(thorough); break; - case 52: result = ValidateXTR_DH(); break; - case 53: result = ValidateSKIPJACK(); break; - case 54: result = ValidateSHA2(); break; - case 55: result = ValidatePanama(); break; - case 56: result = ValidateAdler32(); break; - case 57: result = ValidateMD4(); break; - case 58: result = ValidatePBKDF(); break; - case 59: result = ValidateHKDF(); break; - case 60: result = ValidateScrypt(); break; - case 61: result = ValidateESIGN(); break; - case 62: result = ValidateDLIES(); break; - case 63: result = ValidateBaseCode(); break; - case 64: result = ValidateSHACAL2(); break; - case 65: result = ValidateARIA(); break; - case 66: result = ValidateCamellia(); break; - case 67: result = ValidateWhirlpool(); break; - case 68: result = ValidateLSH(); break; - case 69: result = ValidateTTMAC(); break; - case 70: result = ValidateSalsa(); break; - case 71: result = ValidateChaCha(); break; - case 72: result = ValidateChaChaTLS(); break; - case 73: result = ValidateSosemanuk(); break; - case 74: result = ValidateRabbit(); break; - case 75: result = ValidateHC128(); break; - case 76: result = ValidateHC256(); break; - case 80: result = ValidateVMAC(); break; - case 81: result = ValidateCCM(); break; - case 82: result = ValidateGCM(); break; - case 83: result = ValidateXTS(); break; - case 84: result = ValidateCMAC(); break; - case 85: result = ValidateSM3(); break; - case 86: result = ValidateBLAKE2s(); break; - case 87: result = ValidateBLAKE2b(); break; - case 88: result = ValidatePoly1305(); break; - case 89: result = ValidateSipHash(); break; - case 90: result = ValidateHashDRBG(); break; - case 91: result = ValidateHmacDRBG(); break; - case 92: result = ValidateNaCl(); break; - - case 100: result = ValidateCHAM(); break; - case 101: result = ValidateSIMECK(); break; - case 102: result = ValidateSIMON(); break; - case 103: result = ValidateSPECK(); break; - - case 110: result = ValidateSHA3(); break; - case 111: result = ValidateSHAKE(); break; - case 112: result = ValidateSHAKE_XOF(); break; - - case 120: result = ValidateMQV(); break; - case 121: result = ValidateHMQV(); break; - case 122: result = ValidateFHMQV(); break; - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - // http://github.com/weidai11/cryptopp/issues/92 - case 9999: result = TestSecBlock(); break; - // http://github.com/weidai11/cryptopp/issues/64 - case 9998: result = TestPolynomialMod2(); break; - // http://github.com/weidai11/cryptopp/issues/336 - case 9997: result = TestIntegerBitops(); break; - // http://github.com/weidai11/cryptopp/issues/602 - case 9996: result = TestIntegerOps(); break; - // http://github.com/weidai11/cryptopp/issues/360 - case 9995: result = TestRounding(); break; - // http://github.com/weidai11/cryptopp/issues/242 - case 9994: result = TestHuffmanCodes(); break; - // http://github.com/weidai11/cryptopp/issues/346 - case 9993: result = TestASN1Parse(); break; - case 9992: result = TestASN1Functions(); break; - // http://github.com/weidai11/cryptopp/issues/242 - case 9991: result = TestX25519(); break; - // http://github.com/weidai11/cryptopp/issues/346 - case 9990: result = TestEd25519(); break; -# if defined(CRYPTOPP_ALTIVEC_AVAILABLE) - case 9989: result = TestAltivecOps(); break; -# endif -#endif - - default: return false; - } - - g_testEnd = ::time(NULLPTR); - - std::cout << "\nSeed used was " << s_globalSeed; - std::cout << "\nTest started at " << TimeToString(g_testBegin); - std::cout << "\nTest ended at " << TimeToString(g_testEnd) << std::endl; - - return result; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP - -// Microsoft puts a byte in global namespace. Combined with -// a 'using namespace CryptoPP', it causes compile failures. -// Also see http://github.com/weidai11/cryptopp/issues/442 -// and http://github.com/weidai11/cryptopp/issues/447. -int CRYPTOPP_API main(int argc, char *argv[]) -{ - return CryptoPP::Test::scoped_main(argc, argv); -} diff --git a/vendor/cryptopp/validat0.cpp b/vendor/cryptopp/validat0.cpp deleted file mode 100644 index 9e69ee3f4f..0000000000 --- a/vendor/cryptopp/validat0.cpp +++ /dev/null @@ -1,1672 +0,0 @@ -// validat0.cpp - originally written and placed in the public domain by Wei Dai and Jeffrey Walton -// Routines in this source file are only tested in Debug builds. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "asn.h" -#include "gf2n.h" -#include "default.h" -#include "integer.h" -#include "polynomi.h" -#include "channels.h" - -#include "ida.h" -#include "gzip.h" -#include "zlib.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -// Issue 64: "PolynomialMod2::operator<<=", http://github.com/weidai11/cryptopp/issues/64 -bool TestPolynomialMod2() -{ - std::cout << "\nTesting PolynomialMod2 bit operations...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - const unsigned int start = 0; - const unsigned int stop = 4 * WORD_BITS + 1; - - for (unsigned int i = start; i < stop; i++) - { - PolynomialMod2 p(1); - p <<= i; - - Integer n(Integer::One()); - n <<= i; - - std::ostringstream oss1; - oss1 << p; - - std::string str1, str2; - - // str1 needs the commas removed used for grouping - str1 = oss1.str(); - str1.erase(std::remove(str1.begin(), str1.end(), ','), str1.end()); - - // str1 needs the trailing 'b' removed - str1.erase(str1.end() - 1); - - // str2 is fine as-is - str2 = IntToString(n, 2); - - pass1 &= (str1 == str2); - } - - for (unsigned int i = start; i < stop; i++) - { - const word w((word)SIZE_MAX); - - PolynomialMod2 p(w); - p <<= i; - - Integer n(Integer::POSITIVE, static_cast(w)); - n <<= i; - - std::ostringstream oss1; - oss1 << p; - - std::string str1, str2; - - // str1 needs the commas removed used for grouping - str1 = oss1.str(); - str1.erase(std::remove(str1.begin(), str1.end(), ','), str1.end()); - - // str1 needs the trailing 'b' removed - str1.erase(str1.end() - 1); - - // str2 is fine as-is - str2 = IntToString(n, 2); - - pass2 &= (str1 == str2); - } - - RandomNumberGenerator& prng = GlobalRNG(); - for (unsigned int i = start; i < stop; i++) - { - word w; // Cast to lword due to Visual Studio - prng.GenerateBlock((byte*)&w, sizeof(w)); - - PolynomialMod2 p(w); - p <<= i; - - Integer n(Integer::POSITIVE, static_cast(w)); - n <<= i; - - std::ostringstream oss1; - oss1 << p; - - std::string str1, str2; - - // str1 needs the commas removed used for grouping - str1 = oss1.str(); - str1.erase(std::remove(str1.begin(), str1.end(), ','), str1.end()); - - // str1 needs the trailing 'b' removed - str1.erase(str1.end() - 1); - - // str2 is fine as-is - str2 = IntToString(n, 2); - - if (str1 != str2) - { - std::cout << " Oops..." << "\n"; - std::cout << " random: " << std::hex << n << std::dec << "\n"; - std::cout << " str1: " << str1 << "\n"; - std::cout << " str2: " << str2 << "\n"; - } - - pass3 &= (str1 == str2); - } - - std::cout << (!pass1 ? "FAILED" : "passed") << ": " << "1 shifted over range [" << std::dec << start << "," << stop << "]" << "\n"; - std::cout << (!pass2 ? "FAILED" : "passed") << ": " << "0x" << std::hex << word(SIZE_MAX) << std::dec << " shifted over range [" << start << "," << stop << "]" << "\n"; - std::cout << (!pass3 ? "FAILED" : "passed") << ": " << "random values shifted over range [" << std::dec << start << "," << stop << "]" << "\n"; - - return pass1 && pass2 && pass3; -} -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestCompressors() -{ - std::cout << "\nTesting Compressors and Decompressors...\n\n"; - bool fail1 = false, fail2 = false, fail3 = false; - const unsigned int COMP_COUNT = 64; - - try - { - // Gzip uses Adler32 checksums. We expect a failure to happen on occasion. - // If we see more than 2 failures in a run of 128, then we need to investigate. - unsigned int truncatedCount=0; - for (unsigned int i = 0; i= 2) - { - std::cout << "FAILED: Gzip failed to detect a truncated stream\n"; - fail1 = true; - } - } - catch (const Exception&) {} - } - } - catch (const Exception& ex) - { - std::cout << "FAILED: " << ex.what() << "\n"; - fail1 = true; - } - - // ************************************************************** - - // Gzip Filename, Filetime and Comment - try - { - std::string filename = "test.txt"; - std::string comment = "This is a test"; - word32 filetime = GlobalRNG().GenerateWord32(4, 0xffffff); - - AlgorithmParameters params = MakeParameters(Name::FileTime(), (int)filetime) - (Name::FileName(), ConstByteArrayParameter(filename.c_str(), false)) - (Name::Comment(), ConstByteArrayParameter(comment.c_str(), false)); - - std::string src, dest; - unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff); - - RandomNumberSource(GlobalRNG(), len, true, new StringSink(src)); - Gunzip unzip(new StringSink(dest)); - StringSource(src, true, new Gzip(params, new Redirector(unzip))); - - if (filename != unzip.GetFilename()) - throw Exception(Exception::OTHER_ERROR, "Failed to retrieve filename"); - - if (filetime != unzip.GetFiletime()) - throw Exception(Exception::OTHER_ERROR, "Failed to retrieve filetime"); - - if (comment != unzip.GetComment()) - throw Exception(Exception::OTHER_ERROR, "Failed to retrieve comment"); - - std::cout << "passed: filenames, filetimes and comments\n"; - } - catch (const Exception& ex) - { - std::cout << "FAILED: " << ex.what() << "\n"; - } - - // Unzip random data. See if we can induce a crash - for (unsigned int i = 0; i strShares(shares); - vector_member_ptrs strSinks(shares); - std::string channel; - - // ********** Create Shares - for (unsigned int i=0; i(i); - strSinks[i]->Put((const byte *)channel.data(), CHID_LENGTH); - channelSwitch->AddRoute(channel, *strSinks[i], DEFAULT_CHANNEL); - } - source.PumpAll(); - - // ********** Randomize shares - - GlobalRNG().Shuffle(strShares.begin(), strShares.end()); - - // ********** Recover secret - try - { - std::string recovered; - InformationRecovery recovery(threshold, new StringSink(recovered)); - - vector_member_ptrs strSources(threshold); - channel.resize(CHID_LENGTH); - - for (unsigned int i=0; iPump(CHID_LENGTH); - strSources[i]->Get((byte*)&channel[0], CHID_LENGTH); - strSources[i]->Attach(new ChannelSwitch(recovery, channel)); - } - - while (strSources[0]->Pump(256)) - { - for (unsigned int i=1; iPump(256); - } - - for (unsigned int i=0; iPumpAll(); - - fail = (message != recovered); - } - catch (const Exception&) - { - fail = true; - } - - pass &= !fail; - } - - std::cout << (fail ? "FAILED:" : "passed:") << " " << INFORMATION_SHARES << " information dispersals\n"; - - // ********** Secret Sharing **********// - - for (unsigned int shares=3; shares strShares(shares); - vector_member_ptrs strSinks(shares); - std::string channel; - - // ********** Create Shares - for (unsigned int i=0; i(i); - strSinks[i]->Put((const byte *)channel.data(), CHID_LENGTH); - channelSwitch->AddRoute(channel, *strSinks[i], DEFAULT_CHANNEL); - } - source.PumpAll(); - - // ********** Randomize shares - - GlobalRNG().Shuffle(strShares.begin(), strShares.end()); - - // ********** Recover secret - try - { - std::string recovered; - SecretRecovery recovery(threshold, new StringSink(recovered)); - - vector_member_ptrs strSources(threshold); - channel.resize(CHID_LENGTH); - for (unsigned int i=0; iPump(CHID_LENGTH); - strSources[i]->Get((byte*)&channel[0], CHID_LENGTH); - strSources[i]->Attach(new ChannelSwitch(recovery, channel)); - } - - while (strSources[0]->Pump(256)) - { - for (unsigned int i=1; iPump(256); - } - - for (unsigned int i=0; iPumpAll(); - - fail = (message != recovered); - } - catch (const Exception&) - { - fail = true; - } - - pass &= !fail; - } - - std::cout << (fail ? "FAILED:" : "passed:") << " " << SECRET_SHARES << " secret sharings\n"; - - return pass; -} - -bool TestRounding() -{ - std::cout << "\nTesting RoundUpToMultipleOf/RoundDownToMultipleOf...\n\n"; - bool pass=true, fail; - - // ********** byte **********// - try - { - const byte v=0, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, no overflow\n"; - - try - { - const byte v=1, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - fail = (r != b); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, no overflow\n"; - - try - { - const byte v=0x08, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, no overflow\n"; - - try - { - const byte v=0xf7, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - fail = (r != 0xf8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, no overflow\n"; - - try - { - const byte v=0xf8, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - fail = (r != 0xf8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, no overflow\n"; - - try - { - const byte v=0xf9, b=0x08; - byte r=RoundUpToMultipleOf(v, b); - CRYPTOPP_UNUSED(r); - fail = true; - } - catch(const Exception&) - { - fail = false; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, byte, overflow\n"; - - // ********** word16 **********// - try - { - const word16 v=0, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, no overflow\n"; - - try - { - const word16 v=1, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - fail = (r != b); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, no overflow\n"; - - try - { - const word16 v=0x08, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, no overflow\n"; - - try - { - const word16 v=0xfff7, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - fail = (r != 0xfff8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, no overflow\n"; - - try - { - const word16 v=0xfff8, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - fail = (r != 0xfff8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, no overflow\n"; - - try - { - const word16 v=0xfff9, b=0x08; - word16 r=RoundUpToMultipleOf(v, b); - CRYPTOPP_UNUSED(r); - fail = true; - } - catch(const Exception&) - { - fail = false; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word16, overflow\n"; - - // ********** word32 **********// - try - { - const word32 v=0, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, no overflow\n"; - - try - { - const word32 v=1, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - fail = (r != b); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, no overflow\n"; - - try - { - const word32 v=0x08, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, no overflow\n"; - - try - { - const word32 v=0xfffffff7, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - fail = (r != 0xfffffff8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, no overflow\n"; - - try - { - const word32 v=0xfffffff8, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - fail = (r != 0xfffffff8); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, no overflow\n"; - - try - { - const word32 v=0xfffffff9, b=0x08; - word32 r=RoundUpToMultipleOf(v, b); - CRYPTOPP_UNUSED(r); - fail = true; - } - catch(const Exception&) - { - fail = false; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word32, overflow\n"; - - // ********** word64 **********// - try - { - const word64 v=0, b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, no overflow\n"; - - try - { - const word64 v=1, b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - fail = (r != b); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, no overflow\n"; - - try - { - const word64 v=0x08, b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, no overflow\n"; - - try - { - const word64 v=W64LIT(0xffffffffffffff7), b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - fail = (r != W64LIT(0xffffffffffffff8)); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, no overflow\n"; - - try - { - const word64 v=W64LIT(0xffffffffffffff8), b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - fail = (r != W64LIT(0xffffffffffffff8)); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, no overflow\n"; - - try - { - const word64 v=W64LIT(0xfffffffffffffff9), b=0x08; - word64 r=RoundUpToMultipleOf(v, b); - CRYPTOPP_UNUSED(r); - fail = true; - } - catch(const Exception&) - { - fail = false; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word64, overflow\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - // ********** word128 **********// - try - { - const word128 v=0, b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, no overflow\n"; - - try - { - const word128 v=1, b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - fail = (r != b); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, no overflow\n"; - - try - { - const word128 v=0x08, b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - fail = (r != v); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, no overflow\n"; - - try - { - // http://stackoverflow.com/q/31461318/608639 - const word128 h = ((word128)W64LIT(0xffffffffffffffff)) << 64U; - const word128 v = h | (word128)W64LIT(0xfffffffffffffff7), b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - fail = (r != (h | (word128)W64LIT(0xfffffffffffffff8))); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, no overflow\n"; - - try - { - const word128 h = ((word128)W64LIT(0xffffffffffffffff)) << 64U; - const word128 v = h | (word128)W64LIT(0xfffffffffffffff8), b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - fail = (r != (h | (word128)W64LIT(0xfffffffffffffff8))); - } - catch(const Exception&) - { - fail = true; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, no overflow\n"; - - try - { - const word128 h = ((word128)W64LIT(0xffffffffffffffff)) << 64U; - const word128 v = h | (word128)W64LIT(0xfffffffffffffff9), b=0x08; - word128 r=RoundUpToMultipleOf(v, b); - CRYPTOPP_UNUSED(r); - fail = true; - } - catch(const Exception&) - { - fail = false; - } - - pass = !fail && pass; - std::cout << (fail ? "FAILED:" : "passed:") << " RoundUpToMultipleOf, word128, overflow\n"; -#endif - - return pass; -} -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -struct ASN1_TestTuple -{ - ASN1_TestTuple(int tag, int result, const char* data, size_t len) { - m_result = result; - m_tag = tag; - m_data = std::string(data, len); - } - - std::string Name() const { - return Id2String(); - } - - const byte* Data() const { - return ConstBytePtr(m_data); - } - - size_t Size() const { - return BytePtrSize(m_data); - } - - int Tag() const { - return m_tag; - } - - int Result() const { - return m_result; - } - - std::string Id2String() const - { - switch(m_tag) - { - case BIT_STRING: - return "BIT_STRING"; - case OCTET_STRING: - return "OCTET_STRING"; - case INTEGER: - return "INTEGER"; - case UTF8_STRING: - return "UTF8_STRING"; - case PRINTABLE_STRING: - return "PRINTABLE_STRING"; - case IA5_STRING: - return "IA5_STRING"; - default: - return "Unknown"; - } - } - -protected: - std::string m_data; - int m_tag, m_result; -}; - -bool RunASN1TestSet(const ASN1_TestTuple asnTuples[], size_t count) -{ - bool pass=true, fail; - - // Disposition - enum {REJECT=3, ACCEPT=4}; - - for(size_t i=0; i(as2, unused5, byte(INTEGER), 0, W64LIT(0xffffffffffffffff)); - break; - - case UTF8_STRING: case PRINTABLE_STRING: case IA5_STRING: - BERDecodeTextString(as1, unused2, tag); - break; - - default: - BERGeneralDecoder(as1, tag); - break; - } - - fail = thisTest.Result() != ACCEPT; - } - catch(const Exception&) - { - fail = thisTest.Result() != REJECT; - } - - std::cout << (fail ? "FAILED:" : "passed:") << (thisTest.Result() == ACCEPT ? " accept " : " reject "); - std::cout << asnTuples[i].Name() << " " << val << "\n"; - pass = !fail && pass; - } - - return pass; -} - -bool TestASN1Parse() -{ - std::cout << "\nTesting ASN.1 parser...\n\n"; - - bool pass = true; - - // Disposition - enum {REJECT=3, ACCEPT=4}; - - // All the types Crypto++ recognizes. - // "C" is one content octet with value 0x43. - const ASN1_TestTuple bitStrings[] = - { - // The first "\x00" content octet is the "initial octet" representing unused bits. In the - // primitive encoding form, there may be zero, one or more contents after the initial octet. - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x01" "\x00", 3), // definite length, short form, initial octet, zero subsequent octets - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x01" "\x08", 3), // definite length, short form, initial octet, zero subsequent octets - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x02" "\x00" "C", 4), // definite length, short form, expected subsequent octets - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x02" "\x08" "C", 4), // too many unused bits - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x7F" "\x00" "C", 4), // runt or underrun - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x81\x01" "\x00", 4), // definite length, long form, initial octet, zero subsequent octets - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x81\x01" "\x08", 4), // definite length, long form, initial octet, zero subsequent octets - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x81\x02" "\x00" "C", 5), // definite length, long form - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x81\x02" "\x08" "C", 5), // too many unused bits - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x81\xff" "\x00" "C", 5), // runt or underrun - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x82\x00\x02" "\x00" "C", 6), // definite length, long form - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x82\x00\x02" "\x08" "C", 6), // too many unused bits - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x82\xff\xff" "\x00" "C", 6), // runt or underrun - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x83\x00\x00\x02" "\x00" "C", 7), // definite length, long form - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x83\x00\x00\x02" "\x08" "C", 7), // too many unused bits - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x83\xff\xff\xff" "\x00" "C", 7), // runt or underrun - ASN1_TestTuple(BIT_STRING, ACCEPT, "\x03\x84\x00\x00\x00\x02" "\x00" "C", 8), // definite length, long form - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x84\x00\x00\x00\x02" "\x08" "C", 8), // too many unused bits - ASN1_TestTuple(BIT_STRING, REJECT, "\x03\x84\xff\xff\xff\xff" "\x00" "C", 8), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(bitStrings, COUNTOF(bitStrings)) && pass; - - const ASN1_TestTuple octetStrings[] = - { - // In the primitive encoding form, there may be zero, one or more contents. - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x00", 2), // definite length, short form, zero content octets - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x01" "C", 3), // definite length, short form, expected content octets - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x02" "C", 3), // runt or underrun - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x7F" "C", 3), // runt or underrun - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x81\x00", 3), // definite length, long form, zero content octets - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x81\x01" "C", 4), // definite length, long form, expected content octets - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x81\x02" "C", 4), // runt or underrun - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x81\xff" "C", 4), // runt or underrun - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x82\x00\x00", 4), // definite length, long form, zero content octets - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x82\x00\x01" "C", 5), // definite length, long form, expected content octets - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x82\x00\x02" "C", 5), // runt or underrun - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x82\xff\xff" "C", 5), // runt or underrun - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x83\x00\x00\x00", 5), // definite length, long form, zero content octets - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x83\x00\x00\x01" "C", 6), // definite length, long form, expected content octets - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x83\x00\x00\x02" "C", 6), // runt or underrun - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x83\xff\xff\xff" "C", 6), // runt or underrun - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x84\x00\x00\x00\x00", 6), // definite length, long form, zero content octets - ASN1_TestTuple(OCTET_STRING, ACCEPT, "\x04\x84\x00\x00\x00\x01" "C", 7), // definite length, long form, expected content octets - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x84\x00\x00\x00\x02" "C", 7), // runt or underrun - ASN1_TestTuple(OCTET_STRING, REJECT, "\x04\x84\xff\xff\xff\xff" "C", 7), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(octetStrings, COUNTOF(octetStrings)) && pass; - - const ASN1_TestTuple utf8Strings[] = - { - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x00", 2), // definite length, short form, zero content octets - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x01" "C", 3), // definite length, short form, expected content octets - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x02" "C", 3), // runt or underrun - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x7F" "C", 3), // runt or underrun - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x81\x00", 3), // definite length, long form, zero content octets - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x81\x01" "C", 4), // definite length, long form, expected content octets - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x81\x02" "C", 4), // runt or underrun - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x81\xff" "C", 4), // runt or underrun - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x82\x00\x00", 4), // definite length, long form, zero content octets - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x82\x00\x01" "C", 5), // definite length, long form, expected content octets - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x82\x00\x02" "C", 5), // runt or underrun - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x82\xff\xff" "C", 5), // runt or underrun - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x83\x00\x00\x00", 5), // definite length, long form, zero content octets - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x83\x00\x00\x01" "C", 6), // definite length, long form, expected content octets - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x83\x00\x00\x02" "C", 6), // runt or underrun - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x83\xff\xff\xff" "C", 6), // runt or underrun - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x84\x00\x00\x00\x00", 6), // definite length, long form, zero content octets - ASN1_TestTuple(UTF8_STRING, ACCEPT, "\x0c\x84\x00\x00\x00\x01" "C", 7), // definite length, long form, expected content octets - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x84\x00\x00\x00\x02" "C", 7), // runt or underrun - ASN1_TestTuple(UTF8_STRING, REJECT, "\x0c\x84\xff\xff\xff\xff" "C", 7), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(utf8Strings, COUNTOF(utf8Strings)) && pass; - - const ASN1_TestTuple printableStrings[] = - { - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x00", 2), // definite length, short form, zero content octets - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x01" "C", 3), // definite length, short form, expected content octets - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x02" "C", 3), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x7F" "C", 3), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x81\x00", 3), // definite length, long form, zero content octets - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x81\x01" "C", 4), // definite length, long form, expected content octets - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x81\x02" "C", 4), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x81\xff" "C", 4), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x82\x00\x00", 4), // definite length, long form, zero content octets - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x82\x00\x01" "C", 5), // definite length, long form, expected content octets - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x82\x00\x02" "C", 5), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x82\xff\xff" "C", 5), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x83\x00\x00\x00", 5), // definite length, long form, zero content octets - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x83\x00\x00\x01" "C", 6), // definite length, long form, expected content octets - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x83\x00\x00\x02" "C", 6), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x83\xff\xff\xff" "C", 6), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x84\x00\x00\x00\x00", 6), // definite length, long form, zero content octets - ASN1_TestTuple(PRINTABLE_STRING, ACCEPT, "\x13\x84\x00\x00\x00\x01" "C", 7), // definite length, long form, expected content octets - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x84\x00\x00\x00\x02" "C", 7), // runt or underrun - ASN1_TestTuple(PRINTABLE_STRING, REJECT, "\x13\x84\xff\xff\xff\xff" "C", 7), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(printableStrings, COUNTOF(printableStrings)) && pass; - - const ASN1_TestTuple ia5Strings[] = - { - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x00", 2), // definite length, short form, zero content octets - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x01" "C", 3), // definite length, short form, expected content octets - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x02" "C", 3), // runt or underrun - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x7F" "C", 3), // runt or underrun - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x81\x00", 3), // definite length, long form, zero content octets - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x81\x01" "C", 4), // definite length, long form, expected content octets - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x81\x02" "C", 4), // runt or underrun - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x81\xff" "C", 4), // runt or underrun - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x82\x00\x00", 4), // definite length, long form, zero content octets - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x82\x00\x01" "C", 5), // definite length, long form, expected content octets - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x82\x00\x02" "C", 5), // runt or underrun - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x82\xff\xff" "C", 5), // runt or underrun - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x83\x00\x00\x00", 5), // definite length, long form, zero content octets - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x83\x00\x00\x01" "C", 6), // definite length, long form, expected content octets - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x83\x00\x00\x02" "C", 6), // runt or underrun - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x83\xff\xff\xff" "C", 6), // runt or underrun - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x84\x00\x00\x00\x00", 6), // definite length, long form, zero content octets - ASN1_TestTuple(IA5_STRING, ACCEPT, "\x16\x84\x00\x00\x00\x01" "C", 7), // definite length, long form, expected content octets - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x84\x00\x00\x00\x02" "C", 7), // runt or underrun - ASN1_TestTuple(IA5_STRING, REJECT, "\x16\x84\xff\xff\xff\xff" "C", 7), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(ia5Strings, COUNTOF(ia5Strings)) && pass; - - const ASN1_TestTuple integerValues[] = - { - // 8.3.1 The encoding of an integer value shall be primitive. The contents octets shall consist of one or more octets. - ASN1_TestTuple(INTEGER, REJECT, "\x02\x00", 2), // definite length, short form, zero content octets - ASN1_TestTuple(INTEGER, ACCEPT, "\x02\x01" "C", 3), // definite length, short form, expected content octets - ASN1_TestTuple(INTEGER, REJECT, "\x02\x02" "C", 3), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x7F" "C", 3), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x81\x00", 3), // definite length, long form, zero content octets - ASN1_TestTuple(INTEGER, ACCEPT, "\x02\x81\x01" "C", 4), // definite length, long form, expected content octets - ASN1_TestTuple(INTEGER, REJECT, "\x02\x81\x02" "C", 4), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x81\xff" "C", 4), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x82\x00\x00", 4), // definite length, long form, zero content octets - ASN1_TestTuple(INTEGER, ACCEPT, "\x02\x82\x00\x01" "C", 5), // definite length, long form, expected content octets - ASN1_TestTuple(INTEGER, REJECT, "\x02\x82\x00\x02" "C", 5), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x82\xff\xff" "C", 5), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x83\x00\x00\x00", 5), // definite length, long form, zero content octets - ASN1_TestTuple(INTEGER, ACCEPT, "\x02\x83\x00\x00\x01" "C", 6), // definite length, long form, expected content octets - ASN1_TestTuple(INTEGER, REJECT, "\x02\x83\x00\x00\x02" "C", 6), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x83\xff\xff\xff" "C", 6), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x84\x00\x00\x00\x00", 6), // definite length, long form, zero content octets - ASN1_TestTuple(INTEGER, ACCEPT, "\x02\x84\x00\x00\x00\x01" "C", 7), // definite length, long form, expected content octets - ASN1_TestTuple(INTEGER, REJECT, "\x02\x84\x00\x00\x00\x02" "C", 7), // runt or underrun - ASN1_TestTuple(INTEGER, REJECT, "\x02\x84\xff\xff\xff\xff" "C", 7), // <== Issue 346; requires large allocation - }; - - pass = RunASN1TestSet(integerValues, COUNTOF(integerValues)) && pass; - - return pass; -} - -bool TestASN1Functions() -{ - std::cout << "\nTesting ASN.1 functions...\n\n"; - - bool pass = true, fail; - - { - const std::string message = "Now is the time for all good men to come to the aide of their country"; - ByteQueue encoded, reencoded, decoded; - size_t len = 0, rlen = 0; - - len = DEREncodeOctetString(encoded, ConstBytePtr(message), BytePtrSize(message)); - DERReencode(encoded, reencoded); - rlen = (size_t)reencoded.MaxRetrievable(); - (void)BERDecodeOctetString(reencoded, decoded); - - std::string recovered; - StringSink sink(recovered); - decoded.TransferTo(sink); - - fail = (len != rlen || message != recovered); - pass = pass && !fail; - CRYPTOPP_ASSERT(!fail); - - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "DEREncodeOctetString" << "\n"; - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "BERDecodeOctetString" << "\n"; - } - - { - const std::string message = "Now is the time for all good men to come to the aide of their country"; - const byte asnStringTypes[] = { - UTF8_STRING, PRINTABLE_STRING, T61_STRING, VIDEOTEXT_STRING,IA5_STRING, VISIBLE_STRING - }; - - unsigned int failed = 0; - size_t len = 0, rlen = 0, i = 0; - - for (i = 0; i < COUNTOF(asnStringTypes); ++i) - { - ByteQueue encoded, reencoded, decoded; - std::string recovered; - - len = DEREncodeTextString(encoded, ConstBytePtr(message), BytePtrSize(message), asnStringTypes[i]); - DERReencode(encoded, reencoded); - rlen = (size_t)reencoded.MaxRetrievable(); - (void)BERDecodeTextString(reencoded, recovered, asnStringTypes[i]); - - fail = (len != rlen || message != recovered); - if (fail) failed++; - CRYPTOPP_ASSERT(!fail); - } - - failed ? fail = true : fail = false; - pass = pass && !fail; - - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "DEREncodeTextString" << "\n"; - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "DEREncodeTextString" << "\n"; - } - - { - const byte date[] = "Sun, 21 Mar 2021 01:00:00 +0000"; - SecByteBlock message; message.Assign(date, sizeof(date)-1); - const byte asnDateTypes[] = {UTC_TIME, GENERALIZED_TIME}; - unsigned int failed = 0; - size_t i = 0; - - for (i = 0; i < COUNTOF(asnDateTypes); ++i) - { - ByteQueue encoded, decoded; - SecByteBlock recovered; - - (void)DEREncodeDate(encoded, message, asnDateTypes[i]); - (void)BERDecodeDate(encoded, recovered, asnDateTypes[i]); - - fail = (message != recovered); - if (fail) failed++; - CRYPTOPP_ASSERT(!fail); - } - - failed ? fail = true : fail = false; - pass = pass && !fail; - - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "DEREncodeDate" << "\n"; - std::cout << (fail ? "FAILED" : "passed") << " "; - std::cout << "BERDecodeDate" << "\n"; - } - - return pass; -} - -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestStringSink() -{ - try - { - std::string in = "The quick brown fox jumps over the lazy dog"; - - std::string str; - StringSource s1(in, true, new StringSink(str)); - - std::vector vec; - StringSource s2(in, true, new VectorSink(vec)); - - std::vector vec2; - VectorSource s3(vec, true, new VectorSink(vec2)); - - return str.size() == vec.size() && - std::equal(str.begin(), str.end(), vec.begin()) && - vec.size() == vec2.size() && - std::equal(vec.begin(), vec.end(), vec2.begin()); - } - catch(const std::exception&) - { - } - return false; -} -#endif - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat1.cpp b/vendor/cryptopp/validat1.cpp deleted file mode 100644 index 6aa4e60ff8..0000000000 --- a/vendor/cryptopp/validat1.cpp +++ /dev/null @@ -1,1225 +0,0 @@ -// validat1.cpp - originally written and placed in the public domain by Wei Dai and Jeffrey Walton -// Routines in this source file are only tested in Debug builds. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "secblock.h" -#include "gzip.h" -#include "zlib.h" - -#if defined(CRYPTOPP_ALTIVEC_AVAILABLE) -# include "ppc_simd.h" -#endif - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestSecBlock() -{ - std::cout << "\nTesting SecBlock...\n\n"; - - bool pass1=true, pass2=true, pass3=true, pass4=true, pass5=true, pass6=true, pass7=true, temp=false; - - //************ Allocators ************// - - { - std::basic_string, AllocatorWithCleanup > s1; - std::basic_string, AllocatorWithCleanup > s2; - s1.resize(1024); s2.resize(1024); - - std::vector > v1; - std::vector > v2; - v1.resize(1024); v2.resize(1024); - } - - //********** Zeroized block **********// - - { - // NULL ptr with a size means to create a new SecBlock with all elements zero'd - SecByteBlock z1(NULLPTR, 256); - temp = true; - - for (size_t i = 0; i < z1.size(); i++) - temp &= (z1[i] == 0); - - pass1 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Zeroized byte array\n"; - - SecBlock z2(NULLPTR, 256); - temp = true; - - for (size_t i = 0; i < z2.size(); i++) - temp &= (z2[i] == 0); - - pass1 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Zeroized word32 array\n"; - - SecBlock z3(NULLPTR, 256); - temp = true; - - for (size_t i = 0; i < z3.size(); i++) - temp &= (z3[i] == 0); - - pass1 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Zeroized word64 array\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - SecBlock z4(NULLPTR, 256); - temp = true; - - for (size_t i = 0; i < z4.size(); i++) - temp &= (z4[i] == 0); - - pass1 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Zeroized word128 array\n"; -#endif - } - - //********** Non-zero'd block **********// - - { - SecByteBlock z1(NULLPTR, 256); - z1.SetMark(0); - - SecBlock z2(NULLPTR, 256); - z2.SetMark(0); - - SecBlock z3(NULLPTR, 256); - z3.SetMark(0); - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - SecBlock z4(NULLPTR, 256); - z4.SetMark(0); -#endif - } - - //********** Assign **********// - - try - { - SecByteBlock a, b; - temp = true; - - a.Assign((const byte*)"a", 1); - b.Assign((const byte*)"b", 1); - - temp &= (a.SizeInBytes() == 1); - temp &= (b.SizeInBytes() == 1); - temp &= (a[0] == 'a'); - temp &= (b[0] == 'b'); - - a.Assign((const byte*)"ab", 2); - b.Assign((const byte*)"cd", 2); - - temp &= (a.SizeInBytes() == 2); - temp &= (b.SizeInBytes() == 2); - temp &= (a[0] == 'a' && a[1] == 'b'); - temp &= (b[0] == 'c' && b[1] == 'd'); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass2 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Assign byte\n"; - - try - { - SecBlock a, b; - temp = true; - - word32 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - temp &= (a.SizeInBytes() == 4); - temp &= (b.SizeInBytes() == 4); - temp &= (a[0] == 1); - temp &= (b[0] == 2); - - word32 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - temp &= (a.SizeInBytes() == 8); - temp &= (b.SizeInBytes() == 8); - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass2 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Assign word32\n"; - - try - { - SecBlock a, b; - temp = true; - - word64 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - temp &= (a.SizeInBytes() == 8); - temp &= (b.SizeInBytes() == 8); - temp &= (a[0] == 1); - temp &= (b[0] == 2); - - word64 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - temp &= (a.SizeInBytes() == 16); - temp &= (b.SizeInBytes() == 16); - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass2 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Assign word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - try - { - SecBlock a, b; - temp = true; - - word128 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - temp &= (a.SizeInBytes() == 16); - temp &= (b.SizeInBytes() == 16); - temp &= (a[0] == 1); - temp &= (b[0] == 2); - - word128 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - temp &= (a.SizeInBytes() == 32); - temp &= (b.SizeInBytes() == 32); - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass2 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Assign word128\n"; -#endif - - //********** Append **********// - - try - { - SecByteBlock a, b; - temp = true; - - a.Assign((const byte*)"a", 1); - b.Assign((const byte*)"b", 1); - - a += b; - temp &= (a.SizeInBytes() == 2); - temp &= (a[0] == 'a' && a[1] == 'b'); - - a.Assign((const byte*)"ab", 2); - b.Assign((const byte*)"cd", 2); - - a += b; - temp &= (a.SizeInBytes() == 4); - temp &= (a[0] == 'a' && a[1] == 'b' && a[2] == 'c' && a[3] == 'd'); - - a.Assign((const byte*)"a", 1); - - a += a; - temp &= (a.SizeInBytes() == 2); - temp &= (a[0] == 'a' && a[1] == 'a'); - - a.Assign((const byte*)"ab", 2); - - a += a; - temp &= (a.SizeInBytes() == 4); - temp &= (a[0] == 'a' && a[1] == 'b' && a[2] == 'a' && a[3] == 'b'); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass3 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Append byte\n"; - - try - { - SecBlock a, b; - temp = true; - - const word32 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - a += b; - temp &= (a.SizeInBytes() == 8); - temp &= (a[0] == 1 && a[1] == 2); - - const word32 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - a += b; - temp &= (a.SizeInBytes() == 16); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4); - - a.Assign(one, 1); - - a += a; - temp &= (a.SizeInBytes() == 8); - temp &= (a[0] == 1 && a[1] == 1); - - a.Assign(three, 2); - - a += a; - temp &= (a.SizeInBytes() == 16); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass3 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Append word32\n"; - - try - { - SecBlock a, b; - temp = true; - - const word64 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - a += b; - temp &= (a.SizeInBytes() == 16); - temp &= (a[0] == 1 && a[1] == 2); - - const word64 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - a += b; - temp &= (a.SizeInBytes() == 32); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4); - - a.Assign(one, 1); - - a += a; - temp &= (a.SizeInBytes() == 16); - temp &= (a[0] == 1 && a[1] == 1); - - a.Assign(three, 2); - - a += a; - temp &= (a.SizeInBytes() == 32); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass3 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Append word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - try - { - SecBlock a, b; - temp = true; - - const word128 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - a += b; - temp &= (a.SizeInBytes() == 32); - temp &= (a[0] == 1 && a[1] == 2); - - const word128 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - a += b; - temp &= (a.SizeInBytes() == 64); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4); - - a.Assign(one, 1); - - a += a; - temp &= (a.SizeInBytes() == 32); - temp &= (a[0] == 1 && a[1] == 1); - - a.Assign(three, 2); - - a += a; - temp &= (a.SizeInBytes() == 64); - temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass3 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Append word128\n"; -#endif - - //********** Concatenate **********// - - // byte - try - { - SecByteBlock a, b, c; - temp = true; - - a.Assign((const byte*)"a", 1); - b.Assign((const byte*)"b", 1); - - c = a + b; - temp &= (a[0] == 'a'); - temp &= (b[0] == 'b'); - temp &= (c.SizeInBytes() == 2); - temp &= (c[0] == 'a' && c[1] == 'b'); - - a.Assign((const byte*)"ab", 2); - b.Assign((const byte*)"cd", 2); - - c = a + b; - temp &= (a[0] == 'a' && a[1] == 'b'); - temp &= (b[0] == 'c' && b[1] == 'd'); - temp &= (c.SizeInBytes() == 4); - temp &= (c[0] == 'a' && c[1] == 'b' && c[2] == 'c' && c[3] == 'd'); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass4 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Concatenate byte\n"; - - // word32 - try - { - SecBlock a, b, c; - temp = true; - - const word32 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - c = a + b; - temp &= (a[0] == 1); - temp &= (b[0] == 2); - temp &= (c.SizeInBytes() == 8); - temp &= (c[0] == 1 && c[1] == 2); - - const word32 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - c = a + b; - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - temp &= (c.SizeInBytes() == 16); - temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass4 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Concatenate word32\n"; - - // word64 - try - { - SecBlock a, b, c; - temp = true; - - const word64 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - c = a + b; - temp &= (a[0] == 1); - temp &= (b[0] == 2); - temp &= (c.SizeInBytes() == 16); - temp &= (c[0] == 1 && c[1] == 2); - - const word64 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - c = a + b; - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - temp &= (c.SizeInBytes() == 32); - temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass4 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Concatenate word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - try - { - SecBlock a, b, c; - temp = true; - - const word128 one[1] = {1}, two[1] = {2}; - a.Assign(one, 1); - b.Assign(two, 1); - - c = a + b; - temp &= (a[0] == 1); - temp &= (b[0] == 2); - temp &= (c.SizeInBytes() == 32); - temp &= (c[0] == 1 && c[1] == 2); - - const word128 three[2] = {1,2}, four[2] = {3,4}; - a.Assign(three, 2); - b.Assign(four, 2); - - c = a + b; - temp &= (a[0] == 1 && a[1] == 2); - temp &= (b[0] == 3 && b[1] == 4); - temp &= (c.SizeInBytes() == 64); - temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass4 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Concatenate word128\n"; -#endif - - //********** Equality **********// - - // byte - try - { - static const byte str1[] = "abcdefghijklmnopqrstuvwxyz"; - static const byte str2[] = "zyxwvutsrqponmlkjihgfedcba"; - static const byte str3[] = "0123456789"; - - temp = true; - SecByteBlock a,b; - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str1, COUNTOF(str1)); - temp &= (a.operator==(b)); - - a.Assign(str3, COUNTOF(str3)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a == b); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str2, COUNTOF(str2)); - temp &= (a.operator!=(b)); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a != b); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass5 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Equality byte\n"; - - // word32 - try - { - static const word32 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; - static const word32 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2}; - static const word32 str3[] = {0,1,2,3,4,5,6,7,8,9}; - - temp = true; - SecBlock a,b; - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str1, COUNTOF(str1)); - temp &= (a.operator==(b)); - - a.Assign(str3, COUNTOF(str3)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a == b); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str2, COUNTOF(str2)); - temp &= (a.operator!=(b)); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a != b); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass5 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Equality word32\n"; - - // word64 - try - { - static const word64 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; - static const word64 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2}; - static const word64 str3[] = {0,1,2,3,4,5,6,7,8,9}; - - temp = true; - SecBlock a,b; - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str1, COUNTOF(str1)); - temp &= (a.operator==(b)); - - a.Assign(str3, COUNTOF(str3)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a == b); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str2, COUNTOF(str2)); - temp &= (a.operator!=(b)); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a != b); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass5 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Equality word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - // word128 - try - { - static const word128 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; - static const word128 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2}; - static const word128 str3[] = {0,1,2,3,4,5,6,7,8,9}; - - temp = true; - SecBlock a,b; - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str1, COUNTOF(str1)); - temp &= (a.operator==(b)); - - a.Assign(str3, COUNTOF(str3)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a == b); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str2, COUNTOF(str2)); - temp &= (a.operator!=(b)); - - a.Assign(str1, COUNTOF(str1)); - b.Assign(str3, COUNTOF(str3)); - temp &= (a != b); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - - pass5 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Equality word128\n"; -#endif - - //********** Allocator Size/Overflow **********// - - try - { - temp = false; - - AllocatorBase A; - const size_t max = A.max_size(); - SecBlock t(max+1); - } - catch(const Exception& /*ex*/) - { - temp = true; - } - catch(const std::exception& /*ex*/) - { - temp = true; - } - - pass6 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Overflow word32\n"; - - try - { - temp = false; - - AllocatorBase A; - const size_t max = A.max_size(); - SecBlock t(max+1); - } - catch(const Exception& /*ex*/) - { - temp = true; - } - catch(const std::exception& /*ex*/) - { - temp = true; - } - - pass6 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Overflow word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - try - { - temp = false; - - AllocatorBase A; - const size_t max = A.max_size(); - SecBlock t(max+1); - } - catch(const Exception& /*ex*/) - { - temp = true; - } - catch(const std::exception& /*ex*/) - { - temp = true; - } - - pass6 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Overflow word128\n"; -#endif - - //********** FixedSizeAllocatorWithCleanup and Grow **********// - - // byte - try - { - static const unsigned int SIZE = 8; - SecBlockWithHint block(SIZE); - std::memset(block, 0xaa, block.SizeInBytes()); - - temp = true; - block.CleanGrow(SIZE*2); - temp &= (block.size() == SIZE*2); - - for (size_t i = 0; i < block.size()/2; i++) - temp &= (block[i] == 0xaa); - for (size_t i = block.size()/2; i < block.size(); i++) - temp &= (block[i] == 0); - - block.CleanNew(SIZE*4); - temp &= (block.size() == SIZE*4); - for (size_t i = 0; i < block.size(); i++) - temp &= (block[i] == 0); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - catch(const std::exception& /*ex*/) - { - temp = false; - } - - pass7 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " FixedSizeAllocator Grow with byte\n"; - - // word32 - try - { - static const unsigned int SIZE = 8; - SecBlockWithHint block(SIZE); - std::memset(block, 0xaa, block.SizeInBytes()); - - temp = true; - block.CleanGrow(SIZE*2); - temp &= (block.size() == SIZE*2); - - for (size_t i = 0; i < block.size()/2; i++) - temp &= (block[i] == 0xaaaaaaaa); - - for (size_t i = block.size()/2; i < block.size(); i++) - temp &= (block[i] == 0); - - block.CleanNew(SIZE*4); - temp &= (block.size() == SIZE*4); - for (size_t i = 0; i < block.size(); i++) - temp &= (block[i] == 0); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - catch(const std::exception& /*ex*/) - { - temp = false; - } - - pass7 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " FixedSizeAllocator Grow with word32\n"; - - // word64 - try - { - static const unsigned int SIZE = 8; - SecBlockWithHint block(SIZE); - std::memset(block, 0xaa, block.SizeInBytes()); - - temp = true; - block.CleanGrow(SIZE*2); - temp &= (block.size() == SIZE*2); - - for (size_t i = 0; i < block.size()/2; i++) - temp &= (block[i] == W64LIT(0xaaaaaaaaaaaaaaaa)); - - for (size_t i = block.size()/2; i < block.size(); i++) - temp &= (block[i] == 0); - - block.CleanNew(SIZE*4); - temp &= (block.size() == SIZE*4); - for (size_t i = 0; i < block.size(); i++) - temp &= (block[i] == 0); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - catch(const std::exception& /*ex*/) - { - temp = false; - } - - pass7 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " FixedSizeAllocator Grow with word64\n"; - -#if defined(CRYPTOPP_WORD128_AVAILABLE) - // word128 - try - { - static const unsigned int SIZE = 8; - SecBlock > block(SIZE); - std::memset(block, 0xaa, block.SizeInBytes()); - - temp = true; - block.CleanGrow(SIZE*2); - temp &= (block.size() == SIZE*2); - - for (size_t i = 0; i < block.size()/2; i++) - temp &= (block[i] == (((word128)W64LIT(0xaaaaaaaaaaaaaaaa) << 64U) | W64LIT(0xaaaaaaaaaaaaaaaa))); - - for (size_t i = block.size()/2; i < block.size(); i++) - temp &= (block[i] == 0); - - block.CleanNew(SIZE*4); - temp &= (block.size() == SIZE*4); - for (size_t i = 0; i < block.size(); i++) - temp &= (block[i] == 0); - } - catch(const Exception& /*ex*/) - { - temp = false; - } - catch(const std::exception& /*ex*/) - { - temp = false; - } - - pass7 &= temp; - if (!temp) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " FixedSizeAllocator Grow with word128\n"; -#endif - - return pass1 && pass2 && pass3 && pass4 && pass5 && pass6 && pass7; -} -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestHuffmanCodes() -{ - std::cout << "\nTesting Huffman codes...\n\n"; - bool pass=true; - - static const size_t nCodes = 30; - const unsigned int codeCounts[nCodes] = { - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - - static const unsigned int maxCodeBits = nCodes >> 1; - unsigned int codeBits[nCodes] = { - ~0u, ~0u, ~0u, ~0u, ~0u, - ~0u, ~0u, ~0u, ~0u, ~0u, - ~0u, ~0u, ~0u, ~0u, ~0u, - }; - - try - { - HuffmanEncoder::GenerateCodeLengths(codeBits, maxCodeBits, codeCounts, nCodes); - } - catch(const Exception& /*ex*/) - { - pass=false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " GenerateCodeLengths" << std::endl; - - // Try to crash the HuffmanDecoder - for (unsigned int i=0; i<128; ++i) - { - try - { - byte data1[0xfff]; // Place on stack, avoid new - unsigned int data2[0xff]; - - unsigned int len1 = GlobalRNG().GenerateWord32(4, 0xfff); - GlobalRNG().GenerateBlock(data1, len1); - unsigned int len2 = GlobalRNG().GenerateWord32(4, 0xff); - GlobalRNG().GenerateBlock((byte*)data2, len2*sizeof(unsigned int)); - - ArraySource source(data1, len1, false); - HuffmanDecoder decoder(data2, len2); - - LowFirstBitReader reader(source); - unsigned int val; - for (unsigned int j=0; !source.AnyRetrievable(); ++j) - decoder.Decode(reader, val); - } - catch (const Exception&) {} - } - - std::cout << "passed: HuffmanDecoder decode" << std::endl; - - return pass; -} -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -# if defined(CRYPTOPP_ALTIVEC_AVAILABLE) -bool TestAltivecOps() -{ - std::cout << "\nTesting Altivec operations...\n\n"; - - if (HasAltivec() == false) - { - std::cout << "\nAltivec not available, skipping test." << std::endl; - return true; - } - - // These tests may seem superfluous, but we really want to test the - // Altivec/POWER4 implementation. That does not happen when POWER7 - // or POWER8 is available because we use POWER7's unaligned loads - // and stores with POWER8's AES, SHA, etc. These tests enage - // Altivec/POWER4 without POWER7, like on an old PowerMac. - - //********** Unaligned loads and stores **********// - bool pass1=true; - - CRYPTOPP_ALIGN_DATA(16) - byte dest[20], src[20] = {23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4}; - const byte st1[16] = {22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7}; - const byte st2[16] = {21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6}; - const byte st3[16] = {20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5}; - - VecStore(VecLoad(src), dest); - pass1 = (0 == std::memcmp(src, dest, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStore(VecLoad(src+1), dest+1); - pass1 = (0 == std::memcmp(st1, dest+1, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStore(VecLoad(src+2), dest+2); - pass1 = (0 == std::memcmp(st2, dest+2, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStore(VecLoad(src+3), dest+3); - pass1 = (0 == std::memcmp(st3, dest+3, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStoreBE(VecLoadBE(src), dest); - pass1 = (0 == std::memcmp(src, dest, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStoreBE(VecLoadBE(src+1), dest+1); - pass1 = (0 == std::memcmp(st1, dest+1, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStoreBE(VecLoadBE(src+2), dest+2); - pass1 = (0 == std::memcmp(st2, dest+2, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStoreBE(VecLoadBE(src+3), dest+3); - pass1 = (0 == std::memcmp(st3, dest+3, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - -#if (CRYPTOPP_LITTLE_ENDIAN) - VecStore(VecLoadBE(src), dest); - pass1 = (0 != std::memcmp(src, dest, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); - - VecStoreBE(VecLoad(src), dest); - pass1 = (0 != std::memcmp(src, dest, 16)) && pass1; - CRYPTOPP_ASSERT(pass1); -#endif - - if (!pass1) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Altivec loads and stores" << std::endl; - - //********** Shifts **********// - bool pass2=true; - - uint8x16_p val = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}; - - pass2 = (VecEqual(val, VecShiftLeftOctet<0>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - pass2 = (VecEqual(val, VecShiftRightOctet<0>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - - uint8x16_p lsh1 = {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0x00}; - uint8x16_p rsh1 = {0x00,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}; - - pass2 = (VecEqual(lsh1, VecShiftLeftOctet<1>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - pass2 = (VecEqual(rsh1, VecShiftRightOctet<1>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - - uint8x16_p lsh15 = {0xff,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; - uint8x16_p rsh15 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xff}; - - pass2 = (VecEqual(lsh15, VecShiftLeftOctet<15>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - pass2 = (VecEqual(rsh15, VecShiftRightOctet<15>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - - uint8x16_p lsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; - uint8x16_p rsh16 = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; - - pass2 = (VecEqual(lsh16, VecShiftLeftOctet<16>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - pass2 = (VecEqual(rsh16, VecShiftRightOctet<16>(val))) && pass2; - CRYPTOPP_ASSERT(pass2); - - if (!pass2) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Altivec left and right shifts" << std::endl; - - //********** Extraction **********// - bool pass3=true; - - const byte bex1[] = {0x1f,0x1e,0x1d,0x1c, 0x1b,0x1a,0x19,0x18, - 0x17,0x16,0x15,0x14, 0x13,0x12,0x11,0x10}; - const byte bex2[] = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x17,0x16,0x15,0x14, 0x13,0x12,0x11,0x10}; - const byte bex3[] = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x1f,0x1e,0x1d,0x1c, 0x1b,0x1a,0x19,0x18}; - - const uint8x16_p ex1 = (uint8x16_p)VecLoad(bex1); - const uint8x16_p ex2 = (uint8x16_p)VecLoad(bex2); - const uint8x16_p ex3 = (uint8x16_p)VecLoad(bex3); - - pass3 = VecEqual(ex2, VecGetLow(ex1)) && pass3; - CRYPTOPP_ASSERT(pass3); - pass3 = VecEqual(ex3, VecGetHigh(ex1)) && pass3; - CRYPTOPP_ASSERT(pass3); - - uint8x16_p ex4 = VecShiftRightOctet<8>(VecShiftLeftOctet<8>(ex1)); - pass3 = VecEqual(ex4, VecGetLow(ex1)) && pass3; - CRYPTOPP_ASSERT(pass3); - uint8x16_p ex5 = VecShiftRightOctet<8>(ex1); - pass3 = VecEqual(ex5, VecGetHigh(ex1)) && pass3; - CRYPTOPP_ASSERT(pass3); - - if (!pass3) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Altivec vector extraction" << std::endl; - - return pass1 && pass2 && pass3; -} -#endif -#endif - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat10.cpp b/vendor/cryptopp/validat10.cpp deleted file mode 100644 index d91d8beac5..0000000000 --- a/vendor/cryptopp/validat10.cpp +++ /dev/null @@ -1,535 +0,0 @@ -// validat10.cpp - written and placed in the public domain by Jeffrey Walton -// Routines in this source file test NaCl library routines. -// Source files split in July 2018 to expedite compiles. -// -// There are two types or sets of self tests. First is a known answer test, -// and second are pairwise consistency checks. The known answer tests are test -// vectors lifted from libsodium. The pairwise consistency checks are randomized -// and confirm the library can arrive at the same result or round trip data -// using it's own transformations. -// -// A link like https://github.com/jedisct1/libsodium/blob/master/test/default/box.c -// references the libsodium test data for a test. For example, box.c is one of the -// test runners for crypto_box, and there is a box.exp with the known answer. The -// glue code for box.c and box.exp is in "cmptest.h". box.c runs the test and -// generates output, while cmptest.h gathers the output and compares them. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "secblock.h" -#include "integer.h" -#include "naclite.h" -#include "validate.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4610 4510 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -#ifndef CRYPTOPP_DISABLE_NACL - -USING_NAMESPACE(NaCl) - -bool TestCryptoBox() -{ - // https://github.com/jedisct1/libsodium/blob/master/test/default/box.c - const byte alicesk[32] = { - 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, - 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, - 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a - }; - - const byte bobpk[32] = { - 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, - 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, - 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f - }; - - const byte small_order_p[crypto_box_PUBLICKEYBYTES] = { - 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, - 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, - 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 - }; - - const byte nonce[24] = { - 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73, 0xcd, 0x62, 0xbd, 0xa8, - 0x75, 0xfc, 0x73, 0xd6, 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 - }; - - /* API requires first 32 bytes to be 0 */ - const byte m[163] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5, - 0x3c, 0x81, 0xf2, 0xd5, 0xcf, 0x14, 0x13, 0x16, 0xeb, 0xeb, 0x0c, 0x7b, - 0x52, 0x28, 0xc5, 0x2a, 0x4c, 0x62, 0xcb, 0xd4, 0x4b, 0x66, 0x84, 0x9b, - 0x64, 0x24, 0x4f, 0xfc, 0xe5, 0xec, 0xba, 0xaf, 0x33, 0xbd, 0x75, 0x1a, - 0x1a, 0xc7, 0x28, 0xd4, 0x5e, 0x6c, 0x61, 0x29, 0x6c, 0xdc, 0x3c, 0x01, - 0x23, 0x35, 0x61, 0xf4, 0x1d, 0xb6, 0x6c, 0xce, 0x31, 0x4a, 0xdb, 0x31, - 0x0e, 0x3b, 0xe8, 0x25, 0x0c, 0x46, 0xf0, 0x6d, 0xce, 0xea, 0x3a, 0x7f, - 0xa1, 0x34, 0x80, 0x57, 0xe2, 0xf6, 0x55, 0x6a, 0xd6, 0xb1, 0x31, 0x8a, - 0x02, 0x4a, 0x83, 0x8f, 0x21, 0xaf, 0x1f, 0xde, 0x04, 0x89, 0x77, 0xeb, - 0x48, 0xf5, 0x9f, 0xfd, 0x49, 0x24, 0xca, 0x1c, 0x60, 0x90, 0x2e, 0x52, - 0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37, - 0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 - }; - - const byte exp1[] = { - 0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9, - 0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce, - 0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a, - 0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72, - 0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38, - 0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae, - 0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda, - 0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3, - 0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74, - 0xe3,0x55,0xa5 - }; - - const byte exp2[] = { - 0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9, - 0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce, - 0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a, - 0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72, - 0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38, - 0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae, - 0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda, - 0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3, - 0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74, - 0xe3,0x55,0xa5 - }; - - byte c[163]; - byte k[crypto_box_BEFORENMBYTES]; - - bool pass = true; int rc; - - // Reject small order elements - - rc = crypto_box(c, m, 163, nonce, bobpk, alicesk); - pass = (rc == 0) && pass; - pass = (std::memcmp(c+16, exp1, 163-16) == 0) && pass; - - rc = crypto_box(c, m, 163, nonce, small_order_p, alicesk); - pass = (rc != 0) && pass; - std::memset(c, 0, sizeof(c)); - - rc = crypto_box_beforenm(k, bobpk, alicesk); - pass = (rc == 0) && pass; - rc = crypto_box_afternm(c, m, 163, nonce, k); - pass = (rc == 0) && pass; - pass = (std::memcmp(c+16, exp2, 163-16) == 0) && pass; - - rc = crypto_box_beforenm(k, small_order_p, alicesk); - pass = (rc != 0) && pass; - - // Allow small order elements - - rc = crypto_box_unchecked(c, m, 163, nonce, bobpk, alicesk); - pass = (rc == 0) && pass; - pass = (std::memcmp(c+16, exp1, 163-16) == 0) && pass; - - rc = crypto_box_unchecked(c, m, 163, nonce, small_order_p, alicesk); - pass = (rc == 0) && pass; - std::memset(c, 0, sizeof(c)); - - rc = crypto_box_beforenm_unchecked(k, bobpk, alicesk); - pass = (rc == 0) && pass; - rc = crypto_box_afternm(c, m, 163, nonce, k); - pass = (rc == 0) && pass; - pass = (std::memcmp(c+16, exp2, 163-16) == 0) && pass; - - rc = crypto_box_beforenm_unchecked(k, small_order_p, alicesk); - pass = (rc == 0) && pass; - - return pass; -} - -bool TestCryptoBoxOpen() -{ - // https://github.com/jedisct1/libsodium/blob/master/test/default/box2.c - const byte bobsk[32] = { - 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, - 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, - 0xff, 0x88, 0xe0, 0xeb - }; - - const byte alicepk[32] = { - 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, - 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, - 0xaa, 0x9b, 0x4e, 0x6a - }; - - static const byte small_order_p[crypto_box_PUBLICKEYBYTES] = { - 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, - 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, - 0x5f, 0x49, 0xb8, 0x00 - }; - - const byte nonce[24] = { - 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73, 0xcd, 0x62, 0xbd, 0xa8, - 0x75, 0xfc, 0x73, 0xd6, 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 - }; - - /* API requires first 16 bytes to be 0 */ - const byte c[163] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5, - 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9, 0x8e, 0x99, 0x3b, 0x9f, - 0x48, 0x68, 0x12, 0x73, 0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce, - 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4, 0x47, 0x6f, 0xb8, 0xc5, - 0x31, 0xa1, 0x18, 0x6a, 0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b, - 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72, 0x71, 0xd2, 0xc2, 0x0f, - 0x9b, 0x92, 0x8f, 0xe2, 0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38, - 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a, 0xb9, 0x32, 0x16, 0x45, - 0x48, 0xe5, 0x26, 0xae, 0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea, - 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda, 0x99, 0x83, 0x2b, 0x61, - 0xca, 0x01, 0xb6, 0xde, 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3, - 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, 0x59, 0x9b, 0x1f, 0x65, - 0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 - }; - - const byte exp1[] = { - 0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5, 0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b, - 0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4, 0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc, - 0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a, 0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29, - 0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4, 0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31, - 0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d, 0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57, - 0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a, 0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde, - 0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd, 0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52, - 0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40, 0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64, - 0x5e,0x07,0x05 - }; - - const byte exp2[] = { - 0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5, 0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b, - 0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4, 0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc, - 0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a, 0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29, - 0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4, 0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31, - 0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d, 0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57, - 0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a, 0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde, - 0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd, 0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52, - 0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40, 0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64, - 0x5e,0x07,0x05 - }; - - byte m[163]; - byte k[crypto_box_BEFORENMBYTES]; - - bool pass = true; int rc; - - // Reject small order elements - - rc = crypto_box_open(m, c, 163, nonce, alicepk, bobsk); - pass = (rc == 0) && pass; - pass = (std::memcmp(m+32, exp1, 163-32) == 0) && pass; - - rc = crypto_box_open(m, c, 163, nonce, small_order_p, bobsk); - pass = (rc != 0) && pass; - - rc = crypto_box_beforenm(k, small_order_p, bobsk); - pass = (rc != 0) && pass; - rc = crypto_box_beforenm(k, alicepk, bobsk); - pass = (rc == 0) && pass; - - rc = crypto_box_open_afternm(m, c, 163, nonce, k); - pass = (rc == 0) && pass; - pass = (std::memcmp(m+32, exp2, 163-32) == 0) && pass; - - // Allow small order elements - - rc = crypto_box_open_unchecked(m, c, 163, nonce, alicepk, bobsk); - pass = (rc == 0) && pass; - pass = (std::memcmp(m+32, exp1, 163-32) == 0) && pass; - - rc = crypto_box_beforenm_unchecked(k, small_order_p, bobsk); - pass = (rc == 0) && pass; - rc = crypto_box_beforenm_unchecked(k, alicepk, bobsk); - pass = (rc == 0) && pass; - - rc = crypto_box_open_afternm(m, c, 163, nonce, k); - pass = (rc == 0) && pass; - pass = (std::memcmp(m+32, exp2, 163-32) == 0) && pass; - - return pass; -} - -bool TestCryptoBoxKeys() -{ - // https://github.com/jedisct1/libsodium/blob/master/test/default/box7.c - const unsigned int MAX_TEST = 64; - const unsigned int MAX_MESSAGE = 4096; - - byte alicesk[crypto_box_SECRETKEYBYTES]; - byte alicepk[crypto_box_PUBLICKEYBYTES]; - byte bobsk[crypto_box_SECRETKEYBYTES]; - byte bobpk[crypto_box_PUBLICKEYBYTES]; - - // byte m[MAX_MESSAGE+32]; - // byte c[MAX_MESSAGE+32]; - // byte r[MAX_MESSAGE+32]; - - bool pass = true, fail; int rc; - for (unsigned int i=0; i < MAX_TEST; ++i) - { - fail = (crypto_box_keypair(alicepk, alicesk) != 0); - pass = !fail && pass; - fail = (crypto_box_keypair(bobpk, bobsk) != 0); - pass = !fail && pass; - - SecByteBlock m, c, r, n; - const word32 len = (i == 0 ? 0 : GlobalRNG().GenerateWord32(1, MAX_MESSAGE)); - - m.New(len+crypto_box_ZEROBYTES); - c.New(len+crypto_box_BOXZEROBYTES+crypto_box_MACBYTES); - r.New(len+crypto_box_ZEROBYTES); - n.New(crypto_box_NONCEBYTES); - - GlobalRNG().GenerateBlock(m+crypto_box_ZEROBYTES, len); - GlobalRNG().GenerateBlock(n, crypto_box_NONCEBYTES); - - std::memset(m, 0x00, crypto_box_ZEROBYTES); - rc = crypto_box(c, m, len + crypto_box_ZEROBYTES, n, bobpk, alicesk); - fail = (rc != 0); pass = !fail && pass; - - std::memset(c, 0x00, crypto_box_BOXZEROBYTES); - rc = crypto_box_open(r, c, len + crypto_box_BOXZEROBYTES + crypto_box_MACBYTES, n, alicepk, bobsk); - fail = (rc != 0); pass = !fail && pass; - - fail = std::memcmp(m+crypto_box_ZEROBYTES, r+crypto_box_ZEROBYTES, len) != 0; - pass = !fail && pass; - - m.SetMark(16); c.SetMark(16); r.SetMark(16); - } - - return pass; -} - -struct TestData { - const byte sk[crypto_sign_SEEDBYTES]; - const byte pk[crypto_sign_PUBLICKEYBYTES]; - const byte sig[crypto_sign_BYTES]; - const word32 len; - const char* msg; -}; - -// https://github.com/jedisct1/libsodium/blob/master/test/default/sign.c -const TestData test_data[] = { - {{0x9d,0x61,0xb1,0x9d,0xef,0xfd,0x5a,0x60,0xba,0x84,0x4a,0xf4,0x92,0xec,0x2c,0xc4,0x44,0x49,0xc5,0x69,0x7b,0x32,0x69,0x19,0x70,0x3b,0xac,0x03,0x1c,0xae,0x7f,0x60,},{0xd7,0x5a,0x98,0x01,0x82,0xb1,0x0a,0xb7,0xd5,0x4b,0xfe,0xd3,0xc9,0x64,0x07,0x3a,0x0e,0xe1,0x72,0xf3,0xda,0xa6,0x23,0x25,0xaf,0x02,0x1a,0x68,0xf7,0x07,0x51,0x1a,},{0xe5,0x56,0x43,0x00,0xc3,0x60,0xac,0x72,0x90,0x86,0xe2,0xcc,0x80,0x6e,0x82,0x8a,0x84,0x87,0x7f,0x1e,0xb8,0xe5,0xd9,0x74,0xd8,0x73,0xe0,0x65,0x22,0x49,0x01,0x55,0x5f,0xb8,0x82,0x15,0x90,0xa3,0x3b,0xac,0xc6,0x1e,0x39,0x70,0x1c,0xf9,0xb4,0x6b,0xd2,0x5b,0xf5,0xf0,0x59,0x5b,0xbe,0x24,0x65,0x51,0x41,0x43,0x8e,0x7a,0x10,0x0b,},0,""}, - {{0x4c,0xcd,0x08,0x9b,0x28,0xff,0x96,0xda,0x9d,0xb6,0xc3,0x46,0xec,0x11,0x4e,0x0f,0x5b,0x8a,0x31,0x9f,0x35,0xab,0xa6,0x24,0xda,0x8c,0xf6,0xed,0x4f,0xb8,0xa6,0xfb,},{0x3d,0x40,0x17,0xc3,0xe8,0x43,0x89,0x5a,0x92,0xb7,0x0a,0xa7,0x4d,0x1b,0x7e,0xbc,0x9c,0x98,0x2c,0xcf,0x2e,0xc4,0x96,0x8c,0xc0,0xcd,0x55,0xf1,0x2a,0xf4,0x66,0x0c,},{0x92,0xa0,0x09,0xa9,0xf0,0xd4,0xca,0xb8,0x72,0x0e,0x82,0x0b,0x5f,0x64,0x25,0x40,0xa2,0xb2,0x7b,0x54,0x16,0x50,0x3f,0x8f,0xb3,0x76,0x22,0x23,0xeb,0xdb,0x69,0xda,0x08,0x5a,0xc1,0xe4,0x3e,0x15,0x99,0x6e,0x45,0x8f,0x36,0x13,0xd0,0xf1,0x1d,0x8c,0x38,0x7b,0x2e,0xae,0xb4,0x30,0x2a,0xee,0xb0,0x0d,0x29,0x16,0x12,0xbb,0x0c,0x00,},1,"\x72"}, - {{0xc5,0xaa,0x8d,0xf4,0x3f,0x9f,0x83,0x7b,0xed,0xb7,0x44,0x2f,0x31,0xdc,0xb7,0xb1,0x66,0xd3,0x85,0x35,0x07,0x6f,0x09,0x4b,0x85,0xce,0x3a,0x2e,0x0b,0x44,0x58,0xf7,},{0xfc,0x51,0xcd,0x8e,0x62,0x18,0xa1,0xa3,0x8d,0xa4,0x7e,0xd0,0x02,0x30,0xf0,0x58,0x08,0x16,0xed,0x13,0xba,0x33,0x03,0xac,0x5d,0xeb,0x91,0x15,0x48,0x90,0x80,0x25,},{0x62,0x91,0xd6,0x57,0xde,0xec,0x24,0x02,0x48,0x27,0xe6,0x9c,0x3a,0xbe,0x01,0xa3,0x0c,0xe5,0x48,0xa2,0x84,0x74,0x3a,0x44,0x5e,0x36,0x80,0xd7,0xdb,0x5a,0xc3,0xac,0x18,0xff,0x9b,0x53,0x8d,0x16,0xf2,0x90,0xae,0x67,0xf7,0x60,0x98,0x4d,0xc6,0x59,0x4a,0x7c,0x15,0xe9,0x71,0x6e,0xd2,0x8d,0xc0,0x27,0xbe,0xce,0xea,0x1e,0xc4,0x0a,},2,"\xaf\x82"}, - {{0x0d,0x4a,0x05,0xb0,0x73,0x52,0xa5,0x43,0x6e,0x18,0x03,0x56,0xda,0x0a,0xe6,0xef,0xa0,0x34,0x5f,0xf7,0xfb,0x15,0x72,0x57,0x57,0x72,0xe8,0x00,0x5e,0xd9,0x78,0xe9,},{0xe6,0x1a,0x18,0x5b,0xce,0xf2,0x61,0x3a,0x6c,0x7c,0xb7,0x97,0x63,0xce,0x94,0x5d,0x3b,0x24,0x5d,0x76,0x11,0x4d,0xd4,0x40,0xbc,0xf5,0xf2,0xdc,0x1a,0xa5,0x70,0x57,},{0xd9,0x86,0x8d,0x52,0xc2,0xbe,0xbc,0xe5,0xf3,0xfa,0x5a,0x79,0x89,0x19,0x70,0xf3,0x09,0xcb,0x65,0x91,0xe3,0xe1,0x70,0x2a,0x70,0x27,0x6f,0xa9,0x7c,0x24,0xb3,0xa8,0xe5,0x86,0x06,0xc3,0x8c,0x97,0x58,0x52,0x9d,0xa5,0x0e,0xe3,0x1b,0x82,0x19,0xcb,0xa4,0x52,0x71,0xc6,0x89,0xaf,0xa6,0x0b,0x0e,0xa2,0x6c,0x99,0xdb,0x19,0xb0,0x0c,},3,"\xcb\xc7\x7b"}, - {{0x6d,0xf9,0x34,0x0c,0x13,0x8c,0xc1,0x88,0xb5,0xfe,0x44,0x64,0xeb,0xaa,0x3f,0x7f,0xc2,0x06,0xa2,0xd5,0x5c,0x34,0x34,0x70,0x7e,0x74,0xc9,0xfc,0x04,0xe2,0x0e,0xbb,},{0xc0,0xda,0xc1,0x02,0xc4,0x53,0x31,0x86,0xe2,0x5d,0xc4,0x31,0x28,0x47,0x23,0x53,0xea,0xab,0xdb,0x87,0x8b,0x15,0x2a,0xeb,0x8e,0x00,0x1f,0x92,0xd9,0x02,0x33,0xa7,},{0x12,0x4f,0x6f,0xc6,0xb0,0xd1,0x00,0x84,0x27,0x69,0xe7,0x1b,0xd5,0x30,0x66,0x4d,0x88,0x8d,0xf8,0x50,0x7d,0xf6,0xc5,0x6d,0xed,0xfd,0xb5,0x09,0xae,0xb9,0x34,0x16,0xe2,0x6b,0x91,0x8d,0x38,0xaa,0x06,0x30,0x5d,0xf3,0x09,0x56,0x97,0xc1,0x8b,0x2a,0xa8,0x32,0xea,0xa5,0x2e,0xdc,0x0a,0xe4,0x9f,0xba,0xe5,0xa8,0x5e,0x15,0x0c,0x07,},4,"\x5f\x4c\x89\x89"}, - {{0xb7,0x80,0x38,0x1a,0x65,0xed,0xf8,0xb7,0x8f,0x69,0x45,0xe8,0xdb,0xec,0x79,0x41,0xac,0x04,0x9f,0xd4,0xc6,0x10,0x40,0xcf,0x0c,0x32,0x43,0x57,0x97,0x5a,0x29,0x3c,},{0xe2,0x53,0xaf,0x07,0x66,0x80,0x4b,0x86,0x9b,0xb1,0x59,0x5b,0xe9,0x76,0x5b,0x53,0x48,0x86,0xbb,0xaa,0xb8,0x30,0x5b,0xf5,0x0d,0xbc,0x7f,0x89,0x9b,0xfb,0x5f,0x01,},{0xb2,0xfc,0x46,0xad,0x47,0xaf,0x46,0x44,0x78,0xc1,0x99,0xe1,0xf8,0xbe,0x16,0x9f,0x1b,0xe6,0x32,0x7c,0x7f,0x9a,0x0a,0x66,0x89,0x37,0x1c,0xa9,0x4c,0xaf,0x04,0x06,0x4a,0x01,0xb2,0x2a,0xff,0x15,0x20,0xab,0xd5,0x89,0x51,0x34,0x16,0x03,0xfa,0xed,0x76,0x8c,0xf7,0x8c,0xe9,0x7a,0xe7,0xb0,0x38,0xab,0xfe,0x45,0x6a,0xa1,0x7c,0x09,},5,"\x18\xb6\xbe\xc0\x97"}, - {{0x78,0xae,0x9e,0xff,0xe6,0xf2,0x45,0xe9,0x24,0xa7,0xbe,0x63,0x04,0x11,0x46,0xeb,0xc6,0x70,0xdb,0xd3,0x06,0x0c,0xba,0x67,0xfb,0xc6,0x21,0x6f,0xeb,0xc4,0x45,0x46,},{0xfb,0xcf,0xbf,0xa4,0x05,0x05,0xd7,0xf2,0xbe,0x44,0x4a,0x33,0xd1,0x85,0xcc,0x54,0xe1,0x6d,0x61,0x52,0x60,0xe1,0x64,0x0b,0x2b,0x50,0x87,0xb8,0x3e,0xe3,0x64,0x3d,},{0x6e,0xd6,0x29,0xfc,0x1d,0x9c,0xe9,0xe1,0x46,0x87,0x55,0xff,0x63,0x6d,0x5a,0x3f,0x40,0xa5,0xd9,0xc9,0x1a,0xfd,0x93,0xb7,0x9d,0x24,0x18,0x30,0xf7,0xe5,0xfa,0x29,0x85,0x4b,0x8f,0x20,0xcc,0x6e,0xec,0xbb,0x24,0x8d,0xbd,0x8d,0x16,0xd1,0x4e,0x99,0x75,0x21,0x94,0xe4,0x90,0x4d,0x09,0xc7,0x4d,0x63,0x95,0x18,0x83,0x9d,0x23,0x00,},6,"\x89\x01\x0d\x85\x59\x72"}, - {{0x69,0x18,0x65,0xbf,0xc8,0x2a,0x1e,0x4b,0x57,0x4e,0xec,0xde,0x4c,0x75,0x19,0x09,0x3f,0xaf,0x0c,0xf8,0x67,0x38,0x02,0x34,0xe3,0x66,0x46,0x45,0xc6,0x1c,0x5f,0x79,},{0x98,0xa5,0xe3,0xa3,0x6e,0x67,0xaa,0xba,0x89,0x88,0x8b,0xf0,0x93,0xde,0x1a,0xd9,0x63,0xe7,0x74,0x01,0x3b,0x39,0x02,0xbf,0xab,0x35,0x6d,0x8b,0x90,0x17,0x8a,0x63,},{0x6e,0x0a,0xf2,0xfe,0x55,0xae,0x37,0x7a,0x6b,0x7a,0x72,0x78,0xed,0xfb,0x41,0x9b,0xd3,0x21,0xe0,0x6d,0x0d,0xf5,0xe2,0x70,0x37,0xdb,0x88,0x12,0xe7,0xe3,0x52,0x98,0x10,0xfa,0x55,0x52,0xf6,0xc0,0x02,0x09,0x85,0xca,0x17,0xa0,0xe0,0x2e,0x03,0x6d,0x7b,0x22,0x2a,0x24,0xf9,0x9b,0x77,0xb7,0x5f,0xdd,0x16,0xcb,0x05,0x56,0x81,0x07,},7,"\xb4\xa8\xf3\x81\xe7\x0e\x7a"}, - {{0x3b,0x26,0x51,0x6f,0xb3,0xdc,0x88,0xeb,0x18,0x1b,0x9e,0xd7,0x3f,0x0b,0xcd,0x52,0xbc,0xd6,0xb4,0xc7,0x88,0xe4,0xbc,0xaf,0x46,0x05,0x7f,0xd0,0x78,0xbe,0xe0,0x73,},{0xf8,0x1f,0xb5,0x4a,0x82,0x5f,0xce,0xd9,0x5e,0xb0,0x33,0xaf,0xcd,0x64,0x31,0x40,0x75,0xab,0xfb,0x0a,0xbd,0x20,0xa9,0x70,0x89,0x25,0x03,0x43,0x6f,0x34,0xb8,0x63,},{0xd6,0xad,0xde,0xc5,0xaf,0xb0,0x52,0x8a,0xc1,0x7b,0xb1,0x78,0xd3,0xe7,0xf2,0x88,0x7f,0x9a,0xdb,0xb1,0xad,0x16,0xe1,0x10,0x54,0x5e,0xf3,0xbc,0x57,0xf9,0xde,0x23,0x14,0xa5,0xc8,0x38,0x8f,0x72,0x3b,0x89,0x07,0xbe,0x0f,0x3a,0xc9,0x0c,0x62,0x59,0xbb,0xe8,0x85,0xec,0xc1,0x76,0x45,0xdf,0x3d,0xb7,0xd4,0x88,0xf8,0x05,0xfa,0x08,},8,"\x42\x84\xab\xc5\x1b\xb6\x72\x35"}, - {{0xed,0xc6,0xf5,0xfb,0xdd,0x1c,0xee,0x4d,0x10,0x1c,0x06,0x35,0x30,0xa3,0x04,0x90,0xb2,0x21,0xbe,0x68,0xc0,0x36,0xf5,0xb0,0x7d,0x0f,0x95,0x3b,0x74,0x5d,0xf1,0x92,},{0xc1,0xa4,0x9c,0x66,0xe6,0x17,0xf9,0xef,0x5e,0xc6,0x6b,0xc4,0xc6,0x56,0x4c,0xa3,0x3d,0xe2,0xa5,0xfb,0x5e,0x14,0x64,0x06,0x2e,0x6d,0x6c,0x62,0x19,0x15,0x5e,0xfd,},{0x2c,0x76,0xa0,0x4a,0xf2,0x39,0x1c,0x14,0x70,0x82,0xe3,0x3f,0xaa,0xcd,0xbe,0x56,0x64,0x2a,0x1e,0x13,0x4b,0xd3,0x88,0x62,0x0b,0x85,0x2b,0x90,0x1a,0x6b,0xc1,0x6f,0xf6,0xc9,0xcc,0x94,0x04,0xc4,0x1d,0xea,0x12,0xed,0x28,0x1d,0xa0,0x67,0xa1,0x51,0x38,0x66,0xf9,0xd9,0x64,0xf8,0xbd,0xd2,0x49,0x53,0x85,0x6c,0x50,0x04,0x29,0x01,},9,"\x67\x2b\xf8\x96\x5d\x04\xbc\x51\x46"}, - {{0x4e,0x7d,0x21,0xfb,0x3b,0x18,0x97,0x57,0x1a,0x44,0x58,0x33,0xbe,0x0f,0x9f,0xd4,0x1c,0xd6,0x2b,0xe3,0xaa,0x04,0x04,0x0f,0x89,0x34,0xe1,0xfc,0xbd,0xca,0xcd,0x45,},{0x31,0xb2,0x52,0x4b,0x83,0x48,0xf7,0xab,0x1d,0xfa,0xfa,0x67,0x5c,0xc5,0x38,0xe9,0xa8,0x4e,0x3f,0xe5,0x81,0x9e,0x27,0xc1,0x2a,0xd8,0xbb,0xc1,0xa3,0x6e,0x4d,0xff,},{0x28,0xe4,0x59,0x8c,0x41,0x5a,0xe9,0xde,0x01,0xf0,0x3f,0x9f,0x3f,0xab,0x4e,0x91,0x9e,0x8b,0xf5,0x37,0xdd,0x2b,0x0c,0xdf,0x6e,0x79,0xb9,0xe6,0x55,0x9c,0x94,0x09,0xd9,0x15,0x1a,0x4c,0x40,0xf0,0x83,0x19,0x39,0x37,0x62,0x7c,0x36,0x94,0x88,0x25,0x9e,0x99,0xda,0x5a,0x9f,0x0a,0x87,0x49,0x7f,0xa6,0x69,0x6a,0x5d,0xd6,0xce,0x08,},10,"\x33\xd7\xa7\x86\xad\xed\x8c\x1b\xf6\x91"}, - {{0xa9,0x80,0xf8,0x92,0xdb,0x13,0xc9,0x9a,0x3e,0x89,0x71,0xe9,0x65,0xb2,0xff,0x3d,0x41,0xea,0xfd,0x54,0x09,0x3b,0xc9,0xf3,0x4d,0x1f,0xd2,0x2d,0x84,0x11,0x5b,0xb6,},{0x44,0xb5,0x7e,0xe3,0x0c,0xdb,0x55,0x82,0x9d,0x0a,0x5d,0x4f,0x04,0x6b,0xae,0xf0,0x78,0xf1,0xe9,0x7a,0x7f,0x21,0xb6,0x2d,0x75,0xf8,0xe9,0x6e,0xa1,0x39,0xc3,0x5f,},{0x77,0xd3,0x89,0xe5,0x99,0x63,0x0d,0x93,0x40,0x76,0x32,0x95,0x83,0xcd,0x41,0x05,0xa6,0x49,0xa9,0x29,0x2a,0xbc,0x44,0xcd,0x28,0xc4,0x00,0x00,0xc8,0xe2,0xf5,0xac,0x76,0x60,0xa8,0x1c,0x85,0xb7,0x2a,0xf8,0x45,0x2d,0x7d,0x25,0xc0,0x70,0x86,0x1d,0xae,0x91,0x60,0x1c,0x78,0x03,0xd6,0x56,0x53,0x16,0x50,0xdd,0x4e,0x5c,0x41,0x00,},11,"\x34\x86\xf6\x88\x48\xa6\x5a\x0e\xb5\x50\x7d"}, - {{0x5b,0x5a,0x61,0x9f,0x8c,0xe1,0xc6,0x6d,0x7c,0xe2,0x6e,0x5a,0x2a,0xe7,0xb0,0xc0,0x4f,0xeb,0xcd,0x34,0x6d,0x28,0x6c,0x92,0x9e,0x19,0xd0,0xd5,0x97,0x3b,0xfe,0xf9,},{0x6f,0xe8,0x36,0x93,0xd0,0x11,0xd1,0x11,0x13,0x1c,0x4f,0x3f,0xba,0xaa,0x40,0xa9,0xd3,0xd7,0x6b,0x30,0x01,0x2f,0xf7,0x3b,0xb0,0xe3,0x9e,0xc2,0x7a,0xb1,0x82,0x57,},{0x0f,0x9a,0xd9,0x79,0x30,0x33,0xa2,0xfa,0x06,0x61,0x4b,0x27,0x7d,0x37,0x38,0x1e,0x6d,0x94,0xf6,0x5a,0xc2,0xa5,0xa9,0x45,0x58,0xd0,0x9e,0xd6,0xce,0x92,0x22,0x58,0xc1,0xa5,0x67,0x95,0x2e,0x86,0x3a,0xc9,0x42,0x97,0xae,0xc3,0xc0,0xd0,0xc8,0xdd,0xf7,0x10,0x84,0xe5,0x04,0x86,0x0b,0xb6,0xba,0x27,0x44,0x9b,0x55,0xad,0xc4,0x0e,},12,"\x5a\x8d\x9d\x0a\x22\x35\x7e\x66\x55\xf9\xc7\x85"}, - {{0x94,0x0c,0x89,0xfe,0x40,0xa8,0x1d,0xaf,0xbd,0xb2,0x41,0x6d,0x14,0xae,0x46,0x91,0x19,0x86,0x97,0x44,0x41,0x0c,0x33,0x03,0xbf,0xaa,0x02,0x41,0xda,0xc5,0x78,0x00,},{0xa2,0xeb,0x8c,0x05,0x01,0xe3,0x0b,0xae,0x0c,0xf8,0x42,0xd2,0xbd,0xe8,0xde,0xc7,0x38,0x6f,0x6b,0x7f,0xc3,0x98,0x1b,0x8c,0x57,0xc9,0x79,0x2b,0xb9,0x4c,0xf2,0xdd,},{0xd8,0xbb,0x64,0xaa,0xd8,0xc9,0x95,0x5a,0x11,0x5a,0x79,0x3a,0xdd,0xd2,0x4f,0x7f,0x2b,0x07,0x76,0x48,0x71,0x4f,0x49,0xc4,0x69,0x4e,0xc9,0x95,0xb3,0x30,0xd0,0x9d,0x64,0x0d,0xf3,0x10,0xf4,0x47,0xfd,0x7b,0x6c,0xb5,0xc1,0x4f,0x9f,0xe9,0xf4,0x90,0xbc,0xf8,0xcf,0xad,0xbf,0xd2,0x16,0x9c,0x8a,0xc2,0x0d,0x3b,0x8a,0xf4,0x9a,0x0c,},13,"\xb8\x7d\x38\x13\xe0\x3f\x58\xcf\x19\xfd\x0b\x63\x95"}, - {{0x9a,0xca,0xd9,0x59,0xd2,0x16,0x21,0x2d,0x78,0x9a,0x11,0x92,0x52,0xeb,0xfe,0x0c,0x96,0x51,0x2a,0x23,0xc7,0x3b,0xd9,0xf3,0xb2,0x02,0x29,0x2d,0x69,0x16,0xa7,0x38,},{0xcf,0x3a,0xf8,0x98,0x46,0x7a,0x5b,0x7a,0x52,0xd3,0x3d,0x53,0xbc,0x03,0x7e,0x26,0x42,0xa8,0xda,0x99,0x69,0x03,0xfc,0x25,0x22,0x17,0xe9,0xc0,0x33,0xe2,0xf2,0x91,},{0x6e,0xe3,0xfe,0x81,0xe2,0x3c,0x60,0xeb,0x23,0x12,0xb2,0x00,0x6b,0x3b,0x25,0xe6,0x83,0x8e,0x02,0x10,0x66,0x23,0xf8,0x44,0xc4,0x4e,0xdb,0x8d,0xaf,0xd6,0x6a,0xb0,0x67,0x10,0x87,0xfd,0x19,0x5d,0xf5,0xb8,0xf5,0x8a,0x1d,0x6e,0x52,0xaf,0x42,0x90,0x80,0x53,0xd5,0x5c,0x73,0x21,0x01,0x00,0x92,0x74,0x87,0x95,0xef,0x94,0xcf,0x06,},14,"\x55\xc7\xfa\x43\x4f\x5e\xd8\xcd\xec\x2b\x7a\xea\xc1\x73"}, - {{0xd5,0xae,0xee,0x41,0xee,0xb0,0xe9,0xd1,0xbf,0x83,0x37,0xf9,0x39,0x58,0x7e,0xbe,0x29,0x61,0x61,0xe6,0xbf,0x52,0x09,0xf5,0x91,0xec,0x93,0x9e,0x14,0x40,0xc3,0x00,},{0xfd,0x2a,0x56,0x57,0x23,0x16,0x3e,0x29,0xf5,0x3c,0x9d,0xe3,0xd5,0xe8,0xfb,0xe3,0x6a,0x7a,0xb6,0x6e,0x14,0x39,0xec,0x4e,0xae,0x9c,0x0a,0x60,0x4a,0xf2,0x91,0xa5,},{0xf6,0x8d,0x04,0x84,0x7e,0x5b,0x24,0x97,0x37,0x89,0x9c,0x01,0x4d,0x31,0xc8,0x05,0xc5,0x00,0x7a,0x62,0xc0,0xa1,0x0d,0x50,0xbb,0x15,0x38,0xc5,0xf3,0x55,0x03,0x95,0x1f,0xbc,0x1e,0x08,0x68,0x2f,0x2c,0xc0,0xc9,0x2e,0xfe,0x8f,0x49,0x85,0xde,0xc6,0x1d,0xcb,0xd5,0x4d,0x4b,0x94,0xa2,0x25,0x47,0xd2,0x44,0x51,0x27,0x1c,0x8b,0x00,},15,"\x0a\x68\x8e\x79\xbe\x24\xf8\x66\x28\x6d\x46\x46\xb5\xd8\x1c"}, - {{0x0a,0x47,0xd1,0x04,0x52,0xae,0x2f,0xeb,0xec,0x51,0x8a,0x1c,0x7c,0x36,0x28,0x90,0xc3,0xfc,0x1a,0x49,0xd3,0x4b,0x03,0xb6,0x46,0x7d,0x35,0xc9,0x04,0xa8,0x36,0x2d,},{0x34,0xe5,0xa8,0x50,0x8c,0x47,0x43,0x74,0x69,0x62,0xc0,0x66,0xe4,0xba,0xde,0xa2,0x20,0x1b,0x8a,0xb4,0x84,0xde,0x5c,0x4f,0x94,0x47,0x6c,0xcd,0x21,0x43,0x95,0x5b,},{0x2a,0x3d,0x27,0xdc,0x40,0xd0,0xa8,0x12,0x79,0x49,0xa3,0xb7,0xf9,0x08,0xb3,0x68,0x8f,0x63,0xb7,0xf1,0x4f,0x65,0x1a,0xac,0xd7,0x15,0x94,0x0b,0xdb,0xe2,0x7a,0x08,0x09,0xaa,0xc1,0x42,0xf4,0x7a,0xb0,0xe1,0xe4,0x4f,0xa4,0x90,0xba,0x87,0xce,0x53,0x92,0xf3,0x3a,0x89,0x15,0x39,0xca,0xf1,0xef,0x4c,0x36,0x7c,0xae,0x54,0x50,0x0c,},16,"\xc9\x42\xfa\x7a\xc6\xb2\x3a\xb7\xff\x61\x2f\xdc\x8e\x68\xef\x39"}, - {{0xf8,0x14,0x8f,0x75,0x06,0xb7,0x75,0xef,0x46,0xfd,0xc8,0xe8,0xc7,0x56,0x51,0x68,0x12,0xd4,0x7d,0x6c,0xfb,0xfa,0x31,0x8c,0x27,0xc9,0xa2,0x26,0x41,0xe5,0x6f,0x17,},{0x04,0x45,0xe4,0x56,0xda,0xcc,0x7d,0x5b,0x0b,0xbe,0xd2,0x3c,0x82,0x00,0xcd,0xb7,0x4b,0xdc,0xb0,0x3e,0x4c,0x7b,0x73,0xf0,0xa2,0xb9,0xb4,0x6e,0xac,0x5d,0x43,0x72,},{0x36,0x53,0xcc,0xb2,0x12,0x19,0x20,0x2b,0x84,0x36,0xfb,0x41,0xa3,0x2b,0xa2,0x61,0x8c,0x4a,0x13,0x34,0x31,0xe6,0xe6,0x34,0x63,0xce,0xb3,0xb6,0x10,0x6c,0x4d,0x56,0xe1,0xd2,0xba,0x16,0x5b,0xa7,0x6e,0xaa,0xd3,0xdc,0x39,0xbf,0xfb,0x13,0x0f,0x1d,0xe3,0xd8,0xe6,0x42,0x7d,0xb5,0xb7,0x19,0x38,0xdb,0x4e,0x27,0x2b,0xc3,0xe2,0x0b,},17,"\x73\x68\x72\x4a\x5b\x0e\xfb\x57\xd2\x8d\x97\x62\x2d\xbd\xe7\x25\xaf"}, - {{0x77,0xf8,0x86,0x91,0xc4,0xef,0xf2,0x3e,0xbb,0x73,0x64,0x94,0x70,0x92,0x95,0x1a,0x5f,0xf3,0xf1,0x07,0x85,0xb4,0x17,0xe9,0x18,0x82,0x3a,0x55,0x2d,0xab,0x7c,0x75,},{0x74,0xd2,0x91,0x27,0xf1,0x99,0xd8,0x6a,0x86,0x76,0xae,0xc3,0x3b,0x4c,0xe3,0xf2,0x25,0xcc,0xb1,0x91,0xf5,0x2c,0x19,0x1c,0xcd,0x1e,0x8c,0xca,0x65,0x21,0x3a,0x6b,},{0xfb,0xe9,0x29,0xd7,0x43,0xa0,0x3c,0x17,0x91,0x05,0x75,0x49,0x2f,0x30,0x92,0xee,0x2a,0x2b,0xf1,0x4a,0x60,0xa3,0xfc,0xac,0xec,0x74,0xa5,0x8c,0x73,0x34,0x51,0x0f,0xc2,0x62,0xdb,0x58,0x27,0x91,0x32,0x2d,0x6c,0x8c,0x41,0xf1,0x70,0x0a,0xdb,0x80,0x02,0x7e,0xca,0xbc,0x14,0x27,0x0b,0x70,0x34,0x44,0xae,0x3e,0xe7,0x62,0x3e,0x0a,},18,"\xbd\x8e\x05\x03\x3f\x3a\x8b\xcd\xcb\xf4\xbe\xce\xb7\x09\x01\xc8\x2e\x31"}, - {{0xab,0x6f,0x7a,0xee,0x6a,0x08,0x37,0xb3,0x34,0xba,0x5e,0xb1,0xb2,0xad,0x7f,0xce,0xcf,0xab,0x7e,0x32,0x3c,0xab,0x18,0x7f,0xe2,0xe0,0xa9,0x5d,0x80,0xef,0xf1,0x32,},{0x5b,0x96,0xdc,0xa4,0x97,0x87,0x5b,0xf9,0x66,0x4c,0x5e,0x75,0xfa,0xcf,0x3f,0x9b,0xc5,0x4b,0xae,0x91,0x3d,0x66,0xca,0x15,0xee,0x85,0xf1,0x49,0x1c,0xa2,0x4d,0x2c,},{0x73,0xbc,0xa6,0x4e,0x9d,0xd0,0xdb,0x88,0x13,0x8e,0xed,0xfa,0xfc,0xea,0x8f,0x54,0x36,0xcf,0xb7,0x4b,0xfb,0x0e,0x77,0x33,0xcf,0x34,0x9b,0xaa,0x0c,0x49,0x77,0x5c,0x56,0xd5,0x93,0x4e,0x1d,0x38,0xe3,0x6f,0x39,0xb7,0xc5,0xbe,0xb0,0xa8,0x36,0x51,0x0c,0x45,0x12,0x6f,0x8e,0xc4,0xb6,0x81,0x05,0x19,0x90,0x5b,0x0c,0xa0,0x7c,0x09,},19,"\x81\x71\x45\x6f\x8b\x90\x71\x89\xb1\xd7\x79\xe2\x6b\xc5\xaf\xbb\x08\xc6\x7a"}, - {{0x8d,0x13,0x5d,0xe7,0xc8,0x41,0x1b,0xbd,0xbd,0x1b,0x31,0xe5,0xdc,0x67,0x8f,0x2a,0xc7,0x10,0x9e,0x79,0x2b,0x60,0xf3,0x8c,0xd2,0x49,0x36,0xe8,0xa8,0x98,0xc3,0x2d,},{0x1c,0xa2,0x81,0x93,0x85,0x29,0x89,0x65,0x35,0xa7,0x71,0x4e,0x35,0x84,0x08,0x5b,0x86,0xef,0x9f,0xec,0x72,0x3f,0x42,0x81,0x9f,0xc8,0xdd,0x5d,0x8c,0x00,0x81,0x7f,},{0xa1,0xad,0xc2,0xbc,0x6a,0x2d,0x98,0x06,0x62,0x67,0x7e,0x7f,0xdf,0xf6,0x42,0x4d,0xe7,0xdb,0xa5,0x0f,0x57,0x95,0xca,0x90,0xfd,0xf3,0xe9,0x6e,0x25,0x6f,0x32,0x85,0xca,0xc7,0x1d,0x33,0x60,0x48,0x2e,0x99,0x3d,0x02,0x94,0xba,0x4e,0xc7,0x44,0x0c,0x61,0xaf,0xfd,0xf3,0x5f,0xe8,0x3e,0x6e,0x04,0x26,0x39,0x37,0xdb,0x93,0xf1,0x05,},20,"\x8b\xa6\xa4\xc9\xa1\x5a\x24\x4a\x9c\x26\xbb\x2a\x59\xb1\x02\x6f\x21\x34\x8b\x49"}, - {{0x0e,0x76,0x5d,0x72,0x0e,0x70,0x5f,0x93,0x66,0xc1,0xab,0x8c,0x3f,0xa8,0x4c,0x9a,0x44,0x37,0x0c,0x06,0x96,0x9f,0x80,0x32,0x96,0x88,0x4b,0x28,0x46,0xa6,0x52,0xa4,},{0x7f,0xae,0x45,0xdd,0x0a,0x05,0x97,0x10,0x26,0xd4,0x10,0xbc,0x49,0x7a,0xf5,0xbe,0x7d,0x08,0x27,0xa8,0x2a,0x14,0x5c,0x20,0x3f,0x62,0x5d,0xfc,0xb8,0xb0,0x3b,0xa8,},{0xbb,0x61,0xcf,0x84,0xde,0x61,0x86,0x22,0x07,0xc6,0xa4,0x55,0x25,0x8b,0xc4,0xdb,0x4e,0x15,0xee,0xa0,0x31,0x7f,0xf8,0x87,0x18,0xb8,0x82,0xa0,0x6b,0x5c,0xf6,0xec,0x6f,0xd2,0x0c,0x5a,0x26,0x9e,0x5d,0x5c,0x80,0x5b,0xaf,0xbc,0xc5,0x79,0xe2,0x59,0x0a,0xf4,0x14,0xc7,0xc2,0x27,0x27,0x3c,0x10,0x2a,0x10,0x07,0x0c,0xdf,0xe8,0x0f,},21,"\x1d\x56\x6a\x62\x32\xbb\xaa\xb3\xe6\xd8\x80\x4b\xb5\x18\xa4\x98\xed\x0f\x90\x49\x86"}, - {{0xdb,0x36,0xe3,0x26,0xd6,0x76,0xc2,0xd1,0x9c,0xc8,0xfe,0x0c,0x14,0xb7,0x09,0x20,0x2e,0xcf,0xc7,0x61,0xd2,0x70,0x89,0xeb,0x6e,0xa4,0xb1,0xbb,0x02,0x1e,0xcf,0xa7,},{0x48,0x35,0x9b,0x85,0x0d,0x23,0xf0,0x71,0x5d,0x94,0xbb,0x8b,0xb7,0x5e,0x7e,0x14,0x32,0x2e,0xaf,0x14,0xf0,0x6f,0x28,0xa8,0x05,0x40,0x3f,0xbd,0xa0,0x02,0xfc,0x85,},{0xb6,0xdc,0xd0,0x99,0x89,0xdf,0xba,0xc5,0x43,0x22,0xa3,0xce,0x87,0x87,0x6e,0x1d,0x62,0x13,0x4d,0xa9,0x98,0xc7,0x9d,0x24,0xb5,0x0b,0xd7,0xa6,0xa7,0x97,0xd8,0x6a,0x0e,0x14,0xdc,0x9d,0x74,0x91,0xd6,0xc1,0x4a,0x67,0x3c,0x65,0x2c,0xfb,0xec,0x9f,0x96,0x2a,0x38,0xc9,0x45,0xda,0x3b,0x2f,0x08,0x79,0xd0,0xb6,0x8a,0x92,0x13,0x00,},22,"\x1b\x0a\xfb\x0a\xc4\xba\x9a\xb7\xb7\x17\x2c\xdd\xc9\xeb\x42\xbb\xa1\xa6\x4b\xce\x47\xd4"}, - {{0xc8,0x99,0x55,0xe0,0xf7,0x74,0x1d,0x90,0x5d,0xf0,0x73,0x0b,0x3d,0xc2,0xb0,0xce,0x1a,0x13,0x13,0x4e,0x44,0xfe,0xf3,0xd4,0x0d,0x60,0xc0,0x20,0xef,0x19,0xdf,0x77,},{0xfd,0xb3,0x06,0x73,0x40,0x2f,0xaf,0x1c,0x80,0x33,0x71,0x4f,0x35,0x17,0xe4,0x7c,0xc0,0xf9,0x1f,0xe7,0x0c,0xf3,0x83,0x6d,0x6c,0x23,0x63,0x6e,0x3f,0xd2,0x28,0x7c,},{0x7e,0xf6,0x6e,0x5e,0x86,0xf2,0x36,0x08,0x48,0xe0,0x01,0x4e,0x94,0x88,0x0a,0xe2,0x92,0x0a,0xd8,0xa3,0x18,0x5a,0x46,0xb3,0x5d,0x1e,0x07,0xde,0xa8,0xfa,0x8a,0xe4,0xf6,0xb8,0x43,0xba,0x17,0x4d,0x99,0xfa,0x79,0x86,0x65,0x4a,0x08,0x91,0xc1,0x2a,0x79,0x44,0x55,0x66,0x93,0x75,0xbf,0x92,0xaf,0x4c,0xc2,0x77,0x0b,0x57,0x9e,0x0c,},23,"\x50\x7c\x94\xc8\x82\x0d\x2a\x57\x93\xcb\xf3\x44\x2b\x3d\x71\x93\x6f\x35\xfe\x3a\xfe\xf3\x16"}, - {{0x4e,0x62,0x62,0x7f,0xc2,0x21,0x14,0x24,0x78,0xae,0xe7,0xf0,0x07,0x81,0xf8,0x17,0xf6,0x62,0xe3,0xb7,0x5d,0xb2,0x9b,0xb1,0x4a,0xb4,0x7c,0xf8,0xe8,0x41,0x04,0xd6,},{0xb1,0xd3,0x98,0x01,0x89,0x20,0x27,0xd5,0x8a,0x8c,0x64,0x33,0x51,0x63,0x19,0x58,0x93,0xbf,0xc1,0xb6,0x1d,0xbe,0xca,0x32,0x60,0x49,0x7e,0x1f,0x30,0x37,0x11,0x07,},{0x83,0x6a,0xfa,0x76,0x4d,0x9c,0x48,0xaa,0x47,0x70,0xa4,0x38,0x8b,0x65,0x4e,0x97,0xb3,0xc1,0x6f,0x08,0x29,0x67,0xfe,0xbc,0xa2,0x7f,0x2f,0xc4,0x7d,0xdf,0xd9,0x24,0x4b,0x03,0xcf,0xc7,0x29,0x69,0x8a,0xcf,0x51,0x09,0x70,0x43,0x46,0xb6,0x0b,0x23,0x0f,0x25,0x54,0x30,0x08,0x9d,0xdc,0x56,0x91,0x23,0x99,0xd1,0x12,0x2d,0xe7,0x0a,},24,"\xd3\xd6\x15\xa8\x47\x2d\x99\x62\xbb\x70\xc5\xb5\x46\x6a\x3d\x98\x3a\x48\x11\x04\x6e\x2a\x0e\xf5"}, - {{0x6b,0x83,0xd7,0xda,0x89,0x08,0xc3,0xe7,0x20,0x5b,0x39,0x86,0x4b,0x56,0xe5,0xf3,0xe1,0x71,0x96,0xa3,0xfc,0x9c,0x2f,0x58,0x05,0xaa,0xd0,0xf5,0x55,0x4c,0x14,0x2d,},{0xd0,0xc8,0x46,0xf9,0x7f,0xe2,0x85,0x85,0xc0,0xee,0x15,0x90,0x15,0xd6,0x4c,0x56,0x31,0x1c,0x88,0x6e,0xdd,0xcc,0x18,0x5d,0x29,0x6d,0xbb,0x16,0x5d,0x26,0x25,0xd6,},{0x16,0xe4,0x62,0xa2,0x9a,0x6d,0xd4,0x98,0x68,0x5a,0x37,0x18,0xb3,0xee,0xd0,0x0c,0xc1,0x59,0x86,0x01,0xee,0x47,0x82,0x04,0x86,0x03,0x2d,0x6b,0x9a,0xcc,0x9b,0xf8,0x9f,0x57,0x68,0x4e,0x08,0xd8,0xc0,0xf0,0x55,0x89,0xcd,0xa2,0x88,0x2a,0x05,0xdc,0x4c,0x63,0xf9,0xd0,0x43,0x1d,0x65,0x52,0x71,0x08,0x12,0x43,0x30,0x03,0xbc,0x08,},25,"\x6a\xda\x80\xb6\xfa\x84\xf7\x03\x49\x20\x78\x9e\x85\x36\xb8\x2d\x5e\x46\x78\x05\x9a\xed\x27\xf7\x1c"}, - {{0x19,0xa9,0x1f,0xe2,0x3a,0x4e,0x9e,0x33,0xec,0xc4,0x74,0x87,0x8f,0x57,0xc6,0x4c,0xf1,0x54,0xb3,0x94,0x20,0x34,0x87,0xa7,0x03,0x5e,0x1a,0xd9,0xcd,0x69,0x7b,0x0d,},{0x2b,0xf3,0x2b,0xa1,0x42,0xba,0x46,0x22,0xd8,0xf3,0xe2,0x9e,0xcd,0x85,0xee,0xa0,0x7b,0x9c,0x47,0xbe,0x9d,0x64,0x41,0x2c,0x9b,0x51,0x0b,0x27,0xdd,0x21,0x8b,0x23,},{0x88,0x1f,0x5b,0x8c,0x5a,0x03,0x0d,0xf0,0xf7,0x5b,0x66,0x34,0xb0,0x70,0xdd,0x27,0xbd,0x1e,0xe3,0xc0,0x87,0x38,0xae,0x34,0x93,0x38,0xb3,0xee,0x64,0x69,0xbb,0xf9,0x76,0x0b,0x13,0x57,0x8a,0x23,0x7d,0x51,0x82,0x53,0x5e,0xde,0x12,0x12,0x83,0x02,0x7a,0x90,0xb5,0xf8,0x65,0xd6,0x3a,0x65,0x37,0xdc,0xa0,0x7b,0x44,0x04,0x9a,0x0f,},26,"\x82\xcb\x53\xc4\xd5\xa0\x13\xba\xe5\x07\x07\x59\xec\x06\xc3\xc6\x95\x5a\xb7\xa4\x05\x09\x58\xec\x32\x8c"}, - {{0x1d,0x5b,0x8c,0xb6,0x21,0x5c,0x18,0x14,0x16,0x66,0xba,0xee,0xfc,0xf5,0xd6,0x9d,0xad,0x5b,0xea,0x9a,0x34,0x93,0xdd,0xda,0xa3,0x57,0xa4,0x39,0x7a,0x13,0xd4,0xde,},{0x94,0xd2,0x3d,0x97,0x7c,0x33,0xe4,0x9e,0x5e,0x49,0x92,0xc6,0x8f,0x25,0xec,0x99,0xa2,0x7c,0x41,0xce,0x6b,0x91,0xf2,0xbf,0xa0,0xcd,0x82,0x92,0xfe,0x96,0x28,0x35,},{0x3a,0xcd,0x39,0xbe,0xc8,0xc3,0xcd,0x2b,0x44,0x29,0x97,0x22,0xb5,0x85,0x0a,0x04,0x00,0xc1,0x44,0x35,0x90,0xfd,0x48,0x61,0xd5,0x9a,0xae,0x74,0x96,0xac,0xb3,0xdf,0x73,0xfc,0x3f,0xdf,0x79,0x69,0xae,0x5f,0x50,0xba,0x47,0xdd,0xdc,0x43,0x52,0x46,0xe5,0xfd,0x37,0x6f,0x6b,0x89,0x1c,0xd4,0xc2,0xca,0xf5,0xd6,0x14,0xb6,0x17,0x0c,},27,"\xa9\xa8\xcb\xb0\xad\x58\x51\x24\xe5\x22\xab\xbf\xb4\x05\x33\xbd\xd6\xf4\x93\x47\xb5\x5b\x18\xe8\x55\x8c\xb0"}, - {{0x6a,0x91,0xb3,0x22,0x7c,0x47,0x22,0x99,0x08,0x9b,0xdc,0xe9,0x35,0x6e,0x72,0x6a,0x40,0xef,0xd8,0x40,0xf1,0x10,0x02,0x70,0x8b,0x7e,0xe5,0x5b,0x64,0x10,0x5a,0xc2,},{0x9d,0x08,0x4a,0xa8,0xb9,0x7a,0x6b,0x9b,0xaf,0xa4,0x96,0xdb,0xc6,0xf7,0x6f,0x33,0x06,0xa1,0x16,0xc9,0xd9,0x17,0xe6,0x81,0x52,0x0a,0x0f,0x91,0x43,0x69,0x42,0x7e,},{0xf5,0x87,0x54,0x23,0x78,0x1b,0x66,0x21,0x6c,0xb5,0xe8,0x99,0x8d,0xe5,0xd9,0xff,0xc2,0x9d,0x1d,0x67,0x10,0x70,0x54,0xac,0xe3,0x37,0x45,0x03,0xa9,0xc3,0xef,0x81,0x15,0x77,0xf2,0x69,0xde,0x81,0x29,0x67,0x44,0xbd,0x70,0x6f,0x1a,0xc4,0x78,0xca,0xf0,0x9b,0x54,0xcd,0xf8,0x71,0xb3,0xf8,0x02,0xbd,0x57,0xf9,0xa6,0xcb,0x91,0x01,},28,"\x5c\xb6\xf9\xaa\x59\xb8\x0e\xca\x14\xf6\xa6\x8f\xb4\x0c\xf0\x7b\x79\x4e\x75\x17\x1f\xba\x96\x26\x2c\x1c\x6a\xdc"}, - {{0x93,0xea,0xa8,0x54,0xd7,0x91,0xf0,0x53,0x72,0xce,0x72,0xb9,0x4f,0xc6,0x50,0x3b,0x2f,0xf8,0xae,0x68,0x19,0xe6,0xa2,0x1a,0xfe,0x82,0x5e,0x27,0xad,0xa9,0xe4,0xfb,},{0x16,0xce,0xe8,0xa3,0xf2,0x63,0x18,0x34,0xc8,0x8b,0x67,0x08,0x97,0xff,0x0b,0x08,0xce,0x90,0xcc,0x14,0x7b,0x45,0x93,0xb3,0xf1,0xf4,0x03,0x72,0x7f,0x7e,0x7a,0xd5,},{0xd8,0x34,0x19,0x7c,0x1a,0x30,0x80,0x61,0x4e,0x0a,0x5f,0xa0,0xaa,0xaa,0x80,0x88,0x24,0xf2,0x1c,0x38,0xd6,0x92,0xe6,0xff,0xbd,0x20,0x0f,0x7d,0xfb,0x3c,0x8f,0x44,0x40,0x2a,0x73,0x82,0x18,0x0b,0x98,0xad,0x0a,0xfc,0x8e,0xec,0x1a,0x02,0xac,0xec,0xf3,0xcb,0x7f,0xde,0x62,0x7b,0x9f,0x18,0x11,0x1f,0x26,0x0a,0xb1,0xdb,0x9a,0x07,},29,"\x32\xfe\x27\x99\x41\x24\x20\x21\x53\xb5\xc7\x0d\x38\x13\xfd\xee\x9c\x2a\xa6\xe7\xdc\x74\x3d\x4d\x53\x5f\x18\x40\xa5"}, - {{0x94,0x1c,0xac,0x69,0xfb,0x7b,0x18,0x15,0xc5,0x7b,0xb9,0x87,0xc4,0xd6,0xc2,0xad,0x2c,0x35,0xd5,0xf9,0xa3,0x18,0x2a,0x79,0xd4,0xba,0x13,0xea,0xb2,0x53,0xa8,0xad,},{0x23,0xbe,0x32,0x3c,0x56,0x2d,0xfd,0x71,0xce,0x65,0xf5,0xbb,0xa5,0x6a,0x74,0xa3,0xa6,0xdf,0xc3,0x6b,0x57,0x3d,0x2f,0x94,0xf6,0x35,0xc7,0xf9,0xb4,0xfd,0x5a,0x5b,},{0x0f,0x8f,0xad,0x1e,0x6b,0xde,0x77,0x1b,0x4f,0x54,0x20,0xea,0xc7,0x5c,0x37,0x8b,0xae,0x6d,0xb5,0xac,0x66,0x50,0xcd,0x2b,0xc2,0x10,0xc1,0x82,0x3b,0x43,0x2b,0x48,0xe0,0x16,0xb1,0x05,0x95,0x45,0x8f,0xfa,0xb9,0x2f,0x7a,0x89,0x89,0xb2,0x93,0xce,0xb8,0xdf,0xed,0x6c,0x24,0x3a,0x20,0x38,0xfc,0x06,0x65,0x2a,0xaa,0xf1,0x6f,0x02,},30,"\xbb\x31\x72\x79\x57\x10\xfe\x00\x05\x4d\x3b\x5d\xfe\xf8\xa1\x16\x23\x58\x2d\xa6\x8b\xf8\xe4\x6d\x72\xd2\x7c\xec\xe2\xaa"}, - {{0x1a,0xcd,0xbb,0x79,0x3b,0x03,0x84,0x93,0x46,0x27,0x47,0x0d,0x79,0x5c,0x3d,0x1d,0xd4,0xd7,0x9c,0xea,0x59,0xef,0x98,0x3f,0x29,0x5b,0x9b,0x59,0x17,0x9c,0xbb,0x28,},{0x3f,0x60,0xc7,0x54,0x1a,0xfa,0x76,0xc0,0x19,0xcf,0x5a,0xa8,0x2d,0xcd,0xb0,0x88,0xed,0x9e,0x4e,0xd9,0x78,0x05,0x14,0xae,0xfb,0x37,0x9d,0xab,0xc8,0x44,0xf3,0x1a,},{0xbe,0x71,0xef,0x48,0x06,0xcb,0x04,0x1d,0x88,0x5e,0xff,0xd9,0xe6,0xb0,0xfb,0xb7,0x3d,0x65,0xd7,0xcd,0xec,0x47,0xa8,0x9c,0x8a,0x99,0x48,0x92,0xf4,0xe5,0x5a,0x56,0x8c,0x4c,0xc7,0x8d,0x61,0xf9,0x01,0xe8,0x0d,0xbb,0x62,0x8b,0x86,0xa2,0x3c,0xcd,0x59,0x4e,0x71,0x2b,0x57,0xfa,0x94,0xc2,0xd6,0x7e,0xc2,0x66,0x34,0x87,0x85,0x07,},31,"\x7c\xf3\x4f\x75\xc3\xda\xc9\xa8\x04\xd0\xfc\xd0\x9e\xba\x9b\x29\xc9\x48\x4e\x8a\x01\x8f\xa9\xe0\x73\x04\x2d\xf8\x8e\x3c\x56"}, - {{0x8e,0xd7,0xa7,0x97,0xb9,0xce,0xa8,0xa8,0x37,0x0d,0x41,0x91,0x36,0xbc,0xdf,0x68,0x3b,0x75,0x9d,0x2e,0x3c,0x69,0x47,0xf1,0x7e,0x13,0xe2,0x48,0x5a,0xa9,0xd4,0x20,},{0xb4,0x9f,0x3a,0x78,0xb1,0xc6,0xa7,0xfc,0xa8,0xf3,0x46,0x6f,0x33,0xbc,0x0e,0x92,0x9f,0x01,0xfb,0xa0,0x43,0x06,0xc2,0xa7,0x46,0x5f,0x46,0xc3,0x75,0x93,0x16,0xd9,},{0x04,0x26,0x6c,0x03,0x3b,0x91,0xc1,0x32,0x2c,0xeb,0x34,0x46,0xc9,0x01,0xff,0xcf,0x3c,0xc4,0x0c,0x40,0x34,0xe8,0x87,0xc9,0x59,0x7c,0xa1,0x89,0x3b,0xa7,0x33,0x0b,0xec,0xbb,0xd8,0xb4,0x81,0x42,0xef,0x35,0xc0,0x12,0xc6,0xba,0x51,0xa6,0x6d,0xf9,0x30,0x8c,0xb6,0x26,0x8a,0xd6,0xb1,0xe4,0xb0,0x3e,0x70,0x10,0x24,0x95,0x79,0x0b,},32,"\xa7\x50\xc2\x32\x93\x3d\xc1\x4b\x11\x84\xd8\x6d\x8b\x4c\xe7\x2e\x16\xd6\x97\x44\xba\x69\x81\x8b\x6a\xc3\x3b\x1d\x82\x3b\xb2\xc3"}, - {{0xf2,0xab,0x39,0x6f,0xe8,0x90,0x6e,0x3e,0x56,0x33,0xe9,0x9c,0xab,0xcd,0x5b,0x09,0xdf,0x08,0x59,0xb5,0x16,0x23,0x0b,0x1e,0x04,0x50,0xb5,0x80,0xb6,0x5f,0x61,0x6c,},{0x8e,0xa0,0x74,0x24,0x51,0x59,0xa1,0x16,0xaa,0x71,0x22,0xa2,0x5e,0xc1,0x6b,0x89,0x1d,0x62,0x5a,0x68,0xf3,0x36,0x60,0x42,0x39,0x08,0xf6,0xbd,0xc4,0x4f,0x8c,0x1b,},{0xa0,0x6a,0x23,0xd9,0x82,0xd8,0x1a,0xb8,0x83,0xaa,0xe2,0x30,0xad,0xbc,0x36,0x8a,0x6a,0x99,0x77,0xf0,0x03,0xce,0xbb,0x00,0xd4,0xc2,0xe4,0x01,0x84,0x90,0x19,0x1a,0x84,0xd3,0xa2,0x82,0xfd,0xbf,0xb2,0xfc,0x88,0x04,0x6e,0x62,0xde,0x43,0xe1,0x5f,0xb5,0x75,0x33,0x6b,0x3c,0x8b,0x77,0xd1,0x9c,0xe6,0xa0,0x09,0xce,0x51,0xf5,0x0c,},33,"\x5a\x44\xe3\x4b\x74\x6c\x5f\xd1\x89\x8d\x55\x2a\xb3\x54\xd2\x8f\xb4\x71\x38\x56\xd7\x69\x7d\xd6\x3e\xb9\xbd\x6b\x99\xc2\x80\xe1\x87"}, - {{0x55,0x0a,0x41,0xc0,0x13,0xf7,0x9b,0xab,0x8f,0x06,0xe4,0x3a,0xd1,0x83,0x6d,0x51,0x31,0x27,0x36,0xa9,0x71,0x38,0x06,0xfa,0xfe,0x66,0x45,0x21,0x9e,0xaa,0x1f,0x9d,},{0xaf,0x6b,0x71,0x45,0x47,0x4d,0xc9,0x95,0x4b,0x9a,0xf9,0x3a,0x9c,0xdb,0x34,0x44,0x9d,0x5b,0x7c,0x65,0x1c,0x82,0x4d,0x24,0xe2,0x30,0xb9,0x00,0x33,0xce,0x59,0xc0,},{0x16,0xdc,0x1e,0x2b,0x9f,0xa9,0x09,0xee,0xfd,0xc2,0x77,0xba,0x16,0xeb,0xe2,0x07,0xb8,0xda,0x5e,0x91,0x14,0x3c,0xde,0x78,0xc5,0x04,0x7a,0x89,0xf6,0x81,0xc3,0x3c,0x4e,0x4e,0x34,0x28,0xd5,0xc9,0x28,0x09,0x59,0x03,0xa8,0x11,0xec,0x00,0x2d,0x52,0xa3,0x9e,0xd7,0xf8,0xb3,0xfe,0x19,0x27,0x20,0x0c,0x6d,0xd0,0xb9,0xab,0x3e,0x04,},34,"\x8b\xc4\x18\x5e\x50\xe5\x7d\x5f\x87\xf4\x75\x15\xfe\x2b\x18\x37\xd5\x85\xf0\xaa\xe9\xe1\xca\x38\x3b\x3e\xc9\x08\x88\x4b\xb9\x00\xff\x27"}, - {{0x19,0xac,0x3e,0x27,0x24,0x38,0xc7,0x2d,0xdf,0x7b,0x88,0x19,0x64,0x86,0x7c,0xb3,0xb3,0x1f,0xf4,0xc7,0x93,0xbb,0x7e,0xa1,0x54,0x61,0x3c,0x1d,0xb0,0x68,0xcb,0x7e,},{0xf8,0x5b,0x80,0xe0,0x50,0xa1,0xb9,0x62,0x0d,0xb1,0x38,0xbf,0xc9,0xe1,0x00,0x32,0x7e,0x25,0xc2,0x57,0xc5,0x92,0x17,0xb6,0x01,0xf1,0xf6,0xac,0x9a,0x41,0x3d,0x3f,},{0xea,0x85,0x5d,0x78,0x1c,0xbe,0xa4,0x68,0x2e,0x35,0x01,0x73,0xcb,0x89,0xe8,0x61,0x9c,0xcf,0xdd,0xb9,0x7c,0xdc,0xe1,0x6f,0x9a,0x2f,0x6f,0x68,0x92,0xf4,0x6d,0xbe,0x68,0xe0,0x4b,0x12,0xb8,0xd8,0x86,0x89,0xa7,0xa3,0x16,0x70,0xcd,0xff,0x40,0x9a,0xf9,0x8a,0x93,0xb4,0x9a,0x34,0x53,0x7b,0x6a,0xa0,0x09,0xd2,0xeb,0x8b,0x47,0x01,},35,"\x95\x87\x2d\x5f\x78\x9f\x95\x48\x4e\x30\xcb\xb0\xe1\x14\x02\x89\x53\xb1\x6f\x5c\x6a\x8d\x9f\x65\xc0\x03\xa8\x35\x43\xbe\xaa\x46\xb3\x86\x45"}, - {{0xca,0x26,0x7d,0xe9,0x6c,0x93,0xc2,0x38,0xfa,0xfb,0x12,0x79,0x81,0x20,0x59,0xab,0x93,0xac,0x03,0x05,0x96,0x57,0xfd,0x99,0x4f,0x8f,0xa5,0xa0,0x92,0x39,0xc8,0x21,},{0x01,0x73,0x70,0xc8,0x79,0x09,0x0a,0x81,0xc7,0xf2,0x72,0xc2,0xfc,0x80,0xe3,0xaa,0xc2,0xbc,0x60,0x3f,0xcb,0x37,0x9a,0xfc,0x98,0x69,0x11,0x60,0xab,0x74,0x5b,0x26,},{0xac,0x95,0x7f,0x82,0x33,0x5a,0xa7,0x14,0x1e,0x96,0xb5,0x9d,0x63,0xe3,0xcc,0xee,0x95,0xc3,0xa2,0xc4,0x7d,0x02,0x65,0x40,0xc2,0xaf,0x42,0xdc,0x95,0x33,0xd5,0xfd,0x81,0x82,0x7d,0x16,0x79,0xad,0x18,0x7a,0xea,0xf3,0x78,0x34,0x91,0x5e,0x75,0xb1,0x47,0xa9,0x28,0x68,0x06,0xc8,0x01,0x75,0x16,0xba,0x43,0xdd,0x05,0x1a,0x5e,0x0c,},36,"\xe0\x5f\x71\xe4\xe4\x9a\x72\xec\x55\x0c\x44\xa3\xb8\x5a\xca\x8f\x20\xff\x26\xc3\xee\x94\xa8\x0f\x1b\x43\x1c\x7d\x15\x4e\xc9\x60\x3e\xe0\x25\x31"}, - {{0x3d,0xff,0x5e,0x89,0x94,0x75,0xe7,0xe9,0x1d,0xd2,0x61,0x32,0x2f,0xab,0x09,0x98,0x0c,0x52,0x97,0x0d,0xe1,0xda,0x6e,0x2e,0x20,0x16,0x60,0xcc,0x4f,0xce,0x70,0x32,},{0xf3,0x01,0x62,0xba,0xc9,0x84,0x47,0xc4,0x04,0x2f,0xac,0x05,0xda,0x44,0x80,0x34,0x62,0x9b,0xe2,0xc6,0xa5,0x8d,0x30,0xdf,0xd5,0x78,0xba,0x9f,0xb5,0xe3,0x93,0x0b,},{0x5e,0xfe,0x7a,0x92,0xff,0x96,0x23,0x08,0x9b,0x3e,0x3b,0x78,0xf3,0x52,0x11,0x53,0x66,0xe2,0x6b,0xa3,0xfb,0x1a,0x41,0x62,0x09,0xbc,0x02,0x9e,0x9c,0xad,0xcc,0xd9,0xf4,0xaf,0xfa,0x33,0x35,0x55,0xa8,0xf3,0xa3,0x5a,0x9d,0x0f,0x7c,0x34,0xb2,0x92,0xca,0xe7,0x7e,0xc9,0x6f,0xa3,0xad,0xfc,0xaa,0xde,0xe2,0xd9,0xce,0xd8,0xf8,0x05,},37,"\x93\x8f\x0e\x77\x62\x1b\xf3\xea\x52\xc7\xc4\x91\x1c\x51\x57\xc2\xd8\xa2\xa8\x58\x09\x3e\xf1\x6a\xa9\xb1\x07\xe6\x9d\x98\x03\x7b\xa1\x39\xa3\xc3\x82"}, - {{0x9a,0x6b,0x84,0x78,0x64,0xe7,0x0c,0xfe,0x8b,0xa6,0xab,0x22,0xfa,0x0c,0xa3,0x08,0xc0,0xcc,0x8b,0xec,0x71,0x41,0xfb,0xca,0xa3,0xb8,0x1f,0x5d,0x1e,0x1c,0xfc,0xfc,},{0x34,0xad,0x0f,0xbd,0xb2,0x56,0x65,0x07,0xa8,0x1c,0x2b,0x1f,0x8a,0xa8,0xf5,0x3d,0xcc,0xaa,0x64,0xcc,0x87,0xad,0xa9,0x1b,0x90,0x3e,0x90,0x0d,0x07,0xee,0xe9,0x30,},{0x2a,0xb2,0x55,0x16,0x9c,0x48,0x9c,0x54,0xc7,0x32,0x23,0x2e,0x37,0xc8,0x73,0x49,0xd4,0x86,0xb1,0xeb,0xa2,0x05,0x09,0xdb,0xab,0xe7,0xfe,0xd3,0x29,0xef,0x08,0xfd,0x75,0xba,0x1c,0xd1,0x45,0xe6,0x7b,0x2e,0xa2,0x6c,0xb5,0xcc,0x51,0xca,0xb3,0x43,0xee,0xb0,0x85,0xfe,0x1f,0xd7,0xb0,0xec,0x4c,0x6a,0xfc,0xd9,0xb9,0x79,0xf9,0x05,},38,"\x83\x83\x67\x47\x11\x83\xc7\x1f\x7e\x71\x77\x24\xf8\x9d\x40\x1c\x3a\xd9\x86\x3f\xd9\xcc\x7a\xa3\xcf\x33\xd3\xc5\x29\x86\x0c\xb5\x81\xf3\x09\x3d\x87\xda"}, - {{0x57,0x5b,0xe0,0x7a,0xfc,0xa5,0xd0,0x63,0xc2,0x38,0xcd,0x9b,0x80,0x28,0x77,0x2c,0xc4,0x9c,0xda,0x34,0x47,0x14,0x32,0xa2,0xe1,0x66,0xe0,0x96,0xe2,0x21,0x9e,0xfc,},{0x94,0xe5,0xeb,0x4d,0x50,0x24,0xf4,0x9d,0x7e,0xbf,0x79,0x81,0x7c,0x8d,0xe1,0x14,0x97,0xdc,0x2b,0x55,0x62,0x2a,0x51,0xae,0x12,0x3f,0xfc,0x74,0x9d,0xbb,0x16,0xe0,},{0x58,0x27,0x1d,0x44,0x23,0x6f,0x3b,0x98,0xc5,0x8f,0xd7,0xae,0x0d,0x2f,0x49,0xef,0x2b,0x6e,0x3a,0xff,0xdb,0x22,0x5a,0xa3,0xba,0x55,0x5f,0x0e,0x11,0xcc,0x53,0xc2,0x3a,0xd1,0x9b,0xaf,0x24,0x34,0x65,0x90,0xd0,0x5d,0x7d,0x53,0x90,0x58,0x20,0x82,0xcf,0x94,0xd3,0x9c,0xad,0x65,0x30,0xab,0x93,0xd1,0x3e,0xfb,0x39,0x27,0x95,0x06,},39,"\x33\xe5\x91\x8b\x66\xd3\x3d\x55\xfe\x71\x7c\xa3\x43\x83\xea\xe7\x8f\x0a\xf8\x28\x89\xca\xf6\x69\x6e\x1a\xc9\xd9\x5d\x1f\xfb\x32\xcb\xa7\x55\xf9\xe3\x50\x3e"}, - {{0x15,0xff,0xb4,0x55,0x14,0xd4,0x34,0x44,0xd6,0x1f,0xcb,0x10,0x5e,0x30,0xe1,0x35,0xfd,0x26,0x85,0x23,0xdd,0xa2,0x0b,0x82,0x75,0x8b,0x17,0x94,0x23,0x11,0x04,0x41,},{0x17,0x72,0xc5,0xab,0xc2,0xd2,0x3f,0xd2,0xf9,0xd1,0xc3,0x25,0x7b,0xe7,0xbc,0x3c,0x1c,0xd7,0x9c,0xee,0x40,0x84,0x4b,0x74,0x9b,0x3a,0x77,0x43,0xd2,0xf9,0x64,0xb8,},{0x68,0x28,0xcd,0x76,0x24,0xe7,0x93,0xb8,0xa4,0xce,0xb9,0x6d,0x3c,0x2a,0x97,0x5b,0xf7,0x73,0xe5,0xff,0x66,0x45,0xf3,0x53,0x61,0x40,0x58,0x62,0x1e,0x58,0x83,0x52,0x89,0xe7,0xf3,0x1f,0x42,0xdf,0xe6,0xaf,0x6d,0x73,0x6f,0x26,0x44,0x51,0x1e,0x32,0x0c,0x0f,0xa6,0x98,0x58,0x2a,0x79,0x77,0x8d,0x18,0x73,0x0e,0xd3,0xe8,0xcb,0x08,},40,"\xda\x9c\x55\x59\xd0\xea\x51\xd2\x55\xb6\xbd\x9d\x76\x38\xb8\x76\x47\x2f\x94\x2b\x33\x0f\xc0\xe2\xb3\x0a\xea\x68\xd7\x73\x68\xfc\xe4\x94\x82\x72\x99\x1d\x25\x7e"}, - {{0xfe,0x05,0x68,0x64,0x29,0x43,0xb2,0xe1,0xaf,0xbf,0xd1,0xf1,0x0f,0xe8,0xdf,0x87,0xa4,0x23,0x6b,0xea,0x40,0xdc,0xe7,0x42,0x07,0x2c,0xb2,0x18,0x86,0xee,0xc1,0xfa,},{0x29,0x9e,0xbd,0x1f,0x13,0x17,0x7d,0xbd,0xb6,0x6a,0x91,0x2b,0xbf,0x71,0x20,0x38,0xfd,0xf7,0x3b,0x06,0xc3,0xac,0x02,0x0c,0x7b,0x19,0x12,0x67,0x55,0xd4,0x7f,0x61,},{0xd5,0x9e,0x6d,0xfc,0xc6,0xd7,0xe3,0xe2,0xc5,0x8d,0xec,0x81,0xe9,0x85,0xd2,0x45,0xe6,0x81,0xac,0xf6,0x59,0x4a,0x23,0xc5,0x92,0x14,0xf7,0xbe,0xd8,0x01,0x5d,0x81,0x3c,0x76,0x82,0xb6,0x0b,0x35,0x83,0x44,0x03,0x11,0xe7,0x2a,0x86,0x65,0xba,0x2c,0x96,0xde,0xc2,0x3c,0xe8,0x26,0xe1,0x60,0x12,0x7e,0x18,0x13,0x2b,0x03,0x04,0x04,},41,"\xc5\x9d\x08\x62\xec\x1c\x97\x46\xab\xcc\x3c\xf8\x3c\x9e\xeb\xa2\xc7\x08\x2a\x03\x6a\x8c\xb5\x7c\xe4\x87\xe7\x63\x49\x27\x96\xd4\x7e\x6e\x06\x3a\x0c\x1f\xec\xcc\x2d"}, - {{0x5e,0xcb,0x16,0xc2,0xdf,0x27,0xc8,0xcf,0x58,0xe4,0x36,0xa9,0xd3,0xaf,0xfb,0xd5,0x8e,0x95,0x38,0xa9,0x26,0x59,0xa0,0xf9,0x7c,0x4c,0x4f,0x99,0x46,0x35,0xa8,0xca,},{0xda,0x76,0x8b,0x20,0xc4,0x37,0xdd,0x3a,0xa5,0xf8,0x4b,0xb6,0xa0,0x77,0xff,0xa3,0x4a,0xb6,0x85,0x01,0xc5,0x35,0x2b,0x5c,0xc3,0xfd,0xce,0x7f,0xe6,0xc2,0x39,0x8d,},{0x1c,0x72,0x3a,0x20,0xc6,0x77,0x24,0x26,0xa6,0x70,0xe4,0xd5,0xc4,0xa9,0x7c,0x6e,0xbe,0x91,0x47,0xf7,0x1b,0xb0,0xa4,0x15,0x63,0x1e,0x44,0x40,0x6e,0x29,0x03,0x22,0xe4,0xca,0x97,0x7d,0x34,0x8f,0xe7,0x85,0x6a,0x8e,0xdc,0x23,0x5d,0x0f,0xe9,0x5f,0x7e,0xd9,0x1a,0xef,0xdd,0xf2,0x8a,0x77,0xe2,0xc7,0xdb,0xfd,0x8f,0x55,0x2f,0x0a,},42,"\x56\xf1\x32\x9d\x9a\x6b\xe2\x5a\x61\x59\xc7\x2f\x12\x68\x8d\xc8\x31\x4e\x85\xdd\x9e\x7e\x4d\xc0\x5b\xbe\xcb\x77\x29\xe0\x23\xc8\x6f\x8e\x09\x37\x35\x3f\x27\xc7\xed\xe9"}, - {{0xd5,0x99,0xd6,0x37,0xb3,0xc3,0x0a,0x82,0xa9,0x98,0x4e,0x2f,0x75,0x84,0x97,0xd1,0x44,0xde,0x6f,0x06,0xb9,0xfb,0xa0,0x4d,0xd4,0x0f,0xd9,0x49,0x03,0x9d,0x7c,0x84,},{0x67,0x91,0xd8,0xce,0x50,0xa4,0x46,0x89,0xfc,0x17,0x87,0x27,0xc5,0xc3,0xa1,0xc9,0x59,0xfb,0xee,0xd7,0x4e,0xf7,0xd8,0xe7,0xbd,0x3c,0x1a,0xb4,0xda,0x31,0xc5,0x1f,},{0xeb,0xf1,0x0d,0x9a,0xc7,0xc9,0x61,0x08,0x14,0x0e,0x7d,0xef,0x6f,0xe9,0x53,0x3d,0x72,0x76,0x46,0xff,0x5b,0x3a,0xf2,0x73,0xc1,0xdf,0x95,0x76,0x2a,0x66,0xf3,0x2b,0x65,0xa0,0x96,0x34,0xd0,0x13,0xf5,0x4b,0x5d,0xd6,0x01,0x1f,0x91,0xbc,0x33,0x6c,0xa8,0xb3,0x55,0xce,0x33,0xf8,0xcf,0xbe,0xc2,0x53,0x5a,0x4c,0x42,0x7f,0x82,0x05,},43,"\xa7\xc0\x4e\x8b\xa7\x5d\x0a\x03\xd8\xb1\x66\xad\x7a\x1d\x77\xe1\xb9\x1c\x7a\xaf\x7b\xef\xdd\x99\x31\x1f\xc3\xc5\x4a\x68\x4d\xdd\x97\x1d\x5b\x32\x11\xc3\xee\xaf\xf1\xe5\x4e"}, - {{0x30,0xab,0x82,0x32,0xfa,0x70,0x18,0xf0,0xce,0x6c,0x39,0xbd,0x8f,0x78,0x2f,0xe2,0xe1,0x59,0x75,0x8b,0xb0,0xf2,0xf4,0x38,0x6c,0x7f,0x28,0xcf,0xd2,0xc8,0x58,0x98,},{0xec,0xfb,0x6a,0x2b,0xd4,0x2f,0x31,0xb6,0x12,0x50,0xba,0x5d,0xe7,0xe4,0x6b,0x47,0x19,0xaf,0xdf,0xbc,0x66,0x0d,0xb7,0x1a,0x7b,0xd1,0xdf,0x7b,0x0a,0x3a,0xbe,0x37,},{0x9a,0xf8,0x85,0x34,0x4c,0xc7,0x23,0x94,0x98,0xf7,0x12,0xdf,0x80,0xbc,0x01,0xb8,0x06,0x38,0x29,0x1e,0xd4,0xa1,0xd2,0x8b,0xaa,0x55,0x45,0x01,0x7a,0x72,0xe2,0xf6,0x56,0x49,0xcc,0xf9,0x60,0x3d,0xa6,0xeb,0x5b,0xfa,0xb9,0xf5,0x54,0x3a,0x6c,0xa4,0xa7,0xaf,0x38,0x66,0x15,0x3c,0x76,0xbf,0x66,0xbf,0x95,0xde,0xf6,0x15,0xb0,0x0c,},44,"\x63\xb8\x0b\x79\x56\xac\xbe\xcf\x0c\x35\xe9\xab\x06\xb9\x14\xb0\xc7\x01\x4f\xe1\xa4\xbb\xc0\x21\x72\x40\xc1\xa3\x30\x95\xd7\x07\x95\x3e\xd7\x7b\x15\xd2\x11\xad\xaf\x9b\x97\xdc"}, - {{0x0d,0xdc,0xdc,0x87,0x2c,0x7b,0x74,0x8d,0x40,0xef,0xe9,0x6c,0x28,0x81,0xae,0x18,0x9d,0x87,0xf5,0x61,0x48,0xed,0x8a,0xf3,0xeb,0xbb,0xc8,0x03,0x24,0xe3,0x8b,0xdd,},{0x58,0x8d,0xda,0xdc,0xbc,0xed,0xf4,0x0d,0xf0,0xe9,0x69,0x7d,0x8b,0xb2,0x77,0xc7,0xbb,0x14,0x98,0xfa,0x1d,0x26,0xce,0x0a,0x83,0x5a,0x76,0x0b,0x92,0xca,0x7c,0x85,},{0xc1,0x79,0xc0,0x94,0x56,0xe2,0x35,0xfe,0x24,0x10,0x5a,0xfa,0x6e,0x8e,0xc0,0x46,0x37,0xf8,0xf9,0x43,0x81,0x7c,0xd0,0x98,0xba,0x95,0x38,0x7f,0x96,0x53,0xb2,0xad,0xd1,0x81,0xa3,0x14,0x47,0xd9,0x2d,0x1a,0x1d,0xdf,0x1c,0xeb,0x0d,0xb6,0x21,0x18,0xde,0x9d,0xff,0xb7,0xdc,0xd2,0x42,0x40,0x57,0xcb,0xdf,0xf5,0xd4,0x1d,0x04,0x03,},45,"\x65\x64\x1c\xd4\x02\xad\xd8\xbf\x3d\x1d\x67\xdb\xeb\x6d\x41\xde\xbf\xbe\xf6\x7e\x43\x17\xc3\x5b\x0a\x6d\x5b\xbb\xae\x0e\x03\x4d\xe7\xd6\x70\xba\x14\x13\xd0\x56\xf2\xd6\xf1\xde\x12"}, - {{0x89,0xf0,0xd6,0x82,0x99,0xba,0x0a,0x5a,0x83,0xf2,0x48,0xae,0x0c,0x16,0x9f,0x8e,0x38,0x49,0xa9,0xb4,0x7b,0xd4,0x54,0x98,0x84,0x30,0x5c,0x99,0x12,0xb4,0x66,0x03,},{0xab,0xa3,0xe7,0x95,0xaa,0xb2,0x01,0x2a,0xcc,0xea,0xdd,0x7b,0x3b,0xd9,0xda,0xee,0xed,0x6f,0xf5,0x25,0x8b,0xdc,0xd7,0xc9,0x36,0x99,0xc2,0xa3,0x83,0x6e,0x38,0x32,},{0x2c,0x69,0x1f,0xa8,0xd4,0x87,0xce,0x20,0xd5,0xd2,0xfa,0x41,0x55,0x91,0x16,0xe0,0xbb,0xf4,0x39,0x7c,0xf5,0x24,0x0e,0x15,0x25,0x56,0x18,0x35,0x41,0xd6,0x6c,0xf7,0x53,0x58,0x24,0x01,0xa4,0x38,0x8d,0x39,0x03,0x39,0xdb,0xef,0x4d,0x38,0x47,0x43,0xca,0xa3,0x46,0xf5,0x5f,0x8d,0xab,0xa6,0x8b,0xa7,0xb9,0x13,0x1a,0x8a,0x6e,0x0b,},46,"\x4f\x18\x46\xdd\x7a\xd5\x0e\x54\x5d\x4c\xfb\xff\xbb\x1d\xc2\xff\x14\x5d\xc1\x23\x75\x4d\x08\xaf\x4e\x44\xec\xc0\xbc\x8c\x91\x41\x13\x88\xbc\x76\x53\xe2\xd8\x93\xd1\xea\xc2\x10\x7d\x05"}, - {{0x0a,0x3c,0x18,0x44,0xe2,0xdb,0x07,0x0f,0xb2,0x4e,0x3c,0x95,0xcb,0x1c,0xc6,0x71,0x4e,0xf8,0x4e,0x2c,0xcd,0x2b,0x9d,0xd2,0xf1,0x46,0x0e,0xbf,0x7e,0xcf,0x13,0xb1,},{0x72,0xe4,0x09,0x93,0x7e,0x06,0x10,0xeb,0x5c,0x20,0xb3,0x26,0xdc,0x6e,0xa1,0xbb,0xbc,0x04,0x06,0x70,0x1c,0x5c,0xd6,0x7d,0x1f,0xbd,0xe0,0x91,0x92,0xb0,0x7c,0x01,},{0x87,0xf7,0xfd,0xf4,0x60,0x95,0x20,0x1e,0x87,0x7a,0x58,0x8f,0xe3,0xe5,0xaa,0xf4,0x76,0xbd,0x63,0x13,0x8d,0x8a,0x87,0x8b,0x89,0xd6,0xac,0x60,0x63,0x1b,0x34,0x58,0xb9,0xd4,0x1a,0x3c,0x61,0xa5,0x88,0xe1,0xdb,0x8d,0x29,0xa5,0x96,0x89,0x81,0xb0,0x18,0x77,0x6c,0x58,0x87,0x80,0x92,0x2f,0x5a,0xa7,0x32,0xba,0x63,0x79,0xdd,0x05,},47,"\x4c\x82\x74\xd0\xed\x1f\x74\xe2\xc8\x6c\x08\xd9\x55\xbd\xe5\x5b\x2d\x54\x32\x7e\x82\x06\x2a\x1f\x71\xf7\x0d\x53\x6f\xdc\x87\x22\xcd\xea\xd7\xd2\x2a\xae\xad\x2b\xfa\xa1\xad\x00\xb8\x29\x57"}, - {{0xc8,0xd7,0xa8,0x81,0x8b,0x98,0xdf,0xdb,0x20,0x83,0x9c,0x87,0x1c,0xb5,0xc4,0x8e,0x9e,0x94,0x70,0xca,0x3a,0xd3,0x5b,0xa2,0x61,0x3a,0x5d,0x31,0x99,0xc8,0xab,0x23,},{0x90,0xd2,0xef,0xbb,0xa4,0xd4,0x3e,0x6b,0x2b,0x99,0x2c,0xa1,0x60,0x83,0xdb,0xcf,0xa2,0xb3,0x22,0x38,0x39,0x07,0xb0,0xee,0x75,0xf3,0xe9,0x58,0x45,0xd3,0xc4,0x7f,},{0xfa,0x2e,0x99,0x44,0x21,0xae,0xf1,0xd5,0x85,0x66,0x74,0x81,0x3d,0x05,0xcb,0xd2,0xcf,0x84,0xef,0x5e,0xb4,0x24,0xaf,0x6e,0xcd,0x0d,0xc6,0xfd,0xbd,0xc2,0xfe,0x60,0x5f,0xe9,0x85,0x88,0x33,0x12,0xec,0xf3,0x4f,0x59,0xbf,0xb2,0xf1,0xc9,0x14,0x9e,0x5b,0x9c,0xc9,0xec,0xda,0x05,0xb2,0x73,0x11,0x30,0xf3,0xed,0x28,0xdd,0xae,0x0b,},48,"\x78\x3e\x33\xc3\xac\xbd\xbb\x36\xe8\x19\xf5\x44\xa7\x78\x1d\x83\xfc\x28\x3d\x33\x09\xf5\xd3\xd1\x2c\x8d\xcd\x6b\x0b\x3d\x0e\x89\xe3\x8c\xfd\x3b\x4d\x08\x85\x66\x1c\xa5\x47\xfb\x97\x64\xab\xff"}, - {{0xb4,0x82,0x70,0x36,0x12,0xd0,0xc5,0x86,0xf7,0x6c,0xfc,0xb2,0x1c,0xfd,0x21,0x03,0xc9,0x57,0x25,0x15,0x04,0xa8,0xc0,0xac,0x4c,0x86,0xc9,0xc6,0xf3,0xe4,0x29,0xff,},{0xfd,0x71,0x1d,0xc7,0xdd,0x3b,0x1d,0xfb,0x9d,0xf9,0x70,0x4b,0xe3,0xe6,0xb2,0x6f,0x58,0x7f,0xe7,0xdd,0x7b,0xa4,0x56,0xa9,0x1b,0xa4,0x3f,0xe5,0x1a,0xec,0x09,0xad,},{0x58,0x83,0x2b,0xde,0xb2,0x6f,0xea,0xfc,0x31,0xb4,0x62,0x77,0xcf,0x3f,0xb5,0xd7,0xa1,0x7d,0xfb,0x7c,0xcd,0x9b,0x1f,0x58,0xec,0xbe,0x6f,0xeb,0x97,0x96,0x66,0x82,0x8f,0x23,0x9b,0xa4,0xd7,0x52,0x19,0x26,0x0e,0xca,0xc0,0xac,0xf4,0x0f,0x0e,0x5e,0x25,0x90,0xf4,0xca,0xa1,0x6b,0xbb,0xcd,0x8a,0x15,0x5d,0x34,0x79,0x67,0xa6,0x07,},49,"\x29\xd7\x7a\xcf\xd9\x9c\x7a\x00\x70\xa8\x8f\xeb\x62\x47\xa2\xbc\xe9\x98\x4f\xe3\xe6\xfb\xf1\x9d\x40\x45\x04\x2a\x21\xab\x26\xcb\xd7\x71\xe1\x84\xa9\xa7\x5f\x31\x6b\x64\x8c\x69\x20\xdb\x92\xb8\x7b"}, - {{0x84,0xe5,0x0d,0xd9,0xa0,0xf1,0x97,0xe3,0x89,0x3c,0x38,0xdb,0xd9,0x1f,0xaf,0xc3,0x44,0xc1,0x77,0x6d,0x3a,0x40,0x0e,0x2f,0x0f,0x0e,0xe7,0xaa,0x82,0x9e,0xb8,0xa2,},{0x2c,0x50,0xf8,0x70,0xee,0x48,0xb3,0x6b,0x0a,0xc2,0xf8,0xa5,0xf3,0x36,0xfb,0x09,0x0b,0x11,0x30,0x50,0xdb,0xcc,0x25,0xe0,0x78,0x20,0x0a,0x6e,0x16,0x15,0x3e,0xea,},{0x69,0xe6,0xa4,0x49,0x1a,0x63,0x83,0x73,0x16,0xe8,0x6a,0x5f,0x4b,0xa7,0xcd,0x0d,0x73,0x1e,0xcc,0x58,0xf1,0xd0,0xa2,0x64,0xc6,0x7c,0x89,0xbe,0xfd,0xd8,0xd3,0x82,0x9d,0x8d,0xe1,0x3b,0x33,0xcc,0x0b,0xf5,0x13,0x93,0x17,0x15,0xc7,0x80,0x96,0x57,0xe2,0xbf,0xb9,0x60,0xe5,0xc7,0x64,0xc9,0x71,0xd7,0x33,0x74,0x60,0x93,0xe5,0x00,},50,"\xf3\x99\x2c\xde\x64\x93\xe6\x71\xf1\xe1\x29\xdd\xca\x80\x38\xb0\xab\xdb\x77\xbb\x90\x35\xf9\xf8\xbe\x54\xbd\x5d\x68\xc1\xae\xff\x72\x4f\xf4\x7d\x29\x34\x43\x91\xdc\x53\x61\x66\xb8\x67\x1c\xbb\xf1\x23"}, - {{0xb3,0x22,0xd4,0x65,0x77,0xa2,0xa9,0x91,0xa4,0xd1,0x69,0x82,0x87,0x83,0x2a,0x39,0xc4,0x87,0xef,0x77,0x6b,0x4b,0xff,0x03,0x7a,0x05,0xc7,0xf1,0x81,0x2b,0xde,0xec,},{0xeb,0x2b,0xca,0xdf,0xd3,0xee,0xc2,0x98,0x6b,0xaf,0xf3,0x2b,0x98,0xe7,0xc4,0xdb,0xf0,0x3f,0xf9,0x5d,0x8a,0xd5,0xff,0x9a,0xa9,0x50,0x6e,0x54,0x72,0xff,0x84,0x5f,},{0xc7,0xb5,0x51,0x37,0x31,0x7c,0xa2,0x1e,0x33,0x48,0x9f,0xf6,0xa9,0xbf,0xab,0x97,0xc8,0x55,0xdc,0x6f,0x85,0x68,0x4a,0x70,0xa9,0x12,0x5a,0x26,0x1b,0x56,0xd5,0xe6,0xf1,0x49,0xc5,0x77,0x4d,0x73,0x4f,0x2d,0x8d,0xeb,0xfc,0x77,0xb7,0x21,0x89,0x6a,0x82,0x67,0xc2,0x37,0x68,0xe9,0xba,0xdb,0x91,0x0e,0xef,0x83,0xec,0x25,0x88,0x02,},51,"\x19\xf1\xbf\x5d\xcf\x17\x50\xc6\x11\xf1\xc4\xa2\x86\x52\x00\x50\x4d\x82\x29\x8e\xdd\x72\x67\x1f\x62\xa7\xb1\x47\x1a\xc3\xd4\xa3\x0f\x7d\xe9\xe5\xda\x41\x08\xc5\x2a\x4c\xe7\x0a\x3e\x11\x4a\x52\xa3\xb3\xc5"}, - {{0x96,0x0c,0xab,0x50,0x34,0xb9,0x83,0x8d,0x09,0x8d,0x2d,0xcb,0xf4,0x36,0x4b,0xec,0x16,0xd3,0x88,0xf6,0x37,0x6d,0x73,0xa6,0x27,0x3b,0x70,0xf8,0x2b,0xbc,0x98,0xc0,},{0x5e,0x3c,0x19,0xf2,0x41,0x5a,0xcf,0x72,0x9f,0x82,0x9a,0x4e,0xbd,0x5c,0x40,0xe1,0xa6,0xbc,0x9f,0xbc,0xa9,0x57,0x03,0xa9,0x37,0x60,0x87,0xed,0x09,0x37,0xe5,0x1a,},{0x27,0xd4,0xc3,0xa1,0x81,0x1e,0xf9,0xd4,0x36,0x0b,0x3b,0xdd,0x13,0x3c,0x2c,0xcc,0x30,0xd0,0x2c,0x2f,0x24,0x82,0x15,0x77,0x6c,0xb0,0x7e,0xe4,0x17,0x7f,0x9b,0x13,0xfc,0x42,0xdd,0x70,0xa6,0xc2,0xfe,0xd8,0xf2,0x25,0xc7,0x66,0x3c,0x7f,0x18,0x2e,0x7e,0xe8,0xec,0xcf,0xf2,0x0d,0xc7,0xb0,0xe1,0xd5,0x83,0x4e,0xc5,0xb1,0xea,0x01,},52,"\xf8\xb2\x19\x62\x44\x7b\x0a\x8f\x2e\x42\x79\xde\x41\x1b\xea\x12\x8e\x0b\xe4\x4b\x69\x15\xe6\xcd\xa8\x83\x41\xa6\x8a\x0d\x81\x83\x57\xdb\x93\x8e\xac\x73\xe0\xaf\x6d\x31\x20\x6b\x39\x48\xf8\xc4\x8a\x44\x73\x08"}, - {{0xeb,0x77,0xb2,0x63,0x8f,0x23,0xee,0xbc,0x82,0xef,0xe4,0x5e,0xe9,0xe5,0xa0,0x32,0x66,0x37,0x40,0x1e,0x66,0x3e,0xd0,0x29,0x69,0x9b,0x21,0xe6,0x44,0x3f,0xb4,0x8e,},{0x9e,0xf2,0x76,0x08,0x96,0x1a,0xc7,0x11,0xde,0x71,0xa6,0xe2,0xd4,0xd4,0x66,0x3e,0xa3,0xec,0xd4,0x2f,0xb7,0xe4,0xe8,0x62,0x7c,0x39,0x62,0x2d,0xf4,0xaf,0x0b,0xbc,},{0x18,0xdc,0x56,0xd7,0xbd,0x9a,0xcd,0x4f,0x4d,0xaa,0x78,0x54,0x0b,0x4a,0xc8,0xff,0x7a,0xa9,0x81,0x5f,0x45,0xa0,0xbb,0xa3,0x70,0x73,0x1a,0x14,0xea,0xab,0xe9,0x6d,0xf8,0xb5,0xf3,0x7d,0xbf,0x8e,0xae,0x4c,0xb1,0x5a,0x64,0xb2,0x44,0x65,0x1e,0x59,0xd6,0xa3,0xd6,0x76,0x1d,0x9e,0x3c,0x50,0xf2,0xd0,0xcb,0xb0,0x9c,0x05,0xec,0x06,},53,"\x99\xe3\xd0\x09\x34\x00\x3e\xba\xfc\x3e\x9f\xdb\x68\x7b\x0f\x5f\xf9\xd5\x78\x2a\x4b\x1f\x56\xb9\x70\x00\x46\xc0\x77\x91\x56\x02\xc3\x13\x4e\x22\xfc\x90\xed\x7e\x69\x0f\xdd\xd4\x43\x3e\x20\x34\xdc\xb2\xdc\x99\xab"}, - {{0xb6,0x25,0xaa,0x89,0xd3,0xf7,0x30,0x87,0x15,0x42,0x7b,0x6c,0x39,0xbb,0xac,0x58,0xef,0xfd,0x3a,0x0f,0xb7,0x31,0x6f,0x7a,0x22,0xb9,0x9e,0xe5,0x92,0x2f,0x2d,0xc9,},{0x65,0xa9,0x9c,0x3e,0x16,0xfe,0xa8,0x94,0xec,0x33,0xc6,0xb2,0x0d,0x91,0x05,0xe2,0xa0,0x4e,0x27,0x64,0xa4,0x76,0x9d,0x9b,0xbd,0x4d,0x8b,0xac,0xfe,0xab,0x4a,0x2e,},{0x01,0xbb,0x90,0x1d,0x83,0xb8,0xb6,0x82,0xd3,0x61,0x4a,0xf4,0x6a,0x80,0x7b,0xa2,0x69,0x13,0x58,0xfe,0xb7,0x75,0x32,0x5d,0x34,0x23,0xf5,0x49,0xff,0x0a,0xa5,0x75,0x7e,0x4e,0x1a,0x74,0xe9,0xc7,0x0f,0x97,0x21,0xd8,0xf3,0x54,0xb3,0x19,0xd4,0xf4,0xa1,0xd9,0x14,0x45,0xc8,0x70,0xfd,0x0f,0xfb,0x94,0xfe,0xd6,0x46,0x64,0x73,0x0d,},54,"\xe0\x72\x41\xdb\xd3\xad\xbe\x61\x0b\xbe\x4d\x00\x5d\xd4\x67\x32\xa4\xc2\x50\x86\xec\xb8\xec\x29\xcd\x7b\xca\x11\x6e\x1b\xf9\xf5\x3b\xfb\xf3\xe1\x1f\xa4\x90\x18\xd3\x9f\xf1\x15\x4a\x06\x66\x8e\xf7\xdf\x5c\x67\x8e\x6a"}, - {{0xb1,0xc9,0xf8,0xbd,0x03,0xfe,0x82,0xe7,0x8f,0x5c,0x0f,0xb0,0x64,0x50,0xf2,0x7d,0xac,0xdf,0x71,0x64,0x34,0xdb,0x26,0x82,0x75,0xdf,0x3e,0x1d,0xc1,0x77,0xaf,0x42,},{0x7f,0xc8,0x8b,0x1f,0x7b,0x3f,0x11,0xc6,0x29,0xbe,0x67,0x1c,0x21,0x62,0x1f,0x5c,0x10,0x67,0x2f,0xaf,0xc8,0x49,0x2d,0xa8,0x85,0x74,0x20,0x59,0xee,0x67,0x74,0xcf,},{0x4b,0x22,0x99,0x51,0xef,0x26,0x2f,0x16,0x97,0x8f,0x79,0x14,0xbc,0x67,0x2e,0x72,0x26,0xc5,0xf8,0x37,0x9d,0x27,0x78,0xc5,0xa2,0xdc,0x0a,0x26,0x50,0x86,0x9f,0x7a,0xcf,0xbd,0x0b,0xcd,0x30,0xfd,0xb0,0x61,0x9b,0xb4,0x4f,0xc1,0xae,0x59,0x39,0xb8,0x7c,0xc3,0x18,0x13,0x30,0x09,0xc2,0x03,0x95,0xb6,0xc7,0xeb,0x98,0x10,0x77,0x01,},55,"\x33\x1d\xa7\xa9\xc1\xf8\x7b\x2a\xc9\x1e\xe3\xb8\x6d\x06\xc2\x91\x63\xc0\x5e\xd6\xf8\xd8\xa9\x72\x5b\x47\x1b\x7d\xb0\xd6\xac\xec\x7f\x0f\x70\x24\x87\x16\x3f\x5e\xda\x02\x0c\xa5\xb4\x93\xf3\x99\xe1\xc8\xd3\x08\xc3\xc0\xc2"}, - {{0x6d,0x8c,0xdb,0x2e,0x07,0x5f,0x3a,0x2f,0x86,0x13,0x72,0x14,0xcb,0x23,0x6c,0xeb,0x89,0xa6,0x72,0x8b,0xb4,0xa2,0x00,0x80,0x6b,0xf3,0x55,0x7f,0xb7,0x8f,0xac,0x69,},{0x57,0xa0,0x4c,0x7a,0x51,0x13,0xcd,0xdf,0xe4,0x9a,0x4c,0x12,0x46,0x91,0xd4,0x6c,0x1f,0x9c,0xdc,0x8f,0x34,0x3f,0x9d,0xcb,0x72,0xa1,0x33,0x0a,0xec,0xa7,0x1f,0xda,},{0xa6,0xcb,0xc9,0x47,0xf9,0xc8,0x7d,0x14,0x55,0xcf,0x1a,0x70,0x85,0x28,0xc0,0x90,0xf1,0x1e,0xce,0xe4,0x85,0x5d,0x1d,0xba,0xad,0xf4,0x74,0x54,0xa4,0xde,0x55,0xfa,0x4c,0xe8,0x4b,0x36,0xd7,0x3a,0x5b,0x5f,0x8f,0x59,0x29,0x8c,0xcf,0x21,0x99,0x2d,0xf4,0x92,0xef,0x34,0x16,0x3d,0x87,0x75,0x3b,0x7e,0x9d,0x32,0xf2,0xc3,0x66,0x0b,},56,"\x7f\x31\x8d\xbd\x12\x1c\x08\xbf\xdd\xfe\xff\x4f\x6a\xff\x4e\x45\x79\x32\x51\xf8\xab\xf6\x58\x40\x33\x58\x23\x89\x84\x36\x00\x54\xf2\xa8\x62\xc5\xbb\x83\xed\x89\x02\x5d\x20\x14\xa7\xa0\xce\xe5\x0d\xa3\xcb\x0e\x76\xbb\xb6\xbf"}, - {{0x47,0xad,0xc6,0xd6,0xbf,0x57,0x1e,0xe9,0x57,0x0c,0xa0,0xf7,0x5b,0x60,0x4a,0xc4,0x3e,0x30,0x3e,0x4a,0xb3,0x39,0xca,0x9b,0x53,0xca,0xcc,0x5b,0xe4,0x5b,0x2c,0xcb,},{0xa3,0xf5,0x27,0xa1,0xc1,0xf1,0x7d,0xfe,0xed,0x92,0x27,0x73,0x47,0xc9,0xf9,0x8a,0xb4,0x75,0xde,0x17,0x55,0xb0,0xab,0x54,0x6b,0x8a,0x15,0xd0,0x1b,0x9b,0xd0,0xbe,},{0x4e,0x8c,0x31,0x83,0x43,0xc3,0x06,0xad,0xbb,0xa6,0x0c,0x92,0xb7,0x5c,0xb0,0x56,0x9b,0x92,0x19,0xd8,0xa8,0x6e,0x5d,0x57,0x75,0x2e,0xd2,0x35,0xfc,0x10,0x9a,0x43,0xc2,0xcf,0x4e,0x94,0x2c,0xac,0xf2,0x97,0x27,0x9f,0xbb,0x28,0x67,0x53,0x47,0xe0,0x80,0x27,0x72,0x2a,0x4e,0xb7,0x39,0x5e,0x00,0xa1,0x74,0x95,0xd3,0x2e,0xdf,0x0b,},57,"\xce\x49\x7c\x5f\xf5\xa7\x79\x90\xb7\xd8\xf8\x69\x9e\xb1\xf5\xd8\xc0\x58\x2f\x70\xcb\x7a\xc5\xc5\x4d\x9d\x92\x49\x13\x27\x8b\xc6\x54\xd3\x7e\xa2\x27\x59\x0e\x15\x20\x22\x17\xfc\x98\xda\xc4\xc0\xf3\xbe\x21\x83\xd1\x33\x31\x57\x39"}, - {{0x3c,0x19,0xb5,0x0b,0x0f,0xe4,0x79,0x61,0x71,0x9c,0x38,0x1d,0x0d,0x8d,0xa9,0xb9,0x86,0x9d,0x31,0x2f,0x13,0xe3,0x29,0x8b,0x97,0xfb,0x22,0xf0,0xaf,0x29,0xcb,0xbe,},{0x0f,0x7e,0xda,0x09,0x14,0x99,0x62,0x5e,0x2b,0xae,0x85,0x36,0xea,0x35,0xcd,0xa5,0x48,0x3b,0xd1,0x6a,0x9c,0x7e,0x41,0x6b,0x34,0x1d,0x6f,0x2c,0x83,0x34,0x36,0x12,},{0xef,0xbd,0x41,0xf2,0x6a,0x5d,0x62,0x68,0x55,0x16,0xf8,0x82,0xb6,0xec,0x74,0xe0,0xd5,0xa7,0x18,0x30,0xd2,0x03,0xc2,0x31,0x24,0x8f,0x26,0xe9,0x9a,0x9c,0x65,0x78,0xec,0x90,0x0d,0x68,0xcd,0xb8,0xfa,0x72,0x16,0xad,0x0d,0x24,0xf9,0xec,0xbc,0x9f,0xfa,0x65,0x53,0x51,0x66,0x65,0x82,0xf6,0x26,0x64,0x53,0x95,0xa3,0x1f,0xa7,0x04,},58,"\x8d\xdc\xd6\x30\x43\xf5\x5e\xc3\xbf\xc8\x3d\xce\xae\x69\xd8\xf8\xb3\x2f\x4c\xdb\x6e\x2a\xeb\xd9\x4b\x43\x14\xf8\xfe\x72\x87\xdc\xb6\x27\x32\xc9\x05\x2e\x75\x57\xfe\x63\x53\x43\x38\xef\xb5\xb6\x25\x4c\x5d\x41\xd2\x69\x0c\xf5\x14\x4f"}, - {{0x34,0xe1,0xe9,0xd5,0x39,0x10,0x7e,0xb8,0x6b,0x39,0x3a,0x5c,0xce,0xa1,0x49,0x6d,0x35,0xbc,0x7d,0x5e,0x9a,0x8c,0x51,0x59,0xd9,0x57,0xe4,0xe5,0x85,0x2b,0x3e,0xb0,},{0x0e,0xcb,0x26,0x01,0xd5,0xf7,0x04,0x74,0x28,0xe9,0xf9,0x09,0x88,0x3a,0x12,0x42,0x00,0x85,0xf0,0x4e,0xe2,0xa8,0x8b,0x6d,0x95,0xd3,0xd7,0xf2,0xc9,0x32,0xbd,0x76,},{0x32,0xd2,0x29,0x04,0xd3,0xe7,0x01,0x2d,0x6f,0x5a,0x44,0x1b,0x0b,0x42,0x28,0x06,0x4a,0x5c,0xf9,0x5b,0x72,0x3a,0x66,0xb0,0x48,0xa0,0x87,0xec,0xd5,0x59,0x20,0xc3,0x1c,0x20,0x4c,0x3f,0x20,0x06,0x89,0x1a,0x85,0xdd,0x19,0x32,0xe3,0xf1,0xd6,0x14,0xcf,0xd6,0x33,0xb5,0xe6,0x32,0x91,0xc6,0xd8,0x16,0x6f,0x30,0x11,0x43,0x1e,0x09,},59,"\xa6\xd4\xd0\x54\x2c\xfe\x0d\x24\x0a\x90\x50\x7d\xeb\xac\xab\xce\x7c\xbb\xd4\x87\x32\x35\x3f\x4f\xad\x82\xc7\xbb\x7d\xbd\x9d\xf8\xe7\xd9\xa1\x69\x80\xa4\x51\x86\xd8\x78\x6c\x5e\xf6\x54\x45\xbc\xc5\xb2\xad\x5f\x66\x0f\xfc\x7c\x8e\xaa\xc0"}, - {{0x49,0xdd,0x47,0x3e,0xde,0x6a,0xa3,0xc8,0x66,0x82,0x4a,0x40,0xad,0xa4,0x99,0x6c,0x23,0x9a,0x20,0xd8,0x4c,0x93,0x65,0xe4,0xf0,0xa4,0x55,0x4f,0x80,0x31,0xb9,0xcf,},{0x78,0x8d,0xe5,0x40,0x54,0x4d,0x3f,0xeb,0x0c,0x91,0x92,0x40,0xb3,0x90,0x72,0x9b,0xe4,0x87,0xe9,0x4b,0x64,0xad,0x97,0x3e,0xb6,0x5b,0x46,0x69,0xec,0xf2,0x35,0x01,},{0xd2,0xfd,0xe0,0x27,0x91,0xe7,0x20,0x85,0x25,0x07,0xfa,0xa7,0xc3,0x78,0x90,0x40,0xd9,0xef,0x86,0x64,0x63,0x21,0xf3,0x13,0xac,0x55,0x7f,0x40,0x02,0x49,0x15,0x42,0xdd,0x67,0xd0,0x5c,0x69,0x90,0xcd,0xb0,0xd4,0x95,0x50,0x1f,0xbc,0x5d,0x51,0x88,0xbf,0xbb,0x84,0xdc,0x1b,0xf6,0x09,0x8b,0xee,0x06,0x03,0xa4,0x7f,0xc2,0x69,0x0f,},60,"\x3a\x53\x59\x4f\x3f\xba\x03\x02\x93\x18\xf5\x12\xb0\x84\xa0\x71\xeb\xd6\x0b\xae\xc7\xf5\x5b\x02\x8d\xc7\x3b\xfc\x9c\x74\xe0\xca\x49\x6b\xf8\x19\xdd\x92\xab\x61\xcd\x8b\x74\xbe\x3c\x0d\x6d\xcd\x12\x8e\xfc\x5e\xd3\x34\x2c\xba\x12\x4f\x72\x6c"}, - {{0x33,0x1c,0x64,0xda,0x48,0x2b,0x6b,0x55,0x13,0x73,0xc3,0x64,0x81,0xa0,0x2d,0x81,0x36,0xec,0xad,0xbb,0x01,0xab,0x11,0x4b,0x44,0x70,0xbf,0x41,0x60,0x7a,0xc5,0x71,},{0x52,0xa0,0x0d,0x96,0xa3,0x14,0x8b,0x47,0x26,0x69,0x2d,0x9e,0xff,0x89,0x16,0x0e,0xa9,0xf9,0x9a,0x5c,0xc4,0x38,0x9f,0x36,0x1f,0xed,0x0b,0xb1,0x6a,0x42,0xd5,0x21,},{0x22,0xc9,0x9a,0xa9,0x46,0xea,0xd3,0x9a,0xc7,0x99,0x75,0x62,0x81,0x0c,0x01,0xc2,0x0b,0x46,0xbd,0x61,0x06,0x45,0xbd,0x2d,0x56,0xdc,0xdc,0xba,0xac,0xc5,0x45,0x2c,0x74,0xfb,0xf4,0xb8,0xb1,0x81,0x3b,0x0e,0x94,0xc3,0x0d,0x80,0x8c,0xe5,0x49,0x8e,0x61,0xd4,0xf7,0xcc,0xbb,0x4c,0xc5,0xf0,0x4d,0xfc,0x61,0x40,0x82,0x5a,0x96,0x00,},61,"\x20\xe1\xd0\x5a\x0d\x5b\x32\xcc\x81\x50\xb8\x11\x6c\xef\x39\x65\x9d\xd5\xfb\x44\x3a\xb1\x56\x00\xf7\x8e\x5b\x49\xc4\x53\x26\xd9\x32\x3f\x28\x50\xa6\x3c\x38\x08\x85\x94\x95\xae\x27\x3f\x58\xa5\x1e\x9d\xe9\xa1\x45\xd7\x74\xb4\x0b\xa9\xd7\x53\xd3"}, - {{0x5c,0x0b,0x96,0xf2,0xaf,0x87,0x12,0x12,0x2c,0xf7,0x43,0xc8,0xf8,0xdc,0x77,0xb6,0xcd,0x55,0x70,0xa7,0xde,0x13,0x29,0x7b,0xb3,0xdd,0xe1,0x88,0x62,0x13,0xcc,0xe2,},{0x05,0x10,0xea,0xf5,0x7d,0x73,0x01,0xb0,0xe1,0xd5,0x27,0x03,0x9b,0xf4,0xc6,0xe2,0x92,0x30,0x0a,0x3a,0x61,0xb4,0x76,0x54,0x34,0xf3,0x20,0x3c,0x10,0x03,0x51,0xb1,},{0x06,0xe5,0xd8,0x43,0x6a,0xc7,0x70,0x5b,0x3a,0x90,0xf1,0x63,0x1c,0xdd,0x38,0xec,0x1a,0x3f,0xa4,0x97,0x78,0xa9,0xb9,0xf2,0xfa,0x5e,0xbe,0xa4,0xe7,0xd5,0x60,0xad,0xa7,0xdd,0x26,0xff,0x42,0xfa,0xfa,0x8b,0xa4,0x20,0x32,0x37,0x42,0x76,0x1a,0xca,0x69,0x04,0x94,0x0d,0xc2,0x1b,0xbe,0xf6,0x3f,0xf7,0x2d,0xaa,0xb4,0x5d,0x43,0x0b,},62,"\x54\xe0\xca\xa8\xe6\x39\x19\xca\x61\x4b\x2b\xfd\x30\x8c\xcf\xe5\x0c\x9e\xa8\x88\xe1\xee\x44\x46\xd6\x82\xcb\x50\x34\x62\x7f\x97\xb0\x53\x92\xc0\x4e\x83\x55\x56\xc3\x1c\x52\x81\x6a\x48\xe4\xfb\x19\x66\x93\x20\x6b\x8a\xfb\x44\x08\x66\x2b\x3c\xb5\x75"}, - {{0xde,0x84,0xf2,0x43,0x5f,0x78,0xde,0xdb,0x87,0xda,0x18,0x19,0x4f,0xf6,0xa3,0x36,0xf0,0x81,0x11,0x15,0x0d,0xef,0x90,0x1c,0x1a,0xc4,0x18,0x14,0x6e,0xb7,0xb5,0x4a,},{0xd3,0xa9,0x2b,0xba,0xa4,0xd6,0x3a,0xf7,0x9c,0x22,0x26,0xa7,0x23,0x6e,0x64,0x27,0x42,0x8d,0xf8,0xb3,0x62,0x42,0x7f,0x87,0x30,0x23,0xb2,0x2d,0x2f,0x5e,0x03,0xf2,},{0x47,0x1e,0xbc,0x97,0x3c,0xfd,0xac,0xee,0xc0,0x72,0x79,0x30,0x73,0x68,0xb7,0x3b,0xe3,0x5b,0xc6,0xf8,0xd8,0x31,0x2b,0x70,0x15,0x05,0x67,0x36,0x90,0x96,0x70,0x6d,0xc4,0x71,0x12,0x6c,0x35,0x76,0xf9,0xf0,0xeb,0x55,0x0d,0xf5,0xac,0x6a,0x52,0x51,0x81,0x11,0x00,0x29,0xdd,0x1f,0xc1,0x11,0x74,0xd1,0xaa,0xce,0xd4,0x8d,0x63,0x0f,},63,"\x20\x51\x35\xec\x7f\x41\x7c\x85\x80\x72\xd5\x23\x3f\xb3\x64\x82\xd4\x90\x6a\xbd\x60\xa7\x4a\x49\x8c\x34\x7f\xf2\x48\xdf\xa2\x72\x2c\xa7\x4e\x87\x9d\xe3\x31\x69\xfa\xdc\x7c\xd4\x4d\x6c\x94\xa1\x7d\x16\xe1\xe6\x30\x82\x4b\xa3\xe0\xdf\x22\xed\x68\xea\xab"}, - {{0xba,0x4d,0x6e,0x67,0xb2,0xce,0x67,0xa1,0xe4,0x43,0x26,0x49,0x40,0x44,0xf3,0x7a,0x44,0x2f,0x3b,0x81,0x72,0x5b,0xc1,0xf9,0x34,0x14,0x62,0x71,0x8b,0x55,0xee,0x20,},{0xf7,0x3f,0xa0,0x76,0xf8,0x4b,0x6d,0xb6,0x75,0xa5,0xfd,0xa5,0xad,0x67,0xe3,0x51,0xa4,0x1e,0x8e,0x7f,0x29,0xad,0xd1,0x68,0x09,0xca,0x01,0x03,0x87,0xe9,0xc6,0xcc,},{0x57,0xb9,0xd2,0xa7,0x11,0x20,0x7f,0x83,0x74,0x21,0xba,0xe7,0xdd,0x48,0xea,0xa1,0x8e,0xab,0x1a,0x9a,0x70,0xa0,0xf1,0x30,0x58,0x06,0xfe,0xe1,0x7b,0x45,0x8f,0x3a,0x09,0x64,0xb3,0x02,0xd1,0x83,0x4d,0x3e,0x0a,0xc9,0xe8,0x49,0x6f,0x00,0x0b,0x77,0xf0,0x08,0x3b,0x41,0xf8,0xa9,0x57,0xe6,0x32,0xfb,0xc7,0x84,0x0e,0xee,0x6a,0x06,},64,"\x4b\xaf\xda\xc9\x09\x9d\x40\x57\xed\x6d\xd0\x8b\xca\xee\x87\x56\xe9\xa4\x0f\x2c\xb9\x59\x80\x20\xeb\x95\x01\x95\x28\x40\x9b\xbe\xa3\x8b\x38\x4a\x59\xf1\x19\xf5\x72\x97\xbf\xb2\xfa\x14\x2f\xc7\xbb\x1d\x90\xdb\xdd\xde\x77\x2b\xcd\xe4\x8c\x56\x70\xd5\xfa\x13"}, - {{0x0d,0x13,0x1c,0x45,0xae,0xa6,0xf3,0xa4,0xe1,0xb9,0xa2,0xcf,0x60,0xc5,0x51,0x04,0x58,0x7e,0xfa,0xa8,0x46,0xb2,0x22,0xbf,0x0a,0x7b,0x74,0xce,0x7a,0x3f,0x63,0xb6,},{0x3c,0x67,0x29,0xdb,0xe9,0x3b,0x49,0x9c,0x4e,0x61,0x4a,0x2f,0x21,0xbe,0xb7,0x29,0x43,0x8d,0x49,0x8e,0x1a,0xc8,0xd1,0x4c,0xba,0xd9,0x71,0x7a,0x5d,0xbd,0x97,0xcd,},{0xa9,0xc5,0xee,0x86,0xfb,0x06,0xd9,0xe4,0x6b,0x37,0x9c,0x32,0xdd,0xa7,0xc9,0x2c,0x9c,0x13,0xdb,0x27,0x4d,0xc2,0x41,0x16,0xfb,0xdd,0x87,0x86,0x96,0x04,0x54,0x88,0xcc,0x75,0xa5,0x2f,0xff,0x67,0xd1,0xa5,0x11,0x3d,0x06,0xe3,0x33,0xac,0x67,0xff,0x66,0x4b,0x3f,0x2a,0x40,0x5f,0xa1,0xd1,0x4d,0xd5,0xbb,0xb9,0x74,0x09,0xb6,0x06,},65,"\xb4\x29\x1d\x08\xb8\x8f\xb2\xf7\xb8\xf9\x9d\x0d\xce\x40\x07\x9f\xcb\xab\x71\x8b\xbd\x8f\x4e\x8e\xab\xc3\xc1\x42\x8b\x6a\x07\x1f\xb2\xa3\xc8\xeb\xa1\xca\xcc\xcf\xa8\x71\xb3\x65\xc7\x08\xbe\xf2\x68\x5b\xc1\x3e\x6b\x80\xbc\x14\xa5\xf2\x49\x17\x0f\xfc\x56\xd0\x14"}, -}; - -bool TestCryptoSign() -{ - // https://github.com/jedisct1/libsodium/blob/master/test/default/sign.c - const unsigned int MAX_MESSAGE = 65; // Sync with test data - - byte pk[crypto_sign_PUBLICKEYBYTES]; - byte sk[crypto_sign_SECRETKEYBYTES]; - SecByteBlock sm(MAX_MESSAGE+crypto_sign_BYTES); - SecByteBlock rm(MAX_MESSAGE+crypto_sign_BYTES); - - bool pass = true, fail; int rc; - - for (unsigned int i=0; i(data.msg); - const word64 l = data.len; - word64 smlen; - - rc = crypto_sign(sm, &smlen, m, l, sk); - fail = (rc != 0); pass = !fail && pass; - - word64 s = STDMIN(smlen, (word64)crypto_sign_BYTES); - pass = (s >= crypto_sign_BYTES) && pass; - - fail = std::memcmp(sm, data.sig, (size_t)s) != 0; - pass = !fail && pass; - - word64 rmlen; - rc = crypto_sign_open(rm, &rmlen, sm, smlen, pk); - fail = (rc != 0); pass = !fail && pass; - - pass = (l == rmlen) && pass; - fail = std::memcmp(m, rm, (size_t)STDMIN(l, rmlen)) != 0; - pass = !fail && pass; - } - - return pass; -} - -bool TestCryptoSignKeys() -{ - // https://github.com/jedisct1/libsodium/blob/master/test/default/sign.c - const unsigned int MAX_TEST = 64; - const unsigned int MAX_MESSAGE = 4096; - - byte pk[crypto_sign_PUBLICKEYBYTES]; - byte sk[crypto_sign_SECRETKEYBYTES]; - - bool pass = true, fail; int rc; - - for (unsigned int i=0; i -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestIntegerBitops() -{ - std::cout << "\nTesting Integer bit operations...\n\n"; - - struct Bitops_TestTuple - { - // m,n are operands; a,o,x are and,or,xor results - const char *m, *n, *a, *o, *x; - }; - static const Bitops_TestTuple tests[] = { - { - "0xc2cea8a4", "0xb36e5794", "0x824e0084", "0xf3eeffb4", "0x71a0ff30" - }, - { - "0x436eb828", "0x1b375cb4", "0x3261820", "0x5b7ffcbc", "0x5859e49c" - }, - { - "0x1e5c0b28", "0x4fded465", "0xe5c0020", "0x5fdedf6d", "0x5182df4d" - }, - { - "0xeb71fde7", "0xf7bb47cf", "0xe33145c7", "0xfffbffef", "0x1ccaba28" - }, - { - "0xa6b0f01f", "0x8a8ca98", "0xa0c018", "0xaeb8fa9f", "0xae183a87" - }, - { - "0xa70bd8b7", "0x5c758cf5", "0x40188b5", "0xff7fdcf7", "0xfb7e5442" - }, - { - "0xf91af382", "0x718a9995", "0x710a9180", "0xf99afb97", "0x88906a17" - }, - { - "0xbd2a76ad", "0xddd8dfeb", "0x9d0856a9", "0xfdfaffef", "0x60f2a946" - }, - { - "0xd4b559cc", "0x91a53295", "0x90a51084", "0xd5b57bdd", "0x45106b59" - }, - { - "0x89434e9e", "0xa42fdaf9", "0x80034a98", "0xad6fdeff", "0x2d6c9467" - }, - { - "0xb947ac04", "0xd4201e52", "0x90000c00", "0xfd67be56", "0x6d67b256" - }, - { - "0xa83945c1", "0x3a9c5dba", "0x28184580", "0xbabd5dfb", "0x92a5187b" - }, - { - "0xbca38ffa", "0x881ba9fd", "0x880389f8", "0xbcbbafff", "0x34b82607" - }, - { - "0xfcd0b92", "0xeaad8534", "0xa8d0110", "0xefed8fb6", "0xe5608ea6" - }, - { - "0x50d160d0", "0x64646f75", "0x40406050", "0x74f56ff5", "0x34b50fa5" - }, - { - "0x165ccff8", "0x67d49127", "0x6548120", "0x77dcdfff", "0x71885edf" - }, - { - "0x8c4f4bbb7adaacb5", "0x2566b7a909b24aa9", "0x44603a9089208a1", "0xad6fffbb7bfaeebd", "0xa929fc127368e61c" - }, - { - "0x6f9ef50aafb31e8d", "0x7a93b2ccd1bbbff2", "0x6a92b00881b31e80", "0x7f9ff7ceffbbbfff", "0x150d47c67e08a17f" - }, - { - "0x4c99e967f8de5294", "0x1f4699e0c14e6974", "0xc008960c04e4014", "0x5fdff9e7f9de7bf4", "0x53df708739903be0" - }, - { - "0xcc55f5d6d3ea45c", "0x6805b4ddb6390c2f", "0x805145d2438040c", "0x6cc5ffddff3fac7f", "0x64c0eb80db07a873" - }, - { - "0x90620d1a012459e7", "0x89d31098ce3fed42", "0x8042001800244942", "0x99f31d9acf3ffde7", "0x19b11d82cf1bb4a5" - }, - { - "0xb87d1674e90a935a", "0x75ea466cbb782ac4", "0x30680664a9080240", "0xfdff567cfb7abbde", "0xcd9750185272b99e" - }, - { - "0x1f135732240701f0", "0x6aa09a1614bf4dd4", "0xa001212040701d0", "0x7fb3df3634bf4df4", "0x75b3cd2430b84c24" - }, - { - "0xc9a88d8300099a31", "0xdc8e91df745169ee", "0xc888818300010820", "0xddae9ddf7459fbff", "0x15261c5c7458f3df" - }, - { - "0xc8c828d15228b562", "0x43f86cffa3d15d80", "0x40c828d102001500", "0xcbf86cfff3f9fde2", "0x8b30442ef1f9e8e2" - }, - { - "0x41fdc0bc2009563f", "0x59dd1c417e3c07bc", "0x41dd00002008063c", "0x59fddcfd7e3d57bf", "0x1820dcfd5e355183" - }, - { - "0x9e2f78600c3a84e7", "0xac69a0e1fe7887b0", "0x8c2920600c3884a0", "0xbe6ff8e1fe7a87f7", "0x3246d881f2420357" - }, - { - "0xd424d1d9a955f617", "0x9608f5bde1c4d893", "0x9400d199a144d013", "0xd62cf5fde9d5fe97", "0x422c246448912e84" - }, - { - "0x1aa8b60a0627719a", "0x5b26e6aca95f5f60", "0x1a20a60800075100", "0x5baef6aeaf7f7ffa", "0x418e50a6af782efa" - }, - { - "0xcf5db499233fac00", "0xf33e7a29c3c33da8", "0xc31c300903032c00", "0xff7ffeb9e3ffbda8", "0x3c63ceb0e0fc91a8" - }, - { - "0x6b47c03d576e878d", "0x2032d13574d67da4", "0x2002c03554460584", "0x6b77d13d77feffad", "0x4b75110823b8fa29" - }, - { - "0xd47eeb3aefebf074", "0x6d7ba17a42c66b89", "0x447aa13a42c26000", "0xfd7feb7aefeffbfd", "0xb9054a40ad2d9bfd" - }, - { - "0x33ad9c5d20b03f5c05535f20a2941c8f4ae0f1f19500759151060dce39e5dfed41ec4f", - "0x277401dc000fde7eda4d60a5698935f7febd8fbe49e5d6f56ca2e7f6118380d3cd655da392df3ba6c1b13dc0119af34cfa1d18a65", - "0x10a9841c002016480453410020041c8640c0312191006411110401082924cfa1418845", - "0x277401dc000fde7eda4d60a5698935f7febfbfffcdf7dff7fde2f7f7f38ba9d3cdf5ffaf9fdf7ba7d9b53de0ddfbff5dfedd1ee6f", - "0x277401dc000fde7eda4d60a5698935f7febeb5678c37ddf69962b2c3e389a9920591f3ac8dc66ba198a42da0cd796d1104c90662a" - }, - { - "0xb6ea335c13111216862e370d12fb9c761a6266617f62a1904b0d7944ab3cddc71f11752ad9424b0", - "0xa6b380f048a9cbe45ff4ea824064c831eb03ff875e1e3e", - "0xa62200104028090410d480020044c831e1035285140430", - "0xb6ea335c13111216862e370d12fb9c761a6b7e6f7feabdbe4fff7fecaf3eddc71fb17ffafde3ebe", - "0xb6ea335c13111216862e370d12fb9c7610095e6e7be83d2e0ef237ec8f3a914401a14ad2aca3a8e" - }, - { - "0x8fb9486ad1f89ca5b3f6da9f0d5ef9ec328b8cc3e5122afbd8a67bd1b2b4ab5c548b90cf9fe1933a0362922f1e84ef0", - "0x10615f963dffc13718ed1ecdb9cfbef33148befeb91b190dc7e7d28d8821ff248ab26a34e1b89885c643e447c72", - "0x6051901ca58136188d0c4cb9cc32830040a412281b180443c192848800540080820a208138000082030404c70", - "0x8fb9586bdffebdfff3f7daff1fdff9efbefbbdcbfffebbfbd9affff7f2bdab7dffaf9afffff5f3ba9be7d66ffec7ef2", - "0x8fb9580b8e6ea15a72c1c272139340238c78bd8b5bec93e0c1abbc366039237dabaf1a7df5d572829be7546cfac3282" - }, - { - "0x10af96443b186faf790279bf3bbe0517d56ffc01e7fec8c88e765d48cc32333390224f4d762d1ba788c50801cba02524cb49", - "0x95d44e7344fb1701bace3ae83affbb6290bf282f7565b9a82c386823f5f213a53eccb2cfe5deb4dd040067a64ada8c1b6828599b96cc70647e7d19dc7dfba393addabe689ffbe1a36642bc9844b81c6c4c2e178", - "0x2c96442b084000000260ad288004028509b800c70640c080144548883032118022094d3608122408c1000181800400c148", - "0x95d44e7344fb1701bace3ae83affbb6290bf282f7565b9a82c386823f5f213a53ecdbaffe5dfb5dffef7f7a7dbfbbffb797d5fffd6de7fecfefdfffdfdffe3b3bffbbe6cffffe3f3fe7abcd8c4bcbe6e5e6eb79", - "0x95d44e7344fb1701bace3ae83affbb6290bf282f7565b9a82c386823f5f213a53ecdb836819d055bfef7f781d12937fb39550f6456d20f88f2f5feb9a97760b09ee3bc4c6b2c8372dc3a30c8c4a4a66e1e62a31" - }, - { - "0x5fc77dab8cd9c1da8c91eb7ba9c23ce85375b61bf3b9a8c4e4df7bc917aa8a14e747888c9756a2be2fd2e256e44194ce093a0185594de0dcf8340c45b6af7dbdc7682fbef6313f9f1cb234689d9f1ff603e1273faad89d0fe1ab57fbc7c32d29dce125fafc973754464b55ae5de58a8a5661c2065b95c2c94d7ec34", - "0xd4a9158961d4c11258cd047eda13d6804c16c3a374b7f4115bd835bde0b5", - "0x1080158800548100504504649012c480480081221420641158081495e034", - "0x5fc77dab8cd9c1da8c91eb7ba9c23ce85375b61bf3b9a8c4e4df7bc917aa8a14e747888c9756a2be2fd2e256e44194ce093a0185594de0dcf8340c45b6af7dbdc7682fbef6313f9f1cb234689d9f1ff603e1273faad89d0fe1ab57fbc7cf6fb9dcf73dfefdb7bfd447eff5bf7de5cbee7e77cb7f5b95ffcb5ffecb5", - "0x5fc77dab8cd9c1da8c91eb7ba9c23ce85375b61bf3b9a8c4e4df7bc917aa8a14e747888c9756a2be2fd2e256e44194ce093a0185594de0dcf8340c45b6af7dbdc7682fbef6313f9f1cb234689d9f1ff603e1273faad89d0fe1ab57fbc7ce67b8847738b6edb2bb8401a6f49335e14be66c5689791a807f4a16a0c81" - }, - { - "0x52cbea1f4d78445fb8f9267203f0f04bddf65b69b1acb0877143e77317f2d9679cb", - "0x331e156a1e1daa0039926a08ec80c2d7c1500bc435a53ebfc32fa398a3304fcd79d90725528e320add050da666b9de42b8307b", - "0x88421a41684412b839023200f0d00990725128a120a0805042666315e0090304b", - "0x331e156a1e1daa0039926a08ec80c2d7c1552ffeb5f5ffbfc7ffaf9ae7307fcf7dfddf65f69f3acbdd771dbe77b9ff6fbe79fb", - "0x331e156a1e1daa0039926a08ec80c2d7c155277a9451e93b86d42c0ac41070c27d64d840e41528c1d57219981188a16f2e49b0" - }, - { - "0xbde7e20f37c3ed822555d36050240dcfb5a9a3867d149cffe78e92b95573cbdde33a8c9495148e04cafa1325aae058b4a98c50f7019de1345de6dce12436bed4b86eca2d", - "0xee480b4096f0c1ac565d623dd53b62dba81c507d3c8e15372396fa49de0ecf074fb0ed1785f00f8094022ff50fc436a7cbd18de8ff317c33ea9bdbd8814a7658fcd1fd10b2ed10eaf7e4c2b8f409df3c36f1f0c986a49805a9ed08bbcd603e2eec9e18", - "0x547a00d1781e0020014022050040406a58981846814107c238a929950014a544038809410108c00caf20000a8e00894280450f00184a01005a0cc0020042014286c8a08", - "0xee480b4096f0c1ac565d623dd53b62dba81c507d3c8e15372396fa49de0ecfbfeff2ef37c7fd8fa5d5d36ff52fcdffb7ebf38ffdffbdfff7ee9bfbddf3cbfffbfeddfd95b6ef14eafff7e7baf459ffbdbef1f7c99fe5bc5deffde9bffffefebeeede3d", - "0xee480b4096f0c1ac565d623dd53b62dba81c507d3c8e15372396fa49de0ecfbaa852e220461d8da5c1d14fa52bc9f91262720b95ebad83d46409628df281abbbc65d6985a66314200df7e71214516b95baa107c81b45ac584f31e99ffbdeea96825435" - }, - { - "0x17ed0a1aa80542396e82ab79f6d4dda731d10f9487467fcfa5c8b501fa86488fbe268605c01beb257c9e301a42833d22965ea2ff0eda5f18427481a300a8f9aa81e76d774ea1dbed40268eca094bef627d2c206f6885fc12f71557bfda836", - "0x422340e8ff3b4177efa5f58111fe306aa602d8020164fa34c12acdb3de81e", - "0x2340604e21416540248480014a2062240000020004f810c10045b3da816", - "0x17ed0a1aa80542396e82ab79f6d4dda731d10f9487467fcfa5c8b501fa86488fbe268605c01beb257c9e301a42833d22965ea2ff0eda5f18427481a300a8f9aac3e76dffffbbdbffefa7ffcb19ffff6aff2ef86f69e5fe36f73fdfbfde83e", - "0x17ed0a1aa80542396e82ab79f6d4dda731d10f9487467fcfa5c8b501fa86488fbe268605c01beb257c9e301a42833d22965ea2ff0eda5f18427481a300a8f9aac3c42d9fb19a9a9aaf837b4b18b5df08db2ef86d69e10626363f9a0c04028" - }, - { - "0x290796408a0b8baa742b9d466afc4958528f7976fdce50caa83ed63285f58d200e4c65842ea24c3d4a3850a1824b61d25af9d3b41b9e64407a5262a75d9efd08481cfbc339ae26b0755438894b9e2298a35ed9", - "0x4cb6f7935f5cc586320c6ce957f82cff774cde7d4201735a5acd22190fcb1c9c16d1887a", - "0x4012f193141884040008406007580cfd00481c794201220210450018094b1c0010810858", - "0x290796408a0b8baa742b9d466afc4958528f7976fdce50caa83ed63285f58d200e4c65842ea24c3d4a3850a1824b61defeffd3ff5fdfe6727e7eebf7fdbeff7f4cdeffc339ff7efafd76398fcb9ebe9ef3defb", - "0x290796408a0b8baa742b9d466afc4958528f7976fdce50caa83ed63285f58d200e4c65842ea24c3d4a3850a1824b619eec0e40eb475be272763e8bf0a5b2027f04c2868138dd7ceab87621868082be8e72d6a3" - }, - { - "0x14e55ecb09d8c6827022df7c713c05a5d882e25782", - "0x2dbdb54cb6341fcea6f67cfaa5186aa0a91b9782e362cbb0dd0ef3cbc130ce0cb2ce7232c0562", - "0x10600e020898048060209c1000200124c002200502", - "0x2dbdb54cb6341fcea6f67cfaa5186aa0a91bdfd7eff2dfbcfd2ff3eff7f7dfccfadffa3ee57e2", - "0x2dbdb54cb6341fcea6f67cfaa5186aa0a91ad9d70fd2563cb529f1e636f7ddcce893fa1ce52e0" - }, - { - "0x2b0dfd23fc740e1759697bcba800aa1be7df28c59fe72b9869766ac34ecb4e5d0dbc74c2cbb5f734bb8d38dab59c3f22cdc706c657839580c2793c4c7660606548c048a697db3dfbad82e695c605", - "0x33080f6fd52aeca572f24a98ff19b9e7327c3b951ccfd8c9a6b9bd6f7c940079e4be88178a2a6d5a2b17", - "0x30007249108288030900a00cd0100c612001180004918482620206548800020849a0813880264100205", - "0x2b0dfd23fc740e1759697bcba800aa1be7df28c59fe72b9869766ac34ecb4e5d0dbc74c2fbbdff7fffaffcfff7fe7fbaffdfbfe777ffbf95defffccdf6f9fd6f7cd448fff7ffbdffafaaefdfef17", - "0x2b0dfd23fc740e1759697bcba800aa1be7df28c59fe72b9869766ac34ecb4e5d0dbc74c2f8bdf85b6ea7d47fc76e75ba32debf2165ffae15deb6e485d0d9dd0a345448df7365b5ec27a88bcfed12" - }, - { - "0xc0cc21922748d7626df1ab92b4ad4df1861050ca7de74adb92a140", - "0x3531a6880ccc47bc3826056efe912f3db02df9c0b6931e253ab9248f472359fe59218690f6781f35da89b8f1ff45cd5a1db9a414c9d7ec62ff5859a1572b1c1880a99aa74ebe8b12c68e791c11dd6cc0e5ed5", - "0xc40192054091400800898234a948b104004080410542c8020040", - "0x3531a6880ccc47bc3826056efe912f3db02df9c0b6931e253ab9248f472359fe59218690f6781f35da89b8f1ff45cd5a1db9a414c9d7ec6effda59a377af7e3edfbbbbaf4efedf1ae78f7dbfdffdedf9effd5", - "0x3531a6880ccc47bc3826056efe912f3db02df9c0b6931e253ab9248f472359fe59218690f6781f35da89b8f1ff45cd5a1db9a414c9d7ec6ef39a408323a66a3e5fb3238c046a540aa78b75bbcfa9c179cff95" - }, - { - "0x68cbb0a526d1fa61003e12401db51090fa4649b00b7be7465d0eb18f74c86157a919", - "0x1ca7d6f9bc3e11d3c365af63bf9499b6c7e9c569da7361f0214b8d", - "0x1610001c111080600641b00019a6464904218a704060010909", - "0x68cbb0a526d1fa7da7fefbfc3fb5d3d3ffef6bbf9ffbf7c7fdcff9df77e9f177eb9d", - "0x68cbb0a526d1fa7da7e8ebfc23a4c3539fe92a0f9fe25181b4cbd85507a99176e294" - }, - { - "0x210bef18d384992c5eb72e2b362c7296d9810f5ba9fd25e2d5648989d65095e45d1478f2a83140a0f68033a08fa3d7c392a3dc77e8e6aeba9ed76038e9e7825255fac990bf1098e6f9cba0", - "0xdb48641b3f63e5f1f41ff3b1578c4b190de42379d45cba03c4c6f34b1b14ea930fdff90dca53116710228e45b081fbddc9273a542e6f689642453adb91086bdb99681342113262d67f5517f2691024fe367459b01872549211067798063cc00b16c883b8cd2ffaa6d6116863f204bb23ce26c5bcdaf3e1b816dcf65ca", - "0x21014200d280002452a52800062c309681000113202d25e051640081024081644510008220010000660000208c00914080238c52e8a22c201686202049a20042445ac9803e108064c94180", - "0xdb48641b3f63e5f1f41ff3b1578c4b190de42379d45cba03c4c6f34b1b14ea930fdff90dca53116710228e45b081fbddc9273afeffef78dfd2c5fbfbf3bb6bdfb96d9b52f5baffd67f7d57faf99d65ff7e75d9f79f7ad7961b0f7f9b3e3cfa3f7ef9abbdcf7ffeeeffb9ed77f38ebf7bef27dfbcdbfbf1b99efffefea", - "0xdb48641b3f63e5f1f41ff3b1578c4b190de42379d45cba03c4c6f34b1b14ea930fdff90dca53116710228e45b081fbddc9252aeadfe250dfd080d1a973bb091cb0058b52e488fd04217841baf18d41f7683188f79758d7861b091f9b3c343a366af1a9850a5174cc3db88515f18a255beb039a1043f810b198b36ae6a" - }, - { - "0x143143205d76a7287d48be24db8fbfe37c291d82e103aa05cfc172fb920f0e8cc15c47de948b964e39be34a5b8a2610198c0c5b98543e6e727be153cfff0338f229cc22f029e04f766c62988634fee1a0a16880c93e5b10bada4018b6765b54c08f5710344dbfb9e9ad5dd7914cab496b22a6", - "0x2d58b8b513f4bceb8300f8b978e31c163f36155e9678bb0f221ee7cbcf7262b9d53c7a395ea916218fa2478baada74f3e69df63a7be0c9554c07004f9e4d869642bbd63a9fe07138a6aef7ad14c74231cf6401c597f9b6d15c266c42c28613838609bd4f4522c9eb65fc8456acc339c641ac7d7b7bc2c48c8f2", - "0x100201970a308140836045a8638a30c201c82c103220089c1307a100e0804010c0246808a924431a614a4382260011040050005024486060211143a902001208482270014044220c620004107e8120014000c02c080038184018947452048086570004488c31882418c79104a8084800a2", - "0x2d58b8b513f4bcffb343f8fd7ee73c7f7fbe35df9ffffb7f2b1fe7ebcffa67ffd57efbbb5faf9ee1dfe7df9fabde7efbfebdf7bafbe1c9ddccc7b9cfdfefe7b7febffefffff3ff3abeeeffaf9ec7f777cf6d89e7dfffbedb5eae6cd3e7b71bafa609bf6f65b7cdebf5fd8756fffbbfded5fd7d7ffbf6d6beaf6", - "0x2d58b8b513f4bcffb243d8e40e44346b7788318519c758730b03652accd86776144e81ab51a79ae0d3e5991f214c3aca58a95382d981c8cd8cc2b9caddab61b1fcaeeac56fd3fe1a3a6cd8af8ac3b557094d89a6d817acdb4aae60d12737182e22083628209785e3908d87127738a75c9471046fb176523ea54" - }, - { - "0x258e988b847b06b73462629161e28517f7b9ad7b5c19a9ad2c07f9a66f33fb2220fddb5a33b9cd5c2d63fd543efa1bef16e26b95484d70d0d7cfce28491ace0a608fb6cf9e97cb88d73c96c9150f9ef53c5e75bd68805fdce891e5935e9428ca67eba1e345148fcf2", - "0x1857c0e26e0476169cf804c8d5a431022cce0da75d7642a2414a900370f201f5073c7e700ff6626fbd8a104182954fa9f23a45474af5456a00e36f6a6c8162afdf7492d387a455dd8506167d5cc24e6861d7b480b1458230", - "0x1812c0a04000121280780040d12430020ccc05a319144082400a900360a000f10624385004d6000d3c880000808440a0003a44414874000800c16c0040816203c56412d2800455cc8106103548420c206092140011408030", - "0x258e988b847b06b73462629161e28517f7bdfd7f7ef9efed6dcff9eeef7bfb3222fdfbda77ffed7e2d77fd543fff3bff56f3eff748ff76f6ffdfef2c593bdefaffafb6dffebfdfdef73eb6ffb7cf9efffdff7dbd78fa5fddf8d1e5f7dfdc2ceee7fffbeb4f14dfef2", - "0x258e988b847b06b73462629161e28517f63cd1757af9eecc45c879eae269b83202313b80466ea9760977545409f53bf04691ac7248b216f62c176f2c51339af0ffac129bea389fde7732a03fb3c788dfc1a93c9050fa1a8130c184f48b580c2ce1f6daab4e00d7ec2" - }, - { - "0x328edc02c67d84bf095ac048e50c2dc29cffc08184b11e4da02904be14eccd317e9f6bdd6fe2b8233e8928d65d4ad434ef8a629cae6013bfb3c54be167e16371dc6412b62c2b1213424dfb7d391cea8a7494a28576ce823d8e111994182909efba7dd3533dbbe510dab4ac5ef", - "0x61a1365a1226597896c514f5bb16a064f6ff6982ac91ea568daa43e473aa63867bdb628e92e97ebd4f2091", - "0x4121224210201020968510918a00a04042284100a801c84001884180108a63865911228a92410ca94a0081", - "0x328edc02c67d84bf095ac048e50c2dc29cffc08184b11e4da02904be14eccd317e9f6bdd6fe2b8233e8928d65d4ad434ef8a629cae6013bfb3c54be167e16371dc661ab76dab3277d7cdff7d7f5ffbea76dfeff7feeecb3faf79dbb43e6f3befba7ffff73dfbef97fbf4fe5ff", - "0x328edc02c67d84bf095ac048e50c2dc29cffc08184b11e4da02904be14eccd317e9f6bdd6fe2b8233e8928d65d4ad434ef8a629cae6013bfb3c54be167e16371dc6208a5498a3076d5c4972c76475be072dbcd73eee44b232b79c330266e3349821a6ee51552cb8731605e57e" - }, - { - "0x37a92944b67fae733d201c024838975531bc3f748d98089eed38faed40c9463441cf48ac40e98097ce75db2bf0120ef69087a176d31d562cc99137c67e4a659cbb1298ba150aa191ced4089deee7048511de602414936af93cb2cef1b7ee801d9b75d961d33bb2958669b16193abf7b55ccfebac3a490415128dac92", - "0x6fb8d83d986c4604db1b9396493a0a68270806cdbcc3299a049ebe77bd6891258e6313c720fb1b30ae9c4387ba51db3325e15033d9e01d499707c138b4cf4b85032da65e9ce3aabc5effbf7003771476ff71e86f665d2d3e7578dfcbb8f08c1619f609ec147f0", - "0x88c811882c440490030014400a0008000804c51c822900008e2800380001218462008100780320a6184381280181102001102140801c4810004118a4024101022d824a0ce30a3c4801993001161432bb2148660214093a357855c8b8b080041040012810490", - "0x37a92944b67fae733d201c024838975531bc3f748d9efb9feff9feed60cdf7bd79efdbace6ebf097eeffdf3bf9b24ffff7fff7ffd35df63dfdf33ff7ff4aeddcbb7bbdbfb73aff95cffd9e9dfeff74fd13df6cf4bcd37afb7dfbcefbbfefefffff75ff71d77ff79f86fff5f3d3eff7bdfcffefacfb699f759ecdeff2", - "0x37a92944b67fae733d201c024838975531bc3f748d9ef3136ee17c292084f78d78abdb0ce66bf017a2ae171969b2471d77fc77ffc145b01df5e33877cd408c5883693da7a638ff84cde9969c3a7e74f902552cd0acc35823595b00cb1c2b6fe66c75ee109454458b009fd4b3404ca038a07464a4fb289b758c4ceb62" - }, - { - "0x1ab020d8beb54c354411f3a5658b5e5e87a896d7049c5eab20a302b6e35ca98364d7edd00eb3e209dcb035fe4b6eeace4e525229bf790c67bae63821e1282712d7c624efa64b3e5ad1a73aeb1033d4cd5949d63183173632445c9f488e74cd", - "0x4d706a200a7a70e0b6eeef2dbdb88779dd50af16e6405c17fd2c2efb5493cf13b730207a009a14ca150042af3e6b7f05230161a10073f87a56afede3c2cfd09857f78d7913cdd966e9a2e6e6e3", - "0x45000000a2a20a002a6e30ca9800451cd500e12e2005c10352c0a6a40824e1212202078000210c21000402826025704200120010052d02212ab0023c0cd5008563181111200404489008664c1", - "0x1ab020d8beb54c354411f3a5658b5e5e87a8dff76ebc5efb70e3b6feef7dbdbbe7fffdd0afb7e649dcb7fdfe6ffffedfcf53f739bf7b0cffbeee3d21e3af3f7bffc727efe7eb3e7bf9ff7eeffdf3d6cfd9d9d7f78f7f37ffdd7effeaeef6ef", - "0x1ab020d8beb54c354411f3a5658b5e5e87a8dba76ebc54d15043b4580c71143be3ae3080a1a5044980a7c8d26595be5d8141e5199f030cfdae2c2d21a3871979a8c307eec7ea3e2929dd6c44fdd0160289d181c60e6e25ff9d3a76ea68922e" - }, - { - "0x85993ec08ac960d46bcba87136f24042485c6d3e0a9973e828df60e537860d6bc83dafa7fb292beef466d0a939ab9da2b", - "0x4c9a310b11d6e4b4d29d7ede30fb42161fd6a58792440f416abda6df55913a8a26c35140524de5dd9519c30f19641f4f0863bfefc2ae6c89333dd77d6f688cffcbde281772cee0dac9bb0dd16b6c1d33fa7e39b2e781896dcc2b0aba3abedf1381f9f38eb210f5bd2001ea8453ceb136dc3915fabdc30709db0b1a07ec40be", - "0x811926c08a08601002c8803022a2004040180d1e0889210808d2000420040c6b002d83815b290820700490a1202a8402a", - "0x4c9a310b11d6e4b4d29d7ede30fb42161fd6a58792440f416abda6df55913a8a26c35140524de5dd9519c30f19641f4f0863bfefc2ae6c89333dd77d6f688cffcbde281772cee0dac9bb0dd16b6c1d7bfbfe39bef78dcffdfeaf1bff3ebeff97c7fbf3afb73ef7bdf60ffbfc73debdb7defb7ffabfffef4fff0b9b9ffddabf", - "0x4c9a310b11d6e4b4d29d7ede30fb42161fd6a58792440f416abda6df55913a8a26c35140524de5dd9519c30f19641f4f0863bfefc2ae6c89333dd77d6f688cffcbde281772cee0dac9bb0dd16b6c156a6992311e718ccfd176ac19d51ebafb96472a1327252e7730d60fb9fc33180db506c36a482f7de84fb601899d559a95" - }, - { - "0x4d9f3e8aae22123e382e7835d3d9d7e944a5c81cab3415fda40d0ec8fde8a50d8b21b2298f83a65bbdb10d120d302d8db4e9807715be0e", - "0x4dacc1a6f2cecd4179556cbbdfe1cedbc952de5232ff1fe1ae9c0c3bbfcd9087e4ed5bcd1f8c289b1456ef032d888", - "0xa48104308c4c004854008a93414eda4050cc02128a10c0a2180018b8080083c00051001300089b0410070109808", - "0x4d9f3e8aae22123e3cfefc3ffffdfffd57b5dedfbffe1dfdbc9d2fedffeff5ff9be9f2ebbfffff5bffffddbeddf8ef8db5edeef737fe8e", - "0x4d9f3e8aae22123e3cf4b42fbcf53b3d53309ed716ca09101898232ddec754f391c872ea347f7f53c3ffd8aedcc8ef0405acee87276686" - }, - { - "0x28d61d5ca1f56b4d3134009f478b17ac208a5b559d9c3726a7a16919e3b12ec6d61a142dc04d834141a9a4", - "0xb444947aba00d50e10326ebea7a2618a10144dde07c15c685d4785eae16d232eb741bc2a09b7cf794a33ed3598803ad61af", - "0xc00104a1e06a041020000445801404008050501c8c160222a16019c2a00a44d610002cc04980010121a4", - "0xb444947aba00d78f71f7eebff7b6f39b501dfdfeb7fbde68fdf7ddfbe37f6b7eb7d1be3b1bffef79eb73fd35d8b43ede9af", - "0xb444947aba00d78371e7a4a1f116b299501db9a6b6bb9e60f8f2dc33221f4954a1d022111b5ba218eb71313140b42ecc80b" - }, - { - "0x1b9a0b9c87fa234d05d06e18171cce3f8fc4adf7f75a402c4c5a281f46e714b96badab2184546aa11a7be482616cbb973da00e329628d3e692b69b43d34391884d87fcd64e2339fbb30044a370fffde97a128d1e5", - "0x7d641e556550c3ddb89ee553cbc0d8d92cdaec6519a2ff3bd792e0b309c24cb49056fb219ef4dfb2a72e76ac7df3407a44e55af5689e9c85c87e74d542dfb445f56a0a518c", - "0x78640a55655080008084a001c0405049049ac8201800462a1182a000000248b01052002108608d32212a60a43d30001804c05ac56082108588300440020fb4449520085184", - "0x1b9a0b9c87fa234d05d06e18171cce3fdfc5edf7f75e7dffcdfe7d3ffeef9dbbefafef719e7ffbbd7b7fefb2fd6cfbdf3defbe3bff6dfbeef2f7fbc7df7797ac4fd7ffd6cfebf9ffb7e74df77dfffdff7eb2ad1ed", - "0x1b9a0b9c87fa234d05d06e18171cce38598548a1a2567df7c5b47d23faea992ba6036d701e7b991c6355efb2fd4870de38cfbc2b796528cce051f1840c77962c03d25380c7caf1a734e709f75d04b9b62cb228069" - }, - { - "0x142cd4c71f04927a526ca430e542cd9432860", - "0x1337869f6c145daf15b226485ef3c48b8037bf7cb2cc9834153b90f55d4217a5e4a9ea133", - "0x142c90c41804103a106404000500c48022020", - "0x1337869f6c145daf15b226485ef3c48b8037bf7cf6cf9f34977bd2fdfd72f7e7edbdfa973", - "0x1337869f6c145daf15b226485ef3c48b8037ab50660b87308741c299f972f2e7293dd8953" - }, - { - "0x4f517f63e95a08284faaf4d4a290c334fc5d039e386727ddbb5d0a6d5fbb5540e97767023d60bedd158ed25051a6c56", - "0x9e2c9c6d2e3be2ad25733871aeba4ba64081294478f936f9c4fc45ada6bb2c098c98f21e709a88995cc3b0cf7e693f8e73f58f8f4735c81e8421182fc15426174f3b6da7b493135c", - "0x4f405a4269120008498a20c400808114cc190096200320c53b5808645318014040110200154020541186d2504120054", - "0x9e2c9c6d2e3be2ad25733871aeba4ba64081294478f936f9c4fd57ffbebfac8b8cfaff5f7abb8cbb5fc7f0ffffef7ffffbf5dfafd7fffd5e8eb77e7fe3d62fffdf7beda7b59b7f5e", - "0x9e2c9c6d2e3be2ad25733871aeba4ba64081294478f936f9c009525b982e8c8b08625d533ab384aa130660f69def4df3a8405f2992ce7d4a8ab66e5fe2822dfa9e638082b1897f0a" - }, - { - "0x1713f8f439c07e35b741ec9b0bca80149a7ef129c73c23c34b4515d29dc7dec711007fa395ced70f3bebc6d229edb75bf04231f2414e0a826f3edae4edcf770d59650cc252c6a2eff07fda9baa70938085d1e15144a451d26304d8f3df2406b8eb40f4fae3666780d2e54cd93a5f17439a4d3656dc5d48", - "0x328df4b64b0bd0fbea359666904ea4aa215b03727a70bda853b6cf612b12c3d56ee93b003bd00a7b9c1d6755f580b467deba33bf7f33da4c37fffe79e73e4381ad4bf1306d1b58f5eb276cae813d6f9153d1294c51098d37b3b80154da", - "0x108094864a0310006a219446900e20aa005201603250b00011b241400a0243144ae02900330008610c004244a080b067da9a22301300804021514420411243008843d12004184840e02260260100428140d1284c110188053210005448", - "0x1713f8f439c07e35b741ec9b0bca80149a7ef129c73c23c34b4537dffdf7dfcfd1fbffb797eed74fbfebe7db2bffff7bfdea73f6cf6f2b92effffeedffcf7fdd5b7f9cdf77d7f7eff47fdebbbbffffb3dfddf7fffefdf7fe6385fdfbff346fbbfbf5ffffefeee7bdfff55fd93b5f574b9f7fb7fedd5dda", - "0x1713f8f439c07e35b741ec9b0bca80149a7ef129c73c23c34b45275f697195ccc1fb959603a847419f41e7892a9fcd2b4dea62448e2f2190acebb40dd6cf4cdd531e90df3593576f4418042199cfecb35f9dd6aebaddb6ec208575b82e146ba3b3b51fdd8fc8e6bdbd741f081313464a177a85eedd0992" - }, - { - "0x68bc9c8f8257c6c88c0b2d46defc4539748fb906140acbf1a68820d1748bfc13ec84619f2b495d1ce74e0ca441a246497", - "0x2d30db90794c4b611858b19c973ea865904346738291751ba5fccc5cbf02c09876aca6bf23289174f545ad8039e0fbcefe359521dfc9681a7715e672fdc23cc446c7900851d2ed09568729c88bf9653c63f7e229893f31059e8b51924a54968d44e5bb26decae3159ce786d9b3a1454c6d6cb8108d22bd5111d2cc7eddb", - "0x68241c03824200880c0105068a50000854868904040a02d0828000906482d813a004400d2808100c220c0000408046493", - "0x2d30db90794c4b611858b19c973ea865904346738291751ba5fccc5cbf02c09876aca6bf23289174f545ad8039e0fbcefe359521dfc9681a7715e672fdc23cc446c7900851d2ed09568729c88bf9fdbceff7f7efc9bf3b2ddedffdd77b749fbd46f5bbefffeeeb35ddf78ffdb3edc56dff6ff95d9de7ff5db5d3ee7eddf", - "0x2d30db90794c4b611858b19c973ea865904346738291751ba5fccc5cbf02c09876aca6bf23289174f545ad8039e0fbcefe359521dfc9681a7715e672fdc23cc446c7900851d2ed09568729c88b91d9a0ec75b5ef41b33a28d855add77320193442f1b1ed2f6c6b354d930d25a04dc12df247f14d91c5f35db5936e3894c" - }, - { - "0x6eef644a36b1e052a413160909a537f81d46b2d330981f507d84737065541b5bb5faebfa8491dcd0347fbe498a501e254b91f6d82d6771a69d0aee5a490e2a44a8ba4f5da963d70b486f36f4a65f372a6a60522cac6e6a01d1a2da8743d5381", - "0x391d108a0ba169bb746b3d5816fa985288c230bdde7e3b8433f8d595b63f08a90448923f30926960cf736be42e377b087e68848af89d80d95122b942b0162153d9d665c0e3508d8a25c8862c0bb7ad4f00e4b1213326f5ce32433df12cb9", - "0x3004000a0a01280130601018127a8050080030098074038003300415003508090408800910800140cb6008a4002250081e688082701800d00020a000a004000380d4408021508482214802240332a406002080002220150a200034310081", - "0x6eeff5db3eb1fa56bfb756bbdda57ff99d6ebef33bddfff3fdc77ffd7d5f7bfbbffaeffba7f3ddf6b67fff7fbe52ff77fb97f6d86deff9fe9d9ffe7bdd2f2b66bdbfdf7ffd6ff70bd8ef7efce6dfbf7afef05e6fbe7f7a6fdde3feb7dfd7fb9", - "0x6eecf59b3e115a443fa450badc245851986e3ef03b45f8b3c5c74cfd3c0f78ab3f6aaf73a762d5f6a273497f3412fd52fb16105065c8f87e909ffc71dd252b26bd87d23bf56de20390cd6a7cc49f8c50be905c67be7d586e8d41feb49cc7f38" - }, - { - "0xa210334e6ffbec2fcfa42021075f84222c7", - "0x181b940df674ffa93b3346264fed88e40b8d8f252487bc1f2cb4c3284fa17145d2cd0c77102fc177898e53fb12c40525aeb017a57661a80a268f27b4c78cbb4bae0e96ed0065e32bc7dcb01be9cc4e6bd5db5e453e94855cb2d1d3f86e8218fe55035102fc10901add0eb539089af", - "0x821032440351002c0080000106150000087", - "0x181b940df674ffa93b3346264fed88e40b8d8f252487bc1f2cb4c3284fa17145d2cd0c77102fc177898e53fb12c40525aeb017a57661a80a268f27b4c78cbb4bae0e96ed0065e32bc7dcb01be9cc4e6bd5db5e453e94855cb2d1d3f86ea218ff5f6ffbeeffdfb43afd0fffbd2abef", - "0x181b940df674ffa93b3346264fed88e40b8d8f252487bc1f2cb4c3284fa17145d2cd0c77102fc177898e53fb12c40525aeb017a57661a80a268f27b4c78cbb4bae0e96ed0065e32bc7dcb01be9cc4e6bd5db5e453e94855cb2d1d3f86e2008cd1b6caaeed3df343afc09eabd2ab68" - }, - { - "0x2db0666cd0edeeab9e46e5b729521be3ece0714ffeefe18cd1b8b0f17e04c51b0d79fc6d428c22b9af63756", - "0x1c1d5f18453c10d365065465c676fb8b58cb436b88660a0e19c350feb1f6954caf029a43a3e59bb35ce0bdbf80a7b8ff4b4f5d7d133bd244df8813e9695b1a6af9cea293e5da9ce4f8e1035fc8ce4ca62ecbec89e89fe25053e4153899415f61c41fcb412f13b58ac70fb84077831497f", - "0x8906468c0014e888e44a426094009e08ce05043e4052088411820c01e00410b01318845028800318300156", - "0x1c1d5f18453c10d365065465c676fb8b58cb436b88660a0e19c350feb1f6954caf029a43a3e59bb35ce0bdbf80a7b8ff4b4f5d7d133bd244df8813e9695b1a6af9cea293e5ffbce6fcf1efffebde4ee7bfebfe9bebffe2715ffefff99dd1fff1f57fcfc53f1ffdfeef4fbc62ffaf77f7f", - "0x1c1d5f18453c10d365065465c676fb8b58cb436b88660a0e19c350feb1f6954caf029a43a3e59bb35ce0bdbf80a7b8ff4b4f5d7d133bd244df8813e9695b1a6af9cea293e5f72c829431eeb163500a4399e2be920b7302211c1afad91590e7d13561cf84341ecc76aa4d3462ce2c77e29" - }, - { - "0x33de1dc3fc5d6eeb5cbca27cc816a3727d1f9188400ea6b2c2799a40f7e611770b45cac7ed49fc0b66a46fcaf2393c0e03741bd08d26308fce62b0c56fbe44cb0949990bc3d4e5919ee1706dce518d6a06e865bdc26e761ef6723241b33583262bc4365103ba49dd17c0", - "0x148a80223564208532d09dd94cf189921325cad8f2a6a32568e36b2007f00866ce0c8e59034cac999f915817492737af76413832e2c4e840627b91b54766a1555e91b87b2692df16c41161184ac9a124d59aad5c06b1a61892cf5c0cd6cc628f764a161f1bdd6546cb51a1510eef5ddfbd", - "0x1121081d84c608910102048c812a222250881080006a00042480800510200240905804005492403262441083220040800601b9085062081444290806b2600cb004011010040c18104c1102d4c0081220080451c00464402867202001311812402c01001010a495d1780", - "0x148a8022356420b7fedddffd5dffebdebfa7fed8f6a7f37d7ff3eb600ff6bae6ff9eceffe75dff9bdfdbdfff49ff3feff66ffaf2fbfcee43767bd1bd6776afdf7eb1fd7fbed6df1fcd996bdbdeedb1bef5faedde57bdee1efaeffdcefefe7eff767a57bf3fdf676fcf77f153beefdddffd", - "0x148a8022356420b6eccd5e25119f62ceaf87b610e405d1587772e3600956baa4b796ceaee55ddb92da5b9ffa00db3cc9d22ef2c0dbf8e6431660413861562e9b3c217d1498d6141f8d886adb9e2c30ba34eac092573ccc1e7aaae1ceb8ba7c79047857ac2e5e436d0f67f052b4a680c87d" - }, - { - "0x683d881de1820ee9fbb71ccd74fd10e3a9ce71bd132955b9e9840d9259275498d2fae81b112416f37e9af907c319657d5d81623462b98d93818a23751a2196de6dd7c18e05960", - "0xa9a2ae43423e6c78cc59ceba6601f6d85397527c462767dceeb1ebc6ad425fb2810a2b7525", - "0xa880a002402e24688c104c300601d4d81203422800012018a2314182094046900008205120", - "0x683d881de1820ee9fbb71ccd74fd10e3a9ce71bd132955b9e9840d9259275498d2fafa3bf53437f7ff9efd9febbf657f7d857b7567fdeff7fdceeb7fbe6bd6ffffffd1aeb7d65", - "0x683d881de1820ee9fbb71ccd74fd10e3a9ce71bd132955b9e9840d9259275498d2f07231f5103515b9163c9b28bf056230045b41457defe5fc44c86ba64b42fb96ffd12cb2c45" - }, - { - "0xa827c5e2bd4293ed726065b32cac5c18d9df68b18300848f23f98c22fecd6b9fe7ed38a5adedd78f8dfe975d85c171f62b766947d7cd3d2ed3be52b50b792c0d6bb2701e28f22674a092e5ee0ec89bcd52680c6ae673a", - "0x1deac63a0a7ae71db949662f05aafcefed47a6c6dd5819dc82d250d978001903a1f19e1b8b44e76bd5899884bb97121fa13a63c33822314a486d29b59b66f141fd64af3414a3ea6bdca9b4362e704c744e8a12c1ab736636ca3aa9da4b75795f1a", - "0x202040a28c429068606045810c880c00099700018000040921b88402768d48998049382121e813860c328201048000d20b502047140d140ad30042340239080943226004004020202012a52602488388102004428471a", - "0x1deac63a0a7ae71db9496eaf7dfeffffed7ff7e6df5b3bdec7d3ddddfe8b1933a9f9fe3f9bc6efefd7b9fefefb9f5adffd7afbdff977f95e5f7f6bb7fff6fd7dfff6ef3ff5abfaffdee9f6bf2f71eeff6eef5ac9af7fe6fecbbefdfecbf7ff7f3a", - "0x1deac63a0a7ae71db9496cad79f4d73bc47971e0db032b164713dd448e8b0133a9b96c241386c887033066fa681d48c17c429b1cd157e9165f724b02fdf28c3d2eb6420ff188badc4e69628d0971aefb6ced58c8852d86da43867cfccbb3d73820" - }, - { - "0x1cc981657c8a20f5c777fc1df0e3cde0b23d434e043732dcaaa0758e009a8d1bf8591ff8db693d676eff2c39645b79c06b510ac22b1b47551eb728aa9404c24f2a6dee6bbdf2276759786f4116d21f4009dd6fb8e277976668bd021effecc797ca23682b97dbdffb93333834b8bb8fb68e922f42e3c00111", - "0x1e52f1e05fbedda88873e9984a7a19bfbfbe9ea43e30588f46317b5cadc8eb02d255875f1dde872476d05dec1164e46c7fcf3fd718fff34a80d4c6e951d10f6ae0225d00e3953e99e", - "0x61010a002b094200063608808400824b2a69ea43a10000644110254014821000015865b0c060124668050200164c4687c823682187db14a801002814181086a60200000221400110", - "0x1cc981657c8a20f5c777fc1df0e3cde0b23d434e043732dcaaa0758e009a8d1bf8591ff8db693d676eff2c39645b79c1ef7f1ec7fbffdfdd9fbfb9aeb7a5dbfffbedee6bfff7aff77b7fffcbdedebf6d2ddd7ff9fffff7676dbddedfffeec7d7fef3fd7b9ffffffb9f7f7eb5bdbbffbe8eb7ff4efbd3e99f", - "0x1cc981657c8a20f5c777fc1df0e3cde0b23d434e043732dcaaa0758e009a8d1bf8591ff8db693d676eff2c39645b79c18e7e14c7d0f69ddd9989b12e33a559b4d18404285ef7af933a6fda8bca5caf6d2c851a493f9fe52105b8dcdfe9a2815036d0955a1824eb539e7f56a1a5ab79188cb7ff4cda93e88f" - }, - { - "0xb77c8e0971a4f32bc9539c14b542ed2fa08e87560981cbdca4ccf4f7cc04fe7546a4a7eebe2592d131329fd591f66728a4179e", - "0x2fb77bc1694a8265e74ee9f41672fc681d72ea8eb65ef5807bcba4bc52ef9e381a4e4315a771497e506b734def1ca93dd519fe9e6944dd782380dff70b72798c", - "0x327c080970a08222485180108100ac02a08e0012080101842048745048004c6504a025c4182492410010180180d6670820118c", - "0x2fb77bc1694a8265e74ee9f416f7fcee1d73eeffbfdff79c7fffe6fd7fef9ebf5e4fc3dffff5cdfef7ef77ffff5eadbfffbfff9ef975fffff791fff72bf67f9e", - "0x2fb77bc1694a8265e74ee9f416c580e614034e7d9d97a61c6f7ee6517d4f10bf4c47c2de7bd5858aa7a777b39a5a0d9a3ba7db0cb875efe7f611299023d66e12" - }, - { - "0x89a0fbe80f4c622f45f4f7a15d8dc23bff17d939349f39cffa643af024db78243fc46c7948ab14ea12595e8a6cf2196ed4f353d9b1b8834b96fb61073301b99af019f042b2215e8cd5f31cf65123dab47d6b697a", - "0xc2b6f7a999af54a94c156f771b995b528", - "0x22215a8890f108944102d23039012128", - "0x89a0fbe80f4c622f45f4f7a15d8dc23bff17d939349f39cffa643af024db78243fc46c7948ab14ea12595e8a6cf2196ed4f353d9b1b8834b96fb61073301b99af019f04ebb6f7e9ddff75ef6d177fff5fdfffd7a", - "0x89a0fbe80f4c622f45f4f7a15d8dc23bff17d939349f39cffa643af024db78243fc46c7948ab14ea12595e8a6cf2196ed4f353d9b1b8834b96fb61073301b99af019f04e994e24154f06566290752dc5c4fedc52" - }, - { - "0x61cc2de53fe06a0381ce0dc4999795469453324c9036484632c257f02dddee71188198ed649bbe9ddae347178970bfbd3f1f28a787ee407a433f8473ba4fb77940227b769c9d555a8a70917ecfd038f80da4c6d5dc7211cc468c69a2275cfc119f145d2887543bbeb24", - "0x117135d192a9645062d1be59a1f8b151692159285e5877a0ae304521ad800f51fbba812d038e053cb79578c70cd34248a2b4026533bb961add83d9362893b74ce01695861c82b6f94f181feb4a957875c74cf1e7fe48dcc5196bf1214cc564f599168bf2fee1a07e617cfac992443fcdb28247", - "0x1c408050b000202018205c4811200420452124800340802200250302051ca71108010cd24008a09402243138960ad983d13208103644000411800402a4f947100223020148554508a1011648dc010900d0004c454421180408c29a20204e4118f04192003541b28204", - "0x117135d192a9645062d7bedbfffbff57e9395de8de59fff9fe794533adc90f75fffbad2d7f8eddfef795f8df8ed74bfbebfdae7573fb971bffd3f9f6aafbffece7b6b7fe5fbbb6fb7f9c1feffffdf9f5d7ecf7efffecfdc79febfb6d6ddde7f59dd6ebf6fee3f5ffe17dfbcdd2cc7fcfbbeb67", - "0x117135d192a9645062d7a29b7fab4f57c91945c88211eed9fa59001289490c357fd9ad087c8cd8e25084f0de82050bf34b69ac5142c30111265028c4a2ebc9a8e7b2a67e5bb91202388c1dccfdfcb1a092e456eee9a421c696eb2b6d2198a3d485d2e33464c3d5b1a0650b8c40cc4a8e096963" - }, - { - "0x1af3ce2ba6101f661c52430ae7280e3491d8d044a6621c3ef348c4e6e45fc6dfc91ec46b27214a9ebff52a0922fdebf1e895cd7cc4f428c64b7b3c4711b53f1f04f25b2f63ba70f281f52cb8149509f1ad38156397556eedf9e5c72388364cdba9112913", - "0x5c5811bd255dad9049ec956e6eeaa95895e56e1c5c03cbfe24ae065ac3f528fda51a966771d288dfe3aab7611232e6f6bde10cf0d97620ebde6370ab24dbdecd4d7783c05cc8579517951049f16b26cf1612f6344a669d93ac990a997dfb5180a07a75f6a20dc110fd5547e744cfe0b348cc1786d8c7f587dc83fd9e8fdb9", - "0xa00e02861011200452010885280a201010000426621c10c3088462041dc61708124429240042183c050801205169510095043044f02006434024411130091000925b25000a00a201602098100501502c30046203140cc1786584230834481b89002911", - "0x5c5811bd255dad9049ec956e6eeaa95895e56e1c5c03cbfe24ae07fffff7bafda5fef7e775f2aeffe3ebff7d9f36eef6bde3eff4dd7e6eeffe6ffcbbecdffeff5dffebff5ee8d7bfdfbf1ec9fdffeecf569ef6b7fbe6fd9bfff9fadf7dfbf7bba77f7dfff2cfc159fddf5ff7c5dff9f75eeedf9edcf7fd87fccfff9f9fdbb", - "0x5c5811bd255dad9049ec956e6eeaa95895e56e1c5c03cbfe24ae07f5ff17929ca4ecf7a255e226ad6349fe7c9f36ac909c22e3c455384eae220e8c3ac89d6cbf59de683f0e68c5bac92a0ec0adbcea80549e9283f9a2ec88ff68fad65849a7bb07755de9f0c64059adca5d34c599d9c61e22c81884b5cd04b84e470f9d4aa" - }, - { - "0xcd10bb69c381582eff7391a446db73312e738c6978564b350ca88e09cad650ef89dfb4cb00831c41d4739e957fdac00124348c91183da60b8f12dd3e349cad8b8d752fd9ea5613b1a41818032e0a2f2030790009a4fe9cdca54f96402b143e", - "0x7c4f944973a8882522976043833419c2c15b1531af1207b40092dd1e3c123a4cf06370c3111b", - "0x104d140010a888052007404202101180001801200a020030000009043c10180440024003101a", - "0xcd10bb69c381582eff7391a446db73312e738c6978564b350ca88e09cad650ef89dfb4cb00831c41d4739e957fdac00124348c91183da60b8f7edfbe7dffad8bad77bff9ebd737b9e6d95b173faf3f27b47992ddbefe9efeedfff770eb153f", - "0xcd10bb69c381582eff7391a446db73312e738c6978564b350ca88e09cad650ef89dfb4cb00831c41d4739e957fdac00124348c91183da60b8f6e92aa7def0503a857b8b9a9d527a866d943161fa53d27847992d4bac28ee6e9bff530e80525" - }, - { - "0x1cdc2579b3f1727c03a0f733c6a1a50025c8b51640ed21fb0e700f873d35c83797a14", - "0xe3e7298d39a9c7cd225125b1a01505e3d9ca63f8b494e4d7218b10e8bddc06984bbbe43e263f30f6a92a9d7", - "0x10042120110162580220f03084a085000100a0144004004b0a600e063d30c02102814", - "0xe3e7298d39a9c7cd225dfdb5f9b7f5f3fdcbe3ffb7d6e5f721afd8fdbfdcefb9fbbff43fa73f35febfbfbd7", - "0xe3e7298d39a9c7cd224df994d9a6f491a5c9c30f8752457221aed85dab9cebb9b0b59431a102053e9ebd3c3" - }, - { - "0x3ac7a7062a50d421ec7b732acfeafd988b5fe95661d371a7f2fdb5b9c1d37e304dd3a0dfcb995e9f99e1b86696b54df83fcd4e87764ffe27fbbd785875c31993f20f4628df79cbaeb50c3dfd132e20935f33ee0276c23f445dff5a075a8198907c1e248787fb28c44495d2e2ed677832432eeda5026afb91467cef4b8", - "0x12659e0b26181845981459681797ab57a50c5b4a34882e973f884d99c1e89c0457b99c9445be077039c60cffa057c608594d38423730d3eae76e8a8db6f946877e90bfecde4aaa320128ef3811cd31c3834e66fa7a61d1454778bf82781c091ae5fd348fd903d85116f83f331d84edaa925d1d65b0b30c1b7c6c69da380", - "0x20860306081044000459600287aa5580085b481400021127804d9181c0900410099080458a0150198000b820168408580d0842073043ea276a88081071420112900f44084a280200200c3811012000834e22ea0260c0054458bf0200180118807c14048103d800044015120084652812410c65a002081b104468ca080", - "0x127fdfaf263a58d5b9fc7b7b3fdfebffbd8f5feb76e9fff7bffafdbdf9e9df7e77fddfb4dfff9f7ebfdfedffe6d7f74df97ffd4eb776dffee7ffbffdfefdc79ffff2bfeefedffbfbafbdef3dfddf3fe3935f77fe7a77d37f477dffda7f5e899af5fd3eafdf87fb79d6fcbff3ffedeffab25f3fedb5b36efbfd6e7dff7b8", - "0x125f59ac20324891b9f8221b3d5841aa3d8704a362e9fde6987ab02c78294f7a67f44f349a759e2ea65fed47c6c17345a172f50cb0469c14c09537f5ee8c859eed62b0aaf695d3f9af9de305ecde1fe3101155147817137a032540d87f46888275812aab5e842379d2bcaae1ff698ad2a01e338815b166e0ed2a1535738" - }, - { - "0x39d2210d760b098917fd1293f0708ed6ffcd7686a4041e774a0f52e808524d686429da6774dd45dcf69abb4a7a48116d71f8e38074196cddf128b041a28cdc1e12cf755c7", - "0x59d65c9b948dab08f5c3604fb8b4d15085e4ae6ea8e762bbcceb904b3d9b5837977c4c9f2b9e9f3f8c6babd3b5e846ed8bdad898648bc4f8ccbea95d7a9cf5fd694e6b1a176058fbb30257aafa296741ab7181398c43a264a94972c08b4a5c56807a5f06b5b88eb420df822b43c43b400d0", - "0x284221095208080003c41080b0200c529cc5740004001a17400852a000520868202140237081018c42822008484000094058428070190495b008b00082800802000b400c0", - "0x59d65c9b948dab08f5c3604fb8b4d15085e4ae6ea8e762bbcceb904b3d9b5837977c4c9f2b9e9f3f8c6babd3b5f9d6ed8ffedb99ed9ffdfadffef9dffefffdffefee6f1e776a5ffbfb0a57effa6d6fdbef75dd7ddcf7baffeb7b7ad1ef7bfcf7807e5f6efdf9aeb461ff8eff5fd6ff755d7", - "0x59d65c9b948dab08f5c3604fb8b4d15085e4ae6ea8e762bbcceb904b3d9b5837977c4c9f2b9e9f3f8c6babd3b5d194cc86acd391ed9c39ea5f4ed9d3ac63388befea6f04602a57a95b0a05e7924d4e9bcc055c7c50b538dfe3333ad1e63ba4b5000e466a6849a604617d0ef75dd6f435517" - }, - { - "0xcf08fe64414998cc59938913e660f0f9b221f459cd8e04126cf902d0b6cea0edc26164b9d84e9ce7dfe058c1fe0fb452848616368c3", - "0x234286d14c1098ea9fd7f83508641ef3288da679fce09dd1359514ebf0dbcdc73b8f7f6171762d3d5df6492591c9386", - "0x4000910810806090d1b02100400c820000247900c094c0208500616099c84618875f6050402c0d145200041000082", - "0xcf08fe644149bbcedfd3cd13feeafffffa35fc7ddfff2c9feef9fef0bfdfb5fdd6ebf4fbddcfbfefffe179f7ff3ffdf6cda797ffbc7", - "0xcf08fe644149bb8edf42c5037e8a6f2e4a14fc3dd37d2c9fca80fe302b1f9578d68a94621589a768a08129b7d332e9a4cda387ffb45" - }, - { - "0x343e32e61b86c0c7cc895cf233ea3d5b5ad65435c1f87e034b59788a9af14ffae9249f1f3cfe0789abbe8edc8ce", - "0x63f7afb1dcebc9d65f9d468754ea558119988cb7d85e427003f2c1d9b360d2c75b97c1308ee3a7b5901044c6353e14f3e6b54a2ead64acdf914c6f7b6d4ed3205abdc78aa7bb47d548607b4ffe1db7331aac39c8bc7fcfd62238467352656a3ad04a423", - "0x241e10440b024046c00058b0038a251b42d4402041487e010311188818c00c7ac9040218047202012a3a8048002", - "0x63f7afb1dcebc9d65f9d468754ea558119988cb7d85e427003f2c1d9b360d2c75b97c1308ee3a7b5901044c6353e14f3e6b54a2ead64bcffb3ee7fffedcfdfa95efff7eabffb5fd75c75fbfffe1fff7b7aaebbf9ffffeff6bf3f7eff57edebbededecef", - "0x63f7afb1dcebc9d65f9d468754ea558119988cb7d85e427003f2c1d9b360d2c75b97c1308ee3a7b5901044c6353e14f3e6b54a2ead6498e1a3aa74fdad891fa9064ff4609ae01d031c55bab7801efc6a6226a339f38526f2bd277a8d55ecc1845e96ced" - }, - { - "0x981ba5db1da1fe952887e32cd21d51ba024022c8d837ec00f9772a111f87644012cee4a01f66d09ef168ebdfb91232e9e8f65d63ee7e6e050ae9707e7b15df4f8037b0d8d427f32429a45312a24081ed5a9c8ec22358f3621c961349638f30e049d00d513901fe065d5364f4cfca93f14a2b1b", - "0x1ba08accd8474ea8d9dc2f10d3c2c2edcbf9c3a909ab45", - "0x38000c048400c0019002e00514240e4cbc883a1082b01", - "0x981ba5db1da1fe952887e32cd21d51ba024022c8d837ec00f9772a111f87644012cee4a01f66d09ef168ebdfb91232e9e8f65d63ee7e6e050ae9707e7b15df4f8037b0d8d427f32429a45312a24081ed5a9c8ec22358f3621c9613497bafbaecd9d74ff9f9ddff16dfd3e6fdcffbd3f94bab5f", - "0x981ba5db1da1fe952887e32cd21d51ba024022c8d837ec00f9772a111f87644012cee4a01f66d09ef168ebdfb91232e9e8f65d63ee7e6e050ae9707e7b15df4f8037b0d8d427f32429a45312a24081ed5a9c8ec22358f3621c961349782fba2c919743f9e0ddd1168e91a6190433505843805e" - }, - { - "0x1d9992a4fce731fe937e70ec9efba437b1efa9e5459e3145f8c9142c6988eca9a61273750bcc1f00a64b32bab5a3a4c89858231f4fedce7a73bcc7285bbd18b328ccc298919f5511e973cd124f7e1c3912d52f4593c676f1c3f87a521", - "0x6e195204da93bdade43f0622217647326502417d70305d050d988", - "0x421810045011a921c412062200300210250001447030410008100", - "0x1d9992a4fce731fe937e70ec9efba437b1efa9e5459e3145f8c9142c6988eca9a61273750bcc1f00a64b32bab5a3a4c89858231f4fedce7a73bcc7285bbd18b328ccee99d39fdf93fdffed3f4f7e3d7f57f76f47d3ff76f1dffd7fda9", - "0x1d9992a4fce731fe937e70ec9efba437b1efa9e5459e3145f8c9142c6988eca9a61273750bcc1f00a64b32bab5a3a4c89858231f4fedce7a73bcc7285bbd18b328ccac81c39b8f8254de292d495c3d4f55e74a47d2bb06c19efd77ca9" - }, - { - "0x123b8aaf5660144d596f10574b4c232f267222596831", - "0x10ab460448ce805f18a3c1d64fc8cc0c02b2cd5f860d462e33602f09fd131e5468c86997e5a033729b2a03d3c284ee0111488ea", - "0x1021028c0600144801270012000c2028066000100820", - "0x10ab460448ce805f18a3c1d64fc8cc0c02b2cd5f860d462e33602f09fd133ffceafd6f97e5f5b7f39f7eb7d3f2f6ef2335de8fb", - "0x10ab460448ce805f18a3c1d64fc8cc0c02b2cd5f860d462e33602f09fd123decc23d0f96a175a5839e5eb711f076892334de0db" - }, - { - "0x17529608c59c36277d9e89f9b275032e62ab42b4dc006f1943e12b088c36657b02937109db797e2fbb83c984f507841be083c5e36dd04a8b7d3", - "0x1d556659e3b765044e08b1f7879bf057ef", - "0x1814004940304104080810368500a017c3", - "0x17529608c59c36277d9e89f9b275032e62ab42b4dc006f1943e12b088c36657b02937109db797e2fbbd7dfe5ff3ff65be4e3cfff7df9ff8f7ff", - "0x17529608c59c36277d9e89f9b275032e62ab42b4dc006f1943e12b088c36657b02937109db797e2fba569fe16b3cf24ba4634efc15a9f58e03c" - }, - { - "0x23ed0547893da2de2673832f9e6d988ce38c44a47495c1e0a714eb2f18ec455157cc20ea9da75cdcb0c4e9afa546efb3650b7e5cb7e659359d17fe79d2d5116bcd6c5cca45e0719d063e7df33f6788e5c6bd77c114340748cf553c5aa4992076953c4904181e24bb7c26a6e895d8b808c70133b52c9ca4a2266c2e2302bf777", - "0x3eaf5dd3cbba83558163fd16469a3d64905ff28ee65c15ff01f4d720b1ad669a893671bb614382f2331985333b0af52cbc0af22e50e4cb39d4ab3ad58127b3c481e692bb22dc0b497690e57e6fc84a87c2e1eb85e6c8bfc253fd497fc88", - "0x20aa1d83489880448123a50646922500105cb286401415170070d20011294408080241a061010232311105230800c42c340010240040cb11140a2091002691040104101a20980800268085582808420102a12884a48026400221003f400", - "0x23ed0547893da2de2673832f9e6d988ce38c44a47495c1e0a714eb2f18ec455157cc3eefddf7dffeb3d5e9effd56efbb7d6ffe5ff7eeff7d9dfffffdd7f5b1efeffeddfe75fb71df86fe7ffbbf77bbeff7bdffcbf63e57eccf7dfcfbbedda177b7fcc9e69abf26ff7f6ff6f8f5feffc8cf87f3f5ef9de6eabfee7fff4bfffff", - "0x23ed0547893da2de2673832f9e6d988ce38c44a47495c1e0a714eb2f18ec455157cc1e45c0749766339168cc5850a929586fee034568bf6988e8ff8d05f5a0c6abf6d5fc345b10de84cc4eeaba54b3ef3391cbcbe61a57ac046ce8f19e4ca15126f8c8e28aa50667776fd07870a6d7c08d86f154c719426a99ae7dde4bc0bff" - }, - { - "0x4881b1172db56487aa0b4362479871a57", - "0xd40bc374f241c2bb638ed6dea08d7885135052619d2f58523b3218b57371993a62bea6cfc8abf4abb8e4a96b0a38bbffffdd0bc5e5a6514f0db", - "0x4081210228b16487880b4160061041053", - "0xd40bc374f241c2bb638ed6dea08d7885135052619d2f58523b3218b57371993a62bea6cfc8abf4abb8eca9fb1f3dbfffffff0bc7e7e7d97fadf", - "0xd40bc374f241c2bb638ed6dea08d7885135052619d2f58523b3218b57371993a62bea6cfc8abf4abb8ac28da1d150e9b7877008687e1c93ea8c" - }, - { - "0x1e0e22b43b6de9f7ee3000e87eef492f84ee1bcd3f490cdbf35171b174335fe53afa9b752d9b1e1b0bd58d71d35687cb7b74", - "0xac57c7cfa532414e1182c7c499ffa996f7a28187f7f5d7586f0fd6b64e566bff1ff68daa60d7b650cfece99b8e2551941008aaa5ab966c526d584251600baf9f48d6b573e2779363363cea427961c0ac63d9c9abcc30976c3755b739dcbcccfbb7ae06b5deed54c59a5271caaa26134877898f75b065f3c72a8429ab5", - "0x40602140a4429948a30000876c3410b008c0bcc0f0908c0635160914411052518aa82612483181803510451105280421a34", - "0xac57c7cfa532414e1182c7c499ffa996f7a28187f7f5d7586f0fd6b64e566bff1ff68daa60d7b650cfece99b8e2551941008aaa5ab966c526d584251600baf9f48d6b573e2779363363cebe2fb6bc3beffdfffebcc3e97eef7d7ff7ffdbcdfffb7efbfb5dfff57c7bffe73efabb753d9f7e9bffdf8f7fff76afcbfbf5", - "0xac57c7cfa532414e1182c7c499ffa996f7a28187f7f5d7586f0fd6b64e566bff1ff68daa60d7b650cfece99b8e2551941008aaa5ab966c526d584251600baf9f48d6b573e2779363363ceba29b4a831abd46b748cc3e1082c3c74f773d001f0f2763b980c9f64386afac226503914191c6683fc8e8b2eef242f89e1c1" - }, - { - "0x46529c1d4b03b4a0efd29ce200ce9564cdc4fa4b53b9b6725e3fffe3454d6e53848fa573858f0bdbcf846d790a5bfc7470d0b8ac1d494804fa7048b869d5e016e389bf93cb959469dca3f4c5e93f8bcb7dbb64bcec19c8d9dbc5f2cecb285d81f5fefe99ff4564662c7cc275a40f0ea519adb2", - "0x1b10fed79bfd5e52ba14eea13cf223bfbeb5f42bd781083545c4306ed5f69250efc19707288aadf9df45b4056a293da0cfae076ee9b08e7a7058ef0a58e67149980cdc60a75825607ec4e531e9d036e71e3df52048853e3", - "0x1010d6c518485a523810e0a13cf0029790a5b4034701080041c4100045a6000086811601280889f91c01100408083d004e82002ca190864a40408c0818a4510888008440075825601ec4440060c004271a00f02040801a2", - "0x46529c1d4b03b4a0efd29ce200ce9564cdc4fa4b53b9b6725e3fffe3f54fef7bbfdfe57ba5cfebdbcfa67ffbeb5ffefd78d0bbfc5d4b4eedff796dbefdddf076ebabff9fffdfd47ffeb3fecdfbffffefffbbe7bfed9ff8fddfe7f6dfcbeddf8bf5fefe9fff4f777ebd7fee75e7df5ea599fff3", - "0x46529c1d4b03b4a0efd29ce200ce9564cdc4fa4b53b9b6725e3fffe2f442832a3b5a405824c1e1c800a65682e104bec908c03bf8410a4ee9a5196db695cc90646b23600e3fced43f7e302ec913dffd25e6b3831be997387c55a2e6574be59b8b807ca89e130b3778b17fac0447d05ca191fe51" - }, - { - "0x1c61ea1ba6135d29a669cc258f24a09ce0c6af1fa717", - "0x277557a8f45578e7730c64350cd3fd389bf96320fb3079402e9949062868fda63a6c371adf34952bd8fbf8a361671041556548ecabc7561f3febfcf26290dc819caa54b8eb26a7fb3a593202b2eb9a87fa214342ea4d639c3487882c7b6a03401d0715171c8ec44d45eff0c2571ca3f556d0d986fbeb5ff", - "0x10416008a4005408a60804218a24000c00802f1ea517", - "0x277557a8f45578e7730c64350cd3fd389bf96320fb3079402e9949062868fda63a6c371adf34952bd8fbf8a361671041556548ecabc7561f3febfcf26290dc819caa54b8eb26a7fb3a593202b2eb9a87fa214342ea4d639c3487882c7b6a03401d07d71fbdbee57dd7fff6ded75cf3ff5fdeddeefbfb7ff", - "0x277557a8f45578e7730c64350cd3fd389bf96320fb3079402e9949062868fda63a6c371adf34952bd8fbf8a361671041556548ecabc7561f3febfcf26290dc819caa54b8eb26a7fb3a593202b2eb9a87fa214342ea4d639c3487882c7b6a03401d06d309bd34a5789775965e954451bf5f1ed5ec0a112e8" - }, - { - "0x259856f9c56582b4f8056fdbd37332ff6684ad104683782087ef2b965fa2d22153ca880d735c116878afac5b2477b7f", - "0x1518494828299164e2ee455afe73cd24484df0def1e24c01926bdb2566d44e483a04bbdd5aeab159678305b6ade08cb5bc83e0e63a7bd9e2bb016c355f0fd9e94044e8e9dd380c64ea2f83d239d0987a6864dd1a07c9d742", - "0x20105268c4008210c8040e438331122b2004811040811800044e0a945380c20002c8080111080120000d80002415342", - "0x1518494828299164e2ee455afe73cd24484df0def1e24c01926bdb2566d44e483a04bbdd5aeab15967db85ffbdf6dcbfff83f6ffbf7ffbefff696ef55f6fffeb487efaf9fdfa2d66ff3fabd2fff5d97eefeeffdfb7cfff7f", - "0x1518494828299164e2ee455afe73cd24484df0def1e24c01926bdb2566d44e483a04bbdd5aeab15965da80d931b6d49ef303b61b874ceacd4d6926e45b67ee6b483a1a50b8c22146ff132b52eee5596cefee27dfb58eac3d" - }, - { - "0xd8526c4a399bb415b422ab254fb7c9a053c1507e3260aac195366c5fed9ff583053547f1b8f54561838e8d5fff273e25", - "0xdc8169197ca1b7f60394685c3438a5b9ff07c0deafe3d68064567be3d9ad3c577600e0d98c4bda37a6ed8175d437cded052bdf221c4c3d76221331061", - "0x4002480a30180400b42028044527882012c14076200008808434205a6c981501013446d010b540218082854221231021", - "0xdc8169197ca1b7f60394685c3dbda7fdff9ffbdfffe3feb274ff7ffbddbd3d57f726eafd9d5bfef7fefdff7df477ddff1fafdf761c7cfdf7fff373e65", - "0xdc8169197ca1b7f60394685c39bd837d5c9e7b9ff4a1fc3230ad0779dc9129509526ea759518bcf258347e2de46499921ea48b740474d5a3dde142e44" - }, - { - "0x47ac96c78ee0c7a9906ce5af63d0ad1b0420e1ca783cc6904ee84", - "0x630297e0f122e36f0c5f2f34efbb078c2f4c00e7c16f96cb054", - "0x20028780e002a1000c452f20c0a90304204000600046904a004", - "0x47ef96d7eef1e7ebff6cffaf77ffbf1f8c2fedcafffdef96cfed4", - "0x47cf94506e11e54aff60ba80573f161c880fadca9ffda90685ed0" - }, - { - "0x432a40ea48fcb8b8161bc19a26b544f54833bf5e005c7d1c19e8405c5464c8c139fdd9b627865e596c513fc68454827f070310dd7efe80306693ce441c89a74d91db5e27d6ba966aa1e109cc8385bd86a23d127cf609eea4118e0e1d9be83b561dcffb0ec3844d22", - "0x70d78d38ebcadb77733fc709a6d3b76576ca71acd7e3196640d6adc00225142070b943d5624a3a3d4e77a787d8221848ab06c5135", - "0x50c7880002481864410882008011b560744a212482021004401009c002211020402002c0400820214836838540001800a80044120", - "0x432a40ea48fcb8b8161bc19a26b544f54833bf5e005c7d1c19e8405c5464c8c139fdd9b627865e596c513fc68454827f070310df7ffed3befebfff773ffdf7dffdfb7e77febf9eeffff19fec8feffd86a27d527fff9dfff635afafddfffa7b7f9fefff8ef3ec5d37", - "0x432a40ea48fcb8b8161bc19a26b544f54833bf5e005c7d1c19e8405c5464c8c139fdd9b627865e596c513fc68454827f070310da738653beda3e79332f75d7d7fce02870ba1d8ca7dfd09fa88eef6186806c507bfd9dd3f2352dadc97c92432b9fee7f8473e81c17" - }, - { - "0x7c4c2d104ca2a5c080fbf1e717e47f848ff9be3555bcff60c07907ade9e334a556157dcd28ebbfd73367defdc4d8f5de60815360394e4de6e7535d356ccb8a2d896157ba65a7e8541a06e604454aef3e8cebfc7aedb48466eb65039cf17c13fcdb1b", - "0x2a73b2854f05d043d4e28e0b2634fd7023aaf3e57e58f213dd0693769", - "0x2a0100804e00404084e2880a2604ac50000262a45018c213c10681309", - "0x7c4c2d104ca2a5c080fbf1e717e47f848ff9be3555bcff60c07907ade9e334a556157dcd28ebbfd73367defdc4d8f5de60815360394e4de6e7535d356ccb8a2d896157ba65a7ef7f3a56f65d457fef3eecfbff7fffb6beefff77e79ff17dd3fdff7b", - "0x7c4c2d104ca2a5c080fbf1e717e47f848ff9be3555bcff60c07907ade9e334a556157dcd28ebbfd73367defdc4d8f5de60815360394e4de6e7535d356ccb8a2d896157ba65a54f6f325216594177a1166c599f353ab6bec9d532e613d041c395ec72" - }, - { - "0x3ee957090c3ab10e1c8af669f2093bba430a4322a741522d2ce1d20b07558298627de3dbbbef8828abc64195bad0f9f6acbb734a420d0d8dd330e90d23ab633826a612060eb95070758199006b547b24792d59f97c3191b2dee7a96e", - "0x7e30cfb7abf89648583c2f705f30abb997ded579a0de3172e2b546c920f92fbdf3bf5ffbd5d73620da518e7b4964a44505817d16c7028f4da494135d2589deffbfdb19f6a454f0431cda1884e51f48c67605f9f044e955a4f23da9dfa92af8dfba09ea6adf0390c", - "0x4e102090838a1061808e20122091028020a02228701502d2c415202050500802014424010480000284000949a4041348018114a420d018d42004904218921080600100406205010040091004b005a0478000989782090a28ce0290c", - "0x7e30cfb7abf89648583c2f73ffb5fbb9d7ffd5f9e8ff77ffe2b7ffed30fd3fbff7bf7ffbdfdf36b0ff59afff6ffebdffbff9ff9eff669f5fad9f9f7fefbffeffbfdbd9ffb75ef0d33efe3b86ef7f68e6ff95fff75cf9d5a6f77fbbdfbbffffdffb19fb6fff7b96e", - "0x7e30cfb7abf89648583c2f73b1a5db295475c598687157edc226fd6d105d1d9787aa7d291bca1690af09a7fd6eba99febb79ff9c7b669616099b8c37ee3eea5b9f0bc12b975a6091266c2b068f7e68a69d90fef71cf0c5a2477a1b983bff67487910f1473179062" - }, - { - "0x20265b43c9319cd56eac6a02cbf7913ba44b", - "0x995b92e854a8e0d548bfc02e18529b37790f0e4d9aaf36e7abc4a0f1e6d69489215aaa61b5863b1c86b3536b443dc639d1eb3db7789c2cb2f8cad1a74e5168ef33948c81a06fbad3b9ab0b7c84045cd1f77620ef43c7f2088d2901917bec5346a44f679be9491d273dbe5bf6e39095bb411cac63e38626013d671445c", - "0x20261901493010c0462c2802401390310448", - "0x995b92e854a8e0d548bfc02e18529b37790f0e4d9aaf36e7abc4a0f1e6d69489215aaa61b5863b1c86b3536b443dc639d1eb3db7789c2cb2f8cad1a74e5168ef33948c81a06fbad3b9ab0b7c84045cd1f77620ef43c7f2088d2901917bec5346a44f679be9491d273dbe5bf6e7b4bdbb59ddfeebe7a62ebf7d77be45f", - "0x995b92e854a8e0d548bfc02e18529b37790f0e4d9aaf36e7abc4a0f1e6d69489215aaa61b5863b1c86b3536b443dc639d1eb3db7789c2cb2f8cad1a74e5168ef33948c81a06fbad3b9ab0b7c84045cd1f77620ef43c7f2088d2901917bec5346a44f679be9491d273dbe59f48624a92858d1fa8925260abe4474ae017" - }, - { - "0x20a92c71c161a786989694109718416d7a291b8f9c71a5a71ee827e003a5a19cf2aa8faeecbfa231c330e2d4c747b75ccc4d43d8c37472b60", - "0xc2ba3ef844b62f020cd6e4b010499c2c28ab3c15ed2ef3114e5b806244e57be1a7d999a21399c1e950977f021c82a906bed39caeec6aa077628421f9d5dfed01b24fe857000e259537fbe07d6a83080080ae927512d4518f9a56f0a40376234855377d8ef40dcb6055bd8d351", - "0x20282071400021809096840092084045000801851471a0250a80000000a480141280018e8816a020033022404507350cc40d4340413400340", - "0xc2ba3ef844b62f020cd6e4b010499c2c28ab3c15ed2ef3114e5b806244e57be1a7d999a21399c1e950977f021c82a906bed39caeecebac77e3e5a7ffdddffd11b75fe97f7a2f3f9fbffbe5ff7eeb2fe083afb3fdf2fedfaffefff2b5c376e3dcd777ffdefc4dcbf8d7fdffb71", - "0xc2ba3ef844b62f020cd6e4b010499c2c28ab3c15ed2ef3114e5b806244e57be1a7d999a21399c1e950977f021c82a906bed39caeccc38c06a3e5867f4d4979112557a93a7a273e1aab8a45da746b2fe0830b33e9e07ede2176e95295c046c19c9270cad2384088b896c9ff831" - }, - { - "0xf6b7f399370d10b097b17e514f044d77a8f170148f4837033bb5d425f73a4079e1c7a9c3e69246f902d8c9fd27caad1e93d83578d4af8d3b7b1c02041c44917a22ed56f2562ac1426a356f8d31965e8e367b8929f3907b1dc6e73a8f3a566ca5c4e113e9d2c53770b110df51cf504701ff3fcea5b819b9bfc49f", - "0x61989df2b7097a6a84dc016aec2716d9cac359d2d799d90ec006a66efe3f1fd0851978c4cfe2f64b307b852e23f5dfdc2f63196e1076782a228a46f5f7d4e54afc1ad7abf1f8fef46edaad1706956f95eb95953bd4", - "0x990290097822808c0002c82510d08a8119521400000c40002222ec1612500001404005628401105a8426238109d0006319460032082a020804c4e110e142c41250a110d850c440420117068425900991950094", - "0xf6b7f399370d10b097b17e514f044d77a8f170148f4837033bb5d425f73a4079e1c7a9c3e6f3defdf2ffc9ff6fcefd1ffbfc377eddefcf7bfbdf9bdd1ec497fe6eff7fffd6afd97aeeffefff7bb67f8f3e7bfdffffbf7b1deef77eff3a76eee7f5f7d7eddafd3ff7bbf1ffffff7edfadff3fdfefbdfbbdbfffdf", - "0xf6b7f399370d10b097b17e514f044d77a8f170148f4837033bb5d425f73a4079e1c7a9c3e6f3de64f06fc0874d4e711ff934126e0d654e62a9cb9bdd128497dc4c1369ed86afd83aaefa8d7b7aa6250b18587cf62fbf1804a8f74cf71074e6e33116c70c98392da71ae127af3b3e9dace8395bca2df22c2aff4b" - }, - { - "0x31d126e874580b754389fad8b64aaa61cabb4f8eb6904fe7e504341ed903f7daa3e74d4da3afca80b2415672a", - "0x16fb17a0468c0afa6bad456efa4f9baf26860eda9d7c00c2520c8c9b6026fb50df59b8cb74f6d9be861052c5e831158e7ffd98746328ce11f91d9ea22f0803a8b059aea22d1715ca1abeae53a8bc6b8bfb9b6c9d24ae714767", - "0x11100e0745803440288e0189048aa20c0800a8a04904a22c10014008902e51a83c6080da1a6c880024114722", - "0x16fb17a0468c0afa6bad456efa4f9baf26860eda9d7c00c2520c8c9b6026fb50df59b8cb74f6d9be861052c5eb3d17eefffd98f77738dfbdfb7dbea63fabb7f8fb79aefe7f5757cbffbebf7faabe7fdffbbbfcbd2fae75676f", - "0x16fb17a0468c0afa6bad456efa4f9baf26860eda9d7c00c2520c8c9b6026fb50df59b8cb74f6d9be861052c5eb2c07e0f8b818c3371051bc7279340433a3b7505b30aa5c5347568bf72e912e02821f5f21a190352f8a64204d" - }, - { - "0xbf1a14e469c234b72d56324d100e016bc38cdf7158e35f230c047585e7b107acc8e222e7f19552541e59316affd90e96ca657b6112f5e8c786dfcff342fc46252fcdab10c632578540dbf6235f164bc5711924c7c6ba9da85ab", - "0x5dd3fb9a3de26cd89eb9517af6bb25678f149f906e8751a0c20d7646d21c17191237022a990e0156541e376986fd6a680c60228e5955df08bae5789c81751cdcafe5a2e72d45b09", - "0x5d5158821d220c001481413006a800620204919042041000000876400214020112210220880600564412026806252a480800020251054008b22158140145101824c582a20d00109", - "0xbf1a14e469c234b72d56324d100e016bc38cdff3fbfb7fe36cdcffbdf7fbf7bfede7aff7ff957ed75ff9f36fffdfde9edf7d7b7712fff9cf87dfdfff77fdc6fd6fedaf70e6be5fd5dfdbfee77f9ecbf57dddafe7e6ffbdedfab", - "0xbf1a14e469c234b72d56324d100e016bc38c82a2a37962c160dceb3cb6cbf117ed85adf36e053cd34ff9f367899fdc8add7c695610df71c987899bed7595c0d845a5a770e4bc0ed09fd34cc6278acab06dc58b22645db0edea2" - }, - }; - - bool opa=true, opo=true, opx=true; - - //////////////////// AND //////////////////// - - for (size_t i=0; i and - // Exponentiate(). It can easily consume all machine memory because it is an exponentiation - // without a modular reduction. - - // ****************************** DivideByZero ****************************** - - { - try { - Integer x = Integer(prng, 128) / Integer::Zero(); - result=false; - } catch (const Exception&) { - result=true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // The 0*0 % 0 test. - { - try { - Integer x = 0; - Integer y = 0; - Integer z = ModularMultiplication(y, y, x); - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // Another 0*0 % 0 test. - { - try { - Integer x = 0; - Integer y = 0; - Integer z = (y * y) % x; - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // The 0^0 % 0 test. - { - try { - Integer x = 0; - Integer y = 0; - Integer z = ModularExponentiation(y, y, x); - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // Another 0^0 % 0 test. - { - try { - Integer x = 0; - Integer y = 0; - Integer z = EuclideanDomainOf().Exponentiate(y, y) % x; - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // Integer divide by 0 - { - try { - Integer r=1, q=1, a=1, d=0; - Integer::Divide(r, q, a, d); - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - // Another Integer divide by 0 - { - try { - Integer q=1, a=1; word r=1, d=0; - Integer::Divide(r, q, a, d); - result = false; - } - catch(const Integer::DivideByZero&) { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer DivideByZero\n"; - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Integer DivideByZero\n"; - - // ************************ RandomNumberNotFound ************************ - - try { - // A run of 71 composites; see http://en.wikipedia.org/wiki/Prime_gap - Integer x = Integer(GlobalRNG(), 31398, 31468, Integer::PRIME); - result=false; - } catch (const Exception&) { - result=true; - } - - pass = result && pass; - if (result) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Integer RandomNumberNotFound\n"; - - // ************************ Carmichael pseudo-primes ************************ - - result=true; - if (IsPrime(Integer("561"))) - result = false; - if (IsPrime(Integer("41041"))) - result = false; - if (IsPrime(Integer("321197185"))) - result = false; - if (IsPrime(Integer("5394826801"))) - result = false; - if (IsPrime(Integer("232250619601"))) - result = false; - if (IsPrime(Integer("974637772161"))) - result = false; - - pass = result && pass; - if (result) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Carmichael pseudo-primes\n"; - - // ****************************** Integer Double ****************************** - - try { - Integer x = Integer::One().Doubled(); - result = (x == Integer::Two()); - } catch (const Exception&) { - result=false; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer Doubled\n"; - - // ****************************** Integer Square ****************************** - - try { - Integer x = Integer::Two().Squared(); - result = (x == 4); - } catch (const Exception&) { - result=false; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer Squared\n"; - - try { - Integer x = Integer::Two().Squared(); - result = (x == 4) && x.IsSquare(); - } catch (const Exception&) { - result=false; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Integer IsSquare\n"; - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Squaring operations\n"; - - // ****************************** Integer GCD ****************************** - - { - for (unsigned int i=0; i<128; ++i) - { - Integer x, y; - switch(i%2) - { - case 0: - { - AlgorithmParameters params = - MakeParameters("BitLength", 256)("RandomNumberType", Integer::PRIME); - x.GenerateRandom(prng, params); - y.GenerateRandom(prng, params); - break; - } - case 1: - { - x = MaurerProvablePrime(prng, 256); - y = MihailescuProvablePrime(prng, 256); - } - } - - if (x != y) - { - result = (RelativelyPrime(x, y) == true); - pass = result && pass; - - if (!result) - std::cout << "FAILED: Integer GCD\n"; - } - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " GCD operations\n"; - } - - // ******************** Integer Modulo and InverseMod ******************** - - // http://github.com/weidai11/cryptopp/issues/602 - // The bug report that uncovered the InverseMod problems - { - Integer a("0x2F0500010000018000000000001C1C000000000000000A000B0000000000000000000000000000FDFFFFFF00000000"); - Integer b("0x3D2F050001"); - - result = (Integer("0x3529E4FEBC") == a.InverseMod(b)); - pass = result && pass; - if (!result) - std::cout << "FAILED: InverseMod operation\n"; - } - - // Integer Integer::InverseMod(const Integer &m) - // Large 'a' and 'm' - for (unsigned int i=0; i<128; ++i) - { - Integer a(prng, 1024), m(prng, 1024); - a++, m++; // make non-0 - - Integer x = a.InverseMod(m); - Integer y = (a % m).InverseMod(m); - Integer z = (a * y).Modulo(m); - - if (RelativelyPrime(a, m) == true) - result = (x == y) && (z == 1) && (ModularMultiplication(a, x, m) == 1); - else - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: InverseMod operation\n"; - } - - // Integer Integer::InverseMod(const Integer &m) - // Corner cases like 0, 2m-1 and 2m+1 - for (unsigned int i=0; i<128; ++i) - { - Integer a(prng, 1024), m(prng, 1024); - a++, m++; // make non-0 - - // Corner cases - int j = i % 12; - switch (j) - { - case 0: - a = -1; break; - case 1: - a = 0; break; - case 2: - a = 1; break; - case 3: - a = m-1; break; - case 4: - a = m; break; - case 5: - a = m+1; break; - case 6: - a = 2*m-1; break; - case 7: - a = 2*m; break; - case 8: - a = 2*m+1; break; - case 9: - a = (m<<256)-1; break; - case 10: - a = (m<<256); break; - case 11: - a = (m<<256)+1; break; - default: - ; - } - - Integer x = a.InverseMod(m); - Integer y = (a % m).InverseMod(m); - Integer z = (a * y).Modulo(m); - - if (RelativelyPrime(a, m) == true) - result = (x == y) && (z == 1) && (ModularMultiplication(a, x, m) == 1); - else - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: InverseMod operation\n"; - } - - // Integer Integer::InverseMod(const Integer &m) - // Large 'a', small 'm' - for (unsigned int i=0; i<128; ++i) - { - Integer a(prng, 4096), m(prng, 32); - a++, m++; // make non-0 - - Integer x = a.InverseMod(m); - Integer y = (a % m).InverseMod(m); - Integer z = (a * y).Modulo(m); - - if (RelativelyPrime(a, m) == true) - result = (x == y) && (z == 1) && (ModularMultiplication(a, x, m) == 1); - else - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: InverseMod operation\n"; - } - - // Integer Integer::InverseMod(word m) - // Small 'm' using word - for (unsigned int i=0; i<128; ++i) - { - Integer a(prng, 4096); word m; - prng.GenerateBlock((byte*)&m, sizeof(m)); - - a++; // make non-0 - if (m == 0) m++; - - // Avoid the conversion from word to long - Integer mi = Integer(Integer::POSITIVE, 0, m); - Integer ri = a % Integer(Integer::POSITIVE, 0, m); - - Integer x = Integer(Integer::POSITIVE, 0, a.InverseMod(m)); - Integer y = Integer(Integer::POSITIVE, 0, ri.InverseMod(m)); - Integer z = Integer(Integer::POSITIVE, 0, (a * y).Modulo(m)); - - if (GCD(a,mi) == 1) - result = (x == y) && (z == 1); - else - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: InverseMod operation\n"; - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " InverseMod operations\n"; - - // ****************************** Integer Divide ****************************** - - // Divide (Integer &r, Integer &q, const Integer &a, const Integer &d) - for (unsigned int i=0; i<128; ++i) - { - Integer r, q, a(prng, 1024), d(prng, 1024); - Integer::Divide(r, q, a, d); - - Integer xr = a % d; - Integer xq = a / d; - result = (r == xr) && (q == xq); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Divide operation\n"; - } - - // Divide (word &r, Integer &q, const Integer &a, word d) - for (unsigned int i=0; i<128; ++i) - { - word r, d = prng.GenerateWord32(); - Integer q, a(prng, 1024); - Integer::Divide(r, q, a, d); - - Integer xr = a % Integer(Integer::POSITIVE, 0, d); - Integer xq = a / Integer(Integer::POSITIVE, 0, d); - result = (Integer(Integer::POSITIVE, 0, r) == xr) && (q == xq); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Divide operation\n"; - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Divide operations\n"; - - // ****************************** Integer Power2 ****************************** - - { - Integer x, y; - - x = Integer::Power2(0); - result = (x == 1); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Power2 operation\n"; - - x = Integer::Power2(1); - result = (x == 2); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Power2 operation\n"; - } - - for (unsigned int i=0; i<128; i+=2) - { - Integer b = 2, m(prng, 2048); - - Integer x = EuclideanDomainOf().Exponentiate(b, i) % m; - Integer y = Integer::Power2(i) % m; - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Power2 operation\n"; - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Power2 operations\n"; - - // ****************************** Integer Exponentiation ****************************** - - { - word32 m = prng.GenerateWord32(); - if (m == 0) m++; - - Integer z = Integer::Zero(); - Integer x = ModularExponentiation(z, z, m); - Integer y = EuclideanDomainOf().Exponentiate(z, z) % m; - result = (x == y) && (x == 1); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // The 0^0 % 0 test. - { - try - { - Integer x = 0; - Integer y = ModularExponentiation(x, x, x); - result = false; - } - catch(const Integer::DivideByZero&) - { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // Another 0^0 % 0 test. - { - try - { - Integer x = 0; - Integer z = EuclideanDomainOf().Exponentiate(0, 0) % x; - result = false; - } - catch(const Integer::DivideByZero&) - { - result = true; - } - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // Run the exponent 0 to 128 on base 0 - for (unsigned int i=0; i<128; i+=2) - { - Integer b = 0, m(prng, 2048); - - Integer x = ModularExponentiation(b, i, m); - Integer y = EuclideanDomainOf().Exponentiate(b, i) % m; - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // Run the exponent 1 to 128 on base 2 - for (unsigned int i=0; i<128; i+=2) - { - Integer b = 1, m(prng, 2048); - - Integer x = ModularExponentiation(b, i, m); - Integer y = EuclideanDomainOf().Exponentiate(b, i) % m; - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // Run the exponent 0 to 128 on base 2 - for (unsigned int i=0; i<128; i+=2) - { - Integer b = 2, m(prng, 2048); - - Integer x = ModularExponentiation(b, i, m); - Integer y = EuclideanDomainOf().Exponentiate(b, i) % m; - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - // Run the exponent 0 to 24 on random base - for (unsigned int i=0; i<24; ++i) - { - Integer b(prng, 32), m(prng, 2048); - - Integer x = ModularExponentiation(b, i, m); - Integer y = EuclideanDomainOf().Exponentiate(b, i) % m; - result = (x == y); - - pass = result && pass; - if (!result) - std::cout << "FAILED: Exponentiation operation\n"; - } - - if (pass) - std::cout << "passed:"; - else - std::cout << "FAILED:"; - std::cout << " Exponentiation operations\n"; - - // ****************************** Integer Randomize ****************************** - - try - { - const word32 bitCounts[] = { - 0,1,2,3,4,5,6,7,8,9,15,16,17,31,32,33,63,64,65,127,128,129 - }; - - for (size_t i=0; i -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (CRYPTOPP_MSC_VERSION >= 1500) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -bool ValidateAll(bool thorough) -{ - bool pass=TestSettings(); - pass=TestOS_RNG() && pass; - pass=TestRandomPool() && pass; -#if !defined(NO_OS_DEPENDENCE) && defined(OS_RNG_AVAILABLE) - pass=TestAutoSeededX917() && pass; -#endif - // pass=TestSecRandom() && pass; -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - pass=TestMersenne() && pass; -#endif -#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) - pass=TestPadlockRNG() && pass; - pass=TestRDRAND() && pass; - pass=TestRDSEED() && pass; -#endif -#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) - pass=TestDARN() && pass; -#endif -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - // http://github.com/weidai11/cryptopp/issues/92 - pass=TestSecBlock() && pass; - // http://github.com/weidai11/cryptopp/issues/602 - pass=TestIntegerOps() && pass; - // http://github.com/weidai11/cryptopp/issues/336 - pass=TestIntegerBitops() && pass; - // http://github.com/weidai11/cryptopp/issues/64 - pass=TestPolynomialMod2() && pass; - // http://github.com/weidai11/cryptopp/issues/360 - pass=TestRounding() && pass; - // http://github.com/weidai11/cryptopp/issues/242 - pass=TestHuffmanCodes() && pass; - // http://github.com/weidai11/cryptopp/issues/346 - pass=TestASN1Parse() && pass; - pass=TestASN1Functions() && pass; - // https://github.com/weidai11/cryptopp/pull/334 - pass=TestStringSink() && pass; - // Always part of the self tests; call in Debug -# if defined(CRYPTOPP_ALTIVEC_AVAILABLE) - pass=TestAltivecOps() && pass; -# endif - // Always part of the self tests; call in Debug - pass=ValidateBaseCode() && pass; - // https://github.com/weidai11/cryptopp/issues/562 - pass=ValidateEncoder() && pass; - // Additional tests due to no coverage - pass=TestCompressors() && pass; - pass=TestSharing() && pass; - pass=TestEncryptors() && pass; - pass=TestX25519() && pass; - pass=TestEd25519() && pass; -#endif - - pass=ValidateCRC32() && pass; - pass=ValidateCRC32C() && pass; - pass=ValidateAdler32() && pass; - pass=ValidateMD2() && pass; -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - pass=ValidateMD4() && pass; -#endif - pass=ValidateMD5() && pass; - pass=ValidateSHA() && pass; - - pass=ValidateKeccak() && pass; - pass=ValidateSHA3() && pass; - pass=ValidateSHAKE() && pass; - pass=ValidateSHAKE_XOF() && pass; - - pass=ValidateLSH() && pass; - - pass=ValidateHashDRBG() && pass; - pass=ValidateHmacDRBG() && pass; - - pass=ValidateTiger() && pass; - pass=ValidateRIPEMD() && pass; - pass=ValidatePanama() && pass; - pass=ValidateWhirlpool() && pass; - - pass=ValidateSM3() && pass; - pass=ValidateBLAKE2s() && pass; - pass=ValidateBLAKE2b() && pass; - pass=ValidatePoly1305() && pass; - pass=ValidateSipHash() && pass; - - pass=ValidateHMAC() && pass; - pass=ValidateTTMAC() && pass; - - pass=ValidatePBKDF() && pass; - pass=ValidateHKDF() && pass; - pass=ValidateScrypt() && pass; - - pass=ValidateDES() && pass; - pass=ValidateCipherModes() && pass; - pass=ValidateIDEA() && pass; - pass=ValidateSAFER() && pass; - pass=ValidateRC2() && pass; - pass=ValidateARC4() && pass; - pass=ValidateRC5() && pass; - pass=ValidateBlowfish() && pass; - pass=ValidateThreeWay() && pass; - pass=ValidateGOST() && pass; - pass=ValidateSHARK() && pass; - pass=ValidateCAST() && pass; - pass=ValidateSquare() && pass; - pass=ValidateSKIPJACK() && pass; - pass=ValidateSEAL() && pass; - pass=ValidateRC6() && pass; - pass=ValidateMARS() && pass; - pass=ValidateRijndael() && pass; - pass=ValidateTwofish() && pass; - pass=ValidateSerpent() && pass; - pass=ValidateSHACAL2() && pass; - pass=ValidateARIA() && pass; - pass=ValidateCHAM() && pass; - pass=ValidateHIGHT() && pass; - pass=ValidateLEA() && pass; - pass=ValidateSIMECK() && pass; - pass=ValidateSIMON() && pass; - pass=ValidateSPECK() && pass; - pass=ValidateCamellia() && pass; - pass=ValidateSalsa() && pass; - pass=ValidateChaCha() && pass; - pass=ValidateChaChaTLS() && pass; - pass=ValidateSosemanuk() && pass; - pass=ValidateRabbit() && pass; - pass=ValidateHC128() && pass; - pass=ValidateHC256() && pass; - pass=RunTestDataFile("TestVectors/seed.txt") && pass; - pass=RunTestDataFile("TestVectors/threefish.txt") && pass; - pass=RunTestDataFile("TestVectors/kalyna.txt") && pass; - pass=RunTestDataFile("TestVectors/sm4.txt") && pass; - pass=ValidateVMAC() && pass; - pass=ValidateCCM() && pass; - pass=ValidateGCM() && pass; - pass=ValidateXTS() && pass; - pass=ValidateCMAC() && pass; - pass=RunTestDataFile("TestVectors/eax.txt") && pass; - - pass=ValidateBBS() && pass; - pass=ValidateDH() && pass; - pass=ValidateX25519() && pass; - pass=ValidateMQV() && pass; - pass=ValidateHMQV() && pass; - pass=ValidateFHMQV() && pass; - pass=ValidateRSA() && pass; - pass=ValidateElGamal() && pass; - pass=ValidateDLIES() && pass; - pass=ValidateNR() && pass; - pass=ValidateDSA(thorough) && pass; - pass=ValidateLUC() && pass; - pass=ValidateLUC_DH() && pass; - pass=ValidateLUC_DL() && pass; - pass=ValidateXTR_DH() && pass; - pass=ValidateRabin() && pass; - pass=ValidateRW() && pass; - pass=ValidateECP() && pass; - pass=ValidateEC2N() && pass; - pass=ValidateECP_Legacy_Encrypt() && pass; - pass=ValidateEC2N_Legacy_Encrypt() && pass; - pass=ValidateECDSA() && pass; - pass=ValidateECDSA_RFC6979() && pass; - pass=ValidateECGDSA(thorough) && pass; - pass=ValidateESIGN() && pass; - - pass=ValidateX25519() && pass; - pass=ValidateEd25519() && pass; - pass=ValidateNaCl() && pass; - - if (pass) - std::cout << "\nAll tests passed!\n"; - else - std::cout << "\nOops! Not all tests passed.\n"; - - return pass; -} - -bool TestSettings() -{ - bool pass = true; - - std::cout << "\nTesting Settings...\n\n"; - - word32 w; - const byte s[] = "\x01\x02\x03\x04"; - -#if (CRYPTOPP_MSC_VERSION >= 1400) - memcpy_s(&w, 4, s, 4); -#else - std::copy(s, s+4, reinterpret_cast(&w)); -#endif - - if (w == 0x04030201L) - { -#if (CRYPTOPP_LITTLE_ENDIAN) - std::cout << "passed: "; -#else - std::cout << "FAILED: "; - pass = false; -#endif - std::cout << "Your machine is little endian.\n"; - } - else if (w == 0x01020304L) - { -#if (CRYPTOPP_BIG_ENDIAN) - std::cout << "passed: "; -#else - std::cout << "FAILED: "; - pass = false; -#endif - std::cout << "Your machine is big endian.\n"; - } - else - { - std::cout << "FAILED: Your machine is neither big endian nor little endian.\n"; - pass = false; - } - - // Machine word size does not agree with pointer size on Morello. Also see - // https://developer.arm.com/documentation/den0133/0100/Morello-prototype-architecture/Pointers-and-capabilities - if (sizeof(size_t) == 16) - { - std::cout << "passed: Your machine has 128-bit words.\n"; - } - else if (sizeof(size_t) == 8) - { - std::cout << "passed: Your machine has 64-bit words.\n"; - } - else if (sizeof(size_t) == 4) - { - std::cout << "passed: Your machine has 32-bit words.\n"; - } - else - { - std::cout << "FAILED: Your machine uses unknown word size.\n"; - pass = false; - } - - // Morello uses 129-bit pointers. Also see - // https://developer.arm.com/documentation/den0133/0100/Morello-prototype-architecture/Pointers-and-capabilities - if (sizeof(void*) == 16) - { - std::cout << "passed: Your machine has 128-bit pointers.\n"; - } - else if (sizeof(void*) == 8) - { - std::cout << "passed: Your machine has 64-bit pointers.\n"; - } - else if (sizeof(void*) == 4) - { - std::cout << "passed: Your machine has 32-bit pointers.\n"; - } - else - { - std::cout << "FAILED: Your machine uses unknown pointer size.\n"; - pass = false; - } - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - // App and library versions, http://github.com/weidai11/cryptopp/issues/371 - const int v1 = LibraryVersion(); - const int v2 = HeaderVersion(); - if(v1/10 == v2/10) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "Library version (library): " << v1 << ", header version (app): " << v2 << "\n"; -#endif - - if (sizeof(byte) == 1) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(byte) == " << sizeof(byte) << "\n"; - - if (sizeof(word16) == 2) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(word16) == " << sizeof(word16) << "\n"; - - if (sizeof(word32) == 4) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(word32) == " << sizeof(word32) << "\n"; - - if (sizeof(word64) == 8) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(word64) == " << sizeof(word64) << "\n"; - -#ifdef CRYPTOPP_WORD128_AVAILABLE - if (sizeof(word128) == 16) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(word128) == " << sizeof(word128) << "\n"; -#endif - - if (sizeof(word) == 2*sizeof(hword) -#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE - && sizeof(dword) == 2*sizeof(word) -#endif - ) - std::cout << "passed: "; - else - { - std::cout << "FAILED: "; - pass = false; - } - std::cout << "sizeof(hword) == " << sizeof(hword) << ", sizeof(word) == " << sizeof(word); -#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE - std::cout << ", sizeof(dword) == " << sizeof(dword); -#endif - std::cout << "\n"; - - const int cacheLineSize = GetCacheLineSize(); - if (cacheLineSize < 16 || cacheLineSize > 256 || !IsPowerOf2(cacheLineSize)) - { - std::cout << "FAILED: "; - pass = false; - } - else - std::cout << "passed: "; - std::cout << "cacheLineSize == " << cacheLineSize << "\n"; - -#ifdef CRYPTOPP_CPUID_AVAILABLE - bool hasSSE2 = HasSSE2(); - bool hasSSSE3 = HasSSSE3(); - bool hasSSE41 = HasSSE41(); - bool hasSSE42 = HasSSE42(); - bool hasAVX = HasAVX(); - bool hasAVX2 = HasAVX2(); - bool hasAESNI = HasAESNI(); - bool hasCLMUL = HasCLMUL(); - bool hasRDRAND = HasRDRAND(); - bool hasRDSEED = HasRDSEED(); - bool hasSHA = HasSHA(); - bool isP4 = IsP4(); - - std::cout << "hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3; - std::cout << ", hasSSE4.1 == " << hasSSE41 << ", hasSSE4.2 == " << hasSSE42; - std::cout << ", hasAVX == " << hasAVX << ", hasAVX2 == " << hasAVX2; - std::cout << ", hasAESNI == " << hasAESNI << ", hasCLMUL == " << hasCLMUL; - std::cout << ", hasRDRAND == " << hasRDRAND << ", hasRDSEED == " << hasRDSEED; - std::cout << ", hasSHA == " << hasSHA << ", isP4 == " << isP4; - std::cout << "\n"; - -#elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8) - -# if defined(__arm__) - bool hasARMv7 = HasARMv7(); - bool hasNEON = HasNEON(); - - std::cout << "passed: "; - std::cout << "hasARMv7 == " << hasARMv7 << ", hasNEON == " << hasNEON << "\n"; -# else // __arch32__ and __aarch64__ - bool hasCRC32 = HasCRC32(); - bool hasPMULL = HasPMULL(); - bool hasAES = HasAES(); - bool hasSHA1 = HasSHA1(); - bool hasSHA2 = HasSHA2(); - bool hasSHA3 = HasSHA3(); - bool hasSHA512 = HasSHA512(); - bool hasSM3 = HasSM3(); - bool hasSM4 = HasSM4(); - - std::cout << "passed: hasASIMD == 1"; - std::cout << ", hasCRC32 == " << hasCRC32 << ", hasAES == " << hasAES; - std::cout << ", hasPMULL == " << hasPMULL << ", hasSHA1 == " << hasSHA1; - std::cout << ", hasSHA2 == " << hasSHA2 << ", hasSHA3 == " << hasSHA3; - std::cout << ", hasSHA512 == " << hasSHA512 << ", hasSM3 == " << hasSM3; - std::cout << ", hasSM4 == " << hasSM4 << "\n"; -# endif - -#elif (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) - const bool hasAltivec = HasAltivec(); - const bool hasPower7 = HasPower7(); - const bool hasPower8 = HasPower8(); - const bool hasPower9 = HasPower9(); - const bool hasAES = HasAES(); - const bool hasPMULL = HasPMULL(); - const bool hasSHA256 = HasSHA256(); - const bool hasSHA512 = HasSHA512(); - const bool hasDARN = HasDARN(); - - std::cout << "passed: "; - std::cout << "hasAltivec == " << hasAltivec << ", hasPower7 == " << hasPower7; - std::cout << ", hasPower8 == " << hasPower8 << ", hasPower9 == " << hasPower9; - std::cout << ", hasAES == " << hasAES << ", hasPMULL == " << hasPMULL; - std::cout << ", hasSHA256 == " << hasSHA256 << ", hasSHA512 == " << hasSHA512; - std::cout << ", hasDARN == " << hasDARN << "\n"; - -#endif - - if (!pass) - { - std::cerr << "Some critical setting in config.h is in error. Please fix it and recompile.\n"; - std::abort(); - } - return pass; -} - -bool Test_RandomNumberGenerator(RandomNumberGenerator& prng, bool drain=false) -{ - bool pass = true, result = true; - const size_t GENERATE_SIZE = 1024*10, DISCARD_SIZE = 256, ENTROPY_SIZE = 32; - - if(drain) - { - RandomNumberSource(prng, UINT_MAX, true, new Redirector(TheBitBucket())); - } - - MeterFilter meter(new Redirector(TheBitBucket())); - RandomNumberSource(prng, GENERATE_SIZE, true, new Deflator(new Redirector(meter))); - - if (meter.GetTotalBytes() < GENERATE_SIZE) - { - pass = false; - result = false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " " << GENERATE_SIZE << " generated bytes compressed to "; - std::cout << meter.GetTotalBytes() << " bytes by DEFLATE\n"; - - try - { - pass = true; - if(prng.CanIncorporateEntropy()) - { - SecByteBlock entropy(ENTROPY_SIZE); - GlobalRNG().GenerateBlock(entropy, entropy.SizeInBytes()); - - prng.IncorporateEntropy(entropy, entropy.SizeInBytes()); - prng.IncorporateEntropy(entropy, entropy.SizeInBytes()-1); - prng.IncorporateEntropy(entropy, entropy.SizeInBytes()-2); - prng.IncorporateEntropy(entropy, entropy.SizeInBytes()-3); - } - } - catch (const Exception& /*ex*/) - { - pass = false; - result = false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " IncorporateEntropy with " << 4*ENTROPY_SIZE << " bytes\n"; - - try - { - word32 val = prng.GenerateWord32(); - val = prng.GenerateWord32((val & 0xff), 0xffffffff - (val & 0xff)); - - prng.GenerateBlock(reinterpret_cast(&val), 4); - prng.GenerateBlock(reinterpret_cast(&val), 3); - prng.GenerateBlock(reinterpret_cast(&val), 2); - prng.GenerateBlock(reinterpret_cast(&val), 1); - } - catch (const Exception&) - { - pass = false; - result = false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " GenerateWord32 and Crop\n"; - - try - { - pass = true; - prng.DiscardBytes(DISCARD_SIZE); - prng.DiscardBytes(DISCARD_SIZE-1); - prng.DiscardBytes(DISCARD_SIZE-2); - prng.DiscardBytes(DISCARD_SIZE-3); - } - catch (const Exception&) - { - pass = false; - result = false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " DiscardBytes with " << 4*DISCARD_SIZE << " bytes\n"; - - // Miscellaneous for code coverage - (void)prng.AlgorithmName(); // "unknown" - - CRYPTOPP_ASSERT(result); - return result; -} - -bool TestOS_RNG() -{ - bool pass = true; - - member_ptr rng; - -#ifdef BLOCKING_RNG_AVAILABLE - try {rng.reset(new BlockingRng);} - catch (const OS_RNG_Err &) {} - - if (rng.get()) - { - std::cout << "\nTesting operating system provided blocking random number generator...\n\n"; - - MeterFilter meter(new Redirector(TheBitBucket())); - RandomNumberSource test(*rng, UINT_MAX, false, new Deflator(new Redirector(meter))); - unsigned long total=0; - time_t t = time(NULLPTR), t1 = 0; - - // check that it doesn't take too long to generate a reasonable amount of randomness - while (total < 16 && (t1 < 10 || total*8 > (unsigned long)t1)) - { - test.Pump(1); - total += 1; - t1 = time(NULLPTR) - t; - } - - if (total < 16) - { - std::cout << "FAILED:"; - pass = false; - } - else - std::cout << "passed:"; - std::cout << " it took " << long(t1) << " seconds to generate " << total << " bytes" << std::endl; - - test.AttachedTransformation()->MessageEnd(); - - if (meter.GetTotalBytes() < total) - { - std::cout << "FAILED:"; - pass = false; - } - else - std::cout << "passed:"; - std::cout << " " << total << " generated bytes compressed to " << meter.GetTotalBytes() << " bytes by DEFLATE\n"; - - try - { - // Miscellaneous for code coverage - RandomNumberGenerator& prng = *rng.get(); - (void)prng.AlgorithmName(); - word32 result = prng.GenerateWord32(); - result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); - prng.GenerateBlock(reinterpret_cast(&result), 0); - pass = true; - } - catch (const Exception&) - { - pass = false; - } - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " GenerateWord32 and Crop\n"; - } - else - std::cout << "\nNo operating system provided blocking random number generator, skipping test." << std::endl; -#endif - -#ifdef NONBLOCKING_RNG_AVAILABLE - try {rng.reset(new NonblockingRng);} - catch (OS_RNG_Err &) {} - - if (rng.get()) - { - std::cout << "\nTesting operating system provided nonblocking random number generator...\n\n"; - - pass = Test_RandomNumberGenerator(*rng.get()) && pass; - } - else - std::cout << "\nNo operating system provided non-blocking random number generator, skipping test." << std::endl; -#endif - - CRYPTOPP_ASSERT(pass); - return pass; -} - -bool TestRandomPool() -{ - member_ptr prng; - bool pass=true; - - try {prng.reset(new RandomPool);} - catch (Exception &) {} - - if(prng.get()) - { - std::cout << "\nTesting RandomPool generator...\n\n"; - pass = Test_RandomNumberGenerator(*prng.get()) && pass; - } - -#if !defined(NO_OS_DEPENDENCE) && defined(OS_RNG_AVAILABLE) - try {prng.reset(new AutoSeededRandomPool);} - catch (Exception &) {} - - if(prng.get()) - { - std::cout << "\nTesting AutoSeeded RandomPool generator...\n\n"; - pass = Test_RandomNumberGenerator(*prng.get()) && pass; - } -#endif - - // Old, PGP 2.6 style RandomPool. Added because users were still having problems - // with it in 2017. The missing functionality was a barrier to upgrades. - try {prng.reset(new OldRandomPool);} - catch (Exception &) {} - - if(prng.get()) - { - std::cout << "\nTesting OldRandomPool generator...\n\n"; - pass = Test_RandomNumberGenerator(*prng.get()) && pass; - - // https://github.com/weidai11/cryptopp/issues/452 - byte actual[32], expected[32] = { - 0x41,0xD1,0xEF,0x8F,0x10,0x3C,0xE2,0x94, - 0x47,0xC0,0xC3,0x86,0x66,0xBC,0x86,0x09, - 0x57,0x77,0x73,0x91,0x57,0x4D,0x93,0x66, - 0xD1,0x13,0xE1,0xBA,0x07,0x49,0x8F,0x75 - }; - - prng.reset(new OldRandomPool); - RandomNumberGenerator& old = *prng.get(); - - SecByteBlock seed(384); - for (size_t i=0; i<384; ++i) - seed[i] = static_cast(i); - old.IncorporateEntropy(seed, seed.size()); - - old.GenerateBlock(actual, sizeof(actual)); - pass = (0 == std::memcmp(actual, expected, sizeof(expected))) && pass; - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Expected sequence from PGP-style RandomPool (circa 2007)\n"; - } - - return pass; -} - -#if !defined(NO_OS_DEPENDENCE) && defined(OS_RNG_AVAILABLE) -bool TestAutoSeededX917() -{ - // This tests Auto-Seeding and GenerateIntoBufferedTransformation. - std::cout << "\nTesting AutoSeeded X917 generator...\n\n"; - - AutoSeededX917RNG prng; - return Test_RandomNumberGenerator(prng); -} -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -bool TestMersenne() -{ - std::cout << "\nTesting Mersenne Twister...\n\n"; - - member_ptr rng; - bool pass = true; - - try {rng.reset(new MT19937ar);} - catch (const Exception &) {} - - if(rng.get()) - { - pass = Test_RandomNumberGenerator(*rng.get()); - } - - // Reset state - try {rng.reset(new MT19937ar);} - catch (const Exception &) {} - - if(rng.get()) - { - // First 10; http://create.stephan-brumme.com/mersenne-twister/ - word32 result[10], expected[10] = { - 0xD091BB5C, 0x22AE9EF6, 0xE7E1FAEE, 0xD5C31F79, - 0x2082352C, 0xF807B7DF, 0xE9D30005, 0x3895AFE1, - 0xA1E24BBA, 0x4EE4092B - }; - - rng->GenerateBlock(reinterpret_cast(result), sizeof(result)); - pass = (0 == std::memcmp(result, expected, sizeof(expected))) && pass; - - if (!pass) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Expected sequence from MT19937\n"; - } - - return pass; -} -#endif - -#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) -bool TestPadlockRNG() -{ - std::cout << "\nTesting Padlock RNG generator...\n\n"; - - member_ptr rng; - bool pass = true, fail; - - try {rng.reset(new PadlockRNG);} - catch (const PadlockRNG_Err &) {} - - if (rng.get()) - { - PadlockRNG& padlock = dynamic_cast(*rng.get()); - pass = Test_RandomNumberGenerator(padlock); - - // PadlockRNG does not accept entropy. However, the contract is no throw - const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - (void)padlock.IncorporateEntropy(entropy, sizeof(entropy)); - - SecByteBlock zero(16), one(16), t(16); - std::memset(zero, 0x00, zero.size()); - std::memset( one, 0xff, one.size()); - - // Cryptography Research, Inc tests - word32 oldDivisor = padlock.SetDivisor(0); - padlock.GenerateBlock(t, t.size()); - word32 msr = padlock.GetMSR(); - padlock.SetDivisor(oldDivisor); - - // Bit 6 should be set - fail = !(msr & (1 << 6U)); - pass &= !fail; - if (fail) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " VIA RNG is activated\n"; - - // Bit 13 should be unset - fail = !!(msr & (1 << 13U)); - pass &= !fail; - if (fail) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " von Neumann corrector is activated\n"; - - // Bit 14 should be unset - fail = !!(msr & (1 << 14U)); - pass &= !fail; - if (fail) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " String filter is deactivated\n"; - - // Bit 12:10 should be unset - fail = !!(msr & (0x7 << 10U)); - pass &= !fail; - if (fail) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " Bias voltage is unmodified\n"; - - fail = false; - if (t == zero || t == one) - fail = true; - - pass &= !fail; - if (fail) - std::cout << "FAILED:"; - else - std::cout << "passed:"; - std::cout << " All 0's or all 1's test\n"; - } - else - std::cout << "Padlock RNG generator not available, skipping test.\n"; - - return pass; -} - -bool TestRDRAND() -{ - std::cout << "\nTesting RDRAND generator...\n\n"; - - bool pass = true; - member_ptr rng; - - try {rng.reset(new RDRAND);} - catch (const RDRAND_Err &) {} - - if (rng.get()) - { - RDRAND& rdrand = dynamic_cast(*rng.get()); - pass = Test_RandomNumberGenerator(rdrand) && pass; - - // RDRAND does not accept entropy. However, the contract is no throw - const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - (void)rdrand.IncorporateEntropy(entropy, sizeof(entropy)); - - MaurerRandomnessTest maurer; - const unsigned int SIZE = 1024*10; - RandomNumberSource(rdrand, SIZE, true, new Redirector(maurer)); - - CRYPTOPP_ASSERT(0 == maurer.BytesNeeded()); - const double mv = maurer.GetTestValue(); - if (mv < 0.98f) - pass = false; - - std::ostringstream oss; - oss.flags(std::ios::fixed); - oss.precision(6); - - if (!pass) - oss << "FAILED:"; - else - oss << "passed:"; - oss << " Maurer Randomness Test returned value " << mv << "\n"; - std::cout << oss.str(); - } - else - std::cout << "RDRAND generator not available, skipping test.\n"; - - return pass; -} - -bool TestRDSEED() -{ - std::cout << "\nTesting RDSEED generator...\n\n"; - - bool pass = true; - member_ptr rng; - - try {rng.reset(new RDSEED);} - catch (const RDSEED_Err &) {} - - if (rng.get()) - { - RDSEED& rdseed = dynamic_cast(*rng.get()); - pass = Test_RandomNumberGenerator(rdseed) && pass; - - // RDSEED does not accept entropy. However, the contract is no throw - const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - (void)rdseed.IncorporateEntropy(entropy, sizeof(entropy)); - - MaurerRandomnessTest maurer; - const unsigned int SIZE = 1024*10; - RandomNumberSource(rdseed, SIZE, true, new Redirector(maurer)); - - CRYPTOPP_ASSERT(0 == maurer.BytesNeeded()); - const double mv = maurer.GetTestValue(); - if (mv < 0.98f) - pass = false; - - std::ostringstream oss; - oss.flags(std::ios::fixed); - oss.precision(6); - - if (!pass) - oss << "FAILED:"; - else - oss << "passed:"; - oss << " Maurer Randomness Test returned value " << mv << "\n"; - std::cout << oss.str(); - } - else - std::cout << "RDSEED generator not available, skipping test.\n"; - - return pass; -} -#endif // x86, x32, or x64 - -#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) -bool TestDARN() -{ - std::cout << "\nTesting DARN generator...\n\n"; - - bool pass = true; - member_ptr rng; - - try {rng.reset(new DARN);} - catch (const DARN_Err &) {} - - if (rng.get()) - { - DARN& darn = dynamic_cast(*rng.get()); - pass = Test_RandomNumberGenerator(darn) && pass; - - // DARN does not accept entropy. However, the contract is no throw - const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - (void)darn.IncorporateEntropy(entropy, sizeof(entropy)); - - MaurerRandomnessTest maurer; - const unsigned int SIZE = 1024*10; - RandomNumberSource(darn, SIZE, true, new Redirector(maurer)); - - CRYPTOPP_ASSERT(0 == maurer.BytesNeeded()); - const double mv = maurer.GetTestValue(); - if (mv < 0.98f) - pass = false; - - std::ostringstream oss; - oss.flags(std::ios::fixed); - oss.precision(6); - - if (!pass) - oss << "FAILED:"; - else - oss << "passed:"; - oss << " Maurer Randomness Test returned value " << mv << "\n"; - std::cout << oss.str(); - } - else - std::cout << "DARN generator not available, skipping test.\n"; - - return pass; -} -#endif // PPC32 or PPC64 - -bool ValidateHashDRBG() -{ - std::cout << "\nTesting NIST Hash DRBGs...\n\n"; - bool pass=true, fail; - - // # CAVS 14.3 - // # DRBG800-90A information for "drbg_pr" - // # Generated on Tue Apr 02 15:32:09 2013 - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x16\x10\xb8\x28\xcc\xd2\x7d\xe0\x8c\xee\xa0\x32\xa2\x0e\x92\x08"; - const byte entropy2[] = "\x72\xd2\x8c\x90\x8e\xda\xf9\xa4\xd1\xe5\x26\xd8\xf2\xde\xd5\x44"; - const byte nonce[] = "\x49\x2c\xf1\x70\x92\x42\xf6\xb5"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\x56\xF3\x3D\x4F\xDB\xB9\xA5\xB6\x4D\x26\x23\x44\x97\xE9\xDC\xB8\x77\x98\xC6\x8D" - "\x08\xF7\xC4\x11\x99\xD4\xBD\xDF\x97\xEB\xBF\x6C\xB5\x55\x0E\x5D\x14\x9F\xF4\xD5" - "\xBD\x0F\x05\xF2\x5A\x69\x88\xC1\x74\x36\x39\x62\x27\x18\x4A\xF8\x4A\x56\x43\x35" - "\x65\x8E\x2F\x85\x72\xBE\xA3\x33\xEE\xE2\xAB\xFF\x22\xFF\xA6\xDE\x3E\x22\xAC\xA2"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (COUNT=0, E=16, N=8)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x55\x08\x75\xb7\x4e\xc1\x1f\x90\x67\x78\xa3\x1a\x37\xa3\x29\xfd"; - const byte entropy2[] = "\x96\xc6\x39\xec\x14\x9f\x6b\x28\xe2\x79\x3b\xb9\x37\x9e\x60\x67"; - const byte nonce[] = "\x08\xdd\x8c\xd3\x5b\xfa\x00\x94"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\xEE\x44\xC6\xCF\x2C\x0C\x73\xA8\xAC\x4C\xA5\x6C\x0E\x71\x2C\xA5\x50\x9A\x19\x5D" - "\xE4\x5B\x8D\x2B\xC9\x40\xA7\xDB\x66\xC3\xEB\x2A\xA1\xBD\xB4\xDD\x76\x85\x12\x45" - "\x80\x2E\x68\x05\x4A\xAB\xA8\x7C\xD6\x3A\xD3\xE5\xC9\x7C\x06\xE7\xA3\x9F\xF6\xF9" - "\x8E\xB3\xD9\x72\xD4\x11\x35\xE5\xE7\x46\x1B\x49\x9C\x56\x45\x6A\xBE\x7F\x77\xD4"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (COUNT=1, E=16, N=8)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 128], [ReturnedBitsLen = 640] - const byte entropy1[] = "\xd9\xba\xb5\xce\xdc\xa9\x6f\x61\x78\xd6\x45\x09\xa0\xdf\xdc\x5e"; - const byte entropy2[] = "\xc6\xba\xd0\x74\xc5\x90\x67\x86\xf5\xe1\xf3\x20\x99\xf5\xb4\x91"; - const byte nonce[] = "\xda\xd8\x98\x94\x14\x45\x0e\x01"; - const byte additional1[] = "\x3e\x6b\xf4\x6f\x4d\xaa\x38\x25\xd7\x19\x4e\x69\x4e\x77\x52\xf7"; - const byte additional2[] = "\x04\xfa\x28\x95\xaa\x5a\x6f\x8c\x57\x43\x34\x3b\x80\x5e\x5e\xa4"; - const byte additional3[] = "\xdf\x5d\xc4\x59\xdf\xf0\x2a\xa2\xf0\x52\xd7\x21\xec\x60\x72\x30"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\xC4\x8B\x89\xF9\xDA\x3F\x74\x82\x45\x55\x5D\x5D\x03\x3B\x69\x3D\xD7\x1A\x4D\xF5" - "\x69\x02\x05\xCE\xFC\xD7\x20\x11\x3C\xC2\x4E\x09\x89\x36\xFF\x5E\x77\xB5\x41\x53" - "\x58\x70\xB3\x39\x46\x8C\xDD\x8D\x6F\xAF\x8C\x56\x16\x3A\x70\x0A\x75\xB2\x3E\x59" - "\x9B\x5A\xEC\xF1\x6F\x3B\xAF\x6D\x5F\x24\x19\x97\x1F\x24\xF4\x46\x72\x0F\xEA\xBE"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 128], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x28\x00\x0f\xbf\xf0\x57\x22\xc8\x89\x93\x06\xc2\x9b\x50\x78\x0a"; - const byte entropy2[] = "\xd9\x95\x8e\x8c\x08\xaf\x5a\x41\x0e\x91\x9b\xdf\x40\x8e\x5a\x0a"; - const byte nonce[] = "\x11\x2f\x6e\x20\xc0\x29\xed\x3f"; - const byte additional1[] = "\x91\x1d\x96\x5b\x6e\x77\xa9\x6c\xfe\x3f\xf2\xd2\xe3\x0e\x2a\x86"; - const byte additional2[] = "\xcd\x44\xd9\x96\xab\x05\xef\xe8\x27\xd3\x65\x83\xf1\x43\x18\x2c"; - const byte additional3[] = "\x9f\x6a\x31\x82\x12\x18\x4e\x70\xaf\x5d\x00\x14\x1f\x42\x82\xf6"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\x54\x61\x65\x92\x1E\x71\x4A\xD1\x39\x02\x2F\x97\xD2\x65\x3F\x0D\x47\x69\xB1\x4A" - "\x3E\x6E\xEF\xA1\xA0\x16\xD6\x9E\xA9\x7F\x51\xD5\x81\xDC\xAA\xCF\x66\xF9\xB1\xE8" - "\x06\x94\x41\xD6\xB5\xC5\x44\x60\x54\x07\xE8\xE7\xDC\x1C\xD8\xE4\x70\xAD\x84\x77" - "\x5A\x65\x31\xBE\xE0\xFC\x81\x36\xE2\x8F\x0B\xFE\xEB\xE1\x98\x62\x7E\x98\xE0\xC1"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 128], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x0e\xd5\x4c\xef\x44\x5c\x61\x7d\x58\x86\xe0\x34\xc0\x97\x36\xd4"; - const byte entropy2[] = "\x0b\x90\x27\xb8\x01\xe7\xf7\x2e\xe6\xec\x50\x2b\x8b\x6b\xd7\x11"; - const byte nonce[] = "\x2c\x8b\x07\x13\x55\x6c\x91\x6f"; - const byte personalization[] = "\xf3\x37\x8e\xa1\x45\x34\x30\x41\x12\xe0\xee\x57\xe9\xb3\x4a\x4b"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\x55\x37\x0E\xD4\xB7\xCA\xA4\xBB\x67\x3A\x0F\x58\x40\xB3\x9F\x76\x4E\xDA\xD2\x85" - "\xD5\x6F\x01\x8F\x2D\xA7\x54\x4B\x0E\x66\x39\x62\x35\x96\x1D\xB7\xF6\xDA\xFB\x30" - "\xB6\xC5\x68\xD8\x40\x6E\x2B\xD4\x3D\x23\xEB\x0F\x10\xBA\x5F\x24\x9C\xC9\xE9\x4A" - "\xD3\xA5\xF1\xDF\xA4\xF2\xB4\x80\x40\x91\xED\x8C\xD6\x6D\xE7\xB7\x53\xB2\x09\xD5"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=0, P=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 128], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x8f\x2a\x33\x9f\x5f\x45\x21\x30\xa4\x57\xa9\x6f\xcb\xe2\xe6\x36"; - const byte entropy2[] = "\x1f\xff\x9e\x4f\x4d\x66\x3a\x1f\x9e\x85\x4a\x15\x7d\xad\x97\xe0"; - const byte nonce[] = "\x0e\xd0\xe9\xa5\xa4\x54\x8a\xd0"; - const byte personalization[] = "\x45\xe4\xb3\xe2\x63\x87\x62\x57\x2c\x99\xe4\x03\x45\xd6\x32\x6f"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\x4F\xE8\x96\x41\xF8\xD3\x95\xC4\x43\x6E\xFB\xF8\x05\x75\xA7\x69\x74\x6E\x0C\x5F" - "\x54\x14\x35\xB4\xE6\xA6\xB3\x40\x7C\xA2\xC4\x42\xA2\x2F\x66\x28\x28\xCF\x4A\xA8" - "\xDC\x16\xBC\x5F\x69\xE5\xBB\x05\xD1\x43\x8F\x80\xAB\xC5\x8F\x9C\x3F\x75\x57\xEB" - "\x44\x0D\xF5\x0C\xF4\x95\x23\x94\x67\x11\x55\x98\x14\x43\xFF\x13\x14\x85\x5A\xBC"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=0, P=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 128], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x48\xa1\xa9\x7c\xcc\x49\xd7\xcc\xf6\xe3\x78\xa2\xf1\x6b\x0f\xcd"; - const byte entropy2[] = "\xba\x5d\xa6\x79\x12\x37\x24\x3f\xea\x60\x50\xf5\xb9\x9e\xcd\xf5"; - const byte nonce[] = "\xb0\x91\xd2\xec\x12\xa8\x39\xfe"; - const byte personalization[] = "\x3d\xc1\x6c\x1a\xdd\x9c\xac\x4e\xbb\xb0\xb8\x89\xe4\x3b\x9e\x12"; - const byte additional1[] = "\xd1\x23\xe3\x8e\x4c\x97\xe8\x29\x94\xa9\x71\x7a\xc6\xf1\x7c\x08"; - const byte additional2[] = "\x80\x0b\xed\x97\x29\xcf\xad\xe6\x68\x0d\xfe\x53\xba\x0c\x1e\x28"; - const byte additional3[] = "\x25\x1e\x66\xb9\xe3\x85\xac\x1c\x17\xfb\x77\x1b\x5d\xc7\x6c\xf2"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\xA1\xB2\xEE\x86\xA0\xF1\xDA\xB7\x93\x83\x13\x3A\x62\x27\x99\x08\x95\x3A\x1C\x9A" - "\x98\x77\x60\x12\x11\x19\xCC\x78\xB8\x51\x2B\xD5\x37\xA1\x9D\xB9\x73\xCA\x39\x7A" - "\xDD\x92\x33\x78\x6D\x5D\x41\xFF\xFA\xE9\x80\x59\x04\x85\x21\xE2\x52\x84\xBC\x6F" - "\xDB\x97\xF3\x4E\x6A\x12\x7A\xCD\x41\x0F\x50\x68\x28\x46\xBE\x56\x9E\x9A\x6B\xC8"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=16, P=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 128], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x3b\xcb\xa8\x3b\x6d\xfb\x06\x79\x80\xef\xc3\x1e\xd2\x9e\x68\x57"; - const byte entropy2[] = "\x2f\xc9\x87\x49\x19\xcb\x52\x4a\x5b\xac\xf0\xcd\x96\x4e\xf8\x6e"; - const byte nonce[] = "\x23\xfe\x20\x9f\xac\x70\x45\xde"; - const byte personalization[] = "\xf2\x25\xf4\xd9\x6b\x9c\xab\x49\x1e\xab\x18\x14\xb2\x5e\x78\xef"; - const byte additional1[] = "\x57\x5b\x9a\x11\x32\x7a\xab\x89\x08\xfe\x46\x11\x9a\xed\x14\x5d"; - const byte additional2[] = "\x5d\x19\xcd\xed\xb7\xe3\x44\x66\x8e\x11\x42\x96\xa0\x38\xb1\x7f"; - const byte additional3[] = "\x2b\xaf\xa0\x15\xed\xdd\x5c\x76\x32\x75\x34\x35\xd1\x37\x72\xfb"; - - Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\x1D\x12\xEB\x6D\x42\x60\xBD\xFB\xA7\x99\xB8\x53\xCC\x6F\x19\xB1\x64\xFE\x2F\x55" - "\xBA\xA2\x1C\x89\xD4\xD0\xE9\xB4\xBA\xD4\xE5\xF8\xC5\x30\x06\x41\xBA\xC4\x3D\x2B" - "\x73\x91\x27\xE9\x31\xC0\x55\x55\x11\xE8\xB6\x57\x02\x0D\xCE\x90\xAC\x31\xB9\x00" - "\x31\xC1\xD4\x4F\xE7\x12\x3B\xCC\x85\x16\x2F\x12\x8F\xB2\xDF\x84\x4E\xF7\x06\xBE"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=16, P=16)\n"; - } - - { - // [SHA-256], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] - // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 1024] - const byte entropy1[] = "\xf0\x5b\xab\x56\xc7\xac\x6e\xeb\x31\xa0\xcf\x8a\x8a\x06\x2a\x49\x17\x9a\xcf\x3c\x5b\x20\x4d\x60\xdd\x7a\x3e\xb7\x8f\x5d\x8e\x3b"; - const byte entropy2[] = "\x72\xd4\x02\xa2\x59\x7b\x98\xa3\xb8\xf5\x0b\x71\x6c\x63\xc6\xdb\xa7\x3a\x07\xe6\x54\x89\x06\x3f\x02\xc5\x32\xf5\xda\xc4\xd4\x18"; - const byte nonce[] = "\xa1\x45\x08\x53\x41\x68\xb6\x88\xf0\x5f\x1e\x41\x9c\x88\xcc\x30"; - const byte personalization[] = "\xa0\x34\x72\xf4\x04\x59\xe2\x87\xea\xcb\x21\x32\xc0\xb6\x54\x02\x7d\xa3\xe6\x69\x25\xb4\x21\x25\x54\xc4\x48\x18\x8c\x0e\x86\x01"; - const byte additional1[] = "\xb3\x0d\x28\xaf\xa4\x11\x6b\xbc\x13\x6e\x65\x09\xb5\x82\xa6\x93\xbc\x91\x71\x40\x46\xaa\x3c\x66\xb6\x77\xb3\xef\xf9\xad\xfd\x49"; - const byte additional2[] = "\x77\xfd\x1d\x68\xd6\xa4\xdd\xd5\xf3\x27\x25\x2d\x3f\x6b\xdf\xee\x8c\x35\xce\xd3\x83\xbe\xaf\xc9\x32\x77\xef\xf2\x1b\x6f\xf4\x1b"; - const byte additional3[] = "\x59\xa0\x1f\xf8\x6a\x58\x72\x1e\x85\xd2\xf8\x3f\x73\x99\xf1\x96\x4e\x27\xf8\x7f\xcd\x1b\xf5\xc1\xeb\xf3\x37\x10\x9b\x13\xbd\x24"; - - Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); - drbg.IncorporateEntropy(entropy2, 32, additional1, 32); - - SecByteBlock result(128); - drbg.GenerateBlock(additional2, 32, result, result.size()); - drbg.GenerateBlock(additional3, 32, result, result.size()); - - const byte expected[] = "\xFF\x27\x96\x38\x5C\x32\xBF\x84\x3D\xFA\xBB\xF0\x3E\x70\x5A\x39\xCB\xA3\x4C\xF1" - "\x4F\xAE\xC3\x05\x63\xDF\x5A\xDD\xBD\x2D\x35\x83\xF5\x7E\x05\xF9\x40\x30\x56\x18" - "\xF2\x00\x88\x14\x03\xC2\xD9\x81\x36\x39\xE6\x67\x55\xDC\xFC\x4E\x88\xEA\x71\xDD" - "\xB2\x25\x2E\x09\x91\x49\x40\xEB\xE2\x3D\x63\x44\xA0\xF4\xDB\x5E\xE8\x39\xE6\x70" - "\xEC\x47\x24\x3F\xA0\xFC\xF5\x13\x61\xCE\x53\x98\xAA\xBF\xB4\x19\x1B\xFE\xD5\x00" - "\xE1\x03\x3A\x76\x54\xFF\xD7\x24\x70\x5E\x8C\xB2\x41\x7D\x92\x0A\x2F\x4F\x27\xB8" - "\x45\x13\x7F\xFB\x87\x90\xA9\x49"; - - fail = !!std::memcmp(result, expected, 1024/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA256/128/440 (C0UNT=0, E=32, N=16, A=32, P=32)\n"; - } - - { - // [SHA-256], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] - // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 1024] - const byte entropy1[] = "\xfe\x61\x50\x79\xf1\xad\x2a\x71\xea\x7f\x0f\x5a\x14\x34\xee\xc8\x46\x35\x54\x4a\x95\x6a\x4f\xbd\x64\xff\xba\xf6\x1d\x34\x61\x83"; - const byte entropy2[] = "\x18\x89\x7b\xd8\x3e\xff\x38\xab\xb5\x6e\x82\xa8\x1b\x8c\x5e\x59\x3c\x3d\x85\x62\x2a\xe2\x88\xe5\xb2\xc6\xc5\xd2\xad\x7d\xc9\x45"; - const byte nonce[] = "\x9d\xa7\x87\x56\xb7\x49\x17\x02\x4c\xd2\x00\x65\x11\x9b\xe8\x7e"; - const byte personalization[] = "\x77\x5d\xbf\x32\xf3\x5c\xf3\x51\xf4\xb8\x1c\xd3\xfa\x7f\x65\x0b\xcf\x31\x88\xa1\x25\x57\x0c\xdd\xac\xaa\xfe\xa1\x7b\x3b\x29\xbc"; - const byte additional1[] = "\xef\x96\xc7\x9c\xb1\x73\x1d\x82\x85\x0a\x6b\xca\x9b\x5c\x34\x39\xba\xd3\x4e\x4d\x82\x6f\x35\x9f\x61\x5c\xf6\xf2\xa3\x3e\x91\x05"; - const byte additional2[] = "\xaf\x25\xc4\x6e\x21\xfc\xc3\xaf\x1f\xbb\xf8\x76\xb4\x57\xab\x1a\x94\x0a\x85\x16\x47\x81\xa4\xab\xda\xc8\xab\xca\xd0\x84\xda\xae"; - const byte additional3[] = "\x59\x5b\x44\x94\x38\x86\x36\xff\x8e\x45\x1a\x0c\x42\xc8\xcc\x21\x06\x38\x3a\xc5\xa6\x30\x96\xb9\x14\x81\xb3\xa1\x2b\xc8\xcd\xf6"; - - Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); - drbg.IncorporateEntropy(entropy2, 32, additional1, 32); - - SecByteBlock result(128); - drbg.GenerateBlock(additional2, 32, result, result.size()); - drbg.GenerateBlock(additional3, 32, result, result.size()); - - const byte expected[] = "\x8B\x1C\x9C\x76\xC4\x9B\x3B\xAE\xFD\x6E\xEB\x6C\xFF\xA3\xA1\x03\x3A\x8C\xAF\x09" - "\xFE\xBD\x44\x00\xFC\x0F\xD3\xA8\x26\x9C\xEE\x01\xAC\xE3\x73\x0E\xBE\xDA\x9A\xC6" - "\x23\x44\x6D\xA1\x56\x94\x29\xEC\x4B\xCD\x01\x84\x32\x25\xEF\x00\x91\x0B\xCC\xF3" - "\x06\x3B\x80\xF5\x46\xAC\xD2\xED\x5F\x70\x2B\x56\x2F\x21\x0A\xE9\x80\x87\x38\xAD" - "\xB0\x2A\xEB\x27\xF2\xD9\x20\x2A\x66\x0E\xF5\xC9\x20\x4A\xB4\x3C\xCE\xD6\x24\x97" - "\xDB\xB1\xED\x94\x12\x6A\x2F\x03\x98\x4A\xD4\xD1\x72\xF3\x7A\x66\x74\x7E\x2A\x5B" - "\xDE\xEF\x43\xBC\xB9\x8C\x49\x01"; - - fail = !!std::memcmp(result, expected, 1024/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA256/128/440 (C0UNT=1, E=32, N=16, A=32, P=32)\n"; - } - - { - // [SHA-512], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] - // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 2048] - const byte entropy1[] = "\x55\x4e\x8f\xfd\xc4\x9a\xd8\xf9\x9a\xe5\xd5\xf8\x1a\xf5\xda\xfb\x7f\x75\x53\xd7\xcb\x56\x8e\xa7\x3c\xc0\x82\xdd\x80\x76\x25\xc0"; - const byte entropy2[] = "\x78\x07\x3e\x86\x79\x4b\x10\x95\x88\xf4\x22\xf9\xbd\x04\x7e\xc0\xce\xab\xd6\x78\x6b\xdf\xe2\x89\xb3\x16\x43\x9c\x32\x2d\xb2\x59"; - const byte nonce[] = "\xf0\x89\x78\xde\x2d\xc2\xcd\xd9\xc0\xfd\x3d\x84\xd9\x8b\x8e\x8e"; - const byte personalization[] = "\x3e\x52\x7a\xb5\x81\x2b\x0c\x0e\x98\x2a\x95\x78\x93\x98\xd9\xeb\xf1\xb9\xeb\xd6\x1d\x02\x05\xed\x42\x21\x2d\x24\xb8\x37\xf8\x41"; - const byte additional1[] = "\xf2\x6b\xb1\xef\x30\xca\x8f\x97\xc0\x19\xd0\x79\xe5\xc6\x5e\xae\xd1\xa3\x9a\x52\xaf\x12\xe8\x28\xde\x03\x70\x79\x9a\x70\x11\x8b"; - const byte additional2[] = "\xb0\x9d\xb5\xa8\x45\xec\x79\x7a\x4b\x60\x7e\xe4\xd5\x58\x56\x70\x35\x20\x9b\xd8\xe5\x01\x6c\x78\xff\x1f\x6b\x93\xbf\x7c\x34\xca"; - const byte additional3[] = "\x45\x92\x2f\xb3\x5a\xd0\x6a\x84\x5f\xc9\xca\x16\x4a\x42\xbb\x59\x84\xb4\x38\x57\xa9\x16\x23\x48\xf0\x2f\x51\x61\x24\x35\xb8\x62"; - - Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); - drbg.IncorporateEntropy(entropy2, 32, additional1, 32); - - SecByteBlock result(256); - drbg.GenerateBlock(additional2, 32, result, result.size()); - drbg.GenerateBlock(additional3, 32, result, result.size()); - - const byte expected[] = "\x1F\x20\x83\x9E\x22\x55\x3B\x1E\x6C\xD4\xF6\x3A\x47\xC3\x99\x54\x0F\x69\xA3\xBB" - "\x37\x47\xA0\x2A\x12\xAC\xC7\x00\x85\xC5\xCC\xF4\x7B\x12\x5A\x4A\xEA\xED\x2F\xE5" - "\x31\x51\x0D\xC1\x8E\x50\x29\xE2\xA6\xCB\x8F\x34\xBA\xDA\x8B\x47\x32\x33\x81\xF1" - "\x2D\xF6\x8B\x73\x8C\xFF\x15\xC8\x8E\x8C\x31\x48\xFA\xC3\xC4\x9F\x52\x81\x23\xC2" - "\x2A\x83\xBD\xF1\x44\xEF\x15\x49\x93\x44\x83\x6B\x37\x5D\xBB\xFF\x72\xD2\x86\x96" - "\x62\xF8\x4D\x12\x3B\x16\xCB\xAC\xA1\x00\x12\x1F\x94\xA8\xD5\xAE\x9A\x9E\xDA\xC8" - "\xD7\x6D\x59\x33\xFD\x55\xC9\xCC\x5B\xAD\x39\x73\xB5\x13\x8B\x96\xDF\xDB\xF5\x90" - "\x81\xDF\x68\x6A\x30\x72\x42\xF2\x74\xAE\x7F\x1F\x7F\xFE\x8B\x3D\x49\x38\x98\x34" - "\x7C\x63\x46\x6E\xAF\xFA\xCB\x06\x06\x08\xE6\xC8\x35\x3C\x68\xB8\xCC\x9D\x5C\xDF" - "\xDB\xC0\x41\x44\x48\xE6\x11\xD4\x78\x50\x81\x91\xED\x1D\x75\xF3\xBD\x79\xFF\x1E" - "\x37\xAF\xC6\x5D\x49\xD6\x5C\xAC\x5B\xCB\xD6\x91\x37\x51\xFA\x98\x70\xFC\x32\xB3" - "\xF2\x86\xE4\xED\x74\xF2\x5D\x8B\x6C\x4D\xB8\xDE\xD8\x4A\xD6\x5E\xD6\x6D\xAE\xB1" - "\x1B\xA2\x94\x52\x54\xAD\x3C\x3D\x25\xBD\x12\x46\x3C\xA0\x45\x9D"; - - fail = !!std::memcmp(result, expected, 2048/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA512/256/888 (C0UNT=0, E=32, N=16, A=32, P=32)\n"; - } - - { - // [SHA-512], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] - // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 2048] - const byte entropy1[] = "\x0c\x9f\xcd\x06\x21\x3c\xb2\xf6\x3c\xdf\x79\x76\x4b\x46\x74\xfc\xdf\x68\xb0\xff\xae\xc7\x21\x8a\xa2\xaf\x4e\x4c\xb9\xe6\x60\x78"; - const byte entropy2[] = "\x75\xb8\x49\x54\xdf\x30\x10\x16\x2c\x06\x8c\x12\xeb\x6c\x1d\x03\x64\x5c\xad\x10\x5c\xc3\x17\x69\xb2\x5a\xc1\x7c\xb8\x33\x5b\x45"; - const byte nonce[] = "\x43\x1c\x4d\x65\x93\x96\xad\xdc\xc1\x6d\x17\x9f\x7f\x57\x24\x4d"; - const byte personalization[] = "\x7e\x54\xbd\x87\xd2\x0a\x95\xd7\xc4\x0c\x3b\x1b\x32\x15\x26\xd2\x06\x67\xa4\xac\xc1\xaa\xfb\x55\x91\x68\x2c\xb5\xc9\xcd\x66\x05"; - const byte additional1[] = "\xd5\x74\x9e\x56\xfb\x5f\xf3\xf8\x2c\x73\x2b\x7a\x83\xe0\xde\x06\x85\x0b\xf0\x57\x50\xc8\x55\x60\x4a\x41\x4f\x86\xb1\x68\x14\x03"; - const byte additional2[] = "\x9a\x83\xbb\x06\xdf\x4d\x53\x89\xf5\x3f\x24\xff\xf7\xcd\x0c\xcf\x4f\xbe\x46\x79\x8e\xce\x82\xa8\xc4\x6b\x5f\x8e\x58\x32\x62\x23"; - const byte additional3[] = "\x48\x13\xc4\x95\x10\x99\xdd\x7f\xd4\x77\x3c\x9b\x8a\xa4\x1c\x3d\xb0\x93\x92\x50\xba\x23\x98\xef\x4b\x1b\xd2\x53\xc1\x61\xda\xc6"; - - Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); - drbg.IncorporateEntropy(entropy2, 32, additional1, 32); - - SecByteBlock result(256); - drbg.GenerateBlock(additional2, 32, result, result.size()); - drbg.GenerateBlock(additional3, 32, result, result.size()); - - const byte expected[] = "\xE1\x7E\x4B\xEE\xD1\x65\x4F\xB2\xFC\xC8\xE8\xD7\xC6\x72\x7D\xD2\xE3\x15\x73\xC0" - "\x23\xC8\x55\x5D\x2B\xD8\x28\xD8\x31\xE4\xC9\x87\x42\x51\x87\x66\x43\x1F\x2C\xA4" - "\x73\xED\x4E\x50\x12\xC4\x50\x0E\x4C\xDD\x14\x73\xA2\xFB\xB3\x07\x0C\x66\x97\x4D" - "\x89\xDE\x35\x1C\x93\xE7\xE6\x8F\x20\x3D\x84\xE6\x73\x46\x0F\x7C\xF4\x3B\x6C\x02" - "\x23\x7C\x79\x6C\x86\xD9\x48\x80\x9C\x34\xCB\xA1\x23\xE7\xF7\x8A\x2E\x4B\x9D\x39" - "\xA5\x86\x1A\x73\x58\x28\x5A\x1D\x8D\x4A\xBD\x42\xD5\x49\x2B\xDF\x53\x1D\xE7\x4A" - "\x5F\x74\x09\x7F\xDC\x29\x7D\x58\x9C\x4B\xC5\x2F\x3B\x8F\xBF\x56\xCA\x48\x0A\x74" - "\xAE\xFF\xDD\x12\xE4\xF6\xAB\x83\x26\x4F\x52\x8A\x19\xBB\x91\x32\xA4\x42\xEC\x4F" - "\x3C\x76\xED\x9F\x03\xAA\x5E\x53\x79\x4C\xD0\x06\xD2\x1A\x42\x9D\xB1\xA7\xEC\xF7" - "\x5B\xD4\x03\x70\x1E\xF2\x47\x26\x48\xAC\x35\xEE\xD0\x58\x40\x94\x8C\x11\xD0\xEB" - "\x77\x39\x5A\xA3\xD5\xD0\xD3\xC3\x68\xE1\x75\xAA\xC0\x44\xEA\xD8\xDD\x13\x3F\xF9" - "\x7D\x21\x14\x34\xA5\x87\x43\xA4\x0A\x96\x77\x00\xCC\xCA\xB1\xDA\xC4\x39\xE0\x66" - "\x37\x05\x6E\xAC\xF2\xE6\xC6\xC5\x4F\x79\xD3\xE5\x6A\x3D\x36\x3F"; - - fail = !!std::memcmp(result, expected, 2048/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA512/256/888 (C0UNT=1, E=32, N=16, A=32, P=32)\n"; - } - - return pass; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat4.cpp b/vendor/cryptopp/validat4.cpp deleted file mode 100644 index 3ca3c13d7e..0000000000 --- a/vendor/cryptopp/validat4.cpp +++ /dev/null @@ -1,1813 +0,0 @@ -// validat4.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "hex.h" -#include "base32.h" -#include "base64.h" - -#include "rc2.h" -#include "aes.h" -#include "des.h" -#include "rc5.h" -#include "rc6.h" -#include "3way.h" -#include "aria.h" -#include "cast.h" -#include "mars.h" -#include "idea.h" -#include "gost.h" -#include "seal.h" -#include "seed.h" -#include "safer.h" -#include "shark.h" -#include "square.h" -#include "serpent.h" -#include "shacal2.h" -#include "twofish.h" -#include "blowfish.h" -#include "camellia.h" -#include "skipjack.h" - -#include "arc4.h" -#include "salsa.h" -#include "chacha.h" -#include "rabbit.h" -#include "sosemanuk.h" - -#include "modes.h" -#include "cmac.h" -#include "dmac.h" -#include "hmac.h" -#include "vmac.h" -#include "ttmac.h" - -#include "drbg.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - - -bool ValidateHmacDRBG() -{ - std::cout << "\nTesting NIST HMAC DRBGs...\n\n"; - bool pass=true, fail; - - // # CAVS 14.3 - // # DRBG800-90A information for "drbg_pr" - // # Generated on Tue Apr 02 15:32:12 2013 - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x79\x34\x9b\xbf\x7c\xdd\xa5\x79\x95\x57\x86\x66\x21\xc9\x13\x83"; - const byte entropy2[] = "\xc7\x21\x5b\x5b\x96\xc4\x8e\x9b\x33\x8c\x74\xe3\xe9\x9d\xfe\xdf"; - const byte nonce[] = "\x11\x46\x73\x3a\xbf\x8c\x35\xc8"; - - HMAC_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\xc6\xa1\x6a\xb8\xd4\x20\x70\x6f\x0f\x34\xab\x7f\xec\x5a\xdc\xa9\xd8\xca\x3a\x13" - "\x3e\x15\x9c\xa6\xac\x43\xc6\xf8\xa2\xbe\x22\x83\x4a\x4c\x0a\x0a\xff\xb1\x0d\x71" - "\x94\xf1\xc1\xa5\xcf\x73\x22\xec\x1a\xe0\x96\x4e\xd4\xbf\x12\x27\x46\xe0\x87\xfd" - "\xb5\xb3\xe9\x1b\x34\x93\xd5\xbb\x98\xfa\xed\x49\xe8\x5f\x13\x0f\xc8\xa4\x59\xb7"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=0, E=16, N=8)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\xee\x57\xfc\x23\x60\x0f\xb9\x02\x9a\x9e\xc6\xc8\x2e\x7b\x51\xe4"; - const byte entropy2[] = "\x84\x1d\x27\x6c\xa9\x51\x90\x61\xd9\x2d\x7d\xdf\xa6\x62\x8c\xa3"; - const byte nonce[] = "\x3e\x97\x21\xe4\x39\x3e\xf9\xad"; - - HMAC_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(result, result.size()); - drbg.GenerateBlock(result, result.size()); - - const byte expected[] = "\xee\x26\xa5\xc8\xef\x08\xa1\xca\x8f\x14\x15\x4d\x67\xc8\x8f\x5e\x7e\xd8\x21\x9d" - "\x93\x1b\x98\x42\xac\x00\x39\xf2\x14\x55\x39\xf2\x14\x2b\x44\x11\x7a\x99\x8c\x22" - "\xf5\x90\xf6\xc9\xb3\x8b\x46\x5b\x78\x3e\xcf\xf1\x3a\x77\x50\x20\x1f\x7e\xcf\x1b" - "\x8a\xb3\x93\x60\x4c\x73\xb2\x38\x93\x36\x60\x9a\xf3\x44\x0c\xde\x43\x29\x8b\x84"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=1, E=16, N=8)\n"; - } - - // ***************************************************** - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x7d\x70\x52\xa7\x76\xfd\x2f\xb3\xd7\x19\x1f\x73\x33\x04\xee\x8b"; - const byte entropy2[] = "\x49\x04\x7e\x87\x9d\x61\x09\x55\xee\xd9\x16\xe4\x06\x0e\x00\xc9"; - const byte nonce[] = "\xbe\x4a\x0c\xee\xdc\xa8\x02\x07"; - const byte additional1[] = "\xfd\x8b\xb3\x3a\xab\x2f\x6c\xdf\xbc\x54\x18\x11\x86\x1d\x51\x8d"; - const byte additional2[] = "\x99\xaf\xe3\x47\x54\x04\x61\xdd\xf6\xab\xeb\x49\x1e\x07\x15\xb4"; - const byte additional3[] = "\x02\xf7\x73\x48\x2d\xd7\xae\x66\xf7\x6e\x38\x15\x98\xa6\x4e\xf0"; - - HMAC_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\xa7\x36\x34\x38\x44\xfc\x92\x51\x13\x91\xdb\x0a\xdd\xd9\x06\x4d\xbe\xe2\x4c\x89" - "\x76\xaa\x25\x9a\x9e\x3b\x63\x68\xaa\x6d\xe4\xc9\xbf\x3a\x0e\xff\xcd\xa9\xcb\x0e" - "\x9d\xc3\x36\x52\xab\x58\xec\xb7\x65\x0e\xd8\x04\x67\xf7\x6a\x84\x9f\xb1\xcf\xc1" - "\xed\x0a\x09\xf7\x15\x50\x86\x06\x4d\xb3\x24\xb1\xe1\x24\xf3\xfc\x9e\x61\x4f\xcb"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=0, E=16, N=8, A=16)\n"; - } - - { - // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] - // [PersonalizationStringLen = 0], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x29\xc6\x2a\xfa\x3c\x52\x20\x8a\x3f\xde\xcb\x43\xfa\x61\x3f\x15"; - const byte entropy2[] = "\xbd\x87\xbe\x99\xd1\x84\x16\x54\x12\x31\x41\x40\xd4\x02\x71\x41"; - const byte nonce[] = "\x6c\x9e\xb5\x9a\xc3\xc2\xd4\x8b"; - const byte additional1[] = "\x43\x3d\xda\xf2\x59\xd1\x4b\xcf\x89\x76\x30\xcc\xaa\x27\x33\x8c"; - const byte additional2[] = "\x14\x11\x46\xd4\x04\xf2\x84\xc2\xd0\x2b\x6a\x10\x15\x6e\x33\x82"; - const byte additional3[] = "\xed\xc3\x43\xdb\xff\xe7\x1a\xb4\x11\x4a\xc3\x63\x9d\x44\x5b\x65"; - - HMAC_DRBG drbg(entropy1, 16, nonce, 8); - drbg.IncorporateEntropy(entropy2, 16, additional1, 16); - - SecByteBlock result(80); - drbg.GenerateBlock(additional2, 16, result, result.size()); - drbg.GenerateBlock(additional3, 16, result, result.size()); - - const byte expected[] = "\x8c\x73\x0f\x05\x26\x69\x4d\x5a\x9a\x45\xdb\xab\x05\x7a\x19\x75\x35\x7d\x65\xaf" - "\xd3\xef\xf3\x03\x32\x0b\xd1\x40\x61\xf9\xad\x38\x75\x91\x02\xb6\xc6\x01\x16\xf6" - "\xdb\x7a\x6e\x8e\x7a\xb9\x4c\x05\x50\x0b\x4d\x1e\x35\x7d\xf8\xe9\x57\xac\x89\x37" - "\xb0\x5f\xb3\xd0\x80\xa0\xf9\x06\x74\xd4\x4d\xe1\xbd\x6f\x94\xd2\x95\xc4\x51\x9d"; - - fail = !!std::memcmp(result, expected, 640/8); - pass = !fail && pass; - - std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=1, E=16, N=8, A=16)\n"; - } - - return pass; -} - -class CipherFactory -{ -public: - virtual unsigned int BlockSize() const =0; - virtual unsigned int KeyLength() const =0; - - virtual BlockTransformation* NewEncryption(const byte *keyStr) const =0; - virtual BlockTransformation* NewDecryption(const byte *keyStr) const =0; -}; - -template class FixedRoundsCipherFactory : public CipherFactory -{ -public: - FixedRoundsCipherFactory(unsigned int keylen=0) : - m_keylen(keylen ? keylen : static_cast(E::DEFAULT_KEYLENGTH)) {} - - unsigned int BlockSize() const {return E::BLOCKSIZE;} - unsigned int KeyLength() const {return m_keylen;} - - BlockTransformation* NewEncryption(const byte *keyStr) const - {return new E(keyStr, m_keylen);} - BlockTransformation* NewDecryption(const byte *keyStr) const - {return new D(keyStr, m_keylen);} - - unsigned int m_keylen; -}; - -template class VariableRoundsCipherFactory : public CipherFactory -{ -public: - VariableRoundsCipherFactory(unsigned int keylen=0, unsigned int rounds=0) : - m_keylen(keylen ? keylen : static_cast(E::DEFAULT_KEYLENGTH)), - m_rounds(rounds ? rounds : static_cast(E::DEFAULT_ROUNDS)) {} - - unsigned int BlockSize() const {return static_cast(E::BLOCKSIZE);} - unsigned int KeyLength() const {return m_keylen;} - - BlockTransformation* NewEncryption(const byte *keyStr) const - {return new E(keyStr, m_keylen, m_rounds);} - BlockTransformation* NewDecryption(const byte *keyStr) const - {return new D(keyStr, m_keylen, m_rounds);} - - unsigned int m_keylen, m_rounds; -}; - -bool BlockTransformationTest(const CipherFactory &cg, BufferedTransformation &valdata, unsigned int tuples = 0xffff) -{ - HexEncoder output(new FileSink(std::cout)); - SecByteBlock plain(cg.BlockSize()), cipher(cg.BlockSize()), out(cg.BlockSize()), outplain(cg.BlockSize()); - SecByteBlock key(cg.KeyLength()); - bool pass=true, fail; - - while (valdata.MaxRetrievable() && tuples--) - { - (void)valdata.Get(key, cg.KeyLength()); - (void)valdata.Get(plain, cg.BlockSize()); - (void)valdata.Get(cipher, cg.BlockSize()); - - member_ptr transE(cg.NewEncryption(key)); - transE->ProcessBlock(plain, out); - fail = std::memcmp(out, cipher, cg.BlockSize()) != 0; - - member_ptr transD(cg.NewDecryption(key)); - transD->ProcessBlock(out, outplain); - fail=fail || std::memcmp(outplain, plain, cg.BlockSize()); - - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - output.Put(key, cg.KeyLength()); - std::cout << " "; - output.Put(outplain, cg.BlockSize()); - std::cout << " "; - output.Put(out, cg.BlockSize()); - std::cout << std::endl; - } - return pass; -} - -class FilterTester : public Unflushable -{ -public: - FilterTester(const byte *validOutput, size_t outputLen) - : validOutput(validOutput), outputLen(outputLen), counter(0), fail(false) {} - void PutByte(byte inByte) - { - if (counter >= outputLen || validOutput[counter] != inByte) - { - std::cerr << "incorrect output " << counter << ", " << (word16)validOutput[counter] << ", " << (word16)inByte << "\n"; - fail = true; - CRYPTOPP_ASSERT(false); - } - counter++; - } - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) - { - CRYPTOPP_UNUSED(messageEnd), CRYPTOPP_UNUSED(blocking); - - while (length--) - FilterTester::PutByte(*inString++); - - if (messageEnd) - if (counter != outputLen) - { - fail = true; - CRYPTOPP_ASSERT(false); - } - - return 0; - } - bool GetResult() - { - return !fail; - } - - const byte *validOutput; - size_t outputLen, counter; - bool fail; -}; - -bool TestFilter(BufferedTransformation &bt, const byte *in, size_t inLen, const byte *out, size_t outLen) -{ - FilterTester *ft; - bt.Attach(ft = new FilterTester(out, outLen)); - - while (inLen) - { - size_t randomLen = GlobalRNG().GenerateWord32(0, (word32)inLen); - bt.Put(in, randomLen); - in += randomLen; - inLen -= randomLen; - } - bt.MessageEnd(); - return ft->GetResult(); -} - -bool ValidateDES() -{ - std::cout << "\nDES validation suite running...\n\n"; - - FileSource valdata(DataDir("TestData/descert.dat").c_str(), true, new HexDecoder); - bool pass = BlockTransformationTest(FixedRoundsCipherFactory(), valdata); - - std::cout << "\nTesting EDE2, EDE3, and XEX3 variants...\n\n"; - - FileSource valdata1(DataDir("TestData/3desval.dat").c_str(), true, new HexDecoder); - pass = BlockTransformationTest(FixedRoundsCipherFactory(), valdata1, 1) && pass; - pass = BlockTransformationTest(FixedRoundsCipherFactory(), valdata1, 1) && pass; - pass = BlockTransformationTest(FixedRoundsCipherFactory(), valdata1, 1) && pass; - - return pass; -} - -bool TestModeIV(SymmetricCipher &e, SymmetricCipher &d) -{ - SecByteBlock lastIV, iv(e.IVSize()); - StreamTransformationFilter filter(e, new StreamTransformationFilter(d)); - - // Enterprise Analysis finding on the stack based array - const int BUF_SIZE=20480U; - AlignedSecByteBlock plaintext(BUF_SIZE); - - for (unsigned int i=1; i cbcmac(key); - HashFilter cbcmacFilter(cbcmac); - fail = !TestFilter(cbcmacFilter, plain_3, sizeof(plain_3), mac1, sizeof(mac1)); - pass = pass && !fail; - std::cout << (fail ? "FAILED " : "passed ") << "CBC MAC" << std::endl; - - DMAC dmac(key); - HashFilter dmacFilter(dmac); - fail = !TestFilter(dmacFilter, plain_3, sizeof(plain_3), mac2, sizeof(mac2)); - pass = pass && !fail; - std::cout << (fail ? "FAILED " : "passed ") << "DMAC" << std::endl; - } - - return pass; -} - -bool ValidateIDEA() -{ - std::cout << "\nIDEA validation suite running...\n\n"; - - FileSource valdata(DataDir("TestData/ideaval.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata); -} - -bool ValidateSAFER() -{ - std::cout << "\nSAFER validation suite running...\n\n"; - - FileSource valdata(DataDir("TestData/saferval.dat").c_str(), true, new HexDecoder); - bool pass = true; - pass = BlockTransformationTest(VariableRoundsCipherFactory(8,6), valdata, 4) && pass; - pass = BlockTransformationTest(VariableRoundsCipherFactory(16,12), valdata, 4) && pass; - pass = BlockTransformationTest(VariableRoundsCipherFactory(8,6), valdata, 4) && pass; - pass = BlockTransformationTest(VariableRoundsCipherFactory(16,10), valdata, 4) && pass; - return pass; -} - -bool ValidateRC2() -{ - std::cout << "\nRC2 validation suite running...\n\n"; - - FileSource valdata(DataDir("TestData/rc2val.dat").c_str(), true, new HexDecoder); - HexEncoder output(new FileSink(std::cout)); - SecByteBlock plain(RC2Encryption::BLOCKSIZE), cipher(RC2Encryption::BLOCKSIZE), out(RC2Encryption::BLOCKSIZE), outplain(RC2Encryption::BLOCKSIZE); - SecByteBlock key(128); - bool pass=true, fail; - - while (valdata.MaxRetrievable()) - { - byte keyLen, effectiveLen; - - (void)valdata.Get(keyLen); - (void)valdata.Get(effectiveLen); - (void)valdata.Get(key, keyLen); - (void)valdata.Get(plain, RC2Encryption::BLOCKSIZE); - (void)valdata.Get(cipher, RC2Encryption::BLOCKSIZE); - - member_ptr transE(new RC2Encryption(key, keyLen, effectiveLen)); - transE->ProcessBlock(plain, out); - fail = std::memcmp(out, cipher, RC2Encryption::BLOCKSIZE) != 0; - - member_ptr transD(new RC2Decryption(key, keyLen, effectiveLen)); - transD->ProcessBlock(out, outplain); - fail=fail || std::memcmp(outplain, plain, RC2Encryption::BLOCKSIZE); - - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - output.Put(key, keyLen); - std::cout << " "; - output.Put(outplain, RC2Encryption::BLOCKSIZE); - std::cout << " "; - output.Put(out, RC2Encryption::BLOCKSIZE); - std::cout << std::endl; - } - return pass; -} - -bool ValidateARC4() -{ - unsigned char Key0[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef }; - unsigned char Input0[]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; - unsigned char Output0[] = {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96}; - - unsigned char Key1[]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; - unsigned char Input1[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - unsigned char Output1[]={0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79}; - - unsigned char Key2[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - unsigned char Input2[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - unsigned char Output2[]={0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a}; - - unsigned char Key3[]={0xef,0x01,0x23,0x45}; - unsigned char Input3[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - unsigned char Output3[]={0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61}; - - unsigned char Key4[]={ 0x01,0x23,0x45,0x67,0x89,0xab, 0xcd,0xef }; - unsigned char Input4[] = - {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, - 0x01}; - unsigned char Output4[]= { - 0x75,0x95,0xc3,0xe6,0x11,0x4a,0x09,0x78,0x0c,0x4a,0xd4, - 0x52,0x33,0x8e,0x1f,0xfd,0x9a,0x1b,0xe9,0x49,0x8f, - 0x81,0x3d,0x76,0x53,0x34,0x49,0xb6,0x77,0x8d,0xca, - 0xd8,0xc7,0x8a,0x8d,0x2b,0xa9,0xac,0x66,0x08,0x5d, - 0x0e,0x53,0xd5,0x9c,0x26,0xc2,0xd1,0xc4,0x90,0xc1, - 0xeb,0xbe,0x0c,0xe6,0x6d,0x1b,0x6b,0x1b,0x13,0xb6, - 0xb9,0x19,0xb8,0x47,0xc2,0x5a,0x91,0x44,0x7a,0x95, - 0xe7,0x5e,0x4e,0xf1,0x67,0x79,0xcd,0xe8,0xbf,0x0a, - 0x95,0x85,0x0e,0x32,0xaf,0x96,0x89,0x44,0x4f,0xd3, - 0x77,0x10,0x8f,0x98,0xfd,0xcb,0xd4,0xe7,0x26,0x56, - 0x75,0x00,0x99,0x0b,0xcc,0x7e,0x0c,0xa3,0xc4,0xaa, - 0xa3,0x04,0xa3,0x87,0xd2,0x0f,0x3b,0x8f,0xbb,0xcd, - 0x42,0xa1,0xbd,0x31,0x1d,0x7a,0x43,0x03,0xdd,0xa5, - 0xab,0x07,0x88,0x96,0xae,0x80,0xc1,0x8b,0x0a,0xf6, - 0x6d,0xff,0x31,0x96,0x16,0xeb,0x78,0x4e,0x49,0x5a, - 0xd2,0xce,0x90,0xd7,0xf7,0x72,0xa8,0x17,0x47,0xb6, - 0x5f,0x62,0x09,0x3b,0x1e,0x0d,0xb9,0xe5,0xba,0x53, - 0x2f,0xaf,0xec,0x47,0x50,0x83,0x23,0xe6,0x71,0x32, - 0x7d,0xf9,0x44,0x44,0x32,0xcb,0x73,0x67,0xce,0xc8, - 0x2f,0x5d,0x44,0xc0,0xd0,0x0b,0x67,0xd6,0x50,0xa0, - 0x75,0xcd,0x4b,0x70,0xde,0xdd,0x77,0xeb,0x9b,0x10, - 0x23,0x1b,0x6b,0x5b,0x74,0x13,0x47,0x39,0x6d,0x62, - 0x89,0x74,0x21,0xd4,0x3d,0xf9,0xb4,0x2e,0x44,0x6e, - 0x35,0x8e,0x9c,0x11,0xa9,0xb2,0x18,0x4e,0xcb,0xef, - 0x0c,0xd8,0xe7,0xa8,0x77,0xef,0x96,0x8f,0x13,0x90, - 0xec,0x9b,0x3d,0x35,0xa5,0x58,0x5c,0xb0,0x09,0x29, - 0x0e,0x2f,0xcd,0xe7,0xb5,0xec,0x66,0xd9,0x08,0x4b, - 0xe4,0x40,0x55,0xa6,0x19,0xd9,0xdd,0x7f,0xc3,0x16, - 0x6f,0x94,0x87,0xf7,0xcb,0x27,0x29,0x12,0x42,0x64, - 0x45,0x99,0x85,0x14,0xc1,0x5d,0x53,0xa1,0x8c,0x86, - 0x4c,0xe3,0xa2,0xb7,0x55,0x57,0x93,0x98,0x81,0x26, - 0x52,0x0e,0xac,0xf2,0xe3,0x06,0x6e,0x23,0x0c,0x91, - 0xbe,0xe4,0xdd,0x53,0x04,0xf5,0xfd,0x04,0x05,0xb3, - 0x5b,0xd9,0x9c,0x73,0x13,0x5d,0x3d,0x9b,0xc3,0x35, - 0xee,0x04,0x9e,0xf6,0x9b,0x38,0x67,0xbf,0x2d,0x7b, - 0xd1,0xea,0xa5,0x95,0xd8,0xbf,0xc0,0x06,0x6f,0xf8, - 0xd3,0x15,0x09,0xeb,0x0c,0x6c,0xaa,0x00,0x6c,0x80, - 0x7a,0x62,0x3e,0xf8,0x4c,0x3d,0x33,0xc1,0x95,0xd2, - 0x3e,0xe3,0x20,0xc4,0x0d,0xe0,0x55,0x81,0x57,0xc8, - 0x22,0xd4,0xb8,0xc5,0x69,0xd8,0x49,0xae,0xd5,0x9d, - 0x4e,0x0f,0xd7,0xf3,0x79,0x58,0x6b,0x4b,0x7f,0xf6, - 0x84,0xed,0x6a,0x18,0x9f,0x74,0x86,0xd4,0x9b,0x9c, - 0x4b,0xad,0x9b,0xa2,0x4b,0x96,0xab,0xf9,0x24,0x37, - 0x2c,0x8a,0x8f,0xff,0xb1,0x0d,0x55,0x35,0x49,0x00, - 0xa7,0x7a,0x3d,0xb5,0xf2,0x05,0xe1,0xb9,0x9f,0xcd, - 0x86,0x60,0x86,0x3a,0x15,0x9a,0xd4,0xab,0xe4,0x0f, - 0xa4,0x89,0x34,0x16,0x3d,0xdd,0xe5,0x42,0xa6,0x58, - 0x55,0x40,0xfd,0x68,0x3c,0xbf,0xd8,0xc0,0x0f,0x12, - 0x12,0x9a,0x28,0x4d,0xea,0xcc,0x4c,0xde,0xfe,0x58, - 0xbe,0x71,0x37,0x54,0x1c,0x04,0x71,0x26,0xc8,0xd4, - 0x9e,0x27,0x55,0xab,0x18,0x1a,0xb7,0xe9,0x40,0xb0, - 0xc0}; - - member_ptr arc4; - bool pass=true, fail; - unsigned int i; - - std::cout << "\nARC4 validation suite running...\n\n"; - - arc4.reset(new Weak::ARC4(Key0, sizeof(Key0))); - arc4->ProcessString(Input0, sizeof(Input0)); - fail = std::memcmp(Input0, Output0, sizeof(Input0)) != 0; - std::cout << (fail ? "FAILED" : "passed") << " Test 0" << std::endl; - pass = pass && !fail; - - arc4.reset(new Weak::ARC4(Key1, sizeof(Key1))); - arc4->ProcessString(Key1, Input1, sizeof(Key1)); - fail = std::memcmp(Output1, Key1, sizeof(Key1)) != 0; - std::cout << (fail ? "FAILED" : "passed") << " Test 1" << std::endl; - pass = pass && !fail; - - arc4.reset(new Weak::ARC4(Key2, sizeof(Key2))); - for (i=0, fail=false; iProcessByte(Input2[i]) != Output2[i]) - fail = true; - std::cout << (fail ? "FAILED" : "passed") << " Test 2" << std::endl; - pass = pass && !fail; - - arc4.reset(new Weak::ARC4(Key3, sizeof(Key3))); - for (i=0, fail=false; iProcessByte(Input3[i]) != Output3[i]) - fail = true; - std::cout << (fail ? "FAILED" : "passed") << " Test 3" << std::endl; - pass = pass && !fail; - - arc4.reset(new Weak::ARC4(Key4, sizeof(Key4))); - for (i=0, fail=false; iProcessByte(Input4[i]) != Output4[i]) - fail = true; - std::cout << (fail ? "FAILED" : "passed") << " Test 4" << std::endl; - pass = pass && !fail; - - return pass; -} - -bool ValidateRC5() -{ - std::cout << "\nRC5 validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - RC5Encryption enc; // 0 to 2040-bits (255-bytes) - pass1 = RC5Encryption::DEFAULT_KEYLENGTH == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == 0 && pass1; - pass1 = enc.StaticGetValidKeyLength(254) == 254 && pass1; - pass1 = enc.StaticGetValidKeyLength(255) == 255 && pass1; - pass1 = enc.StaticGetValidKeyLength(256) == 255 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - RC5Decryption dec; - pass2 = RC5Decryption::DEFAULT_KEYLENGTH == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == 0 && pass2; - pass2 = dec.StaticGetValidKeyLength(254) == 254 && pass2; - pass2 = dec.StaticGetValidKeyLength(255) == 255 && pass2; - pass2 = dec.StaticGetValidKeyLength(256) == 255 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/rc5val.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(VariableRoundsCipherFactory(16, 12), valdata) && pass1 && pass2; -} - -bool ValidateRC6() -{ - std::cout << "\nRC6 validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - RC6Encryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - RC6Decryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/rc6val.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 2) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 2) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 2) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateMARS() -{ - std::cout << "\nMARS validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - MARSEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 56 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 56 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - MARSDecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 56 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 56 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/marsval.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 4) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 3) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 2) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateRijndael() -{ - std::cout << "\nRijndael (AES) validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - RijndaelEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - RijndaelDecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/rijndael.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 4) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 3) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 2) && pass3; - pass3 = RunTestDataFile("TestVectors/aes.txt") && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateTwofish() -{ - std::cout << "\nTwofish validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - TwofishEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - - TwofishDecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/twofishv.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 4) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 3) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 2) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateSerpent() -{ - std::cout << "\nSerpent validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - SerpentEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - - SerpentDecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/serpentv.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 5) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 4) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 3) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateBlowfish() -{ - std::cout << "\nBlowfish validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true, fail; - - BlowfishEncryption enc1; // 32 to 448-bits (4 to 56-bytes) - pass1 = enc1.StaticGetValidKeyLength(3) == 4 && pass1; - pass1 = enc1.StaticGetValidKeyLength(4) == 4 && pass1; - pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1; - pass1 = enc1.StaticGetValidKeyLength(8) == 8 && pass1; - pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc1.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc1.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc1.StaticGetValidKeyLength(56) == 56 && pass1; - pass1 = enc1.StaticGetValidKeyLength(57) == 56 && pass1; - pass1 = enc1.StaticGetValidKeyLength(60) == 56 && pass1; - pass1 = enc1.StaticGetValidKeyLength(64) == 56 && pass1; - pass1 = enc1.StaticGetValidKeyLength(128) == 56 && pass1; - - BlowfishDecryption dec1; // 32 to 448-bits (4 to 56-bytes) - pass2 = dec1.StaticGetValidKeyLength(3) == 4 && pass2; - pass2 = dec1.StaticGetValidKeyLength(4) == 4 && pass2; - pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2; - pass2 = dec1.StaticGetValidKeyLength(8) == 8 && pass2; - pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec1.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec1.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec1.StaticGetValidKeyLength(56) == 56 && pass2; - pass2 = dec1.StaticGetValidKeyLength(57) == 56 && pass2; - pass2 = dec1.StaticGetValidKeyLength(60) == 56 && pass2; - pass2 = dec1.StaticGetValidKeyLength(64) == 56 && pass2; - pass2 = dec1.StaticGetValidKeyLength(128) == 56 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - HexEncoder output(new FileSink(std::cout)); - const char *key[]={"abcdefghijklmnopqrstuvwxyz", "Who is John Galt?"}; - byte *plain[]={(byte *)"BLOWFISH", (byte *)"\xfe\xdc\xba\x98\x76\x54\x32\x10"}; - byte *cipher[]={(byte *)"\x32\x4e\xd0\xfe\xf4\x13\xa2\x03", (byte *)"\xcc\x91\x73\x2b\x80\x22\xf6\x84"}; - byte out[8], outplain[8]; - - for (int i=0; i<2; i++) - { - ECB_Mode::Encryption enc2((byte *)key[i], strlen(key[i])); - enc2.ProcessData(out, plain[i], 8); - fail = std::memcmp(out, cipher[i], 8) != 0; - - ECB_Mode::Decryption dec2((byte *)key[i], strlen(key[i])); - dec2.ProcessData(outplain, cipher[i], 8); - fail = fail || std::memcmp(outplain, plain[i], 8); - pass3 = pass3 && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << '\"' << key[i] << '\"'; - for (int j=0; j<(signed int)(30-strlen(key[i])); j++) - std::cout << ' '; - output.Put(outplain, 8); - std::cout << " "; - output.Put(out, 8); - std::cout << std::endl; - } - return pass1 && pass2 && pass3; -} - -bool ValidateThreeWay() -{ - std::cout << "\n3-WAY validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - ThreeWayEncryption enc; // 96-bit only - pass1 = ThreeWayEncryption::KEYLENGTH == 12 && pass1; - pass1 = enc.StaticGetValidKeyLength(8) == 12 && pass1; - pass1 = enc.StaticGetValidKeyLength(12) == 12 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 12 && pass1; - - ThreeWayDecryption dec; // 96-bit only - pass2 = ThreeWayDecryption::KEYLENGTH == 12 && pass2; - pass2 = dec.StaticGetValidKeyLength(8) == 12 && pass2; - pass2 = dec.StaticGetValidKeyLength(12) == 12 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 12 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/3wayval.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata) && pass1 && pass2; -} - -bool ValidateGOST() -{ - std::cout << "\nGOST validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - GOSTEncryption enc; // 256-bit only - pass1 = GOSTEncryption::KEYLENGTH == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(40) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - - GOSTDecryption dec; // 256-bit only - pass2 = GOSTDecryption::KEYLENGTH == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(40) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/gostval.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata) && pass1 && pass2; -} - -bool ValidateSHARK() -{ - std::cout << "\nSHARK validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - SHARKEncryption enc; // 128-bit only - pass1 = SHARKEncryption::KEYLENGTH == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 16 && pass1; - - SHARKDecryption dec; // 128-bit only - pass2 = SHARKDecryption::KEYLENGTH == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 16 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/sharkval.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata) && pass1 && pass2; -} - -bool ValidateCAST() -{ - std::cout << "\nCAST-128 validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - CAST128Encryption enc1; // 40 to 128-bits (5 to 16-bytes) - pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1; - pass1 = enc1.StaticGetValidKeyLength(4) == 5 && pass1; - pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1; - pass1 = enc1.StaticGetValidKeyLength(15) == 15 && pass1; - pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc1.StaticGetValidKeyLength(17) == 16 && pass1; - - CAST128Decryption dec1; // 40 to 128-bits (5 to 16-bytes) - pass2 = CAST128Decryption::DEFAULT_KEYLENGTH == 16 && pass2; - pass2 = dec1.StaticGetValidKeyLength(4) == 5 && pass2; - pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2; - pass2 = dec1.StaticGetValidKeyLength(15) == 15 && pass2; - pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec1.StaticGetValidKeyLength(17) == 16 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource val128(DataDir("TestData/cast128v.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), val128, 1) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(10), val128, 1) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(5), val128, 1) && pass3; - - std::cout << "\nCAST-256 validation suite running...\n\n"; - bool pass4 = true, pass5 = true, pass6 = true; - - CAST256Encryption enc2; // 128, 160, 192, 224, or 256-bits (16 to 32-bytes, step 4) - pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1; - pass4 = enc2.StaticGetValidKeyLength(15) == 16 && pass4; - pass4 = enc2.StaticGetValidKeyLength(16) == 16 && pass4; - pass4 = enc2.StaticGetValidKeyLength(17) == 20 && pass4; - pass4 = enc2.StaticGetValidKeyLength(20) == 20 && pass4; - pass4 = enc2.StaticGetValidKeyLength(24) == 24 && pass4; - pass4 = enc2.StaticGetValidKeyLength(28) == 28 && pass4; - pass4 = enc2.StaticGetValidKeyLength(31) == 32 && pass4; - pass4 = enc2.StaticGetValidKeyLength(32) == 32 && pass4; - pass4 = enc2.StaticGetValidKeyLength(33) == 32 && pass4; - - CAST256Decryption dec2; // 128, 160, 192, 224, or 256-bits (16 to 32-bytes, step 4) - pass2 = CAST256Decryption::DEFAULT_KEYLENGTH == 16 && pass2; - pass5 = dec2.StaticGetValidKeyLength(15) == 16 && pass5; - pass5 = dec2.StaticGetValidKeyLength(16) == 16 && pass5; - pass5 = dec2.StaticGetValidKeyLength(17) == 20 && pass5; - pass5 = dec2.StaticGetValidKeyLength(20) == 20 && pass5; - pass5 = dec2.StaticGetValidKeyLength(24) == 24 && pass5; - pass5 = dec2.StaticGetValidKeyLength(28) == 28 && pass5; - pass5 = dec2.StaticGetValidKeyLength(31) == 32 && pass5; - pass5 = dec2.StaticGetValidKeyLength(32) == 32 && pass5; - pass5 = dec2.StaticGetValidKeyLength(33) == 32 && pass5; - std::cout << (pass4 && pass5 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource val256(DataDir("TestData/cast256v.dat").c_str(), true, new HexDecoder); - pass6 = BlockTransformationTest(FixedRoundsCipherFactory(16), val256, 1) && pass6; - pass6 = BlockTransformationTest(FixedRoundsCipherFactory(24), val256, 1) && pass6; - pass6 = BlockTransformationTest(FixedRoundsCipherFactory(32), val256, 1) && pass6; - - return pass1 && pass2 && pass3 && pass4 && pass5 && pass6; -} - -bool ValidateSquare() -{ - std::cout << "\nSquare validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - SquareEncryption enc; // 128-bits only - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1; - - SquareDecryption dec; // 128-bits only - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/squareva.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata) && pass1 && pass2; -} - -bool ValidateSKIPJACK() -{ - std::cout << "\nSKIPJACK validation suite running...\n\n"; - bool pass1 = true, pass2 = true; - - SKIPJACKEncryption enc; // 80-bits only - pass1 = enc.StaticGetValidKeyLength(8) == 10 && pass1; - pass1 = enc.StaticGetValidKeyLength(9) == 10 && pass1; - pass1 = enc.StaticGetValidKeyLength(10) == 10 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 10 && pass1; - - SKIPJACKDecryption dec; // 80-bits only - pass2 = dec.StaticGetValidKeyLength(8) == 10 && pass2; - pass2 = dec.StaticGetValidKeyLength(9) == 10 && pass2; - pass2 = dec.StaticGetValidKeyLength(10) == 10 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 10 && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/skipjack.dat").c_str(), true, new HexDecoder); - return BlockTransformationTest(FixedRoundsCipherFactory(), valdata) && pass1 && pass2; -} - -bool ValidateSEAL() -{ - const byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c}; - const byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0}; - const byte iv[] = {0x01, 0x35, 0x77, 0xaf}; - byte output[32]; - - std::cout << "\nSEAL validation suite running...\n\n"; - - SEAL<>::Encryption seal(key, sizeof(key), iv); - unsigned int size = sizeof(input); - bool pass = true; - - std::memset(output, 1, size); - seal.ProcessString(output, input, size); - for (unsigned int i=0; iInitialize(CombinedNameValuePairs( - parameters, - MakeParameters(Name::EncodingLookupArray(), (const byte *)&stars[0], false) - (Name::PaddingByte(), padding) - (Name::GroupSize(), insertLineBreaks ? maxLineLength : 0) - (Name::Separator(), ConstByteArrayParameter(lineBreak)) - (Name::Terminator(), ConstByteArrayParameter(lineBreak)) - (Name::Log2Base(), 6, true))); -} - -class MyDecoder : public BaseN_Decoder -{ -public: - MyDecoder(BufferedTransformation *attachment = NULLPTR); - void IsolatedInitialize(const NameValuePairs ¶ms); - static const int * CRYPTOPP_API GetDecodingLookupArray(); -}; - -MyDecoder::MyDecoder(BufferedTransformation *attachment) - : BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) -{ -} - -void MyDecoder::IsolatedInitialize(const NameValuePairs ¶meters) -{ - BaseN_Decoder::IsolatedInitialize(CombinedNameValuePairs( - parameters, - MakeParameters(Name::DecodingLookupArray(), GetDecodingLookupArray(), false)(Name::Log2Base(), 6, true))); -} - -struct MyDecoderAlphabet -{ - MyDecoderAlphabet() { - std::fill(tab, tab+COUNTOF(tab), '*'); - } - byte tab[64]; -}; - -struct MyDecoderArray -{ - MyDecoderArray() { - std::fill(tab, tab+COUNTOF(tab), -1); - } - int tab[256]; -}; - -const int * MyDecoder::GetDecodingLookupArray() -{ - static bool s_initialized = false; - static MyDecoderAlphabet s_alpha; - static MyDecoderArray s_array; - - MEMORY_BARRIER(); - if (!s_initialized) - { - InitializeDecodingLookupArray(s_array.tab, s_alpha.tab, COUNTOF(s_alpha.tab), false); - s_initialized = true; - MEMORY_BARRIER(); - } - return s_array.tab; -} - -bool ValidateEncoder() -{ - // The default encoder and decoder alphabet are bogus. They are a - // string of '*'. To round trip a string both IsolatedInitialize - // must be called and work correctly. - std::cout << "\nCustom encoder validation running...\n\n"; - bool pass = true; - - int lookup[256]; - const char alphabet[64+1] = - "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz01234576789*"; - const char expected[] = - "ILcBMSgriDicmKmTi2oENCsuJTufN0yWjL1HnS8xKdaiOkeZK3gKock1ktmlo1q4LlsNPrAyGrG0gjO2gzQ5FQ=="; - - MyEncoder encoder; - std::string str1; - - AlgorithmParameters eparams = MakeParameters(Name::EncodingLookupArray(),(const byte*)alphabet) - (Name::InsertLineBreaks(), false); - encoder.IsolatedInitialize(eparams); - - encoder.Detach(new StringSink(str1)); - encoder.Put((const byte*) alphabet, 64); - encoder.MessageEnd(); - - MyDecoder decoder; - std::string str2; - - MyDecoder::InitializeDecodingLookupArray(lookup, (const byte*) alphabet, 64, false); - AlgorithmParameters dparams = MakeParameters(Name::DecodingLookupArray(),(const int*)lookup); - decoder.IsolatedInitialize(dparams); - - decoder.Detach(new StringSink(str2)); - decoder.Put(ConstBytePtr(str1), BytePtrSize(str1)); - decoder.MessageEnd(); - - pass = (str1 == std::string(expected)) && pass; - pass = (str2 == std::string(alphabet, 64)) && pass; - - std::cout << (pass ? "passed:" : "FAILED:"); - std::cout << " Encode and decode\n"; - - // Try forcing an empty message. This is the Monero bug - // at https://github.com/weidai11/cryptopp/issues/562. - { - MyDecoder decoder2; - SecByteBlock empty; - - AlgorithmParameters dparams2 = MakeParameters(Name::DecodingLookupArray(),(const int*)lookup); - decoder2.IsolatedInitialize(dparams2); - - decoder2.Detach(new Redirector(TheBitBucket())); - decoder2.Put(empty.BytePtr(), empty.SizeInBytes()); - decoder2.MessageEnd(); - - // Tame the optimizer - volatile lword size = decoder2.MaxRetrievable(); - lword shadow = size; - CRYPTOPP_UNUSED(shadow); - } - - std::cout << "passed: 0-length message\n"; - - return pass; -} - -bool ValidateSHACAL2() -{ - std::cout << "\nSHACAL-2 validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - SHACAL2Encryption enc; // 128 to 512-bits (16 to 64-bytes) - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 64 && pass1; - pass1 = enc.StaticGetValidKeyLength(65) == 64 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 64 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - SHACAL2Decryption dec; // 128 to 512-bits (16 to 64-bytes) - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 64 && pass2; - pass2 = dec.StaticGetValidKeyLength(65) == 64 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 64 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/shacal2v.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 4) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(64), valdata, 10) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateARIA() -{ - std::cout << "\nARIA validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - ARIAEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - ARIADecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/aria.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 15) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 15) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 15) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateSIMECK() -{ - std::cout << "\nSIMECK validation suite running...\n"; - - return RunTestDataFile("TestVectors/simeck.txt"); -} - -bool ValidateCHAM() -{ - std::cout << "\nCHAM validation suite running...\n"; - - return RunTestDataFile("TestVectors/cham.txt"); -} - -bool ValidateHIGHT() -{ - std::cout << "\nHIGHT validation suite running...\n"; - - return RunTestDataFile("TestVectors/hight.txt"); -} - -bool ValidateLEA() -{ - std::cout << "\nLEA validation suite running...\n"; - - return RunTestDataFile("TestVectors/lea.txt"); -} - -bool ValidateSIMON() -{ - std::cout << "\nSIMON validation suite running...\n"; - - return RunTestDataFile("TestVectors/simon.txt"); -} - -bool ValidateSPECK() -{ - std::cout << "\nSPECK validation suite running...\n"; - - return RunTestDataFile("TestVectors/speck.txt"); -} - -bool ValidateCamellia() -{ - std::cout << "\nCamellia validation suite running...\n\n"; - bool pass1 = true, pass2 = true, pass3 = true; - - CamelliaEncryption enc; - pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1; - pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1; - pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1; - pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1; - pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1; - - CamelliaDecryption dec; - pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2; - pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2; - pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2; - pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2; - pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2; - std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n"; - - FileSource valdata(DataDir("TestData/camellia.dat").c_str(), true, new HexDecoder); - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(16), valdata, 15) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(24), valdata, 15) && pass3; - pass3 = BlockTransformationTest(FixedRoundsCipherFactory(32), valdata, 15) && pass3; - return pass1 && pass2 && pass3; -} - -bool ValidateSalsa() -{ - std::cout << "\nSalsa validation suite running...\n"; - - return RunTestDataFile("TestVectors/salsa.txt"); -} - -bool ValidateChaCha() -{ - std::cout << "\nChaCha validation suite running...\n"; - - return RunTestDataFile("TestVectors/chacha.txt"); -} - -bool ValidateChaChaTLS() -{ - std::cout << "\nChaCha-TLS validation suite running...\n"; - - return RunTestDataFile("TestVectors/chacha_tls.txt"); -} - -bool ValidateSosemanuk() -{ - std::cout << "\nSosemanuk validation suite running...\n"; - return RunTestDataFile("TestVectors/sosemanuk.txt"); -} - -bool ValidateRabbit() -{ - std::cout << "\nRabbit validation suite running...\n"; - return RunTestDataFile("TestVectors/rabbit.txt"); -} - -bool ValidateHC128() -{ - std::cout << "\nHC-128 validation suite running...\n"; - return RunTestDataFile("TestVectors/hc128.txt"); -} - -bool ValidateHC256() -{ - std::cout << "\nHC-256 validation suite running...\n"; - return RunTestDataFile("TestVectors/hc256.txt"); -} - -bool ValidateVMAC() -{ - std::cout << "\nVMAC validation suite running...\n"; - return RunTestDataFile("TestVectors/vmac.txt"); -} - -bool ValidateCCM() -{ - std::cout << "\nAES/CCM validation suite running...\n"; - return RunTestDataFile("TestVectors/ccm.txt"); -} - -bool ValidateGCM() -{ - std::cout << "\nAES/GCM validation suite running...\n"; - std::cout << "\n2K tables:"; - bool pass = RunTestDataFile("TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)2048)); - std::cout << "\n64K tables:"; - return RunTestDataFile("TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)64*1024)) && pass; -} - -bool ValidateXTS() -{ - std::cout << "\nAES/XTS validation suite running...\n"; - return RunTestDataFile("TestVectors/xts.txt"); -} - -bool ValidateCMAC() -{ - std::cout << "\nCMAC validation suite running...\n"; - return RunTestDataFile("TestVectors/cmac.txt"); -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat5.cpp b/vendor/cryptopp/validat5.cpp deleted file mode 100644 index 56d6cc7d06..0000000000 --- a/vendor/cryptopp/validat5.cpp +++ /dev/null @@ -1,2224 +0,0 @@ -// validat5.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "aes.h" -#include "crc.h" -#include "adler32.h" - -#include "md2.h" -#include "md4.h" -#include "md5.h" - -#include "sha.h" -#include "sha3.h" -#include "shake.h" -#include "keccak.h" -#include "tiger.h" -#include "blake2.h" -#include "ripemd.h" -#include "siphash.h" -#include "poly1305.h" -#include "whrlpool.h" -#include "lsh.h" - -#include "pssr.h" -#include "hkdf.h" -#include "scrypt.h" -#include "pwdbased.h" - -#include "cmac.h" -#include "dmac.h" -#include "hmac.h" -#include "ttmac.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -struct HashTestTuple -{ - HashTestTuple(const char *input, const char *output, unsigned int repeatTimes=1) - : input((byte *)input), output((byte *)output), inputLen(strlen(input)), repeatTimes(repeatTimes) {} - - HashTestTuple(const char *input, unsigned int inputLen, const char *output, unsigned int repeatTimes) - : input((byte *)input), output((byte *)output), inputLen(inputLen), repeatTimes(repeatTimes) {} - - const byte *input, *output; - size_t inputLen, repeatTimes; -}; - -bool HashModuleTest(HashTransformation &md, const HashTestTuple *testSet, size_t testSetSize) -{ - bool pass=true, fail; - std::ostringstream oss; - - SecByteBlock digest(md.DigestSize()); - for (size_t i=0; i r', -// where 'r' is rate and acts like a blockSize, then TruncatedFinal acts -// like a traditional KDF and applies KeccakF1600 core function multiple -// times on state to create the stream. Regarding the NIST test vectors, -// the SHAKE128 KATs do not engage 'd > r'. However, the SHAKE256 KATs -// do engage it. -bool ValidateSHAKE_XOF() -{ - std::cout << "\nSHAKE XOF validation suite running...\n"; - bool pass = true, fail; - - ////// NIST test vectors SHAKE128VariableOut.rsp ////// - - // SHAKE128, COUNT = 0 (first test) - { - std::string m, msg = "84e950051876050dc851fbd99e6247b8"; - std::string o, out = "8599bd89f63a848c49ca593ec37a12c6"; - std::string r; - - StringSource(msg, true, new HexDecoder(new StringSink(m))); - StringSource(out, true, new HexDecoder(new StringSink(o))); - r.resize(o.size()); - - SHAKE128 hash((unsigned int)o.size()); - hash.Update(ConstBytePtr(m), BytePtrSize(m)); - hash.TruncatedFinal(BytePtr(r), BytePtrSize(r)); - - fail = r != o; - pass = pass & !fail; - - if (fail) - std::cout << "FAILED " << "SHAKE128 test COUNT=0" << std::endl; - - pass = pass && !fail; - } - - // SHAKE128, COUNT = 1125 (last test) - { - std::string m, msg = "0a13ad2c7a239b4ba73ea6592ae84ea9"; - std::string o, out = "5feaf99c15f48851943ff9baa6e5055d 8377f0dd347aa4dbece51ad3a6d9ce0c" - "01aee9fe2260b80a4673a909b532adcd d1e421c32d6460535b5fe392a58d2634" - "979a5a104d6c470aa3306c400b061db9 1c463b2848297bca2bc26d1864ba49d7" - "ff949ebca50fbf79a5e63716dc82b600 bd52ca7437ed774d169f6bf02e464879" - "56fba2230f34cd2a0485484d"; - std::string r; - - StringSource(msg, true, new HexDecoder(new StringSink(m))); - StringSource(out, true, new HexDecoder(new StringSink(o))); - r.resize(o.size()); - - SHAKE128 hash((unsigned int)o.size()); - hash.Update(ConstBytePtr(m), BytePtrSize(m)); - hash.TruncatedFinal(BytePtr(r), BytePtrSize(r)); - - fail = r != o; - pass = pass & !fail; - - if (fail) - std::cout << "FAILED " << "SHAKE128 test COUNT=1125" << std::endl; - - pass = pass && !fail; - } - - ////// NIST test vectors SHAKE256VariableOut.rsp ////// - - // SHAKE256, COUNT = 0 (first test) - { - std::string m, msg = "c61a9188812ae73994bc0d6d4021e31b f124dc72669749111232da7ac29e61c4"; - std::string o, out = "23ce"; - std::string r; - - StringSource(msg, true, new HexDecoder(new StringSink(m))); - StringSource(out, true, new HexDecoder(new StringSink(o))); - r.resize(o.size()); - - SHAKE256 hash((unsigned int)o.size()); - hash.Update(ConstBytePtr(m), BytePtrSize(m)); - hash.TruncatedFinal(BytePtr(r), BytePtrSize(r)); - - fail = r != o; - pass = pass & !fail; - - if (fail) - std::cout << "FAILED " << "SHAKE256 test COUNT=0" << std::endl; - - pass = pass && !fail; - } - - // SHAKE256, COUNT = 1245 (last test) - { - std::string m, msg = "8d8001e2c096f1b88e7c9224a086efd4 797fbf74a8033a2d422a2b6b8f6747e4"; - std::string o, out = "2e975f6a8a14f0704d51b13667d8195c 219f71e6345696c49fa4b9d08e9225d3" - "d39393425152c97e71dd24601c11abcf a0f12f53c680bd3ae757b8134a9c10d4" - "29615869217fdd5885c4db174985703a 6d6de94a667eac3023443a8337ae1bc6" - "01b76d7d38ec3c34463105f0d3949d78 e562a039e4469548b609395de5a4fd43" - "c46ca9fd6ee29ada5efc07d84d553249 450dab4a49c483ded250c9338f85cd93" - "7ae66bb436f3b4026e859fda1ca57143 2f3bfc09e7c03ca4d183b741111ca048" - "3d0edabc03feb23b17ee48e844ba2408 d9dcfd0139d2e8c7310125aee801c61a" - "b7900d1efc47c078281766f361c5e611 1346235e1dc38325666c"; - std::string r; - - StringSource(msg, true, new HexDecoder(new StringSink(m))); - StringSource(out, true, new HexDecoder(new StringSink(o))); - r.resize(o.size()); - - SHAKE256 hash((unsigned int)o.size()); - hash.Update(ConstBytePtr(m), BytePtrSize(m)); - hash.TruncatedFinal(BytePtr(r), BytePtrSize(r)); - - fail = r != o; - pass = pass & !fail; - - if (fail) - std::cout << "FAILED " << "SHAKE256 test COUNT=0" << std::endl; - - pass = pass && !fail; - } - - std::cout << (!pass ? "FAILED " : "passed ") << "SHAKE XOF message digests" << std::endl; - - return pass; -} - -bool ValidateTiger() -{ - std::cout << "\nTiger validation suite running...\n\n"; - - const HashTestTuple testSet[] = - { - HashTestTuple("", "\x32\x93\xac\x63\x0c\x13\xf0\x24\x5f\x92\xbb\xb1\x76\x6e\x16\x16\x7a\x4e\x58\x49\x2d\xde\x73\xf3"), - HashTestTuple("a", "\x77\xBE\xFB\xEF\x2E\x7E\xF8\xAB\x2E\xC8\xF9\x3B\xF5\x87\xA7\xFC\x61\x3E\x24\x7F\x5F\x24\x78\x09"), - HashTestTuple("abc", "\x2a\xab\x14\x84\xe8\xc1\x58\xf2\xbf\xb8\xc5\xff\x41\xb5\x7a\x52\x51\x29\x13\x1c\x95\x7b\x5f\x93"), - HashTestTuple("Tiger", "\xdd\x00\x23\x07\x99\xf5\x00\x9f\xec\x6d\xeb\xc8\x38\xbb\x6a\x27\xdf\x2b\x9d\x6f\x11\x0c\x79\x37"), - HashTestTuple("message digest", "\xD9\x81\xF8\xCB\x78\x20\x1A\x95\x0D\xCF\x30\x48\x75\x1E\x44\x1C\x51\x7F\xCA\x1A\xA5\x5A\x29\xF6"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\x8d\xce\xa6\x80\xa1\x75\x83\xee\x50\x2b\xa3\x8a\x3c\x36\x86\x51\x89\x0f\xfb\xcc\xdc\x49\xa8\xcc"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", "\xf7\x1c\x85\x83\x90\x2a\xfb\x87\x9e\xdf\xe6\x10\xf8\x2c\x0d\x47\x86\xa3\xa5\x34\x50\x44\x86\xb5"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789", "\x48\xce\xeb\x63\x08\xb8\x7d\x46\xe9\x5d\x65\x61\x12\xcd\xf1\x8d\x97\x91\x5f\x97\x65\x65\x89\x57"), - HashTestTuple("Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham", "\x8a\x86\x68\x29\x04\x0a\x41\x0c\x72\x9a\xd2\x3f\x5a\xda\x71\x16\x03\xb3\xcd\xd3\x57\xe4\xc1\x5e"), - HashTestTuple("Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge.", "\xce\x55\xa6\xaf\xd5\x91\xf5\xeb\xac\x54\x7f\xf8\x4f\x89\x22\x7f\x93\x31\xda\xb0\xb6\x11\xc8\x89"), - HashTestTuple("Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.", "\x63\x1a\xbd\xd1\x03\xeb\x9a\x3d\x24\x5b\x6d\xfd\x4d\x77\xb2\x57\xfc\x74\x39\x50\x1d\x15\x68\xdd"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", "\xc5\x40\x34\xe5\xb4\x3e\xb8\x00\x58\x48\xa7\xe0\xae\x6a\xac\x76\xe4\xff\x59\x0a\xe7\x15\xfd\x25") - }; - - Tiger tiger; - - return HashModuleTest(tiger, testSet, COUNTOF(testSet)); -} - -bool ValidateRIPEMD() -{ - const HashTestTuple testSet128[] = - { - HashTestTuple("", "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e\xcb\x61\x0f\x18\xf6\xb3\x8b\x46"), - HashTestTuple("a", "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7\xcf\xc7\x85\xe7\x2f\x57\x8d\x33"), - HashTestTuple("abc", "\xc1\x4a\x12\x19\x9c\x66\xe4\xba\x84\x63\x6b\x0f\x69\x14\x4c\x77"), - HashTestTuple("message digest", "\x9e\x32\x7b\x3d\x6e\x52\x30\x62\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8"), - HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5\x10\x71\x49\x22\xb3\x71\x83\x4e"), - HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d\xdc\x22\xe8\x8b\x49\x13\x3a\x06"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f\xae\xa4\x62\x4c\x60\xc5\xc7\x02"), - HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x3f\x45\xef\x19\x47\x32\xc2\xdb\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3"), - HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x4a\x7f\x57\x23\xf9\x54\xeb\xa1\x21\x6c\x9d\x8f\x63\x20\x43\x1f", 15625) - }; - - const HashTestTuple testSet160[] = - { - HashTestTuple("", "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31"), - HashTestTuple("a", "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe"), - HashTestTuple("abc", "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc"), - HashTestTuple("message digest", "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36"), - HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc"), - HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89"), - HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb"), - HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x52\x78\x32\x43\xc1\x69\x7b\xdb\xe1\x6d\x37\xf9\x7f\x68\xf0\x83\x25\xdc\x15\x28", 15625) - }; - - const HashTestTuple testSet256[] = - { - HashTestTuple("", "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18\x77\xfc\x52\xd6\x4d\x30\xe3\x7a\x2d\x97\x74\xfb\x1e\x5d\x02\x63\x80\xae\x01\x68\xe3\xc5\x52\x2d"), - HashTestTuple("a", "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9\x0a\x91\xba\xb7\x0a\x1e\xba\x0c\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf\xcd\x88\x3a\x91\x34\x69\x29\x25"), - HashTestTuple("abc", "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb\xce\xf5\xca\x2d\x03\xe6\xdb\xa1\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e\x1e\x42\xd2\xe9\x75\x45\x9b\x65"), - HashTestTuple("message digest", "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a\x51\x4d\x5c\x91\x4c\x39\x2c\x90\x18\xc7\xc4\x6b\xc1\x44\x65\x55\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e"), - HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\x64\x9d\x30\x34\x75\x1e\xa2\x16\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc\x78\x96\x11\x8a\x51\x97\x96\x87\x82\xdd\x1f\xd9\x7d\x8d\x51\x33"), - HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\x38\x43\x04\x55\x83\xaa\xc6\xc8\xc8\xd9\x12\x85\x73\xe7\xa9\x80\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\x57\x40\xa4\x08\xac\x16\xb7\x20\xb8\x44\x24\xae\x93\x1c\xbb\x1f\xe3\x63\xd1\xd0\xbf\x40\x17\xf1\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8"), - HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x06\xfd\xcc\x7a\x40\x95\x48\xaa\xf9\x13\x68\xc0\x6a\x62\x75\xb5\x53\xe3\xf0\x99\xbf\x0e\xa4\xed\xfd\x67\x78\xdf\x89\xa8\x90\xdd"), - HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\xac\x95\x37\x44\xe1\x0e\x31\x51\x4c\x15\x0d\x4d\x8d\x7b\x67\x73\x42\xe3\x33\x99\x78\x82\x96\xe4\x3a\xe4\x85\x0c\xe4\xf9\x79\x78", 15625) - }; - - const HashTestTuple testSet320[] = - { - HashTestTuple("", "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8"), - HashTestTuple("a", "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d"), - HashTestTuple("abc", "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d"), - HashTestTuple("message digest", "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97"), - HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09"), - HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4"), - HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42"), - HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\xbd\xee\x37\xf4\x37\x1e\x20\x64\x6b\x8b\x0d\x86\x2d\xda\x16\x29\x2a\xe3\x6f\x40\x96\x5e\x8c\x85\x09\xe6\x3d\x1d\xbd\xde\xcc\x50\x3e\x2b\x63\xeb\x92\x45\xbb\x66", 15625) - }; - - bool pass = true; - - std::cout << "\nRIPEMD-128 validation suite running...\n\n"; - RIPEMD128 md128; - pass = HashModuleTest(md128, testSet128, COUNTOF(testSet128)) && pass; - - std::cout << "\nRIPEMD-160 validation suite running...\n\n"; - RIPEMD160 md160; - pass = HashModuleTest(md160, testSet160, COUNTOF(testSet160)) && pass; - - std::cout << "\nRIPEMD-256 validation suite running...\n\n"; - RIPEMD256 md256; - pass = HashModuleTest(md256, testSet256, COUNTOF(testSet256)) && pass; - - std::cout << "\nRIPEMD-320 validation suite running...\n\n"; - RIPEMD320 md320; - pass = HashModuleTest(md320, testSet320, COUNTOF(testSet320)) && pass; - - return pass; -} - -#ifdef CRYPTOPP_REMOVED -bool ValidateHAVAL() -{ - const HashTestTuple testSet[] = - { - HashTestTuple("", "\xC6\x8F\x39\x91\x3F\x90\x1F\x3D\xDF\x44\xC7\x07\x35\x7A\x7D\x70"), - HashTestTuple("a", "\x4D\xA0\x8F\x51\x4A\x72\x75\xDB\xC4\xCE\xCE\x4A\x34\x73\x85\x98\x39\x83\xA8\x30"), - HashTestTuple("HAVAL", "\x0C\x13\x96\xD7\x77\x26\x89\xC4\x67\x73\xF3\xDA\xAC\xA4\xEF\xA9\x82\xAD\xBF\xB2\xF1\x46\x7E\xEA"), - HashTestTuple("0123456789", "\xBE\xBD\x78\x16\xF0\x9B\xAE\xEC\xF8\x90\x3B\x1B\x9B\xC6\x72\xD9\xFA\x42\x8E\x46\x2B\xA6\x99\xF8\x14\x84\x15\x29"), - HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xC9\xC7\xD8\xAF\xA1\x59\xFD\x9E\x96\x5C\xB8\x3F\xF5\xEE\x6F\x58\xAE\xDA\x35\x2C\x0E\xFF\x00\x55\x48\x15\x3A\x61\x55\x1C\x38\xEE"), - HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xB4\x5C\xB6\xE6\x2F\x2B\x13\x20\xE4\xF8\xF1\xB0\xB2\x73\xD4\x5A\xDD\x47\xC3\x21\xFD\x23\x99\x9D\xCF\x40\x3A\xC3\x76\x36\xD9\x63") - }; - - bool pass=true; - - std::cout << "\nHAVAL validation suite running...\n\n"; - { - HAVAL3 md(16); - pass = HashModuleTest(md, testSet+0, 1) && pass; - } - { - HAVAL3 md(20); - pass = HashModuleTest(md, testSet+1, 1) && pass; - } - { - HAVAL4 md(24); - pass = HashModuleTest(md, testSet+2, 1) && pass; - } - { - HAVAL4 md(28); - pass = HashModuleTest(md, testSet+3, 1) && pass; - } - { - HAVAL5 md(32); - pass = HashModuleTest(md, testSet+4, 1) && pass; - } - { - HAVAL5 md(32); - pass = HashModuleTest(md, testSet+5, 1) && pass; - } - - return pass; -} -#endif - -bool ValidatePanama() -{ - std::cout << "\nPanama validation suite running...\n"; - return RunTestDataFile("TestVectors/panama.txt"); -} - -bool ValidateWhirlpool() -{ - std::cout << "\nWhirlpool validation suite running...\n"; - return RunTestDataFile("TestVectors/whrlpool.txt"); -} - -bool ValidateLSH() -{ - std::cout << "\nLSH validation suite running...\n"; - return RunTestDataFile("TestVectors/lsh.txt"); -} - -#ifdef CRYPTOPP_REMOVED -bool ValidateMD5MAC() -{ - const byte keys[2][MD5MAC::KEYLENGTH]={ - {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff}, - {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}}; - - const char *TestVals[7]={ - "", - "a", - "abc", - "message digest", - "abcdefghijklmnopqrstuvwxyz", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "12345678901234567890123456789012345678901234567890123456789012345678901234567890"}; - - const byte output[2][7][MD5MAC::DIGESTSIZE]={ - {{0x1f,0x1e,0xf2,0x37,0x5c,0xc0,0xe0,0x84,0x4f,0x98,0xe7,0xe8,0x11,0xa3,0x4d,0xa8}, - {0x7a,0x76,0xee,0x64,0xca,0x71,0xef,0x23,0x7e,0x26,0x29,0xed,0x94,0x52,0x73,0x65}, - {0xe8,0x01,0x3c,0x11,0xf7,0x20,0x9d,0x13,0x28,0xc0,0xca,0xa0,0x4f,0xd0,0x12,0xa6}, - {0xc8,0x95,0x53,0x4f,0x22,0xa1,0x74,0xbc,0x3e,0x6a,0x25,0xa2,0xb2,0xef,0xd6,0x30}, - {0x91,0x72,0x86,0x7e,0xb6,0x00,0x17,0x88,0x4c,0x6f,0xa8,0xcc,0x88,0xeb,0xe7,0xc9}, - {0x3b,0xd0,0xe1,0x1d,0x5e,0x09,0x4c,0xb7,0x1e,0x35,0x44,0xac,0xa9,0xb8,0xbf,0xa2}, - {0x93,0x37,0x16,0x64,0x44,0xcc,0x95,0x35,0xb7,0xd5,0xb8,0x0f,0x91,0xe5,0x29,0xcb}}, - {{0x2f,0x6e,0x73,0x13,0xbf,0xbb,0xbf,0xcc,0x3a,0x2d,0xde,0x26,0x8b,0x59,0xcc,0x4d}, - {0x69,0xf6,0xca,0xff,0x40,0x25,0x36,0xd1,0x7a,0xe1,0x38,0x03,0x2c,0x0c,0x5f,0xfd}, - {0x56,0xd3,0x2b,0x6c,0x34,0x76,0x65,0xd9,0x74,0xd6,0xf7,0x5c,0x3f,0xc6,0xf0,0x40}, - {0xb8,0x02,0xb2,0x15,0x4e,0x59,0x8b,0x6f,0x87,0x60,0x56,0xc7,0x85,0x46,0x2c,0x0b}, - {0x5a,0xde,0xf4,0xbf,0xf8,0x04,0xbe,0x08,0x58,0x7e,0x94,0x41,0xcf,0x6d,0xbd,0x57}, - {0x18,0xe3,0x49,0xa5,0x24,0x44,0xb3,0x0e,0x5e,0xba,0x5a,0xdd,0xdc,0xd9,0xf1,0x8d}, - {0xf2,0xb9,0x06,0xa5,0xb8,0x4b,0x9b,0x4b,0xbe,0x95,0xed,0x32,0x56,0x4e,0xe7,0xeb}}}; - - byte digest[MD5MAC::DIGESTSIZE]; - bool pass=true, fail; - std::ostringstream oss; - - oss << "\nMD5MAC validation suite running...\n"; - - for (int k=0; k<2; k++) - { - MD5MAC mac(keys[k]); - oss << "\nKEY: "; - for (int j=0;j XMACC_MD5; - - const byte keys[2][XMACC_MD5::KEYLENGTH]={ - {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb}, - {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98}}; - - const word32 counters[2]={0xccddeeff, 0x76543210}; - - const char *TestVals[7]={ - "", - "a", - "abc", - "message digest", - "abcdefghijklmnopqrstuvwxyz", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "12345678901234567890123456789012345678901234567890123456789012345678901234567890"}; - - const byte output[2][7][XMACC_MD5::DIGESTSIZE]={ - {{0xcc,0xdd,0xef,0x00,0xfa,0x89,0x54,0x92,0x86,0x32,0xda,0x2a,0x3f,0x29,0xc5,0x52,0xa0,0x0d,0x05,0x13}, - {0xcc,0xdd,0xef,0x01,0xae,0xdb,0x8b,0x7b,0x69,0x71,0xc7,0x91,0x71,0x48,0x9d,0x18,0xe7,0xdf,0x9d,0x5a}, - {0xcc,0xdd,0xef,0x02,0x5e,0x01,0x2e,0x2e,0x4b,0xc3,0x83,0x62,0xc2,0xf4,0xe6,0x18,0x1c,0x44,0xaf,0xca}, - {0xcc,0xdd,0xef,0x03,0x3e,0xa9,0xf1,0xe0,0x97,0x91,0xf8,0xe2,0xbe,0xe0,0xdf,0xf3,0x41,0x03,0xb3,0x5a}, - {0xcc,0xdd,0xef,0x04,0x2e,0x6a,0x8d,0xb9,0x72,0xe3,0xce,0x9f,0xf4,0x28,0x45,0xe7,0xbc,0x80,0xa9,0xc7}, - {0xcc,0xdd,0xef,0x05,0x1a,0xd5,0x40,0x78,0xfb,0x16,0x37,0xfc,0x7a,0x1d,0xce,0xb4,0x77,0x10,0xb2,0xa0}, - {0xcc,0xdd,0xef,0x06,0x13,0x2f,0x11,0x47,0xd7,0x1b,0xb5,0x52,0x36,0x51,0x26,0xb0,0x96,0xd7,0x60,0x81}}, - {{0x76,0x54,0x32,0x11,0xe9,0xcb,0x74,0x32,0x07,0x93,0xfe,0x01,0xdd,0x27,0xdb,0xde,0x6b,0x77,0xa4,0x56}, - {0x76,0x54,0x32,0x12,0xcd,0x55,0x87,0x5c,0xc0,0x35,0x85,0x99,0x44,0x02,0xa5,0x0b,0x8c,0xe7,0x2c,0x68}, - {0x76,0x54,0x32,0x13,0xac,0xfd,0x87,0x50,0xc3,0x8f,0xcd,0x58,0xaa,0xa5,0x7e,0x7a,0x25,0x63,0x26,0xd1}, - {0x76,0x54,0x32,0x14,0xe3,0x30,0xf5,0xdd,0x27,0x2b,0x76,0x22,0x7f,0xaa,0x90,0x73,0x6a,0x48,0xdb,0x00}, - {0x76,0x54,0x32,0x15,0xfc,0x57,0x00,0x20,0x7c,0x9d,0xf6,0x30,0x6f,0xbd,0x46,0x3e,0xfb,0x8a,0x2c,0x60}, - {0x76,0x54,0x32,0x16,0xfb,0x0f,0xd3,0xdf,0x4c,0x4b,0xc3,0x05,0x9d,0x63,0x1e,0xba,0x25,0x2b,0xbe,0x35}, - {0x76,0x54,0x32,0x17,0xc6,0xfe,0xe6,0x5f,0xb1,0x35,0x8a,0xf5,0x32,0x7a,0x80,0xbd,0xb8,0x72,0xee,0xae}}}; - - // Coverity finding, also see http://stackoverflow.com/a/34509163/608639. - StreamState ss(std::cout); - - byte digest[XMACC_MD5::DIGESTSIZE]; - bool pass=true, fail; - - std::cout << "\nXMACC/MD5 validation suite running...\n"; - - for (int k=0; k<2; k++) - { - XMACC_MD5 mac(keys[k], counters[k]); - std::cout << "\nKEY: "; - for (int j=0;j pbkdf; - - std::cout << "\nPKCS #12 PBKDF validation suite running...\n\n"; - pass = TestPBKDF(pbkdf, testSet, COUNTOF(testSet)) && pass; - } - - { - // from draft-ietf-smime-password-03.txt, at http://www.imc.org/draft-ietf-smime-password - PBKDF_TestTuple testSet[] = - { - {0, 5, "70617373776f7264", "1234567878563412", "D1DAA78615F287E6"}, - {0, 500, "416C6C206E2D656E746974696573206D75737420636F6D6D756E69636174652077697468206F74686572206E2d656E74697469657320766961206E2D3120656E746974656568656568656573", "1234567878563412","6A8970BF68C92CAEA84A8DF28510858607126380CC47AB2D"} - }; - - PKCS5_PBKDF2_HMAC pbkdf; - - std::cout << "\nPKCS #5 PBKDF2 validation suite running...\n\n"; - pass = TestPBKDF(pbkdf, testSet, COUNTOF(testSet)) && pass; - } - - return pass; -} - -struct HKDF_TestTuple -{ - const char *hexSecret, *hexSalt, *hexInfo, *hexExpected; - size_t len; -}; - -bool TestHKDF(KeyDerivationFunction &kdf, const HKDF_TestTuple *testSet, size_t testSetSize) -{ - bool pass = true; - - for (size_t i=0; i") : ""); - std::cout << " "; - std::cout << (tuple.hexInfo ? (strlen(tuple.hexInfo) ? tuple.hexInfo : "<0-LEN INFO>") : ""); - std::cout << " "; - enc.Put(derived, derived.size()); - std::cout << std::endl; - } - - return pass; -} - -bool ValidateHKDF() -{ - bool pass = true; - - { - // SHA-1 from RFC 5869, Appendix A, https://tools.ietf.org/html/rfc5869 - const HKDF_TestTuple testSet[] = - { - // Test Case #4 - {"0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "085a01ea1b10f36933068b56efa5ad81 a4f14b822f5b091568a9cdd4f155fda2 c22e422478d305f3f896", 42}, - // Test Case #5 - {"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "0bd770a74d1160f7c9f12cd5912a06eb ff6adcae899d92191fe4305673ba2ffe 8fa3f1a4e5ad79f3f334b3b202b2173c 486ea37ce3d397ed034c7f9dfeb15c5e 927336d0441f4c4300e2cff0d0900b52 d3b4", 82}, - // Test Case #6 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "0ac1af7002b3d761d1e55298da9d0506 b9ae52057220a306e07b6b87e8df21d0 ea00033de03984d34918", 42}, - // Test Case #7 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULLPTR, "", "2c91117204d745f3500d636a62f64f0 ab3bae548aa53d423b0d1f27ebba6f5e5 673a081d70cce7acfc48", 42} - }; - - HKDF hkdf; - - std::cout << "\nRFC 5869 HKDF(SHA-1) validation suite running...\n\n"; - pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass; - } - - { - // SHA-256 from RFC 5869, Appendix A, https://tools.ietf.org/html/rfc5869 - const HKDF_TestTuple testSet[] = - { - // Test Case #1 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "3cb25f25faacd57a90434f64d0362f2a 2d2d0a90cf1a5a4c5db02d56ecc4c5bf 34007208d5b887185865", 42}, - // Test Case #2 - {"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "b11e398dc80327a1c8e7f78c596a4934 4f012eda2d4efad8a050cc4c19afa97c 59045a99cac7827271cb41c65e590e09 da3275600c2f09b8367793a9aca3db71 cc30c58179ec3e87c14c01d5c1f3434f 1d87", 82}, - // Test Case #3 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "8da4e775a563c18f715f802a063c5a31 b8a11f5c5ee1879ec3454e5f3c738d2d 9d201395faa4b61a96c8", 42} - }; - - HKDF hkdf; - - std::cout << "\nRFC 5869 HKDF(SHA-256) validation suite running...\n\n"; - pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass; - } - - { - // SHA-512, Crypto++ generated, based on RFC 5869, https://tools.ietf.org/html/rfc5869 - const HKDF_TestTuple testSet[] = - { - // Test Case #0 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "832390086CDA71FB47625BB5CEB168E4 C8E26A1A16ED34D9FC7FE92C14815793 38DA362CB8D9F925D7CB", 42}, - // Test Case #0 - {"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "CE6C97192805B346E6161E821ED16567 3B84F400A2B514B2FE23D84CD189DDF1 B695B48CBD1C8388441137B3CE28F16A A64BA33BA466B24DF6CFCB021ECFF235 F6A2056CE3AF1DE44D572097A8505D9E 7A93", 82}, - // Test Case #0 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "F5FA02B18298A72A8C23898A8703472C 6EB179DC204C03425C970E3B164BF90F FF22D04836D0E2343BAC", 42}, - // Test Case #0 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULLPTR, "", "1407D46013D98BC6DECEFCFEE55F0F90 B0C7F63D68EB1A80EAF07E953CFC0A3A 5240A155D6E4DAA965BB", 42} - }; - - HKDF hkdf; - - std::cout << "\nRFC 5869 HKDF(SHA-512) validation suite running...\n\n"; - pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass; - } - - { - // Whirlpool, Crypto++ generated, based on RFC 5869, https://tools.ietf.org/html/rfc5869 - const HKDF_TestTuple testSet[] = - { - // Test Case #0 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "0D29F74CCD8640F44B0DD9638111C1B5 766EFED752AF358109E2E7C9CD4A28EF 2F90B2AD461FBA0744D4", 42}, - // Test Case #0 - {"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "4EBE4FE2DCCEC42661699500BE279A99 3FED90351E19373B3926FAA3A410700B2 BBF77E254CF1451AE6068D64A0904D96 6F4FF25498445A501B88F50D21E3A68A8 90E09445DC5886DD00E7F4F7C58A5121 70", 82}, - // Test Case #0 - {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "110632D0F7AEFAC31771FC66C22BB346 2614B81E4B04BA7F2B662E0BD694F564 58615F9A9CB56C57ECF2", 42}, - // Test Case #0 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" /*key*/, NULLPTR /*salt*/, "" /*info*/, "4089286EBFB23DD8A02F0C9DAA35D538 EB09CD0A8CBAB203F39083AA3E0BD313 E6F91E64F21A187510B0", 42} - }; - - HKDF hkdf; - - std::cout << "\nRFC 5869 HKDF(Whirlpool) validation suite running...\n\n"; - pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass; - } - - return pass; -} - -struct Scrypt_TestTuple -{ - const char * passwd; - const char * salt; - word64 n; - word32 r; - word32 p; - const char * expect; -}; - -bool TestScrypt(KeyDerivationFunction &pbkdf, const Scrypt_TestTuple *testSet, size_t testSetSize) -{ - bool pass = true; - - for (size_t i=0; i::StaticAlgorithmName() != "Poly1305(AES)"); - std::cout << (fail ? "FAILED " : "passed ") << "algorithm name\n"; - pass = pass && !fail; - } - - // Test data from http://cr.yp.to/mac/poly1305-20050329.pdf - const Poly1305_TestTuples tests[] = - { - // Appendix B, Test 1 - { - "\xec\x07\x4c\x83\x55\x80\x74\x17\x01\x42\x5b\x62\x32\x35\xad\xd6" // Key - "\x85\x1f\xc4\x0c\x34\x67\xac\x0b\xe0\x5c\xc2\x04\x04\xf3\xf7\x00", - "\xf3\xf6", // Message - "\xfb\x44\x73\x50\xc4\xe8\x68\xc5\x2a\xc3\x27\x5c\xf9\xd4\x32\x7e", // Nonce - "\xf4\xc6\x33\xc3\x04\x4f\xc1\x45\xf8\x4f\x33\x5c\xb8\x19\x53\xde", // Digest - 32, 2, 16, 16 - }, - // Appendix B, Test 2 - { - "\x75\xde\xaa\x25\xc0\x9f\x20\x8e\x1d\xc4\xce\x6b\x5c\xad\x3f\xbf" // Key - "\x61\xee\x09\x21\x8d\x29\xb0\xaa\xed\x7e\x15\x4a\x2c\x55\x09\xcc", - "", // Message - "\x61\xee\x09\x21\x8d\x29\xb0\xaa\xed\x7e\x15\x4a\x2c\x55\x09\xcc", // Nonce - "\xdd\x3f\xab\x22\x51\xf1\x1a\xc7\x59\xf0\x88\x71\x29\xcc\x2e\xe7", // Digest - 32, 0, 16, 16 - }, - // Appendix B, Test 3 - { - "\x6a\xcb\x5f\x61\xa7\x17\x6d\xd3\x20\xc5\xc1\xeb\x2e\xdc\xdc\x74" // Key - "\x48\x44\x3d\x0b\xb0\xd2\x11\x09\xc8\x9a\x10\x0b\x5c\xe2\xc2\x08", - "\x66\x3c\xea\x19\x0f\xfb\x83\xd8\x95\x93\xf3\xf4\x76\xb6\xbc\x24" // Message - "\xd7\xe6\x79\x10\x7e\xa2\x6a\xdb\x8c\xaf\x66\x52\xd0\x65\x61\x36", - "\xae\x21\x2a\x55\x39\x97\x29\x59\x5d\xea\x45\x8b\xc6\x21\xff\x0e", // Nonce - "\x0e\xe1\xc1\x6b\xb7\x3f\x0f\x4f\xd1\x98\x81\x75\x3c\x01\xcd\xbe", // Digest - 32, 32, 16, 16 - }, - // Appendix B, Test 4 - { - "\xe1\xa5\x66\x8a\x4d\x5b\x66\xa5\xf6\x8c\xc5\x42\x4e\xd5\x98\x2d" // Key - "\x12\x97\x6a\x08\xc4\x42\x6d\x0c\xe8\xa8\x24\x07\xc4\xf4\x82\x07", - "\xab\x08\x12\x72\x4a\x7f\x1e\x34\x27\x42\xcb\xed\x37\x4d\x94\xd1" // Message - "\x36\xc6\xb8\x79\x5d\x45\xb3\x81\x98\x30\xf2\xc0\x44\x91\xfa\xf0" - "\x99\x0c\x62\xe4\x8b\x80\x18\xb2\xc3\xe4\xa0\xfa\x31\x34\xcb\x67" - "\xfa\x83\xe1\x58\xc9\x94\xd9\x61\xc4\xcb\x21\x09\x5c\x1b\xf9", - "\x9a\xe8\x31\xe7\x43\x97\x8d\x3a\x23\x52\x7c\x71\x28\x14\x9e\x3a", // Nonce - "\x51\x54\xad\x0d\x2c\xb2\x6e\x01\x27\x4f\xc5\x11\x48\x49\x1f\x1b", // Digest - 32, 63, 16, 16 - } - }; - - unsigned int count = 0; - byte digest[Poly1305::DIGESTSIZE]; - - // Positive tests - for (size_t i=0; i poly1305((const byte*)tests[i].key, tests[i].klen); - poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); - poly1305.Final(digest); - - fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0; - if (fail) - { - std::cout << "FAILED " << "Poly1305 test set " << count << std::endl; - } - - count++; - pass = pass && !fail; - } - - // Positive tests - for (size_t i=0; i poly1305((const byte*)tests[i].key, tests[i].klen,(const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); - poly1305.Final(digest); - - fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0; - if (fail) - { - std::cout << "FAILED " << "Poly1305 test set " << count << std::endl; - } - - count++; - pass = pass && !fail; - } - - // Negative tests - for (size_t i=0; i poly1305((const byte*)tests[i].key, tests[i].klen); - poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); - poly1305.Final(digest); - - unsigned int next = (i+1) % COUNTOF(tests); - fail = std::memcmp(digest, tests[next].digest, tests[next].dlen) == 0; - if (fail) - { - std::cout << "FAILED " << "Poly1305 test set " << count << std::endl; - } - - count++; - pass = pass && !fail; - } - - std::cout << (!pass ? "FAILED " : "passed ") << count << " message authentication codes" << std::endl; - - return pass; -} - -bool ValidateSipHash() -{ - std::cout << "\nSipHash validation suite running...\n\n"; - bool fail, pass = true, pass1=true, pass2=true, pass3=true, pass4=true; - - { - fail = (SipHash<2,4>::StaticAlgorithmName() != "SipHash-2-4"); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-2-4 algorithm name\n"; - pass = pass && !fail; - - fail = (SipHash<2,4, false>::DIGESTSIZE != 8); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-2-4 64-bit digest size\n"; - pass = pass && !fail; - - fail = (SipHash<2,4, true>::DIGESTSIZE != 16); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-2-4 128-bit digest size\n"; - pass = pass && !fail; - - fail = (SipHash<4,8>::StaticAlgorithmName() != "SipHash-4-8"); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-4-8 algorithm name\n"; - pass = pass && !fail; - - fail = (SipHash<4,8, false>::DIGESTSIZE != 8); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-4-8 64-bit digest size\n"; - pass = pass && !fail; - - fail = (SipHash<4,8, true>::DIGESTSIZE != 16); - std::cout << (fail ? "FAILED " : "passed ") << "SipHash-4-8 128-bit digest size\n"; - pass = pass && !fail; - } - - // Siphash-2-4, 64-bit MAC - { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; - SipHash<2,4, false> hash(key, 16); - byte digest[SipHash<2,4, false>::DIGESTSIZE]; - - hash.Update((const byte*)"", 0); - hash.Final(digest); - fail = std::memcmp("\x31\x0E\x0E\xDD\x47\xDB\x6F\x72", digest, COUNTOF(digest)) != 0; - pass1 = !fail && pass1; - - hash.Update((const byte*)"\x00", 1); - hash.Final(digest); - fail = std::memcmp("\xFD\x67\xDC\x93\xC5\x39\xF8\x74", digest, COUNTOF(digest)) != 0; - pass1 = !fail && pass1; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); - hash.Final(digest); - fail = std::memcmp("\x37\xD1\x01\x8B\xF5\x00\x02\xAB", digest, COUNTOF(digest)) != 0; - pass1 = !fail && pass1; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); - hash.Final(digest); - fail = std::memcmp("\x62\x24\x93\x9A\x79\xF5\xF5\x93", digest, COUNTOF(digest)) != 0; - pass1 = !fail && pass1; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); - hash.Final(digest); - fail = std::memcmp("\xB0\xE4\xA9\x0B\xDF\x82\x00\x9E", digest, COUNTOF(digest)) != 0; - pass1 = !fail && pass1; - - std::cout << (pass1 ? "passed " : "FAILED ") << "SipHash-2-4 64-bit MAC\n"; - pass = pass1 && pass; - } - - // Siphash-2-4, 128-bit MAC - { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; - SipHash<2,4, true> hash(key, 16); - byte digest[SipHash<2,4, true>::DIGESTSIZE]; - - hash.Update((const byte*)"", 0); - hash.Final(digest); - fail = std::memcmp("\xA3\x81\x7F\x04\xBA\x25\xA8\xE6\x6D\xF6\x72\x14\xC7\x55\x02\x93", digest, COUNTOF(digest)) != 0; - pass3 = !fail && pass3; - - hash.Update((const byte*)"\x00", 1); - hash.Final(digest); - fail = std::memcmp("\xDA\x87\xC1\xD8\x6B\x99\xAF\x44\x34\x76\x59\x11\x9B\x22\xFC\x45", digest, COUNTOF(digest)) != 0; - pass3 = !fail && pass3; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); - hash.Final(digest); - fail = std::memcmp("\xA1\xF1\xEB\xBE\xD8\xDB\xC1\x53\xC0\xB8\x4A\xA6\x1F\xF0\x82\x39", digest, COUNTOF(digest)) != 0; - pass3 = !fail && pass3; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); - hash.Final(digest); - fail = std::memcmp("\x3B\x62\xA9\xBA\x62\x58\xF5\x61\x0F\x83\xE2\x64\xF3\x14\x97\xB4", digest, COUNTOF(digest)) != 0; - pass3 = !fail && pass3; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); - hash.Final(digest); - fail = std::memcmp("\x26\x44\x99\x06\x0A\xD9\xBA\xAB\xC4\x7F\x8B\x02\xBB\x6D\x71\xED", digest, COUNTOF(digest)) != 0; - pass3 = !fail && pass3; - - std::cout << (pass3 ? "passed " : "FAILED ") << "SipHash-2-4 128-bit MAC\n"; - pass = pass3 && pass; - } - - // Siphash-4-8, 64-bit MAC - { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; - SipHash<4, 8, false> hash(key, 16); - byte digest[SipHash<4, 8, false>::DIGESTSIZE]; - - hash.Update((const byte*)"", 0); - hash.Final(digest); - fail = std::memcmp("\x41\xDA\x38\x99\x2B\x05\x79\xC8", digest, COUNTOF(digest)) != 0; - pass2 = !fail && pass2; - - hash.Update((const byte*)"\x00", 1); - hash.Final(digest); - fail = std::memcmp("\x51\xB8\x95\x52\xF9\x14\x59\xC8", digest, COUNTOF(digest)) != 0; - pass2 = !fail && pass2; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); - hash.Final(digest); - fail = std::memcmp("\x47\xD7\x3F\x71\x5A\xBE\xFD\x4E", digest, COUNTOF(digest)) != 0; - pass2 = !fail && pass2; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); - hash.Final(digest); - fail = std::memcmp("\x20\xB5\x8B\x9C\x07\x2F\xDB\x50", digest, COUNTOF(digest)) != 0; - pass2 = !fail && pass2; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); - hash.Final(digest); - fail = std::memcmp("\x36\x31\x9A\xF3\x5E\xE1\x12\x53", digest, COUNTOF(digest)) != 0; - pass2 = !fail && pass2; - - std::cout << (pass2 ? "passed " : "FAILED ") << "SipHash-4-8 64-bit MAC\n"; - pass = pass2 && pass; - } - - // Siphash-4-8, 128-bit MAC - { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; - SipHash<4, 8, true> hash(key, 16); - byte digest[SipHash<4, 8, true>::DIGESTSIZE]; - - hash.Update((const byte*)"", 0); - hash.Final(digest); - fail = std::memcmp("\x1F\x64\xCE\x58\x6D\xA9\x04\xE9\xCF\xEC\xE8\x54\x83\xA7\x0A\x6C", digest, COUNTOF(digest)) != 0; - pass4 = !fail && pass4; - - hash.Update((const byte*)"\x00", 1); - hash.Final(digest); - fail = std::memcmp("\x47\x34\x5D\xA8\xEF\x4C\x79\x47\x6A\xF2\x7C\xA7\x91\xC7\xA2\x80", digest, COUNTOF(digest)) != 0; - pass4 = !fail && pass4; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); - hash.Final(digest); - fail = std::memcmp("\xED\x00\xE1\x3B\x18\x4B\xF1\xC2\x72\x6B\x8B\x54\xFF\xD2\xEE\xE0", digest, COUNTOF(digest)) != 0; - pass4 = !fail && pass4; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); - hash.Final(digest); - fail = std::memcmp("\xA7\xD9\x46\x13\x8F\xF9\xED\xF5\x36\x4A\x5A\x23\xAF\xCA\xE0\x63", digest, COUNTOF(digest)) != 0; - pass4 = !fail && pass4; - - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); - hash.Final(digest); - fail = std::memcmp("\x9E\x73\x14\xB7\x54\x5C\xEC\xA3\x8B\x9A\x55\x49\xE4\xFB\x0B\xE8", digest, COUNTOF(digest)) != 0; - pass4 = !fail && pass4; - - std::cout << (pass4 ? "passed " : "FAILED ") << "SipHash-4-8 128-bit MAC\n"; - pass = pass4 && pass; - } - - return pass; -} - -struct BLAKE2_TestTuples -{ - const char *key, *message, *digest; - size_t klen, mlen, dlen; -}; - -bool ValidateBLAKE2s() -{ - std::cout << "\nBLAKE2s validation suite running...\n\n"; - bool fail, pass = true; - - { - fail = strcmp(BLAKE2s::StaticAlgorithmName(), "BLAKE2s") != 0; - std::cout << (fail ? "FAILED " : "passed ") << "algorithm name\n"; - pass = pass && !fail; - } - - const BLAKE2_TestTuples tests[] = { - { - NULLPTR, - NULLPTR, - "\x8F\x38", - 0, 0, 2 - }, - { - NULLPTR, - NULLPTR, - "\x36\xE9\xD2\x46", - 0, 0, 4 - }, - { - NULLPTR, - NULLPTR, - "\xEF\x2A\x8B\x78\xDD\x80\xDA\x9C", - 0, 0, 8 - }, - { - NULLPTR, - NULLPTR, - "\x64\x55\x0D\x6F\xFE\x2C\x0A\x01\xA1\x4A\xBA\x1E\xAD\xE0\x20\x0C", - 0, 0, 16 - }, - { - NULLPTR, - NULLPTR, - "\x69\x21\x7A\x30\x79\x90\x80\x94\xE1\x11\x21\xD0\x42\x35\x4A\x7C\x1F\x55\xB6\x48\x2C\xA1\xA5\x1E\x1B\x25\x0D\xFD\x1E\xD0\xEE\xF9", - 0, 0, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x25\xEC\xB2\xF6\xA7\x81\x82\x57\x5D\x4B\xD7\x02\x72\x6D\xE1\x82\xBB\x1E\x21\xA8\x5D\x51\x34\xAD\xA2\x25\x8D\x7E\x21\x38\x03\xA7", - 0, 15, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xD4\x1C\x69\x87\x29\x7E\xDE\x4F\x08\x9B\x66\x9B\xC7\x0E\x62\xB9\xFA\xFA\x1C\x37\xCC\x31\x29\x22\xE0\xEA\x63\xE2\xE5\x85\xAA\x9F", - 0, 16, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xE0\xAD\xF2\xCC\x1F\x1F\x55\x3A\xE6\xC3\xCD\x3D\xF7\x68\xEA\x66\x9C\x32\xBE\x1D\x37\xF9\xA2\x61\xD4\x4F\x45\x26\x69\xD0\xD3\xA4", - 0, 17, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x10\x42\x65\x1C\x86\x15\xC4\x87\x69\x41\x19\x1F\xB6\xD5\xC5\x1D\xEB\x4C\xA1\x8C\xAF\xEF\xEB\x79\x69\x62\x87\x0D\x6A\x5D\xEE\x20", - 0, 31, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEA\xB1\xC5\xDD\xDF\xB5\x7C\x48\xC5\xB0\xB3\xF5\xBE\x5B\x47\x6D\xBB\xF5\xA3\x5C\x21\xD3\xDD\x94\x13\xA1\x04\xB8\x14\xF9\x2D\x4B", - 0, 32, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x7E\x82\x07\x49\x14\x62\x11\x96\xC5\xE8\xF3\xCB\x0F\x21\x7B\x37\xAE\x9B\x64\x58\xF4\x66\x01\xB9\x21\x23\xAC\x48\x64\x30\x83\x8F", - 0, 33, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x90\xB5\xA2\x5E\x8E\xA8\xA0\xC8\x74\x85\xAE\x18\x08\x9D\x92\xEB\x14\x5A\x5D\x4E\x2C\x60\x7B\xCB\x4B\x94\xD1\x0F\xAE\x59\x33\xC1", - 0, 63, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x71\x27\x28\x45\x9E\x67\xD7\xED\xB7\xAE\xFA\x88\xFF\x5C\x7E\x7B\x5D\xA9\x94\xA1\xC3\xB1\x7B\x64\xFB\xC1\x4E\x47\xCA\xDA\x45\xDD", - 0, 64, 32 - }, - { - NULLPTR, - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x58\x72\x3B\xB1\xBE\x18\x33\x12\x31\x5E\x6E\xF7\xF2\xB1\x84\x60\x97\x2C\x19\xD3\x01\xAF\x42\x00\xAB\xDB\x04\x26\xFC\xB0\xC1\xF8", - 0, 65, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULLPTR, - "\x9A\xD4\x81\xEF\x81\x6C\xAC\xB6\x59\x35\x8E\x6D\x6B\x73\xF1\xE5\xAC\x71\xD6\x6E\x8B\x12\x6B\x73\xD9\xD9\x7D\x2F\xA7\xA4\x61\xB4", - 15, 0, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x61\x8C\xBE\x19\x4B\x28\xDC\xA3\x8B\xE5\x1A\x79\x37\x45\xB4\x66\x3D\xF1\x9D\xB5\x8F\xFF\xEF\xC4\x5D\x37\x82\x25\x93\xEB\xE2\x93", - 15, 15, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xF3\xEC\x81\x61\x44\x5C\x6E\x2E\xE6\x52\x6A\xCA\x5F\xD9\x25\x74\x2A\x33\xB9\x1F\xEF\x0F\x7E\x54\x4F\x50\xC2\xFB\x04\x3C\x52\xD2", - 15, 16, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xF4\x81\x43\x6E\x2F\x4C\x5D\x09\x21\x73\x24\xDA\xA6\x23\x9E\xFD\xF8\x82\xCE\x0E\x3E\x4C\xB4\x17\xCC\x27\xCD\x1A\xAE\x90\x9B\x94", - 15, 17, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x99\x5E\x74\x8E\x96\xFE\xC0\x39\x5B\x73\xA3\xC0\x4E\xC7\xF7\xBE\x89\x83\xCD\x18\x24\x60\x60\x7B\xBC\xF5\x50\xF5\x84\xD1\x71\x6B", - 15, 31, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x21\x6E\xB9\xE2\xE4\xAF\x94\x5F\x6A\xA3\xD2\xCA\x25\x72\xFB\x8F\xDB\x95\x2F\xAC\x1C\x69\xC1\x26\x28\x31\x63\x16\x25\xA5\x2C\xF8", - 15, 32, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xE3\x71\x9F\xD8\xAE\x68\xC8\xC4\x5D\x17\xDD\x21\x33\xBB\xE1\x61\x51\x22\xC2\x3B\x00\x6E\xDD\x66\x7E\x2A\x0A\x6B\x77\xA9\x0B\x8D", - 15, 33, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xD3\xF8\x5F\x1B\xBE\x9C\x53\xCB\x7F\x5F\x5F\x62\x4D\x06\x36\x8F\xF8\x15\xA7\xF5\xEB\x77\xC6\xC5\xB4\x81\x15\x01\x82\x8D\x9D\x40", - 15, 63, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xBF\xA3\xDA\x09\xF9\xDE\x1B\xE6\x57\x4B\x55\x82\x85\x69\x79\xA1\x89\xD6\xF4\x15\x8B\x03\xFA\xAC\x6E\x00\x80\x26\xF1\x6B\xA1\x28", - 15, 64, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x77\x45\xEA\x51\x24\x46\x53\x19\x6F\xE4\xED\x6B\x54\x5C\x9B\x95\x88\xF5\xD4\x2B\x4C\x3E\xE6\xB7\xA1\xA3\x9F\xC4\x3A\x27\x1E\x45", - 15, 65, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULLPTR, - "\xFD\x61\x6D\xA6\x8E\xEF\x10\x24\x16\xC7\xBD\x7D\xC8\xCA\xF8\x2B\x3D\x92\x7B\xCB\xDD\x06\x8E\x7C\xCA\xA7\x72\x76\xCE\x6C\x8C\xD4", - 16, 0, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x10\x18\x97\x28\xFB\x05\x1D\xA0\xA8\xD6\x8F\x1C\xAD\x81\xFC\x7C\xA2\x6D\x41\x4B\xAA\x0C\x2A\x95\xB7\xF4\xEF\x9A\x67\xB5\x26\x5F", - 16, 15, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x9E\x3B\x50\xF3\xB5\xF4\xC9\xB3\x57\x03\x74\xF1\xB3\xA0\x4B\x3C\xC1\x71\xB4\x30\x42\xE4\x65\x90\xE5\xE2\x8A\x4D\xBA\xCD\xB1\x9F", - 16, 16, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x69\x70\x88\xAB\x61\x39\x46\xEA\x3B\xEB\x98\x98\x78\xCD\x8E\xF1\xB5\x7E\x81\xFC\x42\x7D\x46\xB8\xDA\x85\xD2\xEB\xB8\x56\xE4\xAC", - 16, 17, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xD2\xDA\xAC\x63\x09\xF1\x81\xBB\xCC\x06\x0D\xCC\xB8\xFA\x67\x08\x14\xD4\x6A\x50\xD7\x4F\xBF\x3B\x4A\x2E\x39\x4D\x45\x55\x27\x2F", - 16, 31, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEB\xB0\xF3\x27\xC3\xC4\x35\x97\x4F\x89\x73\x5A\x4D\xEB\xBB\x4C\x7C\xE9\x0C\x3E\x13\xEB\x07\x83\x74\x67\x0A\x86\xA7\xF4\xA8\x73", - 16, 32, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xC8\x96\xC3\x3A\x26\x77\x02\x84\x5D\x95\x1B\x0D\x9F\x5C\x07\xC5\x6D\x21\x5D\x7E\x20\xF1\x2F\xE0\x45\xE3\x50\x42\x9D\x58\xB0\xEA", - 16, 33, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x8A\x3C\x9F\xA4\xAC\x78\x82\xA7\x08\x76\xB9\xE1\xED\x22\x9B\x43\x45\xF4\xD4\x01\x76\xC4\xED\x5D\xA4\x5A\x41\xDE\x28\xB8\x09\x6C", - 16, 63, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x2D\x0C\x97\xBE\xD2\xF2\x13\x40\xB9\xC8\x15\x91\x6A\x55\x86\x7A\x43\xB1\xFD\xC7\x04\x08\x1B\x58\x37\x09\x12\x80\x40\x99\x7C\xED", - 16, 64, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xF7\xC0\x08\xE1\x31\x52\x9B\x71\x87\x51\xCF\xFF\x8B\x08\xA3\x14\x32\x08\x06\x8C\x22\xAD\x83\x97\x71\x95\xC5\x2C\xFC\x66\xA4\xAD", - 16, 65, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULLPTR, - "\xD0\xCE\x8E\x8D\xA0\xBA\xA4\x26\x0E\xD3\x1F\xD1\x7B\x78\xE6\x18\x15\xC6\xFF\xD8\x5A\xDB\x41\x8A\xE7\x36\xF0\xE7\xB9\x87\x2B\x6A", - 17, 0, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xCB\xE4\x63\xEB\x6B\x24\x6C\x08\x55\x84\x36\x30\x8E\xFA\xC1\x6B\x97\x43\xD7\x1F\x1F\x3E\x96\xBA\x7E\x87\xF2\x42\x3E\xF5\x69\x5E", - 17, 15, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEF\x39\x55\x9D\x92\x20\xDC\xB6\x8C\x21\x79\xD6\x7C\x51\xB7\x36\xAC\x4E\xFC\xA1\xDE\x66\xC7\xED\x40\xBF\x23\x15\xD1\x25\x82\x4B", - 17, 16, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xE3\x3E\x44\x7B\xA2\x7F\x69\x21\x09\x57\x79\x72\xE7\x4B\xE0\xC7\xCD\x54\xDC\xCD\x55\x60\x75\x61\x82\x66\xD7\x5B\x6F\x60\xDD\x73", - 17, 17, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xA9\xC4\x29\x2F\x5B\x49\x9A\xE0\x71\xE7\xFD\x65\x98\x53\x42\xC0\xC0\xF1\x75\xBC\xB5\x7B\x5C\xA1\x61\xFC\x8B\x45\x44\x54\xEC\x06", - 17, 31, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x29\x60\xBD\x05\x28\xEA\xF1\xA9\x43\xEF\x2D\x87\xC7\xB5\x27\x47\x33\xBA\xC8\x0C\x9F\x1C\xF5\x72\x62\x4C\xA7\x9E\x10\x23\x66\x76", - 17, 32, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xE2\xF1\x33\x23\x9D\xD8\xBC\x60\x1F\xB7\xD8\x21\xF5\x13\x98\xE2\x5C\x24\x0E\xC0\x60\x18\xB4\x0B\x93\xF1\x04\x25\xC5\xEC\x20\x14", - 17, 33, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEB\x4F\x8D\xB3\xF5\x03\x72\x55\x72\xCE\xF3\x91\x22\xCD\xEA\x5A\xC4\x9A\xD0\x42\xE1\xC4\x62\x90\xCE\x11\x9E\xFD\x11\xDB\xCA\x23", - 17, 63, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xB5\x9A\xA7\x74\xDA\xB8\xDE\x5C\xBB\xC3\x5A\xFC\xF0\xD7\xAF\x51\x1E\x0F\x05\x45\xDB\xDA\xB7\xA4\xA6\x52\xB2\x9E\x0E\x23\x14\x3D", - 17, 64, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x69\xA2\x95\x6C\x87\xED\x22\x76\x0A\x53\x75\x6D\x28\xF4\xCD\xC5\xF7\xF9\x88\x51\x73\xA7\xD9\x44\x0C\x96\xB1\x5F\xE5\x57\xFE\xE3", - 17, 65, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULLPTR, - "\x39\x4A\xB9\x85\xDD\xFF\x59\x59\x84\x5A\xF7\x54\xD6\xFC\x19\xFB\x94\x0E\xAE\xA4\xEA\x70\x54\x3E\x0D\x7E\x9D\xC7\x8A\x22\x77\x3B", - 31, 0, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x1B\x46\x57\xC0\x48\x26\x7B\xC6\x17\xEC\xD5\x76\x89\xEE\x81\xE5\x5B\xE0\xAC\xCE\xB7\x5D\x33\x2A\xAF\xB6\xE2\xF6\xC0\xBB\x93\xE6", - 31, 15, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x53\xB3\x3A\x58\x98\xD2\x0D\x25\x61\x5A\x0C\xF5\x74\x7F\x44\x2F\x51\x70\x31\x66\x5E\x41\x5E\xBC\xF5\xF0\x03\x12\x98\x12\x90\xCC", - 31, 16, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x0B\x2C\x2A\x74\x72\x12\x18\xE1\xCE\xCD\x8A\x7E\xFC\xCE\x8D\x57\xBE\x42\x1A\xCC\xA2\x20\x24\x33\xC5\x1E\x31\x54\x1F\xB6\x45\xBD", - 31, 17, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEF\x13\x95\xD4\x42\xC9\x9A\x04\xFE\xF0\x11\xE9\x72\xA9\x37\x74\x3E\x14\xC4\x4C\x58\x0C\xAC\x81\x4A\x75\x73\x35\x05\xC0\x81\x32", - 31, 31, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x0D\x35\xCF\x7F\x82\x08\x1E\x1B\xE9\x1E\x75\xE1\x96\x05\x9F\xBD\x63\x94\x8E\xE0\x71\xEF\x53\xDE\x79\xC6\x68\x21\xD6\x8A\x5A\xE4", - 31, 32, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x74\x0D\xCB\x50\x59\x59\xB9\x48\x52\x2B\x0B\x2A\x1F\xFC\x4F\x12\xF5\x9F\x49\x11\xED\x43\x61\xA6\x38\x8D\xF9\x35\x5C\xCD\x18\xBB", - 31, 33, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xDD\x48\xE5\xE8\x86\x8E\x61\xFF\x8A\x85\xC6\x5A\xB8\x5A\x32\xD2\x2A\x9C\xA2\xC8\xDC\xB9\xD6\x0A\x44\xD3\xF1\xB4\x8B\x5B\xD3\x80", - 31, 63, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x81\xEF\xAD\x79\x16\xE4\x29\x02\xDB\x89\x8D\xF2\xA4\x6D\xB4\xC4\x2A\x8C\xC6\x7E\xDE\x9B\xF7\x63\xB2\x10\xED\x15\xED\x0A\x0E\x3C", - 31, 64, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEB\x54\xC4\x8A\x8F\x92\x53\x4D\xDF\x1D\x78\xCA\x98\x38\xF9\x10\xE4\x05\xCD\x6D\xB6\x82\x3B\x76\xB7\x82\x3A\xD2\x20\x77\xD4\x89", - 31, 65, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULLPTR, - "\x18\xE3\xCE\x19\x98\x7B\xA5\x0B\x30\xDD\x14\x4C\x16\xF2\x26\x55\xEB\xA3\x14\x09\xD6\x62\x10\xBC\x38\xBB\xC1\x4B\x5D\xAB\x05\x19", - 32, 0, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x10\x9D\x6C\xB3\x37\x9C\x9E\x2B\xC9\x1C\xF9\x79\x7A\x46\xEA\xFA\x78\x5C\xA1\x54\x83\xBD\xC2\x67\x31\xFA\x66\xAC\x5D\x4C\xE7\xAB", - 32, 15, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x76\x83\x9A\x8F\xBC\x20\x81\xD6\x09\x5C\x97\x46\xD3\xD6\xA4\xC4\xC1\x17\x8E\x3B\x14\xFC\xFD\x8F\x72\x20\xEF\xC6\x0B\xD3\xFF\x42", - 32, 16, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEA\x0C\x05\xE6\x8F\xD6\xA6\xA1\xD9\xFC\xDA\x3C\xCB\x49\x02\xA5\xF9\x5D\x80\x9E\x89\xF6\xA2\x15\x74\x48\x84\x87\x77\x47\x6D\xBB", - 32, 17, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x98\x79\xD8\x91\x48\xB3\x12\x10\xE8\x49\x73\x38\x1B\xFA\x6C\xCA\x85\x59\xF9\xF9\xFE\xD3\xF2\x98\x9E\x9D\x5C\xE8\x1E\x59\xB3\x46", - 32, 31, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xC7\x41\x7E\x23\xDD\x7D\xB0\x84\xCA\x64\x26\x5A\xE0\x98\xD7\xF2\x29\xE4\x4C\x88\xC9\xF9\x15\x00\x19\x73\xC7\xCF\x95\xF5\x30\x68", - 32, 32, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\x0F\xDA\x45\x55\xAC\x8F\xB0\x17\x1D\xF2\x41\x54\xFB\x41\x26\x16\x0C\x00\x84\x49\x3D\x54\xAE\x9F\x13\xD4\xE5\x11\x2B\x42\xB5\xF5", - 32, 33, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xF1\x1B\x54\x05\xCE\x3A\xEB\xA1\x1B\x49\x99\x43\xBF\x2C\x73\x10\x0E\x35\x6B\xEA\x40\xAC\xE5\xBC\xD8\xD5\xB0\xAE\xB2\x8E\xFB\x05", - 32, 63, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xEA\xAF\xA4\xBE\xD6\x9D\x98\x73\x5E\xDF\xFC\x35\xFD\xB8\x26\x18\xAC\x15\x9E\x2B\xB2\xF9\x36\xEC\x51\x58\x1E\xD8\x53\xB7\x11\x10", - 32, 64, 32 - }, - { - "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", - "\xC3\x0A\xE0\xAB\xFA\x38\x3C\x3F\xBC\x44\xD3\x2A\x4F\xC8\xFA\x86\xF2\x15\x9E\x83\x75\x65\xE4\x78\x63\xED\xEF\x31\x79\xEC\x00\x21", - 32, 65, 32 - } - }; - - { - byte digest[BLAKE2s::DIGESTSIZE]; - for (size_t i=0; i -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough) -{ - bool pass = true, fail; - - fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "cryptosystem key validation\n"; - - const byte message[] = "test message"; - const int messageLen = 12; - SecByteBlock ciphertext(priv.CiphertextLength(messageLen)); - SecByteBlock plaintext(priv.MaxPlaintextLength(ciphertext.size())); - - pub.Encrypt(GlobalRNG(), message, messageLen, ciphertext); - fail = priv.Decrypt(GlobalRNG(), ciphertext, priv.CiphertextLength(messageLen), plaintext) != DecodingResult(messageLen); - fail = fail || std::memcmp(message, plaintext, messageLen); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "encryption and decryption\n"; - - return pass; -} - -bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d) -{ - if (d.GetCryptoParameters().Validate(GlobalRNG(), 3)) - std::cout << "passed simple key agreement domain parameters validation" << std::endl; - else - { - std::cout << "FAILED simple key agreement domain parameters invalid" << std::endl; - return false; - } - - SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength()); - SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength()); - SecByteBlock val1(d.AgreedValueLength()), val2(d.AgreedValueLength()); - - d.GenerateKeyPair(GlobalRNG(), priv1, pub1); - d.GenerateKeyPair(GlobalRNG(), priv2, pub2); - - std::memset(val1.begin(), 0x10, val1.size()); - std::memset(val2.begin(), 0x11, val2.size()); - - if (!(d.Agree(val1, priv1, pub2) && d.Agree(val2, priv2, pub1))) - { - std::cout << "FAILED simple key agreement failed" << std::endl; - return false; - } - - if (std::memcmp(val1.begin(), val2.begin(), d.AgreedValueLength())) - { - std::cout << "FAILED simple agreed values not equal" << std::endl; - return false; - } - - std::cout << "passed simple key agreement" << std::endl; - return true; -} - -bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d) -{ - if (d.GetCryptoParameters().Validate(GlobalRNG(), 3)) - std::cout << "passed authenticated key agreement domain parameters validation" << std::endl; - else - { - std::cout << "FAILED authenticated key agreement domain parameters invalid" << std::endl; - return false; - } - - SecByteBlock spriv1(d.StaticPrivateKeyLength()), spriv2(d.StaticPrivateKeyLength()); - SecByteBlock epriv1(d.EphemeralPrivateKeyLength()), epriv2(d.EphemeralPrivateKeyLength()); - SecByteBlock spub1(d.StaticPublicKeyLength()), spub2(d.StaticPublicKeyLength()); - SecByteBlock epub1(d.EphemeralPublicKeyLength()), epub2(d.EphemeralPublicKeyLength()); - SecByteBlock val1(d.AgreedValueLength()), val2(d.AgreedValueLength()); - - d.GenerateStaticKeyPair(GlobalRNG(), spriv1, spub1); - d.GenerateStaticKeyPair(GlobalRNG(), spriv2, spub2); - d.GenerateEphemeralKeyPair(GlobalRNG(), epriv1, epub1); - d.GenerateEphemeralKeyPair(GlobalRNG(), epriv2, epub2); - - std::memset(val1.begin(), 0x10, val1.size()); - std::memset(val2.begin(), 0x11, val2.size()); - - if (d.Agree(val1, spriv1, epriv1, spub2, epub2) && d.Agree(val2, spriv2, epriv2, spub1, epub1)) - { - std::cout << "passed authenticated key agreement protocol execution" << std::endl; - } - else - { - std::cout << "FAILED authenticated key agreement protocol execution" << std::endl; - return false; - } - - if (std::memcmp(val1.begin(), val2.begin(), d.AgreedValueLength())) - { - std::cout << "FAILED authenticated agreed values not equal" << std::endl; - return false; - } - - std::cout << "passed authenticated key agreement" << std::endl; - return true; -} - -bool AuthenticatedKeyAgreementWithRolesValidate(AuthenticatedKeyAgreementDomain &initiator, AuthenticatedKeyAgreementDomain &recipient) -{ - if (initiator.GetCryptoParameters().Validate(GlobalRNG(), 3)) - std::cout << "passed authenticated key agreement domain parameters validation (initiator)" << std::endl; - else - { - std::cout << "FAILED authenticated key agreement domain parameters invalid (initiator)" << std::endl; - return false; - } - - if (recipient.GetCryptoParameters().Validate(GlobalRNG(), 3)) - std::cout << "passed authenticated key agreement domain parameters validation (recipient)" << std::endl; - else - { - std::cout << "FAILED authenticated key agreement domain parameters invalid (recipient)" << std::endl; - return false; - } - - if (initiator.StaticPrivateKeyLength() != recipient.StaticPrivateKeyLength() || - initiator.EphemeralPrivateKeyLength() != recipient.EphemeralPrivateKeyLength() || - initiator.StaticPublicKeyLength() != recipient.StaticPublicKeyLength() || - initiator.EphemeralPublicKeyLength() != recipient.EphemeralPublicKeyLength() || - initiator.AgreedValueLength() != recipient.AgreedValueLength()) - { - std::cout << "FAILED authenticated key agreement domain parameter consistency" << std::endl; - return false; - } - else - { - std::cout << "passed authenticated key agreement domain parameter consistency" << std::endl; - } - - SecByteBlock spriv1(initiator.StaticPrivateKeyLength()), spriv2(recipient.StaticPrivateKeyLength()); - SecByteBlock epriv1(initiator.EphemeralPrivateKeyLength()), epriv2(recipient.EphemeralPrivateKeyLength()); - SecByteBlock spub1(initiator.StaticPublicKeyLength()), spub2(recipient.StaticPublicKeyLength()); - SecByteBlock epub1(initiator.EphemeralPublicKeyLength()), epub2(recipient.EphemeralPublicKeyLength()); - SecByteBlock val1(initiator.AgreedValueLength()), val2(recipient.AgreedValueLength()); - - initiator.GenerateStaticKeyPair(GlobalRNG(), spriv1, spub1); - recipient.GenerateStaticKeyPair(GlobalRNG(), spriv2, spub2); - initiator.GenerateEphemeralKeyPair(GlobalRNG(), epriv1, epub1); - recipient.GenerateEphemeralKeyPair(GlobalRNG(), epriv2, epub2); - - std::memset(val1.begin(), 0x10, val1.size()); - std::memset(val2.begin(), 0x11, val2.size()); - - if (initiator.Agree(val1, spriv1, epriv1, spub2, epub2) && recipient.Agree(val2, spriv2, epriv2, spub1, epub1)) - { - std::cout << "passed authenticated key agreement protocol execution" << std::endl; - } - else - { - std::cout << "FAILED authenticated key agreement protocol execution" << std::endl; - return false; - } - - if (std::memcmp(val1.begin(), val2.begin(), initiator.AgreedValueLength())) - { - std::cout << "FAILED authenticated agreed values not equal" << std::endl; - return false; - } - - std::cout << "passed authenticated key agreement shared secret" << std::endl; - return true; -} - -bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough) -{ - bool pass = true, fail; - - fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature key validation\n"; - - const byte message[] = "test message"; - const int messageLen = 12; - - SecByteBlock signature(priv.MaxSignatureLength()); - size_t signatureLength = priv.SignMessage(GlobalRNG(), message, messageLen, signature); - fail = !pub.VerifyMessage(message, messageLen, signature, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature and verification\n"; - - ++signature[0]; - fail = pub.VerifyMessage(message, messageLen, signature, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "checking invalid signature" << std::endl; - - if (priv.MaxRecoverableLength() > 0) - { - signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULLPTR, 0, signature); - SecByteBlock recovered(priv.MaxRecoverableLengthFromSignatureLength(signatureLength)); - DecodingResult result = pub.RecoverMessage(recovered, NULLPTR, 0, signature, signatureLength); - fail = !(result.isValidCoding && result.messageLength == messageLen && std::memcmp(recovered, message, messageLen) == 0); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature and verification with recovery" << std::endl; - - ++signature[0]; - result = pub.RecoverMessage(recovered, NULLPTR, 0, signature, signatureLength); - fail = result.isValidCoding; - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "recovery with invalid signature" << std::endl; - } - - return pass; -} - -bool ValidateBBS() -{ - std::cout << "\nBlumBlumShub validation suite running...\n\n"; - - Integer p("212004934506826557583707108431463840565872545889679278744389317666981496005411448865750399674653351"); - Integer q("100677295735404212434355574418077394581488455772477016953458064183204108039226017738610663984508231"); - Integer seed("63239752671357255800299643604761065219897634268887145610573595874544114193025997412441121667211431"); - BlumBlumShub bbs(p, q, seed); - bool pass = true, fail; - int j; - - const byte output1[] = { - 0x49,0xEA,0x2C,0xFD,0xB0,0x10,0x64,0xA0,0xBB,0xB9, - 0x2A,0xF1,0x01,0xDA,0xC1,0x8A,0x94,0xF7,0xB7,0xCE}; - const byte output2[] = { - 0x74,0x45,0x48,0xAE,0xAC,0xB7,0x0E,0xDF,0xAF,0xD7, - 0xD5,0x0E,0x8E,0x29,0x83,0x75,0x6B,0x27,0x46,0xA1}; - - byte buf[20]; - std::ostringstream oss; - - bbs.GenerateBlock(buf, 20); - fail = std::memcmp(output1, buf, 20) != 0; - pass = pass && !fail; - - oss << (fail ? "FAILED " : "passed "); - for (j=0;j<20;j++) - oss << std::setw(2) << std::setfill('0') << std::hex << (int)buf[j]; - oss << std::endl; - - bbs.Seek(10); - bbs.GenerateBlock(buf, 10); - fail = std::memcmp(output1+10, buf, 10) != 0; - pass = pass && !fail; - - oss << (fail ? "FAILED " : "passed "); - for (j=0;j<10;j++) - oss << std::setw(2) << std::setfill('0') << std::hex << (int)buf[j]; - oss << std::endl; - - bbs.Seek(1234567); - bbs.GenerateBlock(buf, 20); - fail = std::memcmp(output2, buf, 20) != 0; - pass = pass && !fail; - - oss << (fail ? "FAILED " : "passed "); - for (j=0;j<20;j++) - oss << std::setw(2) << std::setfill('0') << std::hex << (int)buf[j]; - oss << std::endl; - - std::cout << oss.str(); - return pass; -} - -bool ValidateECP() -{ - // Remove word recommend. Some ECP curves may not be recommended depending - // on whom you ask. ECP is more descriptive item in this case. - std::cout << "\nTesting SEC 2, NIST and Brainpool ECP curves...\n\n"; - bool pass = true; OID oid; - - while (!(oid = DL_GroupParameters_EC::GetNextRecommendedParametersOID(oid)).GetValues().empty()) - { - DL_GroupParameters_EC params(oid); - pass = params.Validate(GlobalRNG(), 2); - - // Test addition of identity element - DL_GroupParameters_EC::Element e1; - e1 = params.GetCurve().Add(e1, e1); - pass = params.IsIdentity(e1) && pass; - - // Test doubling of identity element - DL_GroupParameters_EC::Element e2; - e2 = params.GetCurve().Double(e2); - pass = params.IsIdentity(e2) && pass; - - // Test multiplication of identity element - DL_GroupParameters_EC::Element e3; - Integer two = Integer::Two(); - e3 = params.GetCurve().Multiply(two, e3); - pass = params.IsIdentity(e3) && pass; - - std::cout << (pass ? "passed" : "FAILED") << " " << std::dec << params.GetCurve().GetField().MaxElementBitLength() << " bits\n"; - } - - std::cout << "\nECP validation suite running...\n\n"; - return ValidateECP_Agreement() && ValidateECP_Encrypt() && ValidateECP_NULLDigest_Encrypt() && ValidateECP_Sign() && pass; -} - -bool ValidateEC2N() -{ - // Remove word recommend. Binary curves may not be recommended depending - // on whom you ask. EC2N is more descriptive item in this case. - std::cout << "\nTesting SEC 2 EC2N curves...\n\n"; - bool pass = true; OID oid; - -#if 1 // TODO: turn this back on when I make EC2N faster for pentanomial basis - while (!(oid = DL_GroupParameters_EC::GetNextRecommendedParametersOID(oid)).GetValues().empty()) - { - DL_GroupParameters_EC params(oid); - pass = params.Validate(GlobalRNG(), 2); - - // Test addition of identity element - DL_GroupParameters_EC::Element e1; - e1 = params.GetCurve().Add(e1, e1); - pass = params.IsIdentity(e1) && pass; - - // Test doubling of identity element - DL_GroupParameters_EC::Element e2; - e2 = params.GetCurve().Double(e2); - pass = params.IsIdentity(e2) && pass; - - // Test multiplication of identity element - DL_GroupParameters_EC::Element e3; - Integer two = Integer::Two(); - e3 = params.GetCurve().Multiply(two, e3); - pass = params.IsIdentity(e3) && pass; - - std::cout << (pass ? "passed" : "FAILED") << " " << params.GetCurve().GetField().MaxElementBitLength() << " bits\n"; - } -#endif - - std::cout << "\nEC2N validation suite running...\n\n"; - return ValidateEC2N_Agreement() && ValidateEC2N_Encrypt() && ValidateEC2N_Sign() && pass; -} - -bool ValidateRSA() -{ - std::cout << "\nRSA validation suite running...\n\n"; - return ValidateRSA_Encrypt() && ValidateRSA_Sign(); -} - -bool ValidateLUC() -{ - std::cout << "\nLUC validation suite running...\n\n"; - return ValidateLUC_Encrypt() && ValidateLUC_Sign(); -} - -bool ValidateLUC_DL() -{ - // Prologue printed in each function - return ValidateLUC_DL_Encrypt() && ValidateLUC_DL_Sign(); -} - -bool ValidateRabin() -{ - std::cout << "\nRabin validation suite running...\n\n"; - return ValidateRabin_Encrypt() && ValidateRabin_Sign(); -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat7.cpp b/vendor/cryptopp/validat7.cpp deleted file mode 100644 index ac17592e76..0000000000 --- a/vendor/cryptopp/validat7.cpp +++ /dev/null @@ -1,705 +0,0 @@ -// validat7.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "asn.h" -#include "oids.h" - -#include "sha.h" -#include "sha3.h" - -#include "dh.h" -#include "luc.h" -#include "mqv.h" -#include "xtr.h" -#include "hmqv.h" -#include "pubkey.h" -#include "xtrcrypt.h" -#include "eccrypto.h" - -// Curve25519 -#include "xed25519.h" -#include "donna.h" -#include "naclite.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -ANONYMOUS_NAMESPACE_BEGIN - -inline bool operator==(const x25519& lhs, const x25519& rhs) -{ - // This is a hack because the KeyAgreement classes do not make it easy to access the PrivateKey - ByteQueue q1, q2; - lhs.DEREncodePrivateKey(q1); - rhs.DEREncodePrivateKey(q2); - - return q1 == q2; -} - -inline bool operator!=(const x25519& lhs, const x25519& rhs) -{ - return !operator==(lhs, rhs); -} - -ANONYMOUS_NAMESPACE_END - -bool ValidateDH() -{ - std::cout << "\nDH validation suite running...\n\n"; - - FileSource f(DataDir("TestData/dh1024.dat").c_str(), true, new HexDecoder); - DH dh(f); - return SimpleKeyAgreementValidate(dh); -} - -bool ValidateX25519() -{ - std::cout << "\nx25519 validation suite running...\n\n"; - - FileSource f(DataDir("TestData/x25519.dat").c_str(), true, new HexDecoder); - x25519 dh(f); - return SimpleKeyAgreementValidate(dh); -} - -bool ValidateMQV() -{ - std::cout << "\nMQV validation suite running...\n\n"; - - FileSource f(DataDir("TestData/mqv1024.dat").c_str(), true, new HexDecoder); - MQV mqv(f); - return AuthenticatedKeyAgreementValidate(mqv); -} - -bool ValidateHMQV() -{ - std::cout << "\nHMQV validation suite running...\n\n"; - bool success = true, fail; - - FileSource f256(DataDir("TestData/hmqv256.dat").c_str(), true, new HexDecoder); - FileSource f384(DataDir("TestData/hmqv384.dat").c_str(), true, new HexDecoder); - FileSource f512(DataDir("TestData/hmqv512.dat").c_str(), true, new HexDecoder); - - ///////////////////////// - - std::cout << "HMQV with NIST P-256 and SHA-256:" << std::endl; - - ECHMQV256 hmqvB256(false); - hmqvB256.AccessGroupParameters().BERDecode(f256); - const OID oid = ASN1::secp256r1(); - ECHMQV< ECP >::Domain hmqvA256(oid, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(hmqvA256, hmqvB256); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - ///////////////////////// - - std::cout << "HMQV with NIST P-384 and SHA-384:" << std::endl; - - ECHMQV384 hmqvB384(false); - hmqvB384.AccessGroupParameters().BERDecode(f384); - const OID oid384 = ASN1::secp384r1(); - ECHMQV384 hmqvA384(oid384, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(hmqvA384, hmqvB384); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - ///////////////////////// - - std::cout << "HMQV with NIST P-521 and SHA-512:" << std::endl; - - ECHMQV512 hmqvB521(false); - hmqvB521.AccessGroupParameters().BERDecode(f512); - const OID oid521 = ASN1::secp521r1(); - ECHMQV512 hmqvA521(oid521, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(hmqvA521, hmqvB521); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - return success; -} - -bool ValidateFHMQV() -{ - std::cout << "\nFHMQV validation suite running...\n\n"; - bool success = true, fail; - - FileSource f256(DataDir("TestData/fhmqv256.dat").c_str(), true, new HexDecoder); - FileSource f384(DataDir("TestData/fhmqv384.dat").c_str(), true, new HexDecoder); - FileSource f512(DataDir("TestData/fhmqv512.dat").c_str(), true, new HexDecoder); - - ///////////////////////// - - std::cout << "FHMQV with NIST P-256 and SHA-256:" << std::endl; - - ECFHMQV256 fhmqvB256(false); - fhmqvB256.AccessGroupParameters().BERDecode(f256); - const OID oid = ASN1::secp256r1(); - ECFHMQV< ECP >::Domain fhmqvA256(oid, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(fhmqvA256, fhmqvB256); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - ///////////////////////// - - std::cout << "FHMQV with NIST P-384 and SHA-384:" << std::endl; - - ECHMQV384 fhmqvB384(false); - fhmqvB384.AccessGroupParameters().BERDecode(f384); - const OID oid384 = ASN1::secp384r1(); - ECHMQV384 fhmqvA384(oid384, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(fhmqvA384, fhmqvB384); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - ///////////////////////// - - std::cout << "FHMQV with NIST P-521 and SHA-512:" << std::endl; - - ECHMQV512 fhmqvB521(false); - fhmqvB521.AccessGroupParameters().BERDecode(f512); - const OID oid521 = ASN1::secp521r1(); - ECHMQV512 fhmqvA521(oid521, true /*client*/); - - fail = !AuthenticatedKeyAgreementWithRolesValidate(fhmqvA521, fhmqvB521); - success = !fail && success; - if (fail == false) - std::cout << "passed authenticated key agreement" << std::endl; - else - std::cout << "FAILED authenticated key agreement" << std::endl; - - return success; -} - -bool ValidateLUC_DH() -{ - std::cout << "\nLUC-DH validation suite running...\n\n"; - - FileSource f(DataDir("TestData/lucd512.dat").c_str(), true, new HexDecoder); - LUC_DH dh(f); - return SimpleKeyAgreementValidate(dh); -} - -bool ValidateXTR_DH() -{ - std::cout << "\nXTR-DH validation suite running...\n\n"; - - FileSource f(DataDir("TestData/xtrdh171.dat").c_str(), true, new HexDecoder); - XTR_DH dh(f); - return SimpleKeyAgreementValidate(dh); -} - -bool ValidateECP_Agreement() -{ - ECDH::Domain ecdhc(ASN1::secp192r1()); - ECMQV::Domain ecmqvc(ASN1::secp192r1()); - bool pass = SimpleKeyAgreementValidate(ecdhc); - pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass; - - std::cout << "Turning on point compression..." << std::endl; - ecdhc.AccessGroupParameters().SetPointCompression(true); - ecmqvc.AccessGroupParameters().SetPointCompression(true); - pass = SimpleKeyAgreementValidate(ecdhc) && pass; - pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass; - - return pass; -} - -bool ValidateEC2N_Agreement() -{ - ECDH::Domain ecdhc(ASN1::sect193r1()); - ECMQV::Domain ecmqvc(ASN1::sect193r1()); - bool pass = SimpleKeyAgreementValidate(ecdhc); - pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass; - - std::cout << "Turning on point compression..." << std::endl; - ecdhc.AccessGroupParameters().SetPointCompression(true); - ecmqvc.AccessGroupParameters().SetPointCompression(true); - pass = SimpleKeyAgreementValidate(ecdhc) && pass; - pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass; - - return pass; -} - -// TestX25519 is slightly more comprehensive than ValidateX25519 -// because it cross-validates against Bernstein's NaCL library. -// TestX25519 called in Debug builds. -bool TestX25519() -{ - std::cout << "\nTesting curve25519 Key Agreements...\n\n"; - const unsigned int AGREE_COUNT = 64; - bool pass = true, fail; - - size_t i = 0; - unsigned int failed = 0; - - SecByteBlock priv1(32), priv2(32), pub1(32), pub2(32), share1(32), share2(32); - for (i=0, failed=0; i -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -ANONYMOUS_NAMESPACE_BEGIN - -inline byte* C2B(char* ptr) { - return reinterpret_cast(ptr); -} - -inline const byte* C2B(const char* ptr) { - return reinterpret_cast(ptr); -} - -inline bool operator==(const RSA::PrivateKey& lhs, const RSA::PrivateKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetPublicExponent() == rhs.GetPublicExponent() && - lhs.GetPrivateExponent() == rhs.GetPrivateExponent(); -} - -inline bool operator!=(const RSA::PrivateKey& lhs, const RSA::PrivateKey& rhs) { - return !operator==(lhs, rhs); -} - -inline bool operator==(const RSA::PublicKey& lhs, const RSA::PublicKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetPublicExponent() == rhs.GetPublicExponent(); -} - -inline bool operator!=(const RSA::PublicKey& lhs, const RSA::PublicKey& rhs) { - return !operator==(lhs, rhs); -} - -inline bool operator==(const LUC::PrivateKey& lhs, const LUC::PrivateKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetPublicExponent() == rhs.GetPublicExponent() && - lhs.GetPrime1() == rhs.GetPrime1() && - lhs.GetPrime2() == rhs.GetPrime2() && - lhs.GetMultiplicativeInverseOfPrime2ModPrime1() == rhs.GetMultiplicativeInverseOfPrime2ModPrime1(); -} - -inline bool operator!=(const LUC::PrivateKey& lhs, const LUC::PrivateKey& rhs) { - return !operator==(lhs, rhs); -} - -inline bool operator==(const LUC::PublicKey& lhs, const LUC::PublicKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetPublicExponent() == rhs.GetPublicExponent(); -} - -inline bool operator!=(const LUC::PublicKey& lhs, const LUC::PublicKey& rhs) { - return !operator==(lhs, rhs); -} - -inline bool operator==(const Rabin::PrivateKey& lhs, const Rabin::PrivateKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetQuadraticResidueModPrime1() == rhs.GetQuadraticResidueModPrime1() && - lhs.GetQuadraticResidueModPrime2() == rhs.GetQuadraticResidueModPrime2() && - lhs.GetPrime1() == rhs.GetPrime1() && - lhs.GetPrime2() == rhs.GetPrime2() && - lhs.GetMultiplicativeInverseOfPrime2ModPrime1() == rhs.GetMultiplicativeInverseOfPrime2ModPrime1(); -} - -inline bool operator!=(const Rabin::PrivateKey& lhs, const Rabin::PrivateKey& rhs) { - return !operator==(lhs, rhs); -} - -inline bool operator==(const Rabin::PublicKey& lhs, const Rabin::PublicKey& rhs) { - return lhs.GetModulus() == rhs.GetModulus() && - lhs.GetQuadraticResidueModPrime1() == rhs.GetQuadraticResidueModPrime1() && - lhs.GetQuadraticResidueModPrime2() == rhs.GetQuadraticResidueModPrime2(); -} - -inline bool operator!=(const Rabin::PublicKey& lhs, const Rabin::PublicKey& rhs) { - return !operator==(lhs, rhs); -} - -ANONYMOUS_NAMESPACE_END - -bool ValidateRSA_Encrypt() -{ - // Must be large enough for RSA-3072 to test SHA3_256 - byte out[256], outPlain[128]; - bool pass = true, fail; - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - { - FileSource keys(DataDir("TestData/rsa1024.dat").c_str(), true, new HexDecoder); - RSA::PrivateKey rsaPriv; rsaPriv.Load(keys); - RSA::PublicKey rsaPub(rsaPriv); - - const Integer& n = rsaPriv.GetModulus(); - const Integer& e = rsaPriv.GetPublicExponent(); - const Integer& d = rsaPriv.GetPrivateExponent(); - - RSA::PrivateKey rsaPriv2; - rsaPriv2.Initialize(n, e, d); - - fail = (rsaPriv != rsaPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "RSA::PrivateKey initialization\n"; - - RSA::PublicKey rsaPub2; - rsaPub2.Initialize(n, e); - - fail = (rsaPub != rsaPub2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "RSA::PublicKey initialization\n"; - } - { - FileSource keys(DataDir("TestData/rsa1024.dat").c_str(), true, new HexDecoder); - RSA::PrivateKey rsaPriv; rsaPriv.Load(keys); - - ByteQueue q; - rsaPriv.DEREncodePrivateKey(q); - - RSA::PrivateKey rsaPriv2; - rsaPriv2.BERDecodePrivateKey(q, true, (size_t)q.MaxRetrievable()); - - fail = (rsaPriv != rsaPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "RSA::PrivateKey encoding and decoding\n"; - } -#endif - - { - FileSource keys(DataDir("TestData/rsa1024.dat").c_str(), true, new HexDecoder); - RSAES_PKCS1v15_Decryptor rsaPriv(keys); - RSAES_PKCS1v15_Encryptor rsaPub(rsaPriv); - - fail = !CryptoSystemValidate(rsaPriv, rsaPub); - pass = pass && !fail; - } - { - RSAES_OAEP_SHA_Decryptor rsaPriv(GlobalRNG(), 512); - RSAES_OAEP_SHA_Encryptor rsaPub(rsaPriv); - - fail = !CryptoSystemValidate(rsaPriv, rsaPub); - pass = pass && !fail; - } - { - RSAES_OAEP_SHA256_Decryptor rsaPriv(GlobalRNG(), 1024); - RSAES_OAEP_SHA256_Encryptor rsaPub(rsaPriv); - - fail = !CryptoSystemValidate(rsaPriv, rsaPub); - pass = pass && !fail; - } - { - const byte plain[] = - "\x54\x85\x9b\x34\x2c\x49\xea\x2a"; - const byte encrypted[] = - "\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a" - "\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4" - "\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52" - "\x62\x51"; - const byte oaepSeed[] = - "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2" - "\xf0\x6c\xb5\x8f"; - ByteQueue bq; - bq.Put(oaepSeed, 20); - FixedRNG rng(bq); - - FileSource privFile(DataDir("TestData/rsa400pv.dat").c_str(), true, new HexDecoder); - FileSource pubFile(DataDir("TestData/rsa400pb.dat").c_str(), true, new HexDecoder); - RSAES_OAEP_SHA_Decryptor rsaPriv; - rsaPriv.AccessKey().BERDecodePrivateKey(privFile, false, 0); - RSAES_OAEP_SHA_Encryptor rsaPub(pubFile); - - std::memset(out, 0, 50); - std::memset(outPlain, 0, 8); - rsaPub.Encrypt(rng, plain, 8, out); - DecodingResult result = rsaPriv.FixedLengthDecrypt(GlobalRNG(), encrypted, outPlain); - fail = !result.isValidCoding || (result.messageLength!=8) || std::memcmp(out, encrypted, 50) || std::memcmp(plain, outPlain, 8); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "PKCS 2.0 encryption and decryption\n"; - } - - return pass; -} - -bool ValidateLUC_Encrypt() -{ - bool pass = true, fail; - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - { - FileSource keys(DataDir("TestData/luc1024.dat").c_str(), true, new HexDecoder); - LUC::PrivateKey lucPriv; lucPriv.BERDecode(keys); - LUC::PublicKey lucPub(lucPriv); - - const Integer& n = lucPriv.GetModulus(); - const Integer& e = lucPriv.GetPublicExponent(); - const Integer& p = lucPriv.GetPrime1(); - const Integer& q = lucPriv.GetPrime2(); - const Integer& u = lucPriv.GetMultiplicativeInverseOfPrime2ModPrime1(); - - LUC::PrivateKey lucPriv2; - lucPriv2.Initialize(n, e, p, q, u); - - fail = (lucPriv != lucPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "LUC::PrivateKey initialization\n"; - - LUC::PublicKey lucPub2; - lucPub2.Initialize(n, e); - - fail = (lucPub != lucPub2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "LUC::PublicKey initialization\n"; - } - { - FileSource keys(DataDir("TestData/luc1024.dat").c_str(), true, new HexDecoder); - LUC::PrivateKey lucPriv; lucPriv.BERDecode(keys); - - ByteQueue q; - lucPriv.DEREncode(q); - - LUC::PrivateKey lucPriv2; - lucPriv2.BERDecode(q); - - fail = (lucPriv != lucPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "LUC::PrivateKey encoding and decoding\n"; - } - { - FileSource keys(DataDir("TestData/luc1024.dat").c_str(), true, new HexDecoder); - LUC::PrivateKey lucPriv; lucPriv.BERDecode(keys); - LUC::PublicKey lucPub(lucPriv); - - ByteQueue q; - lucPub.DEREncode(q); - - LUC::PublicKey lucPub2; - lucPub2.BERDecode(q); - - fail = (lucPub != lucPub2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "LUC::PublicKey encoding and decoding\n"; - } -#endif - - LUCES_OAEP_SHA_Decryptor priv(GlobalRNG(), 512); - LUCES_OAEP_SHA_Encryptor pub(priv); - fail = !CryptoSystemValidate(priv, pub); - pass = pass && !fail; - - return pass; -} - -bool ValidateLUC_DL_Encrypt() -{ - std::cout << "\nLUC-IES validation suite running...\n\n"; - - FileSource fc(DataDir("TestData/lucc512.dat").c_str(), true, new HexDecoder); - LUC_IES<>::Decryptor privC(fc); - LUC_IES<>::Encryptor pubC(privC); - return CryptoSystemValidate(privC, pubC); -} - -bool ValidateRabin_Encrypt() -{ - bool pass = true, fail; - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) - { - FileSource keys(DataDir("TestData/rabi1024.dat").c_str(), true, new HexDecoder); - Rabin::PrivateKey rabinPriv; rabinPriv.BERDecode(keys); - Rabin::PublicKey rabinPub(rabinPriv); - - const Integer& n = rabinPriv.GetModulus(); - const Integer& r = rabinPriv.GetQuadraticResidueModPrime1(); - const Integer& s = rabinPriv.GetQuadraticResidueModPrime2(); - const Integer& p = rabinPriv.GetPrime1(); - const Integer& q = rabinPriv.GetPrime2(); - const Integer& u = rabinPriv.GetMultiplicativeInverseOfPrime2ModPrime1(); - - Rabin::PrivateKey rabinPriv2; - rabinPriv2.Initialize(n, r, s, p, q, u); - - fail = (rabinPriv != rabinPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "Rabin::PrivateKey initialization\n"; - - Rabin::PublicKey rabinPub2; - rabinPub2.Initialize(n, r, s); - - fail = (rabinPub != rabinPub2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "Rabin::PublicKey initialization\n"; - } - { - FileSource keys(DataDir("TestData/rabi1024.dat").c_str(), true, new HexDecoder); - Rabin::PrivateKey rabinPriv; rabinPriv.BERDecode(keys); - - ByteQueue q; - rabinPriv.DEREncode(q); - - Rabin::PrivateKey rabinPriv2; - rabinPriv2.BERDecode(q); - - fail = (rabinPriv != rabinPriv2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "Rabin::PrivateKey encoding and decoding\n"; - } - { - FileSource keys(DataDir("TestData/rabi1024.dat").c_str(), true, new HexDecoder); - Rabin::PrivateKey rabinPriv; rabinPriv.BERDecode(keys); - Rabin::PublicKey rabinPub(rabinPriv); - - ByteQueue q; - rabinPub.DEREncode(q); - - Rabin::PublicKey rabinPub2; - rabinPub2.BERDecode(q); - - fail = (rabinPub != rabinPub2); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "Rabin::PublicKey encoding and decoding\n"; - } -#endif - - FileSource f(DataDir("TestData/rabi1024.dat").c_str(), true, new HexDecoder); - RabinES >::Decryptor priv(f); - RabinES >::Encryptor pub(priv); - fail = !CryptoSystemValidate(priv, pub); - pass = pass && !fail; - - return pass; -} - -bool ValidateECP_Encrypt() -{ - ECIES::Decryptor cpriv(GlobalRNG(), ASN1::secp192r1()); - ECIES::Encryptor cpub(cpriv); - ByteQueue bq; - cpriv.GetKey().DEREncode(bq); - cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); - cpub.GetKey().DEREncode(bq); - - cpub.AccessKey().Precompute(); - cpriv.AccessKey().Precompute(); - bool pass = CryptoSystemValidate(cpriv, cpub); - - std::cout << "Turning on point compression..." << std::endl; - cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true); - cpub.AccessKey().AccessGroupParameters().SetPointCompression(true); - pass = CryptoSystemValidate(cpriv, cpub) && pass; - - return pass; -} - -// https://github.com/weidai11/cryptopp/issues/856 -// Not to be confused with NullHash in trunhash.h. -class NULL_Hash : public CryptoPP::IteratedHashWithStaticTransform - -{ -public: - static void InitState(HashWordType *state) { - CRYPTOPP_UNUSED(state); - } - static void Transform(CryptoPP::word32 *digest, const CryptoPP::word32 *data) { - CRYPTOPP_UNUSED(digest); CRYPTOPP_UNUSED(data); - } - static const char *StaticAlgorithmName() { - return "NULL_Hash"; - } -}; - -// https://github.com/weidai11/cryptopp/issues/856 -template -struct ECIES_NULLDigest - : public DL_ES< - DL_Keys_EC, - DL_KeyAgreementAlgorithm_DH, - DL_KeyDerivationAlgorithm_P1363 >, - DL_EncryptionAlgorithm_Xor, DHAES_MODE, LABEL_OCTETS>, - ECIES > -{ - // TODO: fix this after name is standardized - CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECIES-NULLDigest";} -}; - -bool ValidateECP_NULLDigest_Encrypt() -{ - ECIES_NULLDigest::Decryptor cpriv(GlobalRNG(), ASN1::secp256k1()); - ECIES_NULLDigest::Encryptor cpub(cpriv); - ByteQueue bq; - cpriv.GetKey().DEREncode(bq); - cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); - cpub.GetKey().DEREncode(bq); - - cpub.AccessKey().Precompute(); - cpriv.AccessKey().Precompute(); - bool pass = CryptoSystemValidate(cpriv, cpub); - - std::cout << "Turning on point compression..." << std::endl; - cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true); - cpub.AccessKey().AccessGroupParameters().SetPointCompression(true); - pass = CryptoSystemValidate(cpriv, cpub) && pass; - - return pass; -} - -// Ensure interop with Crypto++ 5.6.4 and earlier -bool ValidateECP_Legacy_Encrypt() -{ - std::cout << "\nLegacy ECIES ECP validation suite running...\n\n"; - bool pass = true; - { - FileSource fc(DataDir("TestData/ecies_p160.dat").c_str(), true, new HexDecoder); - ECIES::Decryptor privC(fc); - ECIES::Encryptor pubC(privC); - - pass = CryptoSystemValidate(privC, pubC) && pass; - - // Test data generated by Crypto++ 5.6.2. - // Also see https://github.com/weidai11/cryptopp/pull/857. - const std::string plain = "Yoda said, Do or do not. There is no try."; - const std::string cipher = - "\x04\xF6\xC1\xB1\xFA\xAC\x8A\xD5\xD3\x96\xE7\x13\xAE\xBD\x0C\xCE" - "\x15\xCF\x44\x54\x08\x63\xCC\xBF\x89\x4D\xD0\xB8\x38\xA1\x3A\xB2" - "\x90\x75\x86\x82\x7F\x9D\x95\x26\xA5\x74\x13\x3A\x74\x63\x11\x71" - "\x70\x4C\x01\xA4\x08\x04\x95\x69\x6A\x91\xF0\xC0\xA4\xBD\x1E\xAA" - "\x59\x57\xB8\xA9\xD2\xF7\x7C\x98\xE3\xC5\xE3\xF4\x4F\xA7\x6E\x73" - "\x83\xF3\x1E\x05\x73\xA4\xEE\x63\x55\xFD\x6D\x31\xBB\x9E\x36\x4C" - "\x79\xD0\x76\xC0\x0D\xE9"; - - std::string recover; - recover.resize(privC.MaxPlaintextLength(cipher.size())); - - DecodingResult result = privC.Decrypt(GlobalRNG(), C2B(&cipher[0]), cipher.size(), C2B(&recover[0])); - if (result.isValidCoding) - recover.resize(result.messageLength); - else - recover.resize(0); - - pass = (plain == recover) && pass; - std::cout << (pass ? "passed " : "FAILED "); - std::cout << "decryption known answer\n"; - } - return pass; -} - -// Ensure interop with Crypto++ 5.6.4 and earlier -bool ValidateEC2N_Legacy_Encrypt() -{ - std::cout << "\nLegacy ECIES EC2N validation suite running...\n\n"; - bool pass = true; - { - FileSource fc(DataDir("TestData/ecies_t163.dat").c_str(), true, new HexDecoder); - ECIES::Decryptor privC(fc); - ECIES::Encryptor pubC(privC); - - pass = CryptoSystemValidate(privC, pubC) && pass; - - // Test data generated by Crypto++ 5.6.2. - // Also see https://github.com/weidai11/cryptopp/pull/857. - const std::string plain = "Yoda said, Do or do not. There is no try."; - const std::string cipher = - "\x04\x01\x3F\x64\x94\x6A\xBE\x2B\x7E\x48\x67\x63\xA2\xD4\x01\xEF" - "\x2B\x13\x1C\x9A\x1B\x7C\x07\x4B\x89\x78\x6C\x65\x51\x1C\x1A\x4E" - "\x20\x7F\xB5\xBF\x12\x3B\x6E\x0A\x87\xFD\xB7\x94\xEF\x4B\xED\x40" - "\xD4\x7A\xCF\xB6\xFC\x9B\x6D\xB0\xB8\x43\x99\x7E\x37\xC1\xF0\xC0" - "\x95\xD4\x80\xE1\x8B\x84\xAE\x64\x9F\xA5\xBA\x32\x95\x8A\xD1\xBE" - "\x7F\xDE\x7E\xA9\xE6\x59\xBF\x89\xA6\xE9\x9F\x5B\x64\xB4\xDD\x0E" - "\x76\xB6\x82\xF6\xA9\xAD\xB5\xC4"; - - std::string recover; - recover.resize(privC.MaxPlaintextLength(cipher.size())); - - DecodingResult result = privC.Decrypt(GlobalRNG(), C2B(&cipher[0]), cipher.size(), C2B(&recover[0])); - if (result.isValidCoding) - recover.resize(result.messageLength); - else - recover.resize(0); - - pass = (plain == recover) && pass; - std::cout << (pass ? "passed " : "FAILED "); - std::cout << "decryption known answer\n"; - } - return pass; -} - -bool ValidateEC2N_Encrypt() -{ - // DEREncode() changed to Save() at Issue 569. - ECIES::Decryptor cpriv(GlobalRNG(), ASN1::sect193r1()); - ECIES::Encryptor cpub(cpriv); - ByteQueue bq; - cpriv.AccessMaterial().Save(bq); - cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); - cpub.AccessMaterial().Save(bq); - bool pass = CryptoSystemValidate(cpriv, cpub); - - std::cout << "Turning on point compression..." << std::endl; - cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true); - cpub.AccessKey().AccessGroupParameters().SetPointCompression(true); - pass = CryptoSystemValidate(cpriv, cpub) && pass; - - return pass; -} - -bool ValidateElGamal() -{ - std::cout << "\nElGamal validation suite running...\n\n"; - bool pass = true; - { - // Data from https://github.com/weidai11/cryptopp/issues/876. - const std::string encodedPublicKey = - "MHYwTwYGKw4HAgEBMEUCIQDebUvQDd9UPMmD27BJ ovZSIgWfexL0SWkfJQPMLsJvMwIgDy/kEthwO6Q+" - "L8XHnzumnEKs+txH8QkQD+M/8u82ql0DIwACIAY6 rfW+BTcRZ9QAJovgoB8DgNLJ8ocqOeF4nEBB0DHH"; - StringSource decodedPublicKey(encodedPublicKey, true, new Base64Decoder); - - ElGamal::PublicKey publicKey; - publicKey.Load(decodedPublicKey); - pass = publicKey.Validate(GlobalRNG(), 3) && pass; - } - { - // Data from https://github.com/weidai11/cryptopp/issues/876. - const std::string encodedPrivateKey = - "MHkCAQAwTwYGKw4HAgEBMEUCIQDebUvQDd9UPMmD 27BJovZSIgWfexL0SWkfJQPMLsJvMwIgDy/kEthw" - "O6Q+L8XHnzumnEKs+txH8QkQD+M/8u82ql0EIwIh AJb0S4TZLvApTVjXZyocPJ5tUgWgRqScXm5vNqu2" - "YqdM"; - StringSource decodedPrivateKey(encodedPrivateKey, true, new Base64Decoder); - - ElGamal::PrivateKey privateKey; - privateKey.Load(decodedPrivateKey); - pass = privateKey.Validate(GlobalRNG(), 3) && pass; - } - { - FileSource fc(DataDir("TestData/elgc1024.dat").c_str(), true, new HexDecoder); - ElGamalDecryptor privC(fc); - ElGamalEncryptor pubC(privC); - privC.AccessKey().Precompute(); - ByteQueue queue; - privC.AccessKey().SavePrecomputation(queue); - privC.AccessKey().LoadPrecomputation(queue); - - pass = CryptoSystemValidate(privC, pubC) && pass; - } - return pass; -} - -bool ValidateDLIES() -{ - std::cout << "\nDLIES validation suite running...\n\n"; - bool pass = true; - { - FileSource fc(DataDir("TestData/dlie1024.dat").c_str(), true, new HexDecoder); - DLIES<>::Decryptor privC(fc); - DLIES<>::Encryptor pubC(privC); - pass = CryptoSystemValidate(privC, pubC) && pass; - } - { - std::cout << "Generating new encryption key..." << std::endl; - DLIES<>::GroupParameters gp; - gp.GenerateRandomWithKeySize(GlobalRNG(), 128); - DLIES<>::Decryptor decryptor; - decryptor.AccessKey().GenerateRandom(GlobalRNG(), gp); - DLIES<>::Encryptor encryptor(decryptor); - - pass = CryptoSystemValidate(decryptor, encryptor) && pass; - } - return pass; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validat9.cpp b/vendor/cryptopp/validat9.cpp deleted file mode 100644 index d4ee587413..0000000000 --- a/vendor/cryptopp/validat9.cpp +++ /dev/null @@ -1,735 +0,0 @@ -// validat9.cpp - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017. -// Source files split in July 2018 to expedite compiles. - -#include "pch.h" - -#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 - -#include "cryptlib.h" -#include "cpu.h" -#include "validate.h" - -#include "asn.h" -#include "oids.h" - -#include "md2.h" -#include "md4.h" -#include "md5.h" - -#include "sha.h" -#include "sha3.h" -#include "pssr.h" -#include "ripemd.h" -#include "whrlpool.h" - -#include "rw.h" -#include "dsa.h" -#include "luc.h" -#include "rsa.h" -#include "esign.h" -#include "rabin.h" -#include "pubkey.h" -#include "eccrypto.h" - -// Curve25519 -#include "xed25519.h" -#include "donna.h" -#include "naclite.h" - -#include -#include -#include - -// Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_FULL_VER >= 140050727) -# pragma strict_gs_check (on) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -bool ValidateRSA_Sign() -{ - // Must be large enough for RSA-3072 to test SHA3_256 - byte out[256]; - bool pass = true, fail; - - { - const char plain[] = "Everyone gets Friday off."; - const byte signature[] = - "\x05\xfa\x6a\x81\x2f\xc7\xdf\x8b\xf4\xf2\x54\x25\x09\xe0\x3e\x84" - "\x6e\x11\xb9\xc6\x20\xbe\x20\x09\xef\xb4\x40\xef\xbc\xc6\x69\x21" - "\x69\x94\xac\x04\xf3\x41\xb5\x7d\x05\x20\x2d\x42\x8f\xb2\xa2\x7b" - "\x5c\x77\xdf\xd9\xb1\x5b\xfc\x3d\x55\x93\x53\x50\x34\x10\xc1\xe1"; - - FileSource keys(DataDir("TestData/rsa512a.dat").c_str(), true, new HexDecoder); - Weak::RSASSA_PKCS1v15_MD2_Signer rsaPriv(keys); - Weak::RSASSA_PKCS1v15_MD2_Verifier rsaPub(rsaPriv); - - size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out); - CRYPTOPP_ASSERT(signatureLength <= sizeof(out)); - fail = std::memcmp(signature, out, signatureLength) != 0; - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature check against test vector\n"; - - fail = !rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "verification check against test vector\n"; - - out[10]++; - fail = rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "invalid signature verification\n"; - } - ///// - { - const char plain[] = "Everyone gets Friday off."; - const byte signature[] = - "\x2e\x87\xda\x1f\xe4\xda\x1d\x7a\xb7\xf2\x42\x36\xe9\xc0\x4e\xab\x3f\x03\x71\xe1" - "\x2b\xc5\x3c\xbf\x21\x21\xa8\xd6\x28\xb0\x08\xfd\x9c\xf6\x94\xbd\x37\x32\xda\xfc" - "\x42\x1c\x8e\xdb\x8a\x81\x90\x46\x45\xb4\xde\x9e\xce\x90\xfe\xa1\xfd\xbc\x5a\xce" - "\xca\x59\x89\x93\xc0\x0f\x2f\xf1\x13\xb0\xf5\x3d\xa3\x9a\x85\xb7\x40\xd9\x34\x88" - "\x29\xb2\x4a\x0f\x9b\xbe\x22\x3a\x5b\x54\x51\xb7\xf0\x10\x72\x50\xc4\x2a\xe9\xe4" - "\xc3\x82\xeb\x32\x33\x14\xb6\xf2\x7b\x30\x7a\xbf\xc2\xf3\x0f\x4d\x72\xa0\x8d\xa1" - "\xc6\xce\xd0\xa3\x3c\xf7\x23\x4b\xb7\x2c\x5e\xca\x83\x01\xc7\x5c\xd5\xd0\xd1\x94" - "\x43\xf0\xad\xa2\xe6\x72\x2b\x13\x39\xb2\x4b\x25\x91\x3a\x4f\x53\x05\x00\x8c\xc7" - "\xcf\x4f\x11\x64\xe6\xf4\x1a\x4d\x90\x7e\xf1\xfe\xed\xec\x8d\xbb\x00\x31\x2e\x03" - "\xbe\x87\x84\x60\xfb\x5e\xef\x9d\x18\x2c\x28\x3d\xaa\x67\x80\xa3\x62\x07\x06\x5e" - "\xce\xee\x3b\xd0\x78\xb5\x98\x38\x1e\xe8\x62\x19\x9c\xc3\xd4\xf7\xc2\xc5\x00\xf0" - "\xeb\x89\x65\x53\x35\xe7\x13\x7e\xbb\x26\xb0\x76\x9c\xf2\x80\xaa\xe1\xb1\x0a\xa6" - "\x47\xfc\x5f\xe0\x7f\x82\xd7\x83\x41\xc3\x50\xa1\xe0\x0e\x1a\xe4"; - - FileSource keys(DataDir("TestData/rsa2048a.dat").c_str(), true, new HexDecoder); - RSASS::Signer rsaPriv(keys); - RSASS::Verifier rsaPub(rsaPriv); - - size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out); - CRYPTOPP_ASSERT(signatureLength <= sizeof(out)); - fail = std::memcmp(signature, out, signatureLength) != 0; - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature check against test vector\n"; - - fail = !rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "verification check against test vector\n"; - - out[10]++; - fail = rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "invalid signature verification\n"; - } - - return pass; -} - -bool ValidateNR() -{ - std::cout << "\nNR validation suite running...\n\n"; - bool pass = true; - { - FileSource f(DataDir("TestData/nr2048.dat").c_str(), true, new HexDecoder); - NR::Signer privS(f); - privS.AccessKey().Precompute(); - NR::Verifier pubS(privS); - - pass = SignatureValidate(privS, pubS) && pass; - } - { - std::cout << "Generating new signature key..." << std::endl; - NR::Signer privS(GlobalRNG(), 256); - NR::Verifier pubS(privS); - - pass = SignatureValidate(privS, pubS) && pass; - } - return pass; -} - -bool ValidateDSA(bool thorough) -{ - std::cout << "\nDSA validation suite running...\n\n"; - - bool pass = true; - FileSource fs1(DataDir("TestData/dsa1024.dat").c_str(), true, new HexDecoder); - DSA::Signer priv(fs1); - DSA::Verifier pub(priv); - FileSource fs2(DataDir("TestData/dsa1024b.dat").c_str(), true, new HexDecoder); - DSA::Verifier pub1(fs2); - CRYPTOPP_ASSERT(pub.GetKey() == pub1.GetKey()); - pass = SignatureValidate(priv, pub, thorough) && pass; - - return pass; -} - -bool ValidateLUC_Sign() -{ - FileSource f(DataDir("TestData/luc1024.dat").c_str(), true, new HexDecoder); - LUCSSA_PKCS1v15_SHA_Signer priv(f); - LUCSSA_PKCS1v15_SHA_Verifier pub(priv); - return SignatureValidate(priv, pub); -} - -bool ValidateLUC_DL_Sign() -{ - std::cout << "\nLUC-HMP validation suite running...\n\n"; - - FileSource f(DataDir("TestData/lucs512.dat").c_str(), true, new HexDecoder); - LUC_HMP::Signer privS(f); - LUC_HMP::Verifier pubS(privS); - return SignatureValidate(privS, pubS); -} - -bool ValidateRabin_Sign() -{ - FileSource f(DataDir("TestData/rabi1024.dat").c_str(), true, new HexDecoder); - RabinSS::Signer priv(f); - RabinSS::Verifier pub(priv); - return SignatureValidate(priv, pub); -} - -bool ValidateRW() -{ - std::cout << "\nRW validation suite running...\n\n"; - - FileSource f(DataDir("TestData/rw1024.dat").c_str(), true, new HexDecoder); - RWSS::Signer priv(f); - RWSS::Verifier pub(priv); - - return SignatureValidate(priv, pub); -} - -bool ValidateECP_Sign() -{ - ECDSA::Signer spriv(GlobalRNG(), ASN1::secp192r1()); - ECDSA::Verifier spub(spriv); - ByteQueue bq; - spriv.GetKey().DEREncode(bq); - spub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); - spub.GetKey().DEREncode(bq); - spriv.AccessKey().BERDecode(bq); - spub.AccessKey().BERDecode(bq); - - spriv.AccessKey().Precompute(); - ByteQueue queue; - spriv.AccessKey().SavePrecomputation(queue); - spriv.AccessKey().LoadPrecomputation(queue); - - return SignatureValidate(spriv, spub); -} - -bool ValidateEC2N_Sign() -{ - // DEREncode() changed to Save() at Issue 569. - ECDSA::Signer spriv(GlobalRNG(), ASN1::sect193r1()); - ECDSA::Verifier spub(spriv); - ByteQueue bq; - spriv.AccessMaterial().Save(bq); - spub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); - spub.AccessMaterial().Save(bq); - spriv.AccessMaterial().Load(bq); - spub.AccessMaterial().Load(bq); - - spriv.AccessKey().Precompute(); - ByteQueue queue; - spriv.AccessKey().SavePrecomputation(queue); - spriv.AccessKey().LoadPrecomputation(queue); - - return SignatureValidate(spriv, spub); -} - -bool ValidateECDSA() -{ - std::cout << "\nECDSA validation suite running...\n\n"; - - // from Sample Test Vectors for P1363 - GF2NT gf2n(191, 9, 0); - const byte a[]="\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67"; - const byte b[]="\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC"; - EC2N ec(gf2n, PolynomialMod2(a,24), PolynomialMod2(b,24)); - - EC2N::Point P; - bool result = ec.DecodePoint(P, (byte *)"\x04\x36\xB3\xDA\xF8\xA2\x32\x06\xF9\xC4\xF2\x99\xD7\xB2\x1A\x9C\x36\x91\x37\xF2\xC8\x4A\xE1\xAA\x0D" - "\x76\x5B\xE7\x34\x33\xB3\xF9\x5E\x33\x29\x32\xE7\x0E\xA2\x45\xCA\x24\x18\xEA\x0E\xF9\x80\x18\xFB", ec.EncodedPointSize()); - CRYPTOPP_ASSERT(result); CRYPTOPP_UNUSED(result); - - Integer n("40000000000000000000000004a20e90c39067c893bbb9a5H"); - Integer d("340562e1dda332f9d2aec168249b5696ee39d0ed4d03760fH"); - EC2N::Point Q(ec.Multiply(d, P)); - ECDSA::Signer priv(ec, P, n, d); - ECDSA::Verifier pub(priv); - - Integer h("A9993E364706816ABA3E25717850C26C9CD0D89DH"); - Integer k("3eeace72b4919d991738d521879f787cb590aff8189d2b69H"); - const byte sig[]="\x03\x8e\x5a\x11\xfb\x55\xe4\xc6\x54\x71\xdc\xd4\x99\x84\x52\xb1\xe0\x2d\x8a\xf7\x09\x9b\xb9\x30" - "\x0c\x9a\x08\xc3\x44\x68\xc2\x44\xb4\xe5\xd6\xb2\x1b\x3c\x68\x36\x28\x07\x41\x60\x20\x32\x8b\x6e"; - Integer r(sig, 24); - Integer s(sig+24, 24); - - Integer rOut, sOut; - bool fail, pass=true; - - priv.RawSign(k, h, rOut, sOut); - fail = (rOut != r) || (sOut != s); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "signature check against test vector\n"; - - fail = !pub.VerifyMessage((byte *)"abc", 3, sig, sizeof(sig)); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "verification check against test vector\n"; - - fail = pub.VerifyMessage((byte *)"xyz", 3, sig, sizeof(sig)); - pass = pass && !fail; - - pass = SignatureValidate(priv, pub) && pass; - - return pass; -} - -bool ValidateECDSA_RFC6979() -{ - std::cout << "\nRFC6979 deterministic ECDSA validation suite running...\n\n"; - - DL_Algorithm_ECDSA_RFC6979 sign; - - const Integer x("09A4D6792295A7F730FC3F2B49CBC0F62E862272Fh"); - const Integer e("AF2BDBE1AA9B6EC1E2ADE1D694F41FC71A831D0268E9891562113D8A62ADD1BFh"); - const Integer q("4000000000000000000020108A2E0CC0D99F8A5EFh"); - const Integer k("23AF4074C90A02B3FE61D286D5C87F425E6BDD81Bh"); - const Integer &k_out = sign.GenerateRandom(x, q, e); - - bool pass = (k_out == k); - - std::cout << (pass ? "passed " : "FAILED "); - std::cout << "deterministic k generation against test vector\n"; - - return pass; -} - -// from http://www.teletrust.de/fileadmin/files/oid/ecgdsa_final.pdf -// ValidateECGDSA split into standard and thorough due to GH #1134 -bool ValidateECGDSAStandard() -{ - bool fail, pass=true; - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-1 (p. 19) - { - const OID oid = ASN1::brainpoolP192r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 80F2425E 89B4F585 F27F3536 ED834D68 E3E492DE 08FE84B9"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 CF00CD42 CAA80DDF 8DDEBDFD 32F2DA15 11B53F29"); - Integer k("0x 22C17C2A 367DD85A B8A365ED 06F19C43 F9ED1834 9A9BC044"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 2D017BE7 F117FF99 4ED6FC63 CA5B4C7A 0430E9FA 095DAFC4"); - Integer sExp("0x 18FD604E 5F00F55B 3585C052 8C319A2B 05B8F2DD EE9CF1A6"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function SHA-1"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP192r1 using SHA-1\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-224 (p. 23) - { - const OID oid = ASN1::brainpoolP320r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 00000000 00000000 92AE8A0E 8D08EADE E9426378 714FF3E0 1957587D 2876FA70 D40E3144"); - Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6"); - Integer sExp("0x 6EA191CA 0D468AC3 E9568768 9338357C 7D0BACB3 F1D87E0D EC05F635 B7ADB842 75AA0086 60F812CF"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function SHA-224"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP320r1 using SHA-224\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-256 (p. 27) - { - const OID oid = ASN1::brainpoolP320r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 00000000 37ED8AA9 4AE667DB BB753330 E050EB8E 12195807 ECDC4FB1 0E0662B4 22C219D7"); - Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6"); - Integer sExp("0x 24370797 A9D11717 BBBB2B76 2E08ECD0 7DD7E033 F544E47C BF3C6D16 FD90B51D CC2E4DD8 E6ECD8CD"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function SHA-256"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP320r1 using SHA-256\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-384 (p. 34) - { - const OID oid = ASN1::brainpoolP512r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 00000000 00000000 00000000 68FEAB7D 8BF8A779 4466E447 5959946B 2136C084 A86090CA 8070C980 68B1250D 88213190 6B7E0CB8 475F9054 E9290C2E"); - Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48"); - Integer sExp("0x 3D233E9F D9EB152E 889F4F7C F325B464 0894E5EA 44C51443 54305CD4 BF70D234 8257C2DB E06C5544 92CE9FDD 6861A565 77B53E5E E80E6062 31A4CF06 8FA1EC21"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function SHA-384"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP512r1 using SHA-384\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-512 (p. 38) - { - const OID oid = ASN1::brainpoolP512r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 1A95EF81 D213BD3B 8191E7FE 7F5BFD43 F51E3EE5 A4FD3D08 4A7C9BB5 411F4649 746AEBC6 623D4DEA 7E02DC5A 85E24AF2 96B5A555 AD470413 71E4BF64 380F3E34"); - Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48"); - Integer sExp("0x 17A011F8 DD7B5665 2B27AA6D 6E7BDF3C 7C23B5FA 32910FBA A107E627 0E1CA8A7 A263F661 8E6098A0 D6CD6BA1 C03544C5 425875EC B3418AF5 A3EE3F32 143E48D2"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function SHA-512"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP512r1 using SHA-512\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - return pass; -} - -// from http://www.teletrust.de/fileadmin/files/oid/ecgdsa_final.pdf -// ValidateECGDSA split into standard and thorough due to GH #1134 -bool ValidateECGDSAThorough() -{ - bool fail, pass=true; - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 10) - { - const OID oid = ASN1::brainpoolP192r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 80F2425E 89B4F585 F27F3536 ED834D68 E3E492DE 08FE84B9"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF"); - Integer k("0x 22C17C2A 367DD85A B8A365ED 06F19C43 F9ED1834 9A9BC044"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 2D017BE7 F117FF99 4ED6FC63 CA5B4C7A 0430E9FA 095DAFC4"); - Integer sExp("0x C02B5CC5 C51D5411 060BF024 5049F824 839F671D 78A1BBF1"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP192r1 using RIPEMD-160\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 13) - { - const OID oid = ASN1::brainpoolP256r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 47B3A278 62DEF037 49ACF0D6 00E69F9B 851D01ED AEFA531F 4D168E78 7307F4D8"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF"); - Integer k("0x 908E3099 776261A4 558FF7A9 FA6DFFE0 CA6BB3F9 CB35C2E4 E1DC73FD 5E8C08A3"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 62CCD1D2 91E62F6A 4FFBD966 C66C85AA BA990BB6 AB0C087D BD54A456 CCC84E4C"); - Integer sExp("0x 9119719B 08EEA0D6 BC56E4D1 D37369BC F3768445 EF65CAE4 A37BF6D4 3BD01646"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP256r1 using RIPEMD-160\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 16) - { - const OID oid = ASN1::brainpoolP320r1(); - DL_GroupParameters_EC params(oid); - Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5"); - ECGDSA::Signer signer(params, x); - ECGDSA::Verifier verifier(signer); - - Integer e("0x 00000000 00000000 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF"); - Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B"); - - Integer r, s; - signer.RawSign(k, e, r, s); - - Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6"); - Integer sExp("0x 06AB5250 B31A8E93 56194894 61733200 E4FD5C12 75C0AB37 E7E41149 5BAAE145 41DF6DE6 66B8CA56"); - - fail = (r != rExp) || (s != sExp); - pass = pass && !fail; - - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; - const size_t len = strlen((char*)msg); - - const size_t maxLength = signer.MaxSignatureLength(); - SecByteBlock signature(maxLength); - r.Encode(signature+ 0, maxLength/2); - s.Encode(signature+maxLength/2, maxLength/2); - - fail = !verifier.VerifyMessage(msg, len, signature, signature.size()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "brainpoolP320r1 using RIPEMD-160\n"; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - } - - return pass; -} - -// ValidateECGDSA split into standard and thorough due to GH #1134 -bool ValidateECGDSA(bool thorough) -{ - std::cout << "\nECGDSA validation suite running...\n\n"; - - bool pass = true, fail; - - fail = !ValidateECGDSAStandard(); - pass = pass && !fail; - - if (thorough) { - fail = !ValidateECGDSAThorough(); - pass = pass && !fail; - } - - return pass; -} - -bool ValidateESIGN() -{ - std::cout << "\nESIGN validation suite running...\n\n"; - - bool pass = true, fail; - - const char plain[] = "test"; - const byte signature[] = - "\xA3\xE3\x20\x65\xDE\xDA\xE7\xEC\x05\xC1\xBF\xCD\x25\x79\x7D\x99\xCD\xD5\x73\x9D\x9D\xF3\xA4\xAA\x9A\xA4\x5A\xC8\x23\x3D\x0D\x37" - "\xFE\xBC\x76\x3F\xF1\x84\xF6\x59\x14\x91\x4F\x0C\x34\x1B\xAE\x9A\x5C\x2E\x2E\x38\x08\x78\x77\xCB\xDC\x3C\x7E\xA0\x34\x44\x5B\x0F" - "\x67\xD9\x35\x2A\x79\x47\x1A\x52\x37\x71\xDB\x12\x67\xC1\xB6\xC6\x66\x73\xB3\x40\x2E\xD6\xF2\x1A\x84\x0A\xB6\x7B\x0F\xEB\x8B\x88" - "\xAB\x33\xDD\xE4\x83\x21\x90\x63\x2D\x51\x2A\xB1\x6F\xAB\xA7\x5C\xFD\x77\x99\xF2\xE1\xEF\x67\x1A\x74\x02\x37\x0E\xED\x0A\x06\xAD" - "\xF4\x15\x65\xB8\xE1\xD1\x45\xAE\x39\x19\xB4\xFF\x5D\xF1\x45\x7B\xE0\xFE\x72\xED\x11\x92\x8F\x61\x41\x4F\x02\x00\xF2\x76\x6F\x7C" - "\x79\xA2\xE5\x52\x20\x5D\x97\x5E\xFE\x39\xAE\x21\x10\xFB\x35\xF4\x80\x81\x41\x13\xDD\xE8\x5F\xCA\x1E\x4F\xF8\x9B\xB2\x68\xFB\x28"; - - FileSource keys(DataDir("TestData/esig1536.dat").c_str(), true, new HexDecoder); - ESIGN::Signer signer(keys); - ESIGN::Verifier verifier(signer); - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - - fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "verification check against test vector\n"; - - std::cout << "Generating signature key from seed..." << std::endl; - signer.AccessKey().GenerateRandom(GlobalRNG(), MakeParameters("Seed", ConstByteArrayParameter((const byte *)"test", 4))("KeySize", 3*512)); - verifier = signer; - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - - return pass; -} - -bool ValidateEd25519() -{ - std::cout << "\ned25519 validation suite running...\n\n"; - bool pass = true, fail; - - const char plain[] = "test"; - const byte signature[] = - "\x91\x12\x44\x91\xA5\x99\xF8\x49\xBA\xB2\xC4\xF2\xBA\x0B\xAA\x99" - "\xC8\xC5\xF5\x19\xDC\x07\xD4\x4C\xF7\x31\xDE\x2F\x2B\x81\xB2\x81" - "\xF6\xA7\xDE\x33\x29\xCA\x45\xAC\x69\x2A\x80\xB7\xDB\x7F\x07\x37" - "\x77\xC4\xBF\xC5\x45\x79\x3A\xAC\xB5\x16\xAE\x4E\xD9\x16\x95\x0E"; - - FileSource keys(DataDir("TestData/ed25519.dat").c_str(), true, new HexDecoder); - ed25519::Signer signer(keys); - ed25519::Verifier verifier(signer); - - fail = !SignatureValidate(signer, verifier); - pass = pass && !fail; - - fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength()); - pass = pass && !fail; - - std::cout << (fail ? "FAILED " : "passed "); - std::cout << "verification check against test vector\n"; - - return pass; -} - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP diff --git a/vendor/cryptopp/validate.h b/vendor/cryptopp/validate.h deleted file mode 100644 index 9a1d3c02e8..0000000000 --- a/vendor/cryptopp/validate.h +++ /dev/null @@ -1,395 +0,0 @@ -// validate.h - originally written and placed in the public domain by Wei Dai -// CryptoPP::Test namespace added by JW in February 2017 - -#ifndef CRYPTOPP_VALIDATE_H -#define CRYPTOPP_VALIDATE_H - -#include "cryptlib.h" -#include "misc.h" -#include "files.h" -#include "argnames.h" -#include "algparam.h" -#include "hex.h" - -#include -#include -#include -#include -#include - -NAMESPACE_BEGIN(CryptoPP) -NAMESPACE_BEGIN(Test) - -// A hint to help locate TestData/ and TestVectors/ after install. Due to -// execve the path can be malicious. If the path is fictitious then we move -// onto the next potential path. Also note we only read from the path; we -// never write through it. Storage for the string is in test.cpp. -extern std::string g_argvPathHint; - -bool ValidateAll(bool thorough); -bool TestSettings(); -bool TestOS_RNG(); -// bool TestSecRandom(); -bool TestRandomPool(); -#if !defined(NO_OS_DEPENDENCE) -bool TestAutoSeededX917(); -#endif -#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) -bool TestRDRAND(); -bool TestRDSEED(); -bool TestPadlockRNG(); -#endif -#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64) -bool TestDARN(); -#endif -bool ValidateBaseCode(); -bool ValidateEncoder(); -bool ValidateCRC32(); -bool ValidateCRC32C(); -bool ValidateAdler32(); -bool ValidateMD2(); -bool ValidateMD4(); -bool ValidateMD5(); -bool ValidateSHA(); -bool ValidateSHA2(); -bool ValidateSHA3(); -bool ValidateSHAKE(); // output <= r, where r is blocksize -bool ValidateSHAKE_XOF(); // output > r, needs hand crafted tests -bool ValidateKeccak(); -bool ValidateTiger(); -bool ValidateRIPEMD(); -bool ValidatePanama(); -bool ValidateWhirlpool(); -bool ValidateLSH(); - -bool ValidateSM3(); -bool ValidateBLAKE2s(); -bool ValidateBLAKE2b(); -bool ValidatePoly1305(); -bool ValidateSipHash(); - -bool ValidateHMAC(); -bool ValidateTTMAC(); - -bool ValidateCipherModes(); -bool ValidatePBKDF(); -bool ValidateHKDF(); -bool ValidateScrypt(); - -bool ValidateDES(); -bool ValidateIDEA(); -bool ValidateSAFER(); -bool ValidateRC2(); -bool ValidateARC4(); - -bool ValidateRC5(); -bool ValidateBlowfish(); -bool ValidateBlowfishCompat(); -bool ValidateThreeWay(); -bool ValidateGOST(); -bool ValidateSHARK(); -bool ValidateSEAL(); -bool ValidateCAST(); -bool ValidateSquare(); -bool ValidateSKIPJACK(); -bool ValidateRC6(); -bool ValidateMARS(); -bool ValidateRijndael(); -bool ValidateTwofish(); -bool ValidateSerpent(); -bool ValidateSHACAL2(); -bool ValidateARIA(); -bool ValidateSIMECK(); -bool ValidateCHAM(); -bool ValidateHIGHT(); -bool ValidateLEA(); -bool ValidateSIMON(); -bool ValidateSPECK(); -bool ValidateCamellia(); - -bool ValidateHC128(); -bool ValidateHC256(); -bool ValidateRabbit(); -bool ValidateSalsa(); -bool ValidateChaCha(); -bool ValidateChaChaTLS(); -bool ValidateSosemanuk(); - -bool ValidateVMAC(); -bool ValidateCCM(); -bool ValidateGCM(); -bool ValidateXTS(); -bool ValidateCMAC(); - -bool ValidateBBS(); -bool ValidateDH(); -bool ValidateMQV(); -bool ValidateHMQV(); -bool ValidateFHMQV(); -bool ValidateRSA(); -bool ValidateElGamal(); -bool ValidateDLIES(); -bool ValidateNR(); -bool ValidateDSA(bool thorough); -bool ValidateLUC(); -bool ValidateLUC_DL(); -bool ValidateLUC_DH(); -bool ValidateXTR_DH(); -bool ValidateRabin(); -bool ValidateRW(); -bool ValidateECP(); -bool ValidateEC2N(); -bool ValidateECDSA(); -bool ValidateECDSA_RFC6979(); -bool ValidateECGDSA(bool thorough); -bool ValidateESIGN(); - -bool ValidateHashDRBG(); -bool ValidateHmacDRBG(); - -bool TestX25519(); -bool TestEd25519(); -bool ValidateX25519(); -bool ValidateEd25519(); -bool ValidateNaCl(); - -// If CRYPTOPP_DEBUG or CRYPTOPP_COVERAGE is in effect, then perform additional tests -#if (defined(CRYPTOPP_DEBUG) || defined(CRYPTOPP_COVERAGE)) && !defined(CRYPTOPP_IMPORTS) -# define CRYPTOPP_EXTENDED_VALIDATION 1 -#endif - -#if defined(CRYPTOPP_EXTENDED_VALIDATION) -// http://github.com/weidai11/cryptopp/issues/92 -bool TestSecBlock(); -// http://github.com/weidai11/cryptopp/issues/64 -bool TestPolynomialMod2(); -// http://github.com/weidai11/cryptopp/issues/336 -bool TestIntegerBitops(); -// http://github.com/weidai11/cryptopp/issues/602 -bool TestIntegerOps(); -// http://github.com/weidai11/cryptopp/issues/360 -bool TestRounding(); -// http://github.com/weidai11/cryptopp/issues/242 -bool TestHuffmanCodes(); -// http://github.com/weidai11/cryptopp/issues/346 -bool TestASN1Parse(); -bool TestASN1Functions(); -// https://github.com/weidai11/cryptopp/pull/334 -bool TestStringSink(); -// Additional tests due to no coverage -bool TestCompressors(); -bool TestEncryptors(); -bool TestMersenne(); -bool TestSharing(); -# if defined(CRYPTOPP_ALTIVEC_AVAILABLE) -bool TestAltivecOps(); -# endif -#endif - -class FixedRNG : public RandomNumberGenerator -{ -public: - FixedRNG(BufferedTransformation &source) : m_source(source) {} - - void GenerateBlock(byte *output, size_t size) - { - m_source.Get(output, size); - } - -private: - BufferedTransformation &m_source; -}; - -// Safer functions on Windows for C&A, http://github.com/weidai11/cryptopp/issues/55 -inline std::string TimeToString(const time_t& t) -{ -#if (CRYPTOPP_MSC_VERSION >= 1400) - tm localTime; - char timeBuf[64]; - errno_t err; - - err = ::localtime_s(&localTime, &t); - CRYPTOPP_ASSERT(err == 0); - err = ::asctime_s(timeBuf, sizeof(timeBuf), &localTime); - CRYPTOPP_ASSERT(err == 0); - - std::string str(err == 0 ? timeBuf : ""); -#elif defined(__MINGW32__) || defined(__MINGW64__) - char* timeString = ::asctime(::localtime(&t)); - std::string str(timeString ? timeString : ""); -#elif (_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || defined(_POSIX_SOURCE)) - tm localTime; - char timeBuf[64]; - char* timeString = ::asctime_r(::localtime_r(&t, &localTime), timeBuf); - std::string str(timeString ? timeString : ""); -#else - char* timeString = ::asctime(::localtime(&t)); - std::string str(timeString ? timeString : ""); -#endif - - // Cleanup whitespace - std::string::size_type pos = 0; - while (!str.empty() && std::isspace(str[str.length()-1])) - {str.erase(str.end()-1);} - while (!str.empty() && std::string::npos != (pos = str.find(" ", pos))) - {str.erase(pos, 1);} - - return str; -} - -// Coverity finding -template -inline T StringToValue(const std::string& str) -{ - std::istringstream iss(str); - - // Arbitrary, but we need to clear a Coverity finding TAINTED_SCALAR - if (iss.str().length() > 25) - throw InvalidArgument(str + "' is too long"); - - T value; - iss >> std::noskipws >> value; - - // Use fail(), not bad() - if (iss.fail()) - throw InvalidArgument(str + "' is not a value"); - - if (NON_NEGATIVE && value < 0) - throw InvalidArgument(str + "' is negative"); - - return value; -} - -// Coverity finding -template<> -inline int StringToValue(const std::string& str) -{ - Integer n(str.c_str()); - long l = n.ConvertToLong(); - - int r; - if (!SafeConvert(l, r)) - throw InvalidArgument(str + "' is not an integer value"); - - return r; -} - -inline std::string AddSeparator(std::string str) -{ - if (str.empty()) return ""; - const char last = str[str.length()-1]; - if (last != '/' && last != '\\') - return str + "/"; - return str; -} - -// Use CRYPTOPP_DATA_DIR last. The problem this sidesteps is, finding an -// old version of Crypto++ library in CRYPTOPP_DATA_DIR when the library -// has been staged in DESTDIR. Using CRYPTOPP_DATA_DIR first only works -// as expected when CRYPTOPP_DATA_DIR is empty before an install. We -// encountered this problem rather quickly during testing of Crypto++ 8.1 -// when Crypto++ 8.0 was installed locally. It took some time to realize -// where the old test data was coming from. -static std::string GetDataDir() -{ - std::ifstream file; - std::string name, filename = "TestData/usage.dat"; - -#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH - // Look in $ORIGIN/../share/. This is likely a Linux install directory. - name = AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/") + filename; - file.open(name.c_str()); - if (file.is_open()) - return AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/"); -#endif -#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH - // Look in current working directory - name = AddSeparator(g_argvPathHint) + filename; - file.open(name.c_str()); - if (file.is_open()) - return AddSeparator(g_argvPathHint); -#endif -#ifdef CRYPTOPP_DATA_DIR - // Honor CRYPTOPP_DATA_DIR. This is likely an install directory if it is not "./". - name = AddSeparator(CRYPTOPP_DATA_DIR) + filename; - file.open(name.c_str()); - if (file.is_open()) - return AddSeparator(CRYPTOPP_DATA_DIR); -#endif - return "./"; -} - -inline std::string DataDir(const std::string& filename) -{ - std::string name; - std::ifstream file; - -#if CRYPTOPP_CXX11_STATIC_INIT - static std::string path = AddSeparator(GetDataDir()); - name = path + filename; - file.open(name.c_str()); - if (file.is_open()) - return name; -#else - // Avoid static initialization problems - name = AddSeparator(GetDataDir()) + filename; - file.open(name.c_str()); - if (file.is_open()) - return name; -#endif - - // This will cause the expected exception in the caller - return filename; -} - -// Definition in test.cpp -RandomNumberGenerator& GlobalRNG(); - -// Definition in datatest.cpp -bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParameters=g_nullNameValuePairs, bool thorough=true); - -// Definitions in validat6.cpp -bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough = false); -bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d); -bool AuthenticatedKeyAgreementWithRolesValidate(AuthenticatedKeyAgreementDomain &initiator, AuthenticatedKeyAgreementDomain &recipient); -bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d); -bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false); - -// Miscellaneous PK definitions in validat6.cpp -// Key Agreement definitions in validat7.cpp -// Encryption and Decryption definitions in validat8.cpp -// Sign and Verify definitions in validat9.cpp - -bool ValidateECP(); -bool ValidateEC2N(); - -bool ValidateRSA_Encrypt(); -bool ValidateRSA_Sign(); - -bool ValidateLUC_Encrypt(); -bool ValidateLUC_Sign(); - -bool ValidateLUC_DL_Encrypt(); -bool ValidateLUC_DL_Sign(); - -bool ValidateRabin_Encrypt(); -bool ValidateRabin_Sign(); - -bool ValidateECP(); -bool ValidateECP_Agreement(); -bool ValidateECP_Encrypt(); -bool ValidateECP_Sign(); - -bool ValidateECP_Legacy_Encrypt(); -bool ValidateEC2N_Legacy_Encrypt(); -bool ValidateECP_NULLDigest_Encrypt(); - -bool ValidateEC2N(); -bool ValidateEC2N_Agreement(); -bool ValidateEC2N_Encrypt(); -bool ValidateEC2N_Sign(); - -NAMESPACE_END // Test -NAMESPACE_END // CryptoPP - -#endif