From de6e367b5b652335d1dc6435b6bbef9b64a748a7 Mon Sep 17 00:00:00 2001 From: weidai Date: Tue, 29 Jun 2010 01:11:47 +0000 Subject: use GlobalRNG(), improved benchmarking of AuthenticatedSymmetricCipher git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@493 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- bench.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'bench.cpp') diff --git a/bench.cpp b/bench.cpp index 537caff..cee316c 100644 --- a/bench.cpp +++ b/bench.cpp @@ -3,9 +3,9 @@ #define _CRT_SECURE_NO_DEPRECATE #include "bench.h" +#include "validate.h" #include "aes.h" #include "blumshub.h" -#include "rng.h" #include "files.h" #include "hex.h" #include "modes.h" @@ -96,6 +96,7 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal) { const int BUF_SIZE=RoundUpToMultipleOf(2048U, cipher.OptimalBlockSize()); AlignedSecByteBlock buf(BUF_SIZE); + GlobalRNG().GenerateBlock(buf, BUF_SIZE); clock_t start = clock(); unsigned long i=0, blocks=1; @@ -112,12 +113,19 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal) OutputResultBytes(name, double(blocks) * BUF_SIZE, 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); +} + void BenchMark(const char *name, HashTransformation &ht, double timeTotal) { const int BUF_SIZE=2048U; AlignedSecByteBlock buf(BUF_SIZE); - LC_RNG rng((word32)time(NULL)); - rng.GenerateBlock(buf, BUF_SIZE); + GlobalRNG().GenerateBlock(buf, BUF_SIZE); clock_t start = clock(); unsigned long i=0, blocks=1; @@ -138,8 +146,7 @@ void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal) { const int BUF_SIZE=2048U; AlignedSecByteBlock buf(BUF_SIZE); - LC_RNG rng((word32)time(NULL)); - rng.GenerateBlock(buf, BUF_SIZE); + GlobalRNG().GenerateBlock(buf, BUF_SIZE); clock_t start = clock(); unsigned long i=0, blocks=1; @@ -235,10 +242,10 @@ void BenchmarkAll(double t, double hertz) cout << "AlgorithmMiB/Second" << cpb << "Microseconds to
Setup Key and IV" << cpk << endl; cout << "\n"; - 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("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"); cout << "\n"; BenchMarkByName2("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048)); -- cgit v1.2.1