benchmark key and IV setup. remove low security benchmarks

This commit is contained in:
weidai 2007-04-15 23:42:58 +00:00
parent 0014078939
commit c2397a4600
3 changed files with 193 additions and 177 deletions

261
bench.cpp
View File

@ -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 <time.h>
#include <math.h>
@ -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 << "<TR><TH>" << name;
cout << "<TD>" << setprecision(3) << length / (1024*1024);
cout << "\n<TR><TH>" << name;
// cout << "<TD>" << setprecision(3) << length / (1024*1024);
cout << setiosflags(ios::fixed);
cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(3) << mbs << endl;
// cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << mbs;
if (g_hertz)
cout << "<TD>" << setprecision(1) << setiosflags(ios::fixed) << timeTaken * g_hertz / length;
cout << resetiosflags(ios::fixed);
logtotal += log(mbs);
logcount++;
}
void OutputResultKeying(double iterations, double timeTaken)
{
cout << "<TD>" << setprecision(3) << setiosflags(ios::fixed) << (1000*1000*timeTaken/iterations);
if (g_hertz)
cout << "<TD>" << 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 << "<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : "");
cout << "<TD>" << iterations;
cout << setiosflags(ios::fixed);
cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(2) << (1000*timeTaken/iterations) << endl;
cout << "\n<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : "");
// cout << "<TD>" << iterations;
// cout << setiosflags(ios::fixed);
// cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(2) << setiosflags(ios::fixed) << (1000*timeTaken/iterations);
if (g_hertz)
cout << "<TD>" << 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 &params)
{
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 <class T>
void BenchMarkKeyed(const char *name, double timeTotal, const NameValuePairs &params = 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 <class T>
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = 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<T> obj(ObjectFactoryRegistry<T>::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 <class T>
void BenchMarkByNameKeyLess(const char *factoryName, char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T *x=NULL)
{
std::string name = factoryName;
if (displayName)
name = displayName;
std::auto_ptr<T> obj(ObjectFactoryRegistry<T>::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 << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right>" << endl;
cout << "<THEAD><TR><TH>Algorithm<TH>Megabytes(2^20 bytes) Processed<TH>Time Taken<TH>MB/Second\n<TBODY>" << endl;
char *cpb, *cpk;
if (g_hertz)
{
cpb = "<TH>Cycles Per Byte";
cpk = "<TH>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 << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right><COL align=right>" << endl;
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds Per Key and IV Setup" << cpk << endl;
cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-64");
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-128");
BenchMarkByName<MessageAuthenticationCode>("HMAC(SHA-1)");
BenchMarkByName<MessageAuthenticationCode>("Two-Track-MAC");
BenchMarkKeyed<CBC_MAC<AES> >("CBC-MAC/AES", t);
BenchMarkKeyed<DMAC<AES> >("DMAC/AES", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkKeyless<CRC32>("CRC-32", t);
BenchMarkKeyless<Adler32>("Adler-32", t);
BenchMarkKeyless<MD2>("MD2", t);
BenchMarkKeyless<MD5>("MD5", t);
BenchMarkKeyless<SHA>("SHA-1", t);
BenchMarkKeyless<SHA256>("SHA-256", t);
BenchMarkByNameKeyLess<HashTransformation>("MD5", "MD5 (broken)");
BenchMarkByNameKeyLess<HashTransformation>("SHA-1");
BenchMarkByNameKeyLess<HashTransformation>("SHA-256");
#ifdef WORD64_AVAILABLE
BenchMarkKeyless<SHA512>("SHA-512", t);
BenchMarkByNameKeyLess<HashTransformation>("SHA-512");
BenchMarkByNameKeyLess<HashTransformation>("Tiger");
BenchMarkByNameKeyLess<HashTransformation>("Whirlpool");
#endif
BenchMarkKeyless<HAVAL3>("HAVAL (pass=3)", t);
BenchMarkKeyless<HAVAL4>("HAVAL (pass=4)", t);
BenchMarkKeyless<HAVAL5>("HAVAL (pass=5)", t);
#ifdef WORD64_AVAILABLE
BenchMarkKeyless<Tiger>("Tiger", t);
#endif
BenchMarkKeyless<RIPEMD160>("RIPE-MD160", t);
BenchMarkKeyless<RIPEMD320>("RIPE-MD320", t);
BenchMarkKeyless<RIPEMD128>("RIPE-MD128", t);
BenchMarkKeyless<RIPEMD256>("RIPE-MD256", t);
BenchMarkKeyless<PanamaHash<LittleEndian> >("Panama Hash (little endian)", t);
BenchMarkKeyless<PanamaHash<BigEndian> >("Panama Hash (big endian)", t);
#ifdef WORD64_AVAILABLE
BenchMarkKeyless<Whirlpool>("Whirlpool", t);
#endif
BenchMarkKeyed<MDC<MD5>::Encryption>("MDC/MD5", t);
BenchMarkKeyed<LR<MD5>::Encryption>("Luby-Rackoff/MD5", t);
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-160");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-320");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-128");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-256");
cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName<SymmetricCipher>("Panama-LE");
BenchMarkByName<SymmetricCipher>("Panama-BE");
BenchMarkByName<SymmetricCipher>("Salsa20");
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/12", MakeParameters(Name::Rounds(), 12));
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/8", MakeParameters(Name::Rounds(), 8));
BenchMarkByName<SymmetricCipher>("Sosemanuk");
BenchMarkKeyed<ARC4>("ARC4", t);
BenchMarkKeyed<SEAL<BigEndian>::Encryption>("SEAL-3.0-BE", t);
BenchMarkKeyed<SEAL<LittleEndian>::Encryption>("SEAL-3.0-LE", t);
BenchMarkKeyed<WAKE_OFB<BigEndian>::Encryption>("WAKE-OFB-BE", t);
BenchMarkKeyed<WAKE_OFB<LittleEndian>::Encryption>("WAKE-OFB-LE", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkByName<SymmetricCipher>("AES/ECB", 16);
BenchMarkByName<SymmetricCipher>("AES/ECB", 24);
BenchMarkByName<SymmetricCipher>("AES/ECB", 32);
BenchMarkByName<SymmetricCipher>("AES/CTR", 16);
BenchMarkByName<SymmetricCipher>("AES/OFB", 16);
BenchMarkByName<SymmetricCipher>("AES/CFB", 16);
BenchMarkByName<SymmetricCipher>("AES/CBC", 16);
BenchMarkByName<SymmetricCipher>("Camellia/ECB", 16);
BenchMarkByName<SymmetricCipher>("Camellia/ECB", 32);
BenchMarkKeyed<Twofish::Encryption>("Twofish", t);
BenchMarkKeyed<Serpent::Encryption>("Serpent", t);
BenchMarkKeyed<CAST256::Encryption>("CAST-256", t);
BenchMarkKeyed<RC6::Encryption>("RC6", t);
BenchMarkKeyed<MARS::Encryption>("MARS", t);
BenchMarkByName<SymmetricCipher>("SHACAL-2/ECB", 16);
BenchMarkByName<SymmetricCipher>("SHACAL-2/ECB", 64);
BenchMarkKeyed<DES::Encryption>("DES", t);
BenchMarkKeyed<DES_XEX3::Encryption>("DES-XEX3", t);
BenchMarkKeyed<DES_EDE3::Encryption>("DES-EDE3", t);
BenchMarkKeyed<IDEA::Encryption>("IDEA", t);
BenchMarkKeyed<RC2::Encryption>("RC2", t);
BenchMarkKeyed<RC5::Encryption>("RC5 (r=16)", t);
BenchMarkKeyed<Blowfish::Encryption>("Blowfish", t);
BenchMarkKeyed<ThreeWayDecryption>("3-WAY", t);
BenchMarkKeyed<TEA::Encryption>("TEA", t);
BenchMarkKeyedVariable<SAFER_SK::Encryption>("SAFER (r=8)", t, 8);
BenchMarkKeyed<GOST::Encryption>("GOST", t);
#ifdef WORD64_AVAILABLE
BenchMarkKeyed<SHARK::Encryption>("SHARK (r=6)", t);
#endif
BenchMarkByName<SymmetricCipher>("TEA/ECB");
BenchMarkByName<SymmetricCipher>("XTEA/ECB");
BenchMarkKeyed<CAST128::Encryption>("CAST-128", t);
BenchMarkKeyed<CAST256::Encryption>("CAST-256", t);
BenchMarkKeyed<Square::Encryption>("Square", t);
BenchMarkKeyed<SKIPJACK::Encryption>("SKIPJACK", t);
BenchMarkKeyed<RC6::Encryption>("RC6", t);
BenchMarkKeyed<MARS::Encryption>("MARS", t);
BenchMarkKeyedVariable<Rijndael::Encryption>("Rijndael (128-bit key)", t, 16);
BenchMarkKeyedVariable<Rijndael::Encryption>("Rijndael (192-bit key)", t, 24);
BenchMarkKeyedVariable<Rijndael::Encryption>("Rijndael (256-bit key)", t, 32);
BenchMarkKeyedVariable<CTR_Mode<Rijndael>::Encryption>("Rijndael (128) CTR", t, 16);
BenchMarkKeyedVariable<OFB_Mode<Rijndael>::Encryption>("Rijndael (128) OFB", t, 16);
BenchMarkKeyedVariable<CFB_Mode<Rijndael>::Encryption>("Rijndael (128) CFB", t, 16);
BenchMarkKeyedVariable<CBC_Mode<Rijndael>::Encryption>("Rijndael (128) CBC", t, 16);
BenchMarkKeyed<Twofish::Encryption>("Twofish", t);
BenchMarkKeyed<Serpent::Encryption>("Serpent", t);
BenchMarkKeyed<ARC4>("ARC4", t);
BenchMarkKeyed<SEAL<BigEndian>::Encryption>("SEAL-3.0-BE", t);
BenchMarkKeyed<SEAL<LittleEndian>::Encryption>("SEAL-3.0-LE", t);
BenchMarkKeyed<WAKE_CFB<BigEndian>::Encryption>("WAKE-CFB-BE", t);
BenchMarkKeyed<WAKE_CFB<LittleEndian>::Encryption>("WAKE-CFB-LE", t);
BenchMarkKeyed<WAKE_OFB<BigEndian>::Encryption>("WAKE-OFB-BE", t);
BenchMarkKeyed<WAKE_OFB<LittleEndian>::Encryption>("WAKE-OFB-LE", t);
BenchMarkKeyed<PanamaCipher<LittleEndian>::Encryption>("Panama Cipher (little endian)", t);
BenchMarkKeyed<PanamaCipher<BigEndian>::Encryption>("Panama Cipher (big endian)", t);
BenchMarkKeyedVariable<SHACAL2::Encryption>("SHACAL-2 (128-bit key)", t, 16);
BenchMarkKeyedVariable<SHACAL2::Encryption>("SHACAL-2 (512-bit key)", t, 64);
#ifdef WORD64_AVAILABLE
BenchMarkKeyedVariable<Camellia::Encryption>("Camellia (128-bit key)", t, 16);
BenchMarkKeyedVariable<Camellia::Encryption>("Camellia (256-bit key)", t, 32);
#endif
BenchMarkKeyed<Salsa20::Encryption>("Salsa20", t);
BenchMarkKeyed<Salsa20::Encryption>("Salsa20/12", t, MakeParameters(Name::Rounds(), 12));
BenchMarkKeyed<Salsa20::Encryption>("Salsa20/8", t, MakeParameters(Name::Rounds(), 8));
BenchMarkKeyed<MD5MAC>("MD5-MAC", t);
BenchMarkKeyed<XMACC<MD5> >("XMACC/MD5", t);
BenchMarkKeyed<HMAC<MD5> >("HMAC/MD5", t);
BenchMarkKeyed<TTMAC>("Two-Track-MAC", t);
BenchMarkKeyed<CBC_MAC<Rijndael> >("CBC-MAC/Rijndael", t);
BenchMarkKeyed<DMAC<Rijndael> >("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 << "</TABLE>" << endl;
BenchmarkAll2(t);
BenchmarkAll2(t, hertz);
cout << "Throughput Geometric Average: " << setiosflags(ios::fixed) << exp(logtotal/logcount) << endl;

View File

@ -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

View File

@ -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)
{
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;
extern double g_hertz;
cout << "<TBODY style=\"background: yellow\">" << endl;
void BenchmarkAll2(double t, double hertz)
{
g_hertz = hertz;
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);
ECDH<ECP>::Domain ecdhc(ASN1::secp256k1());
ECMQV<ECP>::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 << "<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);
ECDH<EC2N>::Domain ecdhc(ASN1::sect233r1());
ECMQV<EC2N>::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 << "</TABLE>" << endl;
}