21#if CRYPTOPP_MSC_VERSION
22# pragma warning(disable: 4355)
25#if CRYPTOPP_MSC_VERSION
26# pragma warning(disable: 4505 4355)
34 unsigned long iterations = 0;
37 clock_t start = ::clock();
40 for (
unsigned int i=0; i<1024; i++)
41 c.SetKey(defaultKey, keyLength, params);
42 timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND;
45 while (timeTaken < g_allocatedTime);
47 OutputResultKeying(iterations, timeTaken);
58template <
class T_FactoryOutput,
class T_Interface>
61 std::string name(factoryName ? factoryName :
"");
65 keyLength = obj->DefaultKeyLength();
67 if (displayName != NULLPTR)
69 else if (keyLength != 0)
70 name +=
" (" +
IntToString(keyLength * 8) +
"-bit key)";
73 BenchMark(name.c_str(), *
static_cast<T_Interface *
>(obj.get()), g_allocatedTime);
77template <
class T_FactoryOutput>
80 BenchMarkByName2<T_FactoryOutput,T_FactoryOutput>(factoryName, keyLength, displayName, params);
83void BenchmarkSharedKeyedAlgorithms(
double t,
double hertz)
88 const char *cpb, *cpk;
91 cpb =
"<TH>Cycles/Byte";
92 cpk =
"<TH>Cycles to<BR>Setup Key and IV";
99 std::cout <<
"\n<TABLE>";
100 std::cout <<
"\n<COLGROUP><COL style=\"text-align: left;\"><COL style=\"text-align: right;\"><COL style=";
101 std::cout <<
"\"text-align: right;\"><COL style=\"text-align: right;\"><COL style=\"text-align: right;\">";
102 std::cout <<
"\n<THEAD style=\"background: #F0F0F0\">";
103 std::cout <<
"\n<TR><TH>Algorithm<TH>Provider<TH>MiB/Second" << cpb;
104 std::cout <<
"<TH>Microseconds to<BR>Setup Key and IV" << cpk;
106 std::cout <<
"\n<TBODY style=\"background: white;\">";
108#if CRYPTOPP_AESNI_AVAILABLE
110 BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>(
"AES/GCM", 0,
"GMAC(AES)");
112#elif CRYPTOPP_ARM_PMULL_AVAILABLE
114 BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>(
"AES/GCM", 0,
"GMAC(AES)");
116#elif CRYPTOPP_POWER8_VMULL_AVAILABLE
118 BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>(
"AES/GCM", 0,
"GMAC(AES)");
122 BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>(
"AES/GCM", 0,
"GMAC(AES) (2K tables)",
MakeParameters(
Name::TableSize(), 2048));
123 BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>(
"AES/GCM", 0,
"GMAC(AES) (64K tables)",
MakeParameters(
Name::TableSize(), 64 * 1024));
126 BenchMarkByName<MessageAuthenticationCode>(
"VMAC(AES)-64");
127 BenchMarkByName<MessageAuthenticationCode>(
"VMAC(AES)-128");
128 BenchMarkByName<MessageAuthenticationCode>(
"HMAC(SHA-1)");
129 BenchMarkByName<MessageAuthenticationCode>(
"HMAC(SHA-256)");
130 BenchMarkByName<MessageAuthenticationCode>(
"Two-Track-MAC");
131 BenchMarkByName<MessageAuthenticationCode>(
"CMAC(AES)");
132 BenchMarkByName<MessageAuthenticationCode>(
"DMAC(AES)");
133 BenchMarkByName<MessageAuthenticationCode>(
"Poly1305(AES)");
134 BenchMarkByName<MessageAuthenticationCode>(
"Poly1305TLS");
135 BenchMarkByName<MessageAuthenticationCode>(
"BLAKE2s");
136 BenchMarkByName<MessageAuthenticationCode>(
"BLAKE2b");
137 BenchMarkByName<MessageAuthenticationCode>(
"SipHash-2-4");
138 BenchMarkByName<MessageAuthenticationCode>(
"SipHash-4-8");
141 std::cout <<
"\n<TBODY style=\"background: yellow;\">";
143 BenchMarkByName<SymmetricCipher>(
"Panama-LE");
144 BenchMarkByName<SymmetricCipher>(
"Panama-BE");
145 BenchMarkByName<SymmetricCipher>(
"Salsa20", 0,
"Salsa20");
148 BenchMarkByName<SymmetricCipher>(
"ChaCha", 0,
"ChaCha20");
151 BenchMarkByName<SymmetricCipher>(
"ChaChaTLS");
152 BenchMarkByName<SymmetricCipher>(
"Sosemanuk");
153 BenchMarkByName<SymmetricCipher>(
"Rabbit");
154 BenchMarkByName<SymmetricCipher>(
"RabbitWithIV");
155 BenchMarkByName<SymmetricCipher>(
"HC-128");
156 BenchMarkByName<SymmetricCipher>(
"HC-256");
157 BenchMarkByName<SymmetricCipher>(
"MARC4");
158 BenchMarkByName<SymmetricCipher>(
"SEAL-3.0-LE");
159 BenchMarkByName<SymmetricCipher>(
"WAKE-OFB-LE");
162 std::cout <<
"\n<TBODY style=\"background: white;\">";
164 BenchMarkByName<SymmetricCipher>(
"AES/CTR", 16);
165 BenchMarkByName<SymmetricCipher>(
"AES/CTR", 24);
166 BenchMarkByName<SymmetricCipher>(
"AES/CTR", 32);
167 BenchMarkByName<SymmetricCipher>(
"AES/CBC", 16);
168 BenchMarkByName<SymmetricCipher>(
"AES/CBC", 24);
169 BenchMarkByName<SymmetricCipher>(
"AES/CBC", 32);
170 BenchMarkByName<SymmetricCipher>(
"AES/XTS", 32);
171 BenchMarkByName<SymmetricCipher>(
"AES/XTS", 48);
172 BenchMarkByName<SymmetricCipher>(
"AES/XTS", 64);
173 BenchMarkByName<SymmetricCipher>(
"AES/OFB", 16);
174 BenchMarkByName<SymmetricCipher>(
"AES/CFB", 16);
175 BenchMarkByName<SymmetricCipher>(
"AES/ECB", 16);
176 BenchMarkByName<SymmetricCipher>(
"ARIA/CTR", 16);
177 BenchMarkByName<SymmetricCipher>(
"ARIA/CTR", 32);
178 BenchMarkByName<SymmetricCipher>(
"HIGHT/CTR");
179 BenchMarkByName<SymmetricCipher>(
"Camellia/CTR", 16);
180 BenchMarkByName<SymmetricCipher>(
"Camellia/CTR", 32);
181 BenchMarkByName<SymmetricCipher>(
"Twofish/CTR");
182 BenchMarkByName<SymmetricCipher>(
"Threefish-256(256)/CTR", 32);
183 BenchMarkByName<SymmetricCipher>(
"Threefish-512(512)/CTR", 64);
184 BenchMarkByName<SymmetricCipher>(
"Threefish-1024(1024)/CTR", 128);
185 BenchMarkByName<SymmetricCipher>(
"Serpent/CTR");
186 BenchMarkByName<SymmetricCipher>(
"CAST-128/CTR");
187 BenchMarkByName<SymmetricCipher>(
"CAST-256/CTR", 32);
188 BenchMarkByName<SymmetricCipher>(
"RC6/CTR");
189 BenchMarkByName<SymmetricCipher>(
"MARS/CTR");
190 BenchMarkByName<SymmetricCipher>(
"SHACAL-2/CTR", 16);
191 BenchMarkByName<SymmetricCipher>(
"SHACAL-2/CTR", 64);
192 BenchMarkByName<SymmetricCipher>(
"DES/CTR");
193 BenchMarkByName<SymmetricCipher>(
"DES-XEX3/CTR");
194 BenchMarkByName<SymmetricCipher>(
"DES-EDE3/CTR");
195 BenchMarkByName<SymmetricCipher>(
"IDEA/CTR");
196 BenchMarkByName<SymmetricCipher>(
"RC5/CTR", 0,
"RC5 (r=16)");
197 BenchMarkByName<SymmetricCipher>(
"Blowfish/CTR");
198 BenchMarkByName<SymmetricCipher>(
"SKIPJACK/CTR");
199 BenchMarkByName<SymmetricCipher>(
"SEED/CTR", 0,
"SEED/CTR (1/2 K table)");
200 BenchMarkByName<SymmetricCipher>(
"SM4/CTR");
202 BenchMarkByName<SymmetricCipher>(
"Kalyna-128/CTR", 16,
"Kalyna-128(128)/CTR (128-bit key)");
203 BenchMarkByName<SymmetricCipher>(
"Kalyna-128/CTR", 32,
"Kalyna-128(256)/CTR (256-bit key)");
204 BenchMarkByName<SymmetricCipher>(
"Kalyna-256/CTR", 32,
"Kalyna-256(256)/CTR (256-bit key)");
205 BenchMarkByName<SymmetricCipher>(
"Kalyna-256/CTR", 64,
"Kalyna-256(512)/CTR (512-bit key)");
206 BenchMarkByName<SymmetricCipher>(
"Kalyna-512/CTR", 64,
"Kalyna-512(512)/CTR (512-bit key)");
209 std::cout <<
"\n<TBODY style=\"background: yellow;\">";
211 BenchMarkByName<SymmetricCipher>(
"CHAM-64/CTR", 16,
"CHAM-64(128)/CTR (128-bit key)");
212 BenchMarkByName<SymmetricCipher>(
"CHAM-128/CTR", 16,
"CHAM-128(128)/CTR (128-bit key)");
213 BenchMarkByName<SymmetricCipher>(
"CHAM-128/CTR", 32,
"CHAM-128(256)/CTR (256-bit key)");
215 BenchMarkByName<SymmetricCipher>(
"LEA-128/CTR", 16,
"LEA-128(128)/CTR (128-bit key)");
216 BenchMarkByName<SymmetricCipher>(
"LEA-128/CTR", 24,
"LEA-128(192)/CTR (192-bit key)");
217 BenchMarkByName<SymmetricCipher>(
"LEA-128/CTR", 32,
"LEA-128(256)/CTR (256-bit key)");
219 BenchMarkByName<SymmetricCipher>(
"SIMECK-32/CTR", 8,
"SIMECK-32(64)/CTR (64-bit key)");
220 BenchMarkByName<SymmetricCipher>(
"SIMECK-64/CTR", 16,
"SIMECK-64(128)/CTR (128-bit key)");
222 BenchMarkByName<SymmetricCipher>(
"SIMON-64/CTR", 12,
"SIMON-64(96)/CTR (96-bit key)");
223 BenchMarkByName<SymmetricCipher>(
"SIMON-64/CTR", 16,
"SIMON-64(128)/CTR (128-bit key)");
224 BenchMarkByName<SymmetricCipher>(
"SIMON-128/CTR", 16,
"SIMON-128(128)/CTR (128-bit key)");
225 BenchMarkByName<SymmetricCipher>(
"SIMON-128/CTR", 24,
"SIMON-128(192)/CTR (192-bit key)");
226 BenchMarkByName<SymmetricCipher>(
"SIMON-128/CTR", 32,
"SIMON-128(256)/CTR (256-bit key)");
228 BenchMarkByName<SymmetricCipher>(
"SPECK-64/CTR", 12,
"SPECK-64(96)/CTR (96-bit key)");
229 BenchMarkByName<SymmetricCipher>(
"SPECK-64/CTR", 16,
"SPECK-64(128)/CTR (128-bit key)");
230 BenchMarkByName<SymmetricCipher>(
"SPECK-128/CTR", 16,
"SPECK-128(128)/CTR (128-bit key)");
231 BenchMarkByName<SymmetricCipher>(
"SPECK-128/CTR", 24,
"SPECK-128(192)/CTR (192-bit key)");
232 BenchMarkByName<SymmetricCipher>(
"SPECK-128/CTR", 32,
"SPECK-128(256)/CTR (256-bit key)");
234 BenchMarkByName<SymmetricCipher>(
"TEA/CTR");
235 BenchMarkByName<SymmetricCipher>(
"XTEA/CTR");
238 std::cout <<
"\n<TBODY style=\"background: white;\">";
240#if CRYPTOPP_AESNI_AVAILABLE
242 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/GCM", 0,
"AES/GCM");
244#elif CRYPTOPP_ARM_PMULL_AVAILABLE
246 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/GCM", 0,
"AES/GCM");
248#elif CRYPTOPP_POWER8_VMULL_AVAILABLE
250 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/GCM", 0,
"AES/GCM");
254 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/GCM", 0,
"AES/GCM (2K tables)",
MakeParameters(
Name::TableSize(), 2048));
255 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/GCM", 0,
"AES/GCM (64K tables)",
MakeParameters(
Name::TableSize(), 64 * 1024));
257 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/CCM");
258 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"AES/EAX");
259 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"ChaCha20/Poly1305");
260 BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>(
"XChaCha20/Poly1305");
263 std::cout <<
"\n</TABLE>" << std::endl;
Classes for working with NameValuePairs.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Standard names for retrieving values by name when working with NameValuePairs.
Interface for authenticated encryption modes of operation.
void SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength=0)
Prescribes the data lengths.
virtual lword MaxMessageLength() const =0
Provides the maximum length of encrypted data.
virtual bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
Combines two sets of NameValuePairs.
Used to pass byte array input as part of a NameValuePairs object.
Interface for retrieving values given their names.
Interface for algorithms that take byte strings as keys.
Pointer that overloads operator ->
Classes for CMAC message authentication code.
Functions for CPU features and intrinsics.
Abstract base classes that provide a uniform interface to this library.
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Classes for DMAC message authentication code.
Classes and functions for registering and locating library objects.
Classes for HMAC message authentication codes.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
Crypto++ library namespace.
const char * IV()
ConstByteArrayParameter, also accepts const byte * for backwards compatibility.
const char * TableSize()
int, in bytes
Namespace containing testing and benchmark classes.
Classes for automatic resource management.
Classes for the TTMAC message authentication code.
Classes for the VMAC message authentication code.