diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-04-15 23:42:58 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-04-15 23:42:58 +0000 |
commit | 5974a0b0e7698d56a0c28f1a34043eedf9be7edb (patch) | |
tree | 3908753a45519e1a9f12b01b54a3e355df497e0c /bench2.cpp | |
parent | 868dbb4ea7f92845edde81993aa9309db7f27195 (diff) | |
download | cryptopp-5974a0b0e7698d56a0c28f1a34043eedf9be7edb.tar.gz |
benchmark key and IV setup. remove low security benchmarks
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@289 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'bench2.cpp')
-rw-r--r-- | bench2.cpp | 107 |
1 files changed, 44 insertions, 63 deletions
@@ -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 <time.h> #include <math.h> @@ -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) +extern double g_hertz; + +void BenchmarkAll2(double t, double hertz) { - cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right>" << endl; - cout << "<THEAD><TR><TH>Operation<TH>Iterations<TH>Total Time<TH>Milliseconds/Operation" << endl; + g_hertz = hertz; - cout << "<TBODY style=\"background: yellow\">" << endl; + cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right>" << endl; + cout << "<THEAD><TR><TH>Operation<TH>Milliseconds/Operation" << (g_hertz ? "<TH>Megacycles/Operation" : "") << endl; + + cout << "\n<TBODY style=\"background: yellow\">"; BenchMarkCrypto<RSAES<OAEP<SHA> > >("rsa1024.dat", "RSA 1024", t); - BenchMarkCrypto<RabinES<OAEP<SHA> > >("rabi1024.dat", "Rabin 1024", t); BenchMarkCrypto<LUCES<OAEP<SHA> > >("luc1024.dat", "LUC 1024", t); BenchMarkCrypto<DLIES<> >("dlie1024.dat", "DLIES 1024", t); BenchMarkCrypto<LUC_IES<> >("lucc512.dat", "LUCELG 512", t); - cout << "<TBODY style=\"background: white\">" << endl; + cout << "\n<TBODY style=\"background: white\">"; BenchMarkCrypto<RSAES<OAEP<SHA> > >("rsa2048.dat", "RSA 2048", t); - BenchMarkCrypto<RabinES<OAEP<SHA> > >("rabi2048.dat", "Rabin 2048", t); BenchMarkCrypto<LUCES<OAEP<SHA> > >("luc2048.dat", "LUC 2048", t); BenchMarkCrypto<DLIES<> >("dlie2048.dat", "DLIES 2048", t); BenchMarkCrypto<LUC_IES<> >("lucc1024.dat", "LUCELG 1024", t); - cout << "<TBODY style=\"background: yellow\">" << endl; + cout << "\n<TBODY style=\"background: yellow\">"; BenchMarkSignature<RSASS<PSSR, SHA> >("rsa1024.dat", "RSA 1024", t); - BenchMarkSignature<RabinSS<PSSR, SHA> >("rabi1024.dat", "Rabin 1024", t); BenchMarkSignature<RWSS<PSSR, SHA> >("rw1024.dat", "RW 1024", t); BenchMarkSignature<LUCSS<PSSR, SHA> >("luc1024.dat", "LUC 1024", t); BenchMarkSignature<NR<SHA> >("nr1024.dat", "NR 1024", t); @@ -263,16 +266,15 @@ void BenchmarkAll2(double t) BenchMarkSignature<ESIGN<SHA> >("esig1023.dat", "ESIGN 1023", t); BenchMarkSignature<ESIGN<SHA> >("esig1536.dat", "ESIGN 1536", t); - cout << "<TBODY style=\"background: white\">" << endl; + cout << "\n<TBODY style=\"background: white\">"; BenchMarkSignature<RSASS<PSSR, SHA> >("rsa2048.dat", "RSA 2048", t); - BenchMarkSignature<RabinSS<PSSR, SHA> >("rabi2048.dat", "Rabin 2048", t); BenchMarkSignature<RWSS<PSSR, SHA> >("rw2048.dat", "RW 2048", t); BenchMarkSignature<LUCSS<PSSR, SHA> >("luc2048.dat", "LUC 2048", t); BenchMarkSignature<NR<SHA> >("nr2048.dat", "NR 2048", t); BenchMarkSignature<LUC_HMP<SHA> >("lucs1024.dat", "LUC-HMP 1024", t); BenchMarkSignature<ESIGN<SHA> >("esig2046.dat", "ESIGN 2046", t); - cout << "<TBODY style=\"background: yellow\">" << endl; + cout << "\n<TBODY style=\"background: yellow\">"; BenchMarkKeyAgreement<XTR_DH>("xtrdh171.dat", "XTR-DH 171", t); BenchMarkKeyAgreement<XTR_DH>("xtrdh342.dat", "XTR-DH 342", t); BenchMarkKeyAgreement<DH>("dh1024.dat", "DH 1024", t); @@ -282,65 +284,44 @@ void BenchmarkAll2(double t) BenchMarkKeyAgreement<MQV>("mqv1024.dat", "MQV 1024", t); BenchMarkKeyAgreement<MQV>("mqv2048.dat", "MQV 2048", t); - cout << "<TBODY style=\"background: white\">" << endl; + cout << "\n<TBODY style=\"background: white\">"; { - 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<ECP>::Decryptor cpriv(ec, P, r, d); + RandomPool rng; // not seeded + ECIES<ECP>::Decryptor cpriv(rng, ASN1::secp256k1()); ECIES<ECP>::Encryptor cpub(cpriv); ECDSA<ECP, SHA>::Signer spriv(cpriv); ECDSA<ECP, SHA>::Verifier spub(spriv); - ECDH<ECP>::Domain ecdhc(ec, P, r, k); - ECMQV<ECP>::Domain ecmqvc(ec, P, r, k); - - 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); + ECDH<ECP>::Domain ecdhc(ASN1::secp256k1()); + ECMQV<ECP>::Domain ecmqvc(ASN1::secp256k1()); + + 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 << "<TBODY style=\"background: yellow\">" << 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<EC2N>::Decryptor cpriv(ec, P, r, d); + RandomPool rng; // not seeded + ECIES<EC2N>::Decryptor cpriv(rng, ASN1::sect233r1()); ECIES<EC2N>::Encryptor cpub(cpriv); ECDSA<EC2N, SHA>::Signer spriv(cpriv); ECDSA<EC2N, SHA>::Verifier spub(spriv); - ECDH<EC2N>::Domain ecdhc(ec, P, r, k); - ECMQV<EC2N>::Domain ecmqvc(ec, P, r, k); - - 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); + ECDH<EC2N>::Domain ecdhc(ASN1::sect233r1()); + ECMQV<EC2N>::Domain ecmqvc(ASN1::sect233r1()); + + 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 << "</TABLE>" << endl; } |