Crypto++  5.6.5
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 template <class SCHEME>
241 void BenchMarkCrypto(const char *filename, const char *name, double timeTotal)
242 {
243  FileSource f(filename, true, new HexDecoder());
244  typename SCHEME::Decryptor priv(f);
245  typename SCHEME::Encryptor pub(priv);
246  BenchMarkEncryption(name, pub, timeTotal);
247  BenchMarkDecryption(name, priv, pub, timeTotal);
248 }
249 
250 template <class SCHEME>
251 void BenchMarkSignature(const char *filename, const char *name, double timeTotal)
252 {
253  FileSource f(filename, true, new HexDecoder());
254  typename SCHEME::Signer priv(f);
255  typename SCHEME::Verifier pub(priv);
256  BenchMarkSigning(name, priv, timeTotal);
257  BenchMarkVerification(name, priv, pub, timeTotal);
258 }
259 
260 template <class D>
261 void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal)
262 {
263  FileSource f(filename, true, new HexDecoder());
264  D d(f);
265  BenchMarkKeyGen(name, d, timeTotal);
266  BenchMarkAgreement(name, d, timeTotal);
267 }
268 
269 extern double g_hertz;
270 
271 void BenchmarkAll2(double t, double hertz)
272 {
273  g_hertz = hertz;
274 
275  cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right>" << endl;
276  cout << "<THEAD><TR><TH>Operation<TH>Milliseconds/Operation" << (g_hertz ? "<TH>Megacycles/Operation" : "") << endl;
277 
278  cout << "\n<TBODY style=\"background: yellow\">";
279  BenchMarkCrypto<RSAES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
280  BenchMarkCrypto<LUCES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
281  BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie1024.dat", "DLIES 1024", t);
282  BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc512.dat", "LUCELG 512", t);
283 
284  cout << "\n<TBODY style=\"background: white\">";
285  BenchMarkCrypto<RSAES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
286  BenchMarkCrypto<LUCES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
287  BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie2048.dat", "DLIES 2048", t);
288  BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc1024.dat", "LUCELG 1024", t);
289 
290  cout << "\n<TBODY style=\"background: yellow\">";
291  BenchMarkSignature<RSASS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
292  BenchMarkSignature<RWSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rw1024.dat", "RW 1024", t);
293  BenchMarkSignature<LUCSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
294  BenchMarkSignature<NR<SHA> >(CRYPTOPP_DATA_DIR "TestData/nr1024.dat", "NR 1024", t);
295  BenchMarkSignature<DSA>(CRYPTOPP_DATA_DIR "TestData/dsa1024.dat", "DSA 1024", t);
296  BenchMarkSignature<LUC_HMP<SHA> >(CRYPTOPP_DATA_DIR "TestData/lucs512.dat", "LUC-HMP 512", t);
297  BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig1023.dat", "ESIGN 1023", t);
298  BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig1536.dat", "ESIGN 1536", t);
299 
300  cout << "\n<TBODY style=\"background: white\">";
301  BenchMarkSignature<RSASS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
302  BenchMarkSignature<RWSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rw2048.dat", "RW 2048", t);
303  BenchMarkSignature<LUCSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
304  BenchMarkSignature<NR<SHA> >(CRYPTOPP_DATA_DIR "TestData/nr2048.dat", "NR 2048", t);
305  BenchMarkSignature<LUC_HMP<SHA> >(CRYPTOPP_DATA_DIR "TestData/lucs1024.dat", "LUC-HMP 1024", t);
306  BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig2046.dat", "ESIGN 2046", t);
307 
308  cout << "\n<TBODY style=\"background: yellow\">";
309  BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh171.dat", "XTR-DH 171", t);
310  BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh342.dat", "XTR-DH 342", t);
311  BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh1024.dat", "DH 1024", t);
312  BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh2048.dat", "DH 2048", t);
313  BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd512.dat", "LUCDIF 512", t);
314  BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd1024.dat", "LUCDIF 1024", t);
315  BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv1024.dat", "MQV 1024", t);
316  BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv2048.dat", "MQV 2048", t);
317 
318 #if 0
319  BenchMarkKeyAgreement<ECHMQV160>(CRYPTOPP_DATA_DIR "TestData/hmqv160.dat", "HMQV P-160", t);
320  BenchMarkKeyAgreement<ECHMQV256>(CRYPTOPP_DATA_DIR "TestData/hmqv256.dat", "HMQV P-256", t);
321  BenchMarkKeyAgreement<ECHMQV384>(CRYPTOPP_DATA_DIR "TestData/hmqv384.dat", "HMQV P-384", t);
322  BenchMarkKeyAgreement<ECHMQV512>(CRYPTOPP_DATA_DIR "TestData/hmqv512.dat", "HMQV P-512", t);
323 
324  BenchMarkKeyAgreement<ECFHMQV160>(CRYPTOPP_DATA_DIR "TestData/fhmqv160.dat", "FHMQV P-160", t);
325  BenchMarkKeyAgreement<ECFHMQV256>(CRYPTOPP_DATA_DIR "TestData/fhmqv256.dat", "FHMQV P-256", t);
326  BenchMarkKeyAgreement<ECFHMQV384>(CRYPTOPP_DATA_DIR "TestData/fhmqv384.dat", "FHMQV P-384", t);
327  BenchMarkKeyAgreement<ECFHMQV512>(CRYPTOPP_DATA_DIR "TestData/fhmqv512.dat", "FHMQV P-512", t);
328 #endif
329 
330  cout << "\n<TBODY style=\"background: white\">";
331  {
332  ECIES<ECP>::Decryptor cpriv(GlobalRNG(), ASN1::secp256k1());
333  ECIES<ECP>::Encryptor cpub(cpriv);
334  ECDSA<ECP, SHA>::Signer spriv(cpriv);
335  ECDSA<ECP, SHA>::Verifier spub(spriv);
336  ECDH<ECP>::Domain ecdhc(ASN1::secp256k1());
337  ECMQV<ECP>::Domain ecmqvc(ASN1::secp256k1());
338 
339  BenchMarkEncryption("ECIES over GF(p) 256", cpub, t);
340  BenchMarkDecryption("ECIES over GF(p) 256", cpriv, cpub, t);
341  BenchMarkSigning("ECDSA over GF(p) 256", spriv, t);
342  BenchMarkVerification("ECDSA over GF(p) 256", spriv, spub, t);
343  BenchMarkKeyGen("ECDHC over GF(p) 256", ecdhc, t);
344  BenchMarkAgreement("ECDHC over GF(p) 256", ecdhc, t);
345  BenchMarkKeyGen("ECMQVC over GF(p) 256", ecmqvc, t);
346  BenchMarkAgreement("ECMQVC over GF(p) 256", ecmqvc, t);
347  }
348 
349  cout << "<TBODY style=\"background: yellow\">" << endl;
350  {
351  ECIES<EC2N>::Decryptor cpriv(GlobalRNG(), ASN1::sect233r1());
352  ECIES<EC2N>::Encryptor cpub(cpriv);
353  ECDSA<EC2N, SHA>::Signer spriv(cpriv);
354  ECDSA<EC2N, SHA>::Verifier spub(spriv);
355  ECDH<EC2N>::Domain ecdhc(ASN1::sect233r1());
356  ECMQV<EC2N>::Domain ecmqvc(ASN1::sect233r1());
357 
358  BenchMarkEncryption("ECIES over GF(2^n) 233", cpub, t);
359  BenchMarkDecryption("ECIES over GF(2^n) 233", cpriv, cpub, t);
360  BenchMarkSigning("ECDSA over GF(2^n) 233", spriv, t);
361  BenchMarkVerification("ECDSA over GF(2^n) 233", spriv, spub, t);
362  BenchMarkKeyGen("ECDHC over GF(2^n) 233", ecdhc, t);
363  BenchMarkAgreement("ECDHC over GF(2^n) 233", ecdhc, t);
364  BenchMarkKeyGen("ECMQVC over GF(2^n) 233", ecmqvc, t);
365  BenchMarkAgreement("ECMQVC over GF(2^n) 233", ecmqvc, t);
366  }
367  cout << "</TABLE>" << endl;
368 }
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
Definition: cryptlib.h:2125
virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
Definition: cryptlib.cpp:942
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:906
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.
This file contains helper classes/functions for implementing public key algorithms.
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
Implementation of Store interface.
Definition: files.h:80
Classes for Elliptic Curves over prime fields.
Interface for public-key signers.
Definition: cryptlib.h:2526
Interface for public-key encryptors.
Definition: cryptlib.h:2336
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:2256
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:2115
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:2259
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.
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:2663
Classes for Rabin-Williams signature scheme.
Interface for public-key decryptors.
Definition: cryptlib.h:2372
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:930
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:2280
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:936
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:2236
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:884
Diffie-Hellman domain.
Definition: dh.h:25
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:2232
Interface for public-key signature verifiers.
Definition: cryptlib.h:2591
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:2277
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 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:2726
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:1954
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.