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