From c2397a460098debadac81cbe48129ba1e013f3b8 Mon Sep 17 00:00:00 2001 From: weidai Date: Sun, 15 Apr 2007 23:42:58 +0000 Subject: [PATCH] benchmark key and IV setup. remove low security benchmarks --- bench.cpp | 261 ++++++++++++++++++++++++++++++----------------------- bench.h | 4 +- bench2.cpp | 105 +++++++++------------ 3 files changed, 193 insertions(+), 177 deletions(-) diff --git a/bench.cpp b/bench.cpp index b1017c17..cb9b56bd 100644 --- a/bench.cpp +++ b/bench.cpp @@ -5,51 +5,28 @@ #include "bench.h" #include "crc.h" #include "adler32.h" -#include "md2.h" -#include "md5.h" -#include "md5mac.h" -#include "sha.h" -#include "haval.h" -#include "tiger.h" -#include "ripemd.h" -#include "panama.h" -#include "whrlpool.h" #include "idea.h" #include "des.h" -#include "rc2.h" #include "arc4.h" #include "rc5.h" #include "blowfish.h" #include "wake.h" -#include "3way.h" -#include "safer.h" -#include "gost.h" -#include "shark.h" #include "cast.h" -#include "square.h" -#include "skipjack.h" #include "seal.h" #include "rc6.h" #include "mars.h" -#include "rijndael.h" #include "twofish.h" #include "serpent.h" -#include "shacal2.h" -#include "camellia.h" -#include "hmac.h" -#include "xormac.h" +#include "skipjack.h" #include "cbcmac.h" #include "dmac.h" -#include "ttmac.h" +#include "aes.h" #include "blumshub.h" #include "rng.h" #include "files.h" #include "hex.h" #include "modes.h" -#include "mdc.h" -#include "lubyrack.h" -#include "tea.h" -#include "salsa.h" +#include "factory.h" #include #include @@ -67,7 +44,7 @@ const double CLOCK_TICKS_PER_SECOND = (double)CLK_TCK; const double CLOCK_TICKS_PER_SECOND = 1000000.0; #endif -double logtotal = 0; +double logtotal = 0, g_allocatedTime, g_hertz; unsigned int logcount = 0; static const byte *const key=(byte *)"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; @@ -75,23 +52,34 @@ static const byte *const key=(byte *)"0123456789abcdefghijklmnopqrstuvwxyzABCDEF void OutputResultBytes(const char *name, double length, double timeTaken) { double mbs = length / timeTaken / (1024*1024); - cout << "" << name; - cout << "" << setprecision(3) << length / (1024*1024); + cout << "\n" << name; +// cout << "" << setprecision(3) << length / (1024*1024); cout << setiosflags(ios::fixed); - cout << "" << setprecision(3) << timeTaken; - cout << "" << setprecision(3) << mbs << endl; +// cout << "" << setprecision(3) << timeTaken; + cout << "" << setprecision(0) << setiosflags(ios::fixed) << mbs; + if (g_hertz) + cout << "" << setprecision(1) << setiosflags(ios::fixed) << timeTaken * g_hertz / length; cout << resetiosflags(ios::fixed); logtotal += log(mbs); logcount++; } +void OutputResultKeying(double iterations, double timeTaken) +{ + cout << "" << setprecision(3) << setiosflags(ios::fixed) << (1000*1000*timeTaken/iterations); + if (g_hertz) + cout << "" << setprecision(0) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations; +} + void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken) { - cout << "" << name << " " << operation << (pc ? " with precomputation" : ""); - cout << "" << iterations; - cout << setiosflags(ios::fixed); - cout << "" << setprecision(3) << timeTaken; - cout << "" << setprecision(2) << (1000*timeTaken/iterations) << endl; + cout << "\n" << name << " " << operation << (pc ? " with precomputation" : ""); +// cout << "" << iterations; +// cout << setiosflags(ios::fixed); +// cout << "" << setprecision(3) << timeTaken; + cout << "" << setprecision(2) << setiosflags(ios::fixed) << (1000*timeTaken/iterations); + if (g_hertz) + cout << "" << setprecision(2) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations / 1000000; cout << resetiosflags(ios::fixed); logtotal += log(iterations/timeTaken); @@ -101,7 +89,7 @@ void OutputResultOperations(const char *name, const char *operation, bool pc, un void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal) { const int BUF_SIZE = RoundDownToMultipleOf(1024U, cipher.OptimalNumberOfParallelBlocks() * cipher.BlockSize()); - SecByteBlock buf(BUF_SIZE); + AlignedSecByteBlock buf(BUF_SIZE); const int nBlocks = BUF_SIZE / cipher.BlockSize(); clock_t start = clock(); @@ -121,8 +109,8 @@ void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal) void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal) { - const int BUF_SIZE=1024; - SecByteBlock buf(BUF_SIZE); + const int BUF_SIZE=RoundDownToMultipleOf(1024U, cipher.OptimalBlockSize()); + AlignedSecByteBlock buf(BUF_SIZE); clock_t start = clock(); unsigned long i=0, blocks=1; @@ -142,7 +130,7 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal) void BenchMark(const char *name, HashTransformation &ht, double timeTotal) { const int BUF_SIZE=1024; - SecByteBlock buf(BUF_SIZE); + AlignedSecByteBlock buf(BUF_SIZE); LC_RNG rng((word32)time(NULL)); rng.GenerateBlock(buf, BUF_SIZE); clock_t start = clock(); @@ -164,7 +152,7 @@ void BenchMark(const char *name, HashTransformation &ht, double timeTotal) void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal) { const int BUF_SIZE=1024; - SecByteBlock buf(BUF_SIZE); + AlignedSecByteBlock buf(BUF_SIZE); LC_RNG rng((word32)time(NULL)); rng.GenerateBlock(buf, BUF_SIZE); clock_t start = clock(); @@ -183,6 +171,23 @@ void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal) OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken); } +void BenchMarkKeying(SimpleKeyingInterface &c, unsigned int keyLength, const NameValuePairs ¶ms) +{ + unsigned long iterations = 0; + clock_t start = clock(); + double timeTaken; + do + { + for (unsigned int i=0; i<1024; i++) + c.SetKey(key, keyLength, params); + timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND; + iterations += 1024; + } + while (timeTaken < g_allocatedTime); + + OutputResultKeying(iterations, timeTaken); +} + //VC60 workaround: compiler bug triggered without the extra dummy parameters template void BenchMarkKeyed(const char *name, double timeTotal, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL) @@ -190,6 +195,7 @@ void BenchMarkKeyed(const char *name, double timeTotal, const NameValuePairs &pa T c; c.SetKey(key, c.DefaultKeyLength(), CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); BenchMark(name, c, timeTotal); + BenchMarkKeying(c, c.DefaultKeyLength(), CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); } //VC60 workaround: compiler bug triggered without the extra dummy parameters @@ -199,6 +205,7 @@ void BenchMarkKeyedVariable(const char *name, double timeTotal, unsigned int key T c; c.SetKey(key, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); BenchMark(name, c, timeTotal); + BenchMarkKeying(c, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); } //VC60 workaround: compiler bug triggered without the extra dummy parameters @@ -209,95 +216,123 @@ void BenchMarkKeyless(const char *name, double timeTotal, T *x=NULL) BenchMark(name, c, timeTotal); } -void BenchmarkAll(double t) +//VC60 workaround: compiler bug triggered without the extra dummy parameters +template +void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL) +{ + std::string name = factoryName; + if (displayName) + name = displayName; + else if (keyLength) + name += " (" + IntToString(keyLength * 8) + "-bit key)"; + + std::auto_ptr obj(ObjectFactoryRegistry::Registry().CreateObject(factoryName)); + if (!keyLength) + keyLength = obj->DefaultKeyLength(); + obj->SetKey(key, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); + BenchMark(name.c_str(), *obj, g_allocatedTime); + BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), key, false))); +} + +template +void BenchMarkByNameKeyLess(const char *factoryName, char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs, T *x=NULL) +{ + std::string name = factoryName; + if (displayName) + name = displayName; + + std::auto_ptr obj(ObjectFactoryRegistry::Registry().CreateObject(factoryName)); + BenchMark(name.c_str(), *obj, g_allocatedTime); +} + +void BenchmarkAll(double t, double hertz) { #if 1 logtotal = 0; logcount = 0; + g_allocatedTime = t; + g_hertz = hertz; - cout << "" << endl; - cout << "" << endl; + char *cpb, *cpk; + if (g_hertz) + { + cpb = "
AlgorithmMegabytes(2^20 bytes) ProcessedTime TakenMB/Second\n
Cycles Per Byte"; + cpk = "Cycles Per Key and IV Setup"; + cout << "CPU frequency of the test platform is " << g_hertz << " Hz.\n"; + } + else + { + cpb = cpk = ""; + cout << "CPU frequency of the test platform was not provided.\n"; + } + cout << "" << endl; + cout << ""; + BenchMarkByName("VMAC(AES)-64"); + BenchMarkByName("VMAC(AES)-128"); + BenchMarkByName("HMAC(SHA-1)"); + BenchMarkByName("Two-Track-MAC"); + BenchMarkKeyed >("CBC-MAC/AES", t); + BenchMarkKeyed >("DMAC/AES", t); + + cout << "\n"; BenchMarkKeyless("CRC-32", t); BenchMarkKeyless("Adler-32", t); - BenchMarkKeyless("MD2", t); - BenchMarkKeyless("MD5", t); - BenchMarkKeyless("SHA-1", t); - BenchMarkKeyless("SHA-256", t); + BenchMarkByNameKeyLess("MD5", "MD5 (broken)"); + BenchMarkByNameKeyLess("SHA-1"); + BenchMarkByNameKeyLess("SHA-256"); #ifdef WORD64_AVAILABLE - BenchMarkKeyless("SHA-512", t); + BenchMarkByNameKeyLess("SHA-512"); + BenchMarkByNameKeyLess("Tiger"); + BenchMarkByNameKeyLess("Whirlpool"); #endif - BenchMarkKeyless("HAVAL (pass=3)", t); - BenchMarkKeyless("HAVAL (pass=4)", t); - BenchMarkKeyless("HAVAL (pass=5)", t); -#ifdef WORD64_AVAILABLE - BenchMarkKeyless("Tiger", t); -#endif - BenchMarkKeyless("RIPE-MD160", t); - BenchMarkKeyless("RIPE-MD320", t); - BenchMarkKeyless("RIPE-MD128", t); - BenchMarkKeyless("RIPE-MD256", t); - BenchMarkKeyless >("Panama Hash (little endian)", t); - BenchMarkKeyless >("Panama Hash (big endian)", t); -#ifdef WORD64_AVAILABLE - BenchMarkKeyless("Whirlpool", t); -#endif - BenchMarkKeyed::Encryption>("MDC/MD5", t); - BenchMarkKeyed::Encryption>("Luby-Rackoff/MD5", t); + BenchMarkByNameKeyLess("RIPEMD-160"); + BenchMarkByNameKeyLess("RIPEMD-320"); + BenchMarkByNameKeyLess("RIPEMD-128"); + BenchMarkByNameKeyLess("RIPEMD-256"); + + cout << "\n"; + BenchMarkByName("Panama-LE"); + BenchMarkByName("Panama-BE"); + BenchMarkByName("Salsa20"); + BenchMarkByName("Salsa20", 0, "Salsa20/12", MakeParameters(Name::Rounds(), 12)); + BenchMarkByName("Salsa20", 0, "Salsa20/8", MakeParameters(Name::Rounds(), 8)); + BenchMarkByName("Sosemanuk"); + BenchMarkKeyed("ARC4", t); + BenchMarkKeyed::Encryption>("SEAL-3.0-BE", t); + BenchMarkKeyed::Encryption>("SEAL-3.0-LE", t); + BenchMarkKeyed::Encryption>("WAKE-OFB-BE", t); + BenchMarkKeyed::Encryption>("WAKE-OFB-LE", t); + + cout << "\n"; + BenchMarkByName("AES/ECB", 16); + BenchMarkByName("AES/ECB", 24); + BenchMarkByName("AES/ECB", 32); + BenchMarkByName("AES/CTR", 16); + BenchMarkByName("AES/OFB", 16); + BenchMarkByName("AES/CFB", 16); + BenchMarkByName("AES/CBC", 16); + BenchMarkByName("Camellia/ECB", 16); + BenchMarkByName("Camellia/ECB", 32); + BenchMarkKeyed("Twofish", t); + BenchMarkKeyed("Serpent", t); + BenchMarkKeyed("CAST-256", t); + BenchMarkKeyed("RC6", t); + BenchMarkKeyed("MARS", t); + BenchMarkByName("SHACAL-2/ECB", 16); + BenchMarkByName("SHACAL-2/ECB", 64); BenchMarkKeyed("DES", t); BenchMarkKeyed("DES-XEX3", t); BenchMarkKeyed("DES-EDE3", t); BenchMarkKeyed("IDEA", t); - BenchMarkKeyed("RC2", t); BenchMarkKeyed("RC5 (r=16)", t); BenchMarkKeyed("Blowfish", t); - BenchMarkKeyed("3-WAY", t); - BenchMarkKeyed("TEA", t); - BenchMarkKeyedVariable("SAFER (r=8)", t, 8); - BenchMarkKeyed("GOST", t); -#ifdef WORD64_AVAILABLE - BenchMarkKeyed("SHARK (r=6)", t); -#endif + BenchMarkByName("TEA/ECB"); + BenchMarkByName("XTEA/ECB"); BenchMarkKeyed("CAST-128", t); - BenchMarkKeyed("CAST-256", t); - BenchMarkKeyed("Square", t); BenchMarkKeyed("SKIPJACK", t); - BenchMarkKeyed("RC6", t); - BenchMarkKeyed("MARS", t); - BenchMarkKeyedVariable("Rijndael (128-bit key)", t, 16); - BenchMarkKeyedVariable("Rijndael (192-bit key)", t, 24); - BenchMarkKeyedVariable("Rijndael (256-bit key)", t, 32); - BenchMarkKeyedVariable::Encryption>("Rijndael (128) CTR", t, 16); - BenchMarkKeyedVariable::Encryption>("Rijndael (128) OFB", t, 16); - BenchMarkKeyedVariable::Encryption>("Rijndael (128) CFB", t, 16); - BenchMarkKeyedVariable::Encryption>("Rijndael (128) CBC", t, 16); - BenchMarkKeyed("Twofish", t); - BenchMarkKeyed("Serpent", t); - BenchMarkKeyed("ARC4", t); - BenchMarkKeyed::Encryption>("SEAL-3.0-BE", t); - BenchMarkKeyed::Encryption>("SEAL-3.0-LE", t); - BenchMarkKeyed::Encryption>("WAKE-CFB-BE", t); - BenchMarkKeyed::Encryption>("WAKE-CFB-LE", t); - BenchMarkKeyed::Encryption>("WAKE-OFB-BE", t); - BenchMarkKeyed::Encryption>("WAKE-OFB-LE", t); - BenchMarkKeyed::Encryption>("Panama Cipher (little endian)", t); - BenchMarkKeyed::Encryption>("Panama Cipher (big endian)", t); - BenchMarkKeyedVariable("SHACAL-2 (128-bit key)", t, 16); - BenchMarkKeyedVariable("SHACAL-2 (512-bit key)", t, 64); -#ifdef WORD64_AVAILABLE - BenchMarkKeyedVariable("Camellia (128-bit key)", t, 16); - BenchMarkKeyedVariable("Camellia (256-bit key)", t, 32); -#endif - BenchMarkKeyed("Salsa20", t); - BenchMarkKeyed("Salsa20/12", t, MakeParameters(Name::Rounds(), 12)); - BenchMarkKeyed("Salsa20/8", t, MakeParameters(Name::Rounds(), 8)); - - BenchMarkKeyed("MD5-MAC", t); - BenchMarkKeyed >("XMACC/MD5", t); - BenchMarkKeyed >("HMAC/MD5", t); - BenchMarkKeyed("Two-Track-MAC", t); - BenchMarkKeyed >("CBC-MAC/Rijndael", t); - BenchMarkKeyed >("DMAC/Rijndael", t); { Integer p("CB6C,B8CE,6351,164F,5D0C,0C9E,9E31,E231,CF4E,D551,CBD0,E671,5D6A,7B06,D8DF,C4A7h"); @@ -340,7 +375,7 @@ void BenchmarkAll(double t) } cout << "
AlgorithmMiB/Second" << cpb << "Microseconds Per Key and IV Setup" << cpk << endl; + + cout << "\n
" << endl; - BenchmarkAll2(t); + BenchmarkAll2(t, hertz); cout << "Throughput Geometric Average: " << setiosflags(ios::fixed) << exp(logtotal/logcount) << endl; diff --git a/bench.h b/bench.h index 496b07a1..8bb6ab96 100644 --- a/bench.h +++ b/bench.h @@ -5,7 +5,7 @@ extern const double CLOCK_TICKS_PER_SECOND; -void BenchmarkAll(double t); -void BenchmarkAll2(double t); +void BenchmarkAll(double t, double hertz); +void BenchmarkAll2(double t, double hertz); #endif diff --git a/bench2.cpp b/bench2.cpp index 64279cf3..60a9b048 100644 --- a/bench2.cpp +++ b/bench2.cpp @@ -9,7 +9,6 @@ #include "nr.h" #include "dsa.h" #include "luc.h" -#include "rabin.h" #include "rw.h" #include "eccrypto.h" #include "ecp.h" @@ -19,6 +18,9 @@ #include "mqv.h" #include "xtrcrypt.h" #include "esign.h" +#include "pssr.h" +#include "oids.h" +#include "randpool.h" #include #include @@ -74,7 +76,7 @@ void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool p { unsigned int len = 16; LC_RNG rng((word32)time(NULL)); - SecByteBlock message(len), signature(key.SignatureLength()); + AlignedSecByteBlock message(len), signature(key.SignatureLength()); rng.GenerateBlock(message, len); clock_t start = clock(); @@ -96,7 +98,7 @@ void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier { unsigned int len = 16; LC_RNG rng((word32)time(NULL)); - SecByteBlock message(len), signature(pub.SignatureLength()); + AlignedSecByteBlock message(len), signature(pub.SignatureLength()); rng.GenerateBlock(message, len); priv.SignMessage(rng, message, len, signature); @@ -233,28 +235,29 @@ void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTo BenchMarkAgreement(name, d, timeTotal); } -void BenchmarkAll2(double t) -{ - cout << "" << endl; - cout << "" << endl; +void BenchmarkAll2(double t, double hertz) +{ + g_hertz = hertz; + + cout << "
OperationIterationsTotal TimeMilliseconds/Operation" << endl; +extern double g_hertz; - cout << "
" << endl; + cout << ""; BenchMarkCrypto > >("rsa1024.dat", "RSA 1024", t); - BenchMarkCrypto > >("rabi1024.dat", "Rabin 1024", t); BenchMarkCrypto > >("luc1024.dat", "LUC 1024", t); BenchMarkCrypto >("dlie1024.dat", "DLIES 1024", t); BenchMarkCrypto >("lucc512.dat", "LUCELG 512", t); - cout << "" << endl; + cout << "\n"; BenchMarkCrypto > >("rsa2048.dat", "RSA 2048", t); - BenchMarkCrypto > >("rabi2048.dat", "Rabin 2048", t); BenchMarkCrypto > >("luc2048.dat", "LUC 2048", t); BenchMarkCrypto >("dlie2048.dat", "DLIES 2048", t); BenchMarkCrypto >("lucc1024.dat", "LUCELG 1024", t); - cout << "" << endl; + cout << "\n"; BenchMarkSignature >("rsa1024.dat", "RSA 1024", t); - BenchMarkSignature >("rabi1024.dat", "Rabin 1024", t); BenchMarkSignature >("rw1024.dat", "RW 1024", t); BenchMarkSignature >("luc1024.dat", "LUC 1024", t); BenchMarkSignature >("nr1024.dat", "NR 1024", t); @@ -263,16 +266,15 @@ void BenchmarkAll2(double t) BenchMarkSignature >("esig1023.dat", "ESIGN 1023", t); BenchMarkSignature >("esig1536.dat", "ESIGN 1536", t); - cout << "" << endl; + cout << "\n"; BenchMarkSignature >("rsa2048.dat", "RSA 2048", t); - BenchMarkSignature >("rabi2048.dat", "Rabin 2048", t); BenchMarkSignature >("rw2048.dat", "RW 2048", t); BenchMarkSignature >("luc2048.dat", "LUC 2048", t); BenchMarkSignature >("nr2048.dat", "NR 2048", t); BenchMarkSignature >("lucs1024.dat", "LUC-HMP 1024", t); BenchMarkSignature >("esig2046.dat", "ESIGN 2046", t); - cout << "" << endl; + cout << "\n"; BenchMarkKeyAgreement("xtrdh171.dat", "XTR-DH 171", t); BenchMarkKeyAgreement("xtrdh342.dat", "XTR-DH 342", t); BenchMarkKeyAgreement("dh1024.dat", "DH 1024", t); @@ -282,65 +284,44 @@ void BenchmarkAll2(double t) BenchMarkKeyAgreement("mqv1024.dat", "MQV 1024", t); BenchMarkKeyAgreement("mqv2048.dat", "MQV 2048", t); - cout << "" << endl; + cout << "\n"; { - Integer modulus("199999999999999999999999980586675243082581144187569"); - Integer a("659942,b7261b,249174,c86bd5,e2a65b,45fe07,37d110h"); - Integer b("3ece7d,09473d,666000,5baef5,d4e00e,30159d,2df49ah"); - Integer x("25dd61,4c0667,81abc0,fe6c84,fefaa3,858ca6,96d0e8h"); - Integer y("4e2477,05aab0,b3497f,d62b5e,78a531,446729,6c3fach"); - Integer r("100000000000000000000000000000000000000000000000151"); - Integer k(2); - Integer d("76572944925670636209790912427415155085360939712345"); - - ECP ec(modulus, a, b); - ECP::Point P(x, y); - P = ec.Multiply(k, P); - ECP::Point Q(ec.Multiply(d, P)); - ECIES::Decryptor cpriv(ec, P, r, d); + RandomPool rng; // not seeded + ECIES::Decryptor cpriv(rng, ASN1::secp256k1()); ECIES::Encryptor cpub(cpriv); ECDSA::Signer spriv(cpriv); ECDSA::Verifier spub(spriv); - ECDH::Domain ecdhc(ec, P, r, k); - ECMQV::Domain ecmqvc(ec, P, r, k); + ECDH::Domain ecdhc(ASN1::secp256k1()); + ECMQV::Domain ecmqvc(ASN1::secp256k1()); - BenchMarkEncryption("ECIES over GF(p) 168", cpub, t); - BenchMarkDecryption("ECIES over GF(p) 168", cpriv, cpub, t); - BenchMarkSigning("ECNR over GF(p) 168", spriv, t); - BenchMarkVerification("ECNR over GF(p) 168", spriv, spub, t); - BenchMarkKeyGen("ECDHC over GF(p) 168", ecdhc, t); - BenchMarkAgreement("ECDHC over GF(p) 168", ecdhc, t); - BenchMarkKeyGen("ECMQVC over GF(p) 168", ecmqvc, t); - BenchMarkAgreement("ECMQVC over GF(p) 168", ecmqvc, t); + BenchMarkEncryption("ECIES over GF(p) 256", cpub, t); + BenchMarkDecryption("ECIES over GF(p) 256", cpriv, cpub, t); + BenchMarkSigning("ECNR over GF(p) 256", spriv, t); + BenchMarkVerification("ECNR over GF(p) 256", spriv, spub, 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); } cout << "" << endl; { - Integer r("3805993847215893016155463826195386266397436443"); - Integer k(12); - Integer d("2065729449256706362097909124274151550853609397"); - - GF2NT gf2n(155, 62, 0); - byte b[]={0x7, 0x33, 0x8f}; - EC2N ec(gf2n, PolynomialMod2::Zero(), PolynomialMod2(b,3)); - EC2N::Point P(0x7B, 0x1C8); - P = ec.Multiply(k, P); - EC2N::Point Q(ec.Multiply(d, P)); - ECIES::Decryptor cpriv(ec, P, r, d); + RandomPool rng; // not seeded + ECIES::Decryptor cpriv(rng, ASN1::sect233r1()); ECIES::Encryptor cpub(cpriv); ECDSA::Signer spriv(cpriv); ECDSA::Verifier spub(spriv); - ECDH::Domain ecdhc(ec, P, r, k); - ECMQV::Domain ecmqvc(ec, P, r, k); + ECDH::Domain ecdhc(ASN1::sect233r1()); + ECMQV::Domain ecmqvc(ASN1::sect233r1()); - BenchMarkEncryption("ECIES over GF(2^n) 155", cpub, t); - BenchMarkDecryption("ECIES over GF(2^n) 155", cpriv, cpub, t); - BenchMarkSigning("ECNR over GF(2^n) 155", spriv, t); - BenchMarkVerification("ECNR over GF(2^n) 155", spriv, spub, t); - BenchMarkKeyGen("ECDHC over GF(2^n) 155", ecdhc, t); - BenchMarkAgreement("ECDHC over GF(2^n) 155", ecdhc, t); - BenchMarkKeyGen("ECMQVC over GF(2^n) 155", ecmqvc, t); - BenchMarkAgreement("ECMQVC over GF(2^n) 155", ecmqvc, t); + BenchMarkEncryption("ECIES over GF(2^n) 233", cpub, t); + BenchMarkDecryption("ECIES over GF(2^n) 233", cpriv, cpub, t); + BenchMarkSigning("ECNR over GF(2^n) 233", spriv, t); + BenchMarkVerification("ECNR over GF(2^n) 233", spriv, spub, 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); } cout << "
OperationMilliseconds/Operation" << (g_hertz ? "Megacycles/Operation" : "") << endl; + + cout << "\n
" << endl; }