Crypto++ 8.5 Free C++ class library of cryptographic schemes

bench.h
1 // bench.h - originally written and placed in the public domain by Wei Dai
2 // CryptoPP::Test namespace added by JW in February 2017
3
4 #ifndef CRYPTOPP_BENCH_H
5 #define CRYPTOPP_BENCH_H
6
7 #include "cryptlib.h"
8
9 #include <iostream>
10 #include <iomanip>
11 #include <cmath>
12 #include <ctime>
13
14 NAMESPACE_BEGIN(CryptoPP)
15 NAMESPACE_BEGIN(Test)
16
17 // More granular control over benchmarks
18 enum TestClass {
19 /// \brief Random number generators
20 UnkeyedRNG=(1<<0),
21 /// \brief Message digests
22 UnkeyedHash=(1<<1),
23 /// \brief Other unkeyed algorithms
24 UnkeyedOther=(1<<2),
25
26 /// \brief Message authentication codes
27 SharedKeyMAC=(1<<3),
28 /// \brief Stream ciphers
29 SharedKeyStream=(1<<4),
30 /// \brief Block ciphers ciphers
31 SharedKeyBlock=(1<<5),
32 /// \brief Other shared key algorithms
33 SharedKeyOther=(1<<6),
34
35 /// \brief Key agreement algorithms over integers
36 PublicKeyAgreement=(1<<7),
37 /// \brief Encryption algorithms over integers
38 PublicKeyEncryption=(1<<8),
39 /// \brief Signature algorithms over integers
40 PublicKeySignature=(1<<9),
41 /// \brief Other public key algorithms over integers
42 PublicKeyOther=(1<<10),
43
44 /// \brief Key agreement algorithms over EC
45 PublicKeyAgreementEC=(1<<11),
46 /// \brief Encryption algorithms over EC
47 PublicKeyEncryptionEC=(1<<12),
48 /// \brief Signature algorithms over EC
49 PublicKeySignatureEC=(1<<13),
50 /// \brief Other public key algorithms over EC
51 PublicKeyOtherEC=(1<<14),
52
53 Unkeyed=UnkeyedRNG|UnkeyedHash|UnkeyedOther,
54 SharedKey=SharedKeyMAC|SharedKeyStream|SharedKeyBlock|SharedKeyOther,
55 PublicKey=PublicKeyAgreement|PublicKeyEncryption|PublicKeySignature|PublicKeyOther,
56 PublicKeyEC=PublicKeyAgreementEC|PublicKeyEncryptionEC|PublicKeySignatureEC|PublicKeyOtherEC,
57
58 All=Unkeyed|SharedKey|PublicKey|PublicKeyEC,
59
60 TestFirst=(0), TestLast=(1<<15)
61 };
62
63 extern const double CLOCK_TICKS_PER_SECOND;
64 extern double g_allocatedTime;
65 extern double g_hertz;
66 extern double g_logTotal;
67 extern unsigned int g_logCount;
68 extern const byte defaultKey[];
69
70 // Test book keeping
71 extern time_t g_testBegin;
72 extern time_t g_testEnd;
73
74 // Benchmark command handler
75 void BenchmarkWithCommand(int argc, const char* const argv[]);
76 // Top level, prints preamble and postamble
77 void Benchmark(Test::TestClass suites, double t, double hertz);
78 // Unkeyed systems
79 void BenchmarkUnkeyedAlgorithms(double t, double hertz);
80 // Shared key systems
81 void BenchmarkSharedKeyedAlgorithms(double t, double hertz);
82 // Public key systems over integers
83 void BenchmarkPublicKeyAlgorithms(double t, double hertz);
84 // Public key systems over elliptic curves
85 void BenchmarkEllipticCurveAlgorithms(double t, double hertz);
86
87 // These are defined in bench1.cpp
88 extern void OutputResultKeying(double iterations, double timeTaken);
89 extern void OutputResultBytes(const char *name, const char *provider, double length, double timeTaken);
90 extern void OutputResultOperations(const char *name, const char *provider, const char *operation, bool pc, unsigned long iterations, double timeTaken);
91
92 // These are defined in bench1.cpp
93 extern void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal);
94 extern void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal);
95 extern void BenchMark(const char *name, HashTransformation &ht, double timeTotal);
96 extern void BenchMark(const char *name, RandomNumberGenerator &rng, double timeTotal);
97
98 // These are defined in bench2.cpp
99 extern void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValuePairs &params);
100 extern void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal);
101
102 NAMESPACE_END // Test
103 NAMESPACE_END // CryptoPP
104
105 #endif
HashTransformation
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:1112
BufferedTransformation
Interface for buffered transformations.
Definition: cryptlib.h:1634
SimpleKeyingInterface
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:641
RandomNumberGenerator
Interface for random number generators.
Definition: cryptlib.h:1417
PublicKey
Interface for public keys.
Definition: cryptlib.h:2518
Test
Namespace containing testing and benchmark classes.
Definition: cryptlib.h:575
CryptoPP
Crypto++ library namespace.
StreamTransformation
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:945
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:321
cryptlib.h
Abstract base classes that provide a uniform interface to this library.
AuthenticatedSymmetricCipher
Interface for authenticated encryption modes of operation.
Definition: cryptlib.h:1320