Crypto++  5.6.5
Free C++ class library of cryptographic schemes
bench2.cpp
1 // bench2.cpp - originally written and placed in the public domain by Wei Dai
2 // CryptoPP::Test namespace added by JW in February 2017
3 
4 #include "cryptlib.h"
5 #include "bench.h"
6 #include "validate.h"
7 
8 #include "pubkey.h"
9 #include "gfpcrypt.h"
10 #include "eccrypto.h"
11 #include "pkcspad.h"
12 
13 #include "files.h"
14 #include "filters.h"
15 #include "hex.h"
16 #include "rsa.h"
17 #include "nr.h"
18 #include "dsa.h"
19 #include "luc.h"
20 #include "rw.h"
21 #include "ecp.h"
22 #include "ec2n.h"
23 #include "asn.h"
24 #include "dh.h"
25 #include "mqv.h"
26 #include "hmqv.h"
27 #include "fhmqv.h"
28 #include "xtrcrypt.h"
29 #include "esign.h"
30 #include "pssr.h"
31 #include "oids.h"
32 #include "randpool.h"
33 #include "stdcpp.h"
34 
35 #if CRYPTOPP_MSC_VERSION
36 # pragma warning(disable: 4505 4355)
37 #endif
38 
39 NAMESPACE_BEGIN(CryptoPP)
40 NAMESPACE_BEGIN(Test)
41 
42 void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false)
43 {
44  unsigned int len = 16;
45  SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len));
46  Test::GlobalRNG().GenerateBlock(plaintext, len);
47 
48  unsigned int i;
49  double timeTaken;
50 
51  const clock_t start = ::clock();
52  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
53  key.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext);
54 
55  OutputResultOperations(name, "Encryption", pc, i, timeTaken);
56 
57  if (!pc && key.GetMaterial().SupportsPrecomputation())
58  {
59  key.AccessMaterial().Precompute(16);
60  BenchMarkEncryption(name, key, timeTotal, true);
61  }
62 }
63 
64 void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal)
65 {
66  unsigned int len = 16;
67  SecByteBlock ciphertext(pub.CiphertextLength(len));
68  SecByteBlock plaintext(pub.MaxPlaintextLength(ciphertext.size()));
69  Test::GlobalRNG().GenerateBlock(plaintext, len);
70  pub.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext);
71 
72  unsigned int i;
73  double timeTaken;
74 
75  const clock_t start = ::clock();
76  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
77  priv.Decrypt(Test::GlobalRNG(), ciphertext, ciphertext.size(), plaintext);
78 
79  OutputResultOperations(name, "Decryption", false, i, timeTaken);
80 }
81 
82 void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool pc=false)
83 {
84  unsigned int len = 16;
85  AlignedSecByteBlock message(len), signature(key.SignatureLength());
86  Test::GlobalRNG().GenerateBlock(message, len);
87 
88  unsigned int i;
89  double timeTaken;
90 
91  const clock_t start = ::clock();
92  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
93  (void)key.SignMessage(Test::GlobalRNG(), message, len, signature);
94 
95  OutputResultOperations(name, "Signature", pc, i, timeTaken);
96 
97  if (!pc && key.GetMaterial().SupportsPrecomputation())
98  {
99  key.AccessMaterial().Precompute(16);
100  BenchMarkSigning(name, key, timeTotal, true);
101  }
102 }
103 
104 void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier &pub, double timeTotal, bool pc=false)
105 {
106  unsigned int len = 16;
107  AlignedSecByteBlock message(len), signature(pub.SignatureLength());
108  Test::GlobalRNG().GenerateBlock(message, len);
109  priv.SignMessage(Test::GlobalRNG(), message, len, signature);
110 
111  unsigned int i;
112  double timeTaken;
113 
114  const clock_t start = ::clock();
115  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
116  (void)pub.VerifyMessage(message, len, signature, signature.size());
117 
118  OutputResultOperations(name, "Verification", pc, i, timeTaken);
119 
120  if (!pc && pub.GetMaterial().SupportsPrecomputation())
121  {
122  pub.AccessMaterial().Precompute(16);
123  BenchMarkVerification(name, priv, pub, timeTotal, true);
124  }
125 }
126 
127 void BenchMarkKeyGen(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false)
128 {
129  SecByteBlock priv(d.PrivateKeyLength()), pub(d.PublicKeyLength());
130 
131  unsigned int i;
132  double timeTaken;
133 
134  const clock_t start = ::clock();
135  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
136  d.GenerateKeyPair(Test::GlobalRNG(), priv, pub);
137 
138  OutputResultOperations(name, "Key-Pair Generation", pc, i, timeTaken);
139 
140  if (!pc && d.GetMaterial().SupportsPrecomputation())
141  {
142  d.AccessMaterial().Precompute(16);
143  BenchMarkKeyGen(name, d, timeTotal, true);
144  }
145 }
146 
147 void BenchMarkKeyGen(const char *name, AuthenticatedKeyAgreementDomain &d, double timeTotal, bool pc=false)
148 {
150 
151  unsigned int i;
152  double timeTaken;
153 
154  const clock_t start = ::clock();
155  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
156  d.GenerateEphemeralKeyPair(Test::GlobalRNG(), priv, pub);
157 
158  OutputResultOperations(name, "Key-Pair Generation", pc, i, timeTaken);
159 
160  if (!pc && d.GetMaterial().SupportsPrecomputation())
161  {
162  d.AccessMaterial().Precompute(16);
163  BenchMarkKeyGen(name, d, timeTotal, true);
164  }
165 }
166 
167 void BenchMarkAgreement(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false)
168 {
169  SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength());
170  SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength());
171  d.GenerateKeyPair(Test::GlobalRNG(), priv1, pub1);
172  d.GenerateKeyPair(Test::GlobalRNG(), priv2, pub2);
174 
175  unsigned int i;
176  double timeTaken;
177 
178  const clock_t start = ::clock();
179  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i+=2)
180  {
181  d.Agree(val, priv1, pub2);
182  d.Agree(val, priv2, pub1);
183  }
184 
185  OutputResultOperations(name, "Key Agreement", pc, i, timeTaken);
186 }
187 
188 void BenchMarkAgreement(const char *name, AuthenticatedKeyAgreementDomain &d, double timeTotal, bool pc=false)
189 {
194  d.GenerateStaticKeyPair(Test::GlobalRNG(), spriv1, spub1);
195  d.GenerateStaticKeyPair(Test::GlobalRNG(), spriv2, spub2);
196  d.GenerateEphemeralKeyPair(Test::GlobalRNG(), epriv1, epub1);
197  d.GenerateEphemeralKeyPair(Test::GlobalRNG(), epriv2, epub2);
199 
200  unsigned int i;
201  double timeTaken;
202 
203  const clock_t start = ::clock();
204  for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i+=2)
205  {
206  d.Agree(val, spriv1, epriv1, spub2, epub2);
207  d.Agree(val, spriv2, epriv2, spub1, epub1);
208  }
209 
210  OutputResultOperations(name, "Key Agreement", pc, i, timeTaken);
211 }
212 
213 template <class SCHEME>
214 void BenchMarkCrypto(const char *filename, const char *name, double timeTotal)
215 {
216  FileSource f(filename, true, new HexDecoder);
217  typename SCHEME::Decryptor priv(f);
218  typename SCHEME::Encryptor pub(priv);
219  BenchMarkEncryption(name, pub, timeTotal);
220  BenchMarkDecryption(name, priv, pub, timeTotal);
221 }
222 
223 template <class SCHEME>
224 void BenchMarkSignature(const char *filename, const char *name, double timeTotal)
225 {
226  FileSource f(filename, true, new HexDecoder);
227  typename SCHEME::Signer priv(f);
228  typename SCHEME::Verifier pub(priv);
229  BenchMarkSigning(name, priv, timeTotal);
230  BenchMarkVerification(name, priv, pub, timeTotal);
231 }
232 
233 template <class D>
234 void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal)
235 {
236  FileSource f(filename, true, new HexDecoder);
237  D d(f);
238  BenchMarkKeyGen(name, d, timeTotal);
239  BenchMarkAgreement(name, d, timeTotal);
240 }
241 
242 void Benchmark3(double t, double hertz)
243 {
244  g_allocatedTime = t;
245  g_hertz = hertz;
246 
247  const char *mco;
248  if (g_hertz > 1.0f)
249  mco = "<TH>Megacycles/Operation";
250  else
251  mco = "";
252 
253  std::cout << "\n<TABLE>";
254  std::cout << "\n<COLGROUP><COL style=\"text-align: left;\"><COL style=";
255  std::cout << "\"text-align: right;\"><COL style=\"text-align: right;\">";
256  std::cout << "\n<THEAD style=\"background: #F0F0F0\">";
257  std::cout << "\n<TR><TH>Operation<TH>Milliseconds/Operation" << mco;
258 
259  std::cout << "\n<TBODY style=\"background: white;\">";
260  {
261  BenchMarkCrypto<RSAES<OAEP<SHA1> > >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
262  BenchMarkCrypto<LUCES<OAEP<SHA1> > >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
263  BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie1024.dat", "DLIES 1024", t);
264  BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc512.dat", "LUCELG 512", t);
265  }
266 
267  std::cout << "\n<TBODY style=\"background: yellow;\">";
268  {
269  BenchMarkCrypto<RSAES<OAEP<SHA1> > >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
270  BenchMarkCrypto<LUCES<OAEP<SHA1> > >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
271  BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie2048.dat", "DLIES 2048", t);
272  BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc1024.dat", "LUCELG 1024", t);
273  }
274 
275  std::cout << "\n<TBODY style=\"background: white;\">";
276  {
277  BenchMarkSignature<RSASS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
278  BenchMarkSignature<RWSS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/rw1024.dat", "RW 1024", t);
279  BenchMarkSignature<LUCSS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
280  BenchMarkSignature<NR<SHA1> >(CRYPTOPP_DATA_DIR "TestData/nr1024.dat", "NR 1024", t);
281  BenchMarkSignature<DSA>(CRYPTOPP_DATA_DIR "TestData/dsa1024.dat", "DSA 1024", t);
282  BenchMarkSignature<LUC_HMP<SHA1> >(CRYPTOPP_DATA_DIR "TestData/lucs512.dat", "LUC-HMP 512", t);
283  BenchMarkSignature<ESIGN<SHA1> >(CRYPTOPP_DATA_DIR "TestData/esig1023.dat", "ESIGN 1023", t);
284  BenchMarkSignature<ESIGN<SHA1> >(CRYPTOPP_DATA_DIR "TestData/esig1536.dat", "ESIGN 1536", t);
285  }
286 
287  std::cout << "\n<TBODY style=\"background: yellow;\">";
288  {
289  BenchMarkSignature<RSASS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
290  BenchMarkSignature<RWSS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/rw2048.dat", "RW 2048", t);
291  BenchMarkSignature<LUCSS<PSSR, SHA1> >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
292  BenchMarkSignature<NR<SHA1> >(CRYPTOPP_DATA_DIR "TestData/nr2048.dat", "NR 2048", t);
293  BenchMarkSignature<LUC_HMP<SHA1> >(CRYPTOPP_DATA_DIR "TestData/lucs1024.dat", "LUC-HMP 1024", t);
294  BenchMarkSignature<ESIGN<SHA1> >(CRYPTOPP_DATA_DIR "TestData/esig2046.dat", "ESIGN 2046", t);
295  }
296 
297  std::cout << "\n<TBODY style=\"background: white;\">";
298  {
299  BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh171.dat", "XTR-DH 171", t);
300  BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh342.dat", "XTR-DH 342", t);
301  BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh1024.dat", "DH 1024", t);
302  BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh2048.dat", "DH 2048", t);
303  BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd512.dat", "LUCDIF 512", t);
304  BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd1024.dat", "LUCDIF 1024", t);
305  BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv1024.dat", "MQV 1024", t);
306  BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv2048.dat", "MQV 2048", t);
307 
308 #if 0
309  BenchMarkKeyAgreement<ECHMQV160>(CRYPTOPP_DATA_DIR "TestData/hmqv160.dat", "HMQV P-160", t);
310  BenchMarkKeyAgreement<ECHMQV256>(CRYPTOPP_DATA_DIR "TestData/hmqv256.dat", "HMQV P-256", t);
311  BenchMarkKeyAgreement<ECHMQV384>(CRYPTOPP_DATA_DIR "TestData/hmqv384.dat", "HMQV P-384", t);
312  BenchMarkKeyAgreement<ECHMQV512>(CRYPTOPP_DATA_DIR "TestData/hmqv512.dat", "HMQV P-512", t);
313 
314  BenchMarkKeyAgreement<ECFHMQV160>(CRYPTOPP_DATA_DIR "TestData/fhmqv160.dat", "FHMQV P-160", t);
315  BenchMarkKeyAgreement<ECFHMQV256>(CRYPTOPP_DATA_DIR "TestData/fhmqv256.dat", "FHMQV P-256", t);
316  BenchMarkKeyAgreement<ECFHMQV384>(CRYPTOPP_DATA_DIR "TestData/fhmqv384.dat", "FHMQV P-384", t);
317  BenchMarkKeyAgreement<ECFHMQV512>(CRYPTOPP_DATA_DIR "TestData/fhmqv512.dat", "FHMQV P-512", t);
318 #endif
319  }
320 
321  std::cout << "\n<TBODY style=\"background: yellow;\">";
322  {
323  ECIES<ECP>::Decryptor cpriv(Test::GlobalRNG(), ASN1::secp256k1());
324  ECIES<ECP>::Encryptor cpub(cpriv);
325  ECDSA<ECP, SHA1>::Signer spriv(cpriv);
326  ECDSA<ECP, SHA1>::Verifier spub(spriv);
327  ECDSA_RFC6979<ECP, SHA1>::Signer spriv2(cpriv);
329  ECGDSA<ECP, SHA1>::Signer spriv3(Test::GlobalRNG(), ASN1::secp256k1());
330  ECGDSA<ECP, SHA1>::Verifier spub3(spriv3);
331  ECDH<ECP>::Domain ecdhc(ASN1::secp256k1());
332  ECMQV<ECP>::Domain ecmqvc(ASN1::secp256k1());
333 
334  BenchMarkEncryption("ECIES over GF(p) 256", cpub, t);
335  BenchMarkDecryption("ECIES over GF(p) 256", cpriv, cpub, t);
336  BenchMarkSigning("ECDSA over GF(p) 256", spriv, t);
337  BenchMarkVerification("ECDSA over GF(p) 256", spriv, spub, t);
338  BenchMarkSigning("ECDSA-RFC6979 over GF(p) 256", spriv2, t);
339  BenchMarkVerification("ECDSA-RFC6979 over GF(p) 256", spriv2, spub2, t);
340  BenchMarkSigning("ECGDSA over GF(p) 256", spriv3, t);
341  BenchMarkVerification("ECGDSA over GF(p) 256", spriv3, spub3, t);
342  BenchMarkKeyGen("ECDHC over GF(p) 256", ecdhc, t);
343  BenchMarkAgreement("ECDHC over GF(p) 256", ecdhc, t);
344  BenchMarkKeyGen("ECMQVC over GF(p) 256", ecmqvc, t);
345  BenchMarkAgreement("ECMQVC over GF(p) 256", ecmqvc, t);
346  }
347 
348  std::cout << "\n<TBODY style=\"background: white;\">";
349  {
350  ECIES<EC2N>::Decryptor cpriv(Test::GlobalRNG(), ASN1::sect233r1());
351  ECIES<EC2N>::Encryptor cpub(cpriv);
352  ECDSA<EC2N, SHA1>::Signer spriv(cpriv);
353  ECDSA<EC2N, SHA1>::Verifier spub(spriv);
354  ECDSA_RFC6979<EC2N, SHA1>::Signer spriv2(cpriv);
356  ECGDSA<EC2N, SHA1>::Signer spriv3(Test::GlobalRNG(), ASN1::sect233r1());
357  ECGDSA<EC2N, SHA1>::Verifier spub3(spriv3);
358  ECDH<EC2N>::Domain ecdhc(ASN1::sect233r1());
359  ECMQV<EC2N>::Domain ecmqvc(ASN1::sect233r1());
360 
361  BenchMarkEncryption("ECIES over GF(2^n) 233", cpub, t);
362  BenchMarkDecryption("ECIES over GF(2^n) 233", cpriv, cpub, t);
363  BenchMarkSigning("ECDSA over GF(2^n) 233", spriv, t);
364  BenchMarkVerification("ECDSA over GF(2^n) 233", spriv, spub, t);
365  BenchMarkSigning("ECDSA-RFC6979 over GF(2^n) 233", spriv2, t);
366  BenchMarkVerification("ECDSA-RFC6979 over GF(2^n) 233", spriv2, spub2, t);
367  BenchMarkSigning("ECGDSA over GF(2^n) 233", spriv3, t);
368  BenchMarkVerification("ECGDSA over GF(2^n) 233", spriv3, spub3, t);
369  BenchMarkKeyGen("ECDHC over GF(2^n) 233", ecdhc, t);
370  BenchMarkAgreement("ECDHC over GF(2^n) 233", ecdhc, t);
371  BenchMarkKeyGen("ECMQVC over GF(2^n) 233", ecmqvc, t);
372  BenchMarkAgreement("ECMQVC over GF(2^n) 233", ecmqvc, t);
373  }
374 
375  std::cout << "\n</TABLE>" << std::endl;
376 }
377 
378 NAMESPACE_END // Test
379 NAMESPACE_END // CryptoPP
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
Definition: cryptlib.h:2240
virtual bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const =0
Derive agreed value.
virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a private/public key pair.
Definition: cryptlib.cpp:906
Classes for Fully Hashed Menezes-Qu-Vanstone key agreement in GF(p)
virtual unsigned int StaticPublicKeyLength() const =0
Provides the size of the static public key.
Class file for Randomness Pool.
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
This file contains helper classes/functions for implementing public key algorithms.
virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const
Sign a message.
Definition: cryptlib.cpp:860
Implementation of Store interface.
Definition: files.h:82
Classes for Elliptic Curves over prime fields.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to Crypto Parameters.
Definition: cryptlib.h:2402
Interface for public-key signers.
Definition: cryptlib.h:2631
virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a static private/public key pair.
Definition: cryptlib.cpp:912
Interface for public-key encryptors.
Definition: cryptlib.h:2452
Decode base 16 data back to bytes.
Definition: hex.h:34
Abstract base classes that provide a uniform interface to this library.
virtual void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs &parameters=g_nullNameValuePairs) const =0
Encrypt a byte string.
virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0
Provides the maximum length of plaintext for a given ciphertext length.
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Private Key.
Definition: cryptlib.h:2378
ASN.1 object identifiers for algorthms and schemes.
virtual unsigned int PrivateKeyLength() const =0
Provides the size of the private key.
virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
Definition: cryptlib.cpp:918
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.
SecBlock<byte> typedef.
Definition: secblock.h:822
virtual unsigned int StaticPrivateKeyLength() const =0
Provides the size of the static private key.
virtual unsigned int PublicKeyLength() const =0
Provides the size of the public key.
Classes providing ESIGN signature schemes as defined in IEEE P1363a.
Classes for Hashed Menezes-Qu-Vanstone key agreement in GF(p)
Classes for the LUC cryptosystem.
Classes for Elliptic Curves over binary fields.
virtual unsigned int EphemeralPrivateKeyLength() const =0
Provides the size of ephemeral private key.
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2766
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Private Key.
Definition: cryptlib.h:2381
Classes for PKCS padding schemes.
Classes for Rabin-Williams signature scheme.
Interface for public-key decryptors.
Definition: cryptlib.h:2487
MQV domain for performing authenticated key agreement.
Definition: mqv.h:26
Classes for Diffie-Hellman key exchange.
Classes for HexEncoder and HexDecoder.
virtual bool VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLen) const
Check whether input signature is a valid signature for input message.
Definition: cryptlib.cpp:882
virtual unsigned int EphemeralPublicKeyLength() const =0
Provides the size of ephemeral public key.
Namespace containing testing and benchmark classes.
Definition: cryptlib.h:552
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
SecBlock using AllocatorWithCleanup<byte, true> typedef.
Definition: secblock.h:826
Classes for the DSA signature algorithm.
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
Derive agreed value.
Diffie-Hellman domain.
Definition: dh.h:25
Classes and functions for working with ANS.1 objects.
Implementation of BufferedTransformation&#39;s attachment interface.
"The XTR public key system" by Arjen K.
Classes for the RSA cryptosystem.
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Public Key.
Definition: cryptlib.h:2354
Interface for public-key signature verifiers.
Definition: cryptlib.h:2695
virtual size_t CiphertextLength(size_t plaintextLength) const =0
Calculate the length of ciphertext given length of plaintext.
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
CryptoMaterial & AccessMaterial()
Retrieves a reference to Crypto Parameters.
Definition: cryptlib.h:2399
Classes providing file-based library services.
Classes and functions for Elliptic Curves over prime and binary fields.
Crypto++ library namespace.
Interface for domains of authenticated key agreement protocols.
Definition: cryptlib.h:2824
virtual bool SupportsPrecomputation() const
Determines whether the object supports precomputation.
Definition: cryptlib.h:2230
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
Classes for probablistic signature schemes.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Public Key.
Definition: cryptlib.h:2358
virtual DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs &parameters=g_nullNameValuePairs) const =0
Decrypt a byte string.
Template implementing constructors for public key algorithm classes.
Definition: pubkey.h:2115