38 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 39 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 49 unsigned int len = 16;
50 SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len));
53 const clock_t start =
clock();
57 key.Encrypt(
GlobalRNG(), plaintext, len, ciphertext);
61 if (!pc && key.GetMaterial().SupportsPrecomputation())
63 key.AccessMaterial().Precompute(16);
70 unsigned int len = 16;
76 const clock_t start =
clock();
87 unsigned int len = 16;
91 const clock_t start =
clock();
108 unsigned int len = 16;
113 const clock_t start =
clock();
119 bool unused = pub.
VerifyMessage(message, len, signature, signature.size());
136 const clock_t start =
clock();
155 const clock_t start =
clock();
178 const clock_t start =
clock();
183 d.
Agree(val, priv1, pub2);
184 d.
Agree(val, priv2, pub1);
202 const clock_t start =
clock();
207 d.
Agree(val, spriv1, epriv1, spub2, epub2);
208 d.
Agree(val, spriv2, epriv2, spub1, epub1);
215 void BenchMarkAgreement(
const char *
name, AuthenticatedKeyAgreementDomainWithRoles &
d,
double timeTotal,
bool pc=
false)
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);
227 const clock_t start =
clock();
232 d.Agree(val, spriv1, epriv1, spub2, epub2);
233 d.Agree(val, spriv2, epriv2, spub1, epub1);
240 template <
class SCHEME>
244 typename SCHEME::Decryptor priv(f);
245 typename SCHEME::Encryptor pub(priv);
250 template <
class SCHEME>
254 typename SCHEME::Signer priv(f);
255 typename SCHEME::Verifier pub(priv);
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;
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);
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);
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);
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);
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);
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);
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);
330 cout <<
"\n<TBODY style=\"background: white\">";
357 cout <<
"<TBODY style=\"background: yellow\">" << endl;
383 cout <<
"</TABLE>" << endl;
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
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 GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
Classes for Fully Hashed Menezes-Qu-Vanstone key agreement in GF(p)
void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal)
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.
void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal)
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.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
Implementation of Store interface.
Classes for Elliptic Curves over prime fields.
Interface for public-key signers.
Interface for public-key encryptors.
Decode base 16 data back to bytes.
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 ¶meters=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.
virtual bool SupportsPrecomputation() const
Determines whether the object supports precomputation.
RandomNumberGenerator & GlobalRNG()
ASN.1 object identifiers for algorthms and schemes.
virtual unsigned int PrivateKeyLength() const =0
Provides the size of the private key.
std::hash for asio::adress
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.
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.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Private 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.
void BenchmarkAll2(double t, double hertz)
Classes for Rabin-Williams signature scheme.
Interface for public-key decryptors.
MQV domain for performing authenticated key agreement.
virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a private/public key pair.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to Crypto Parameters.
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.
void BenchMarkSignature(const char *filename, const char *name, double timeTotal)
virtual unsigned int EphemeralPublicKeyLength() const =0
Provides the size of ephemeral public key.
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Public Key.
void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false)
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
Classes for the DSA signature algorithm.
virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const
Sign a message.
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
Derive agreed value.
void BenchMarkKeyGen(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false)
Classes and functions for working with ANS.1 objects.
Implementation of BufferedTransformation's attachment interface.
#define USING_NAMESPACE(x)
void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool pc=false)
"The XTR public key system" by Arjen K.
Classes for the RSA cryptosystem.
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Public Key.
Interface for public-key signature verifiers.
virtual size_t CiphertextLength(size_t plaintextLength) const =0
Calculate the length of ciphertext given length of plaintext.
#define CRYPTOPP_UNUSED(x)
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
CryptoMaterial & AccessMaterial()
Retrieves a reference to Crypto Parameters.
Classes providing file-based library services.
Classes and functions for Elliptic Curves over prime and binary fields.
void BenchMarkAgreement(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false)
Interface for domains of authenticated key agreement protocols.
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
void BenchMarkCrypto(const char *filename, const char *name, double timeTotal)
void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier &pub, double timeTotal, bool pc=false)
Classes for probablistic signature schemes.
#define CRYPTOPP_DATA_DIR
void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken)
const double CLOCK_TICKS_PER_SECOND
virtual DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const =0
Decrypt a byte string.
Template implementing constructors for public key algorithm classes.