5 #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 45 #if (CRYPTOPP_MSC_VERSION >= 1410) 46 # pragma strict_gs_check (on) 59 m_source.Get(output, size);
68 cout <<
"\nBlumBlumShub validation suite running...\n\n";
70 Integer p(
"212004934506826557583707108431463840565872545889679278744389317666981496005411448865750399674653351");
71 Integer q(
"100677295735404212434355574418077394581488455772477016953458064183204108039226017738610663984508231");
72 Integer seed(
"63239752671357255800299643604761065219897634268887145610573595874544114193025997412441121667211431");
74 bool pass =
true, fail;
77 const byte output1[] = {
78 0x49,0xEA,0x2C,0xFD,0xB0,0x10,0x64,0xA0,0xBB,0xB9,
79 0x2A,0xF1,0x01,0xDA,0xC1,0x8A,0x94,0xF7,0xB7,0xCE};
80 const byte output2[] = {
81 0x74,0x45,0x48,0xAE,0xAC,0xB7,0x0E,0xDF,0xAF,0xD7,
82 0xD5,0x0E,0x8E,0x29,0x83,0x75,0x6B,0x27,0x46,0xA1};
87 fail = memcmp(output1, buf, 20) != 0;
90 cout << (fail ?
"FAILED " :
"passed ");
92 cout << setw(2) << setfill(
'0') << hex << (int)buf[j];
97 fail = memcmp(output1+10, buf, 10) != 0;
100 cout << (fail ?
"FAILED " :
"passed ");
102 cout << setw(2) << setfill(
'0') << hex << (int)buf[j];
107 fail = memcmp(output2, buf, 20) != 0;
108 pass = pass && !fail;
110 cout << (fail ?
"FAILED " :
"passed ");
112 cout << setw(2) << setfill(
'0') << hex << (int)buf[j];
120 bool pass =
true, fail;
123 pass = pass && !fail;
125 cout << (fail ?
"FAILED " :
"passed ");
126 cout <<
"signature key validation\n";
128 const byte *message = (byte *)
"test message";
129 const int messageLen = 12;
132 size_t signatureLength = priv.
SignMessage(GlobalRNG(), message, messageLen, signature);
133 fail = !pub.
VerifyMessage(message, messageLen, signature, signatureLength);
134 pass = pass && !fail;
136 cout << (fail ?
"FAILED " :
"passed ");
137 cout <<
"signature and verification\n";
140 fail = pub.
VerifyMessage(message, messageLen, signature, signatureLength);
141 pass = pass && !fail;
143 cout << (fail ?
"FAILED " :
"passed ");
144 cout <<
"checking invalid signature" << endl;
151 fail = !(result.isValidCoding && result.messageLength == messageLen && memcmp(recovered, message, messageLen) == 0);
152 pass = pass && !fail;
154 cout << (fail ?
"FAILED " :
"passed ");
155 cout <<
"signature and verification with recovery" << endl;
158 result = pub.
RecoverMessage(recovered, NULL, 0, signature, signatureLength);
160 pass = pass && !fail;
162 cout << (fail ?
"FAILED " :
"passed ");
163 cout <<
"recovery with invalid signature" << endl;
171 bool pass =
true, fail;
174 pass = pass && !fail;
176 cout << (fail ?
"FAILED " :
"passed ");
177 cout <<
"cryptosystem key validation\n";
179 const byte *message = (byte *)
"test message";
180 const int messageLen = 12;
184 pub.
Encrypt(GlobalRNG(), message, messageLen, ciphertext);
186 fail = fail || memcmp(message, plaintext, messageLen);
187 pass = pass && !fail;
189 cout << (fail ?
"FAILED " :
"passed ");
190 cout <<
"encryption and decryption\n";
197 if (d.GetCryptoParameters().
Validate(GlobalRNG(), 3))
198 cout <<
"passed simple key agreement domain parameters validation" << endl;
201 cout <<
"FAILED simple key agreement domain parameters invalid" << endl;
212 memset(val1.begin(), 0x10, val1.size());
213 memset(val2.begin(), 0x11, val2.size());
215 if (!(d.
Agree(val1, priv1, pub2) && d.
Agree(val2, priv2, pub1)))
217 cout <<
"FAILED simple key agreement failed" << endl;
223 cout <<
"FAILED simple agreed values not equal" << endl;
227 cout <<
"passed simple key agreement" << endl;
233 if (d.GetCryptoParameters().
Validate(GlobalRNG(), 3))
234 cout <<
"passed authenticated key agreement domain parameters validation" << endl;
237 cout <<
"FAILED authenticated key agreement domain parameters invalid" << endl;
252 memset(val1.begin(), 0x10, val1.size());
253 memset(val2.begin(), 0x11, val2.size());
255 if (!(d.
Agree(val1, spriv1, epriv1, spub2, epub2) && d.
Agree(val2, spriv2, epriv2, spub1, epub1)))
257 cout <<
"FAILED authenticated key agreement failed" << endl;
263 cout <<
"FAILED authenticated agreed values not equal" << endl;
267 cout <<
"passed authenticated key agreement" << endl;
273 cout <<
"\nRSA validation suite running...\n\n";
275 byte out[100], outPlain[100];
276 bool pass =
true, fail;
279 const char *plain =
"Everyone gets Friday off.";
280 static const byte signature[] =
281 "\x05\xfa\x6a\x81\x2f\xc7\xdf\x8b\xf4\xf2\x54\x25\x09\xe0\x3e\x84" 282 "\x6e\x11\xb9\xc6\x20\xbe\x20\x09\xef\xb4\x40\xef\xbc\xc6\x69\x21" 283 "\x69\x94\xac\x04\xf3\x41\xb5\x7d\x05\x20\x2d\x42\x8f\xb2\xa2\x7b" 284 "\x5c\x77\xdf\xd9\xb1\x5b\xfc\x3d\x55\x93\x53\x50\x34\x10\xc1\xe1";
290 size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out);
291 fail = memcmp(signature, out, 64) != 0;
292 pass = pass && !fail;
294 cout << (fail ?
"FAILED " :
"passed ");
295 cout <<
"signature check against test vector\n";
297 fail = !rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength);
298 pass = pass && !fail;
300 cout << (fail ?
"FAILED " :
"passed ");
301 cout <<
"verification check against test vector\n";
304 fail = rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength);
305 pass = pass && !fail;
307 cout << (fail ?
"FAILED " :
"passed ");
308 cout <<
"invalid signature verification\n";
315 pass = CryptoSystemValidate(rsaPriv, rsaPub) && pass;
321 pass = CryptoSystemValidate(rsaPriv, rsaPub) && pass;
324 byte *plain = (byte *)
325 "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
326 static const byte encrypted[] =
327 "\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a" 328 "\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4" 329 "\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52" 331 static const byte oaepSeed[] =
332 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2" 335 bq.
Put(oaepSeed, 20);
341 rsaPriv.AccessKey().BERDecodePrivateKey(privFile,
false, 0);
345 memset(outPlain, 0, 8);
346 rsaPub.Encrypt(rng, plain, 8, out);
347 DecodingResult result = rsaPriv.FixedLengthDecrypt(GlobalRNG(), encrypted, outPlain);
349 pass = pass && !fail;
351 cout << (fail ?
"FAILED " :
"passed ");
352 cout <<
"PKCS 2.0 encryption and decryption\n";
360 cout <<
"\nDH validation suite running...\n\n";
364 return SimpleKeyAgreementValidate(dh);
369 cout <<
"\nMQV validation suite running...\n\n";
373 return AuthenticatedKeyAgreementValidate(mqv);
376 bool ValidateLUC_DH()
378 cout <<
"\nLUC-DH validation suite running...\n\n";
382 return SimpleKeyAgreementValidate(dh);
385 bool ValidateXTR_DH()
387 cout <<
"\nXTR-DH validation suite running...\n\n";
391 return SimpleKeyAgreementValidate(dh);
394 bool ValidateElGamal()
396 cout <<
"\nElGamal validation suite running...\n\n";
402 privC.AccessKey().Precompute();
404 privC.AccessKey().SavePrecomputation(queue);
405 privC.AccessKey().LoadPrecomputation(queue);
407 pass = CryptoSystemValidate(privC, pubC) && pass;
414 cout <<
"\nDLIES validation suite running...\n\n";
420 pass = CryptoSystemValidate(privC, pubC) && pass;
423 cout <<
"Generating new encryption key..." << endl;
427 decryptor.AccessKey().GenerateRandom(GlobalRNG(), gp);
430 pass = CryptoSystemValidate(decryptor, encryptor) && pass;
437 cout <<
"\nNR validation suite running...\n\n";
442 privS.AccessKey().Precompute();
445 pass = SignatureValidate(privS, pubS) && pass;
448 cout <<
"Generating new signature key..." << endl;
452 pass = SignatureValidate(privS, pubS) && pass;
457 bool ValidateDSA(
bool thorough)
459 cout <<
"\nDSA validation suite running...\n\n";
467 assert(pub.GetKey() == pub1.GetKey());
468 pass = SignatureValidate(priv, pub, thorough) && pass;
476 cout <<
"\nLUC validation suite running...\n\n";
483 pass = SignatureValidate(priv, pub) && pass;
488 pass = CryptoSystemValidate(priv, pub) && pass;
493 bool ValidateLUC_DL()
495 cout <<
"\nLUC-HMP validation suite running...\n\n";
500 bool pass = SignatureValidate(privS, pubS);
502 cout <<
"\nLUC-IES validation suite running...\n\n";
507 pass = CryptoSystemValidate(privC, pubC) && pass;
514 cout <<
"\nRabin validation suite running...\n\n";
521 pass = SignatureValidate(priv, pub) && pass;
526 pass = CryptoSystemValidate(priv, pub) && pass;
533 cout <<
"\nRW validation suite running...\n\n";
539 return SignatureValidate(priv, pub);
555 #if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) 557 bool TestPolynomialMod2()
559 bool pass1 =
true, pass2 =
true, pass3 =
true;
561 cout <<
"\nTesting PolynomialMod2 bit operations...\n\n";
563 static const unsigned int start = 0;
564 static const unsigned int stop = 4 * WORD_BITS + 1;
566 for (
unsigned int i=start; i < stop; i++)
574 std::ostringstream oss1;
577 std::string str1, str2;
581 str1.erase(std::remove(str1.begin(), str1.end(),
','), str1.end());
584 str1.erase(str1.end() - 1);
589 pass1 &= (str1 == str2);
592 for (
unsigned int i=start; i < stop; i++)
602 std::ostringstream oss1;
605 std::string str1, str2;
609 str1.erase(std::remove(str1.begin(), str1.end(),
','), str1.end());
612 str1.erase(str1.end() - 1);
617 pass2 &= (str1 == str2);
621 for (
unsigned int i=start; i < stop; i++)
632 std::ostringstream oss1;
635 std::string str1, str2;
639 str1.erase(std::remove(str1.begin(), str1.end(),
','), str1.end());
642 str1.erase(str1.end() - 1);
649 cout <<
" Oops..." <<
"\n";
650 cout <<
" random: " << std::hex << n << std::dec <<
"\n";
651 cout <<
" str1: " << str1 <<
"\n";
652 cout <<
" str2: " << str2 <<
"\n";
655 pass3 &= (str1 == str2);
658 cout << (!pass1 ?
"FAILED" :
"passed") <<
" " <<
"1 shifted over range [" << dec << start <<
"," << stop <<
"]" <<
"\n";
659 cout << (!pass2 ?
"FAILED" :
"passed") <<
" " <<
"0x" << hex << word(
SIZE_MAX) << dec <<
" shifted over range [" << start <<
"," << stop <<
"]" <<
"\n";
660 cout << (!pass3 ?
"FAILED" :
"passed") <<
" " <<
"random values shifted over range [" << dec << start <<
"," << stop <<
"]" <<
"\n";
662 if (!(pass1 && pass2 && pass3))
665 return pass1 && pass2 && pass3;
671 cout <<
"\nECP validation suite running...\n\n";
676 cpriv.GetKey().DEREncode(bq);
677 cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(
true);
678 cpub.GetKey().DEREncode(bq);
684 spriv.AccessKey().Precompute();
686 spriv.AccessKey().SavePrecomputation(queue);
687 spriv.AccessKey().LoadPrecomputation(queue);
689 bool pass = SignatureValidate(spriv, spub);
690 cpub.AccessKey().Precompute();
691 cpriv.AccessKey().Precompute();
692 pass = CryptoSystemValidate(cpriv, cpub) && pass;
693 pass = SimpleKeyAgreementValidate(ecdhc) && pass;
694 pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;
696 cout <<
"Turning on point compression..." << endl;
697 cpriv.AccessKey().AccessGroupParameters().SetPointCompression(
true);
698 cpub.AccessKey().AccessGroupParameters().SetPointCompression(
true);
699 ecdhc.AccessGroupParameters().SetPointCompression(
true);
700 ecmqvc.AccessGroupParameters().SetPointCompression(
true);
701 pass = CryptoSystemValidate(cpriv, cpub) && pass;
702 pass = SimpleKeyAgreementValidate(ecdhc) && pass;
703 pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;
705 cout <<
"Testing SEC 2, NIST, and Brainpool recommended curves..." << endl;
710 bool fail = !params.
Validate(GlobalRNG(), 2);
711 cout << (fail ?
"FAILED" :
"passed") <<
" " << dec << params.GetCurve().GetField().MaxElementBitLength() <<
" bits" << endl;
712 pass = pass && !fail;
720 cout <<
"\nEC2N validation suite running...\n\n";
726 cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(
true);
733 spriv.AccessKey().Precompute();
735 spriv.AccessKey().SavePrecomputation(queue);
736 spriv.AccessKey().LoadPrecomputation(queue);
738 bool pass = SignatureValidate(spriv, spub);
739 pass = CryptoSystemValidate(cpriv, cpub) && pass;
740 pass = SimpleKeyAgreementValidate(ecdhc) && pass;
741 pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;
743 cout <<
"Turning on point compression..." << endl;
744 cpriv.AccessKey().AccessGroupParameters().SetPointCompression(
true);
745 cpub.AccessKey().AccessGroupParameters().SetPointCompression(
true);
746 ecdhc.AccessGroupParameters().SetPointCompression(
true);
747 ecmqvc.AccessGroupParameters().SetPointCompression(
true);
748 pass = CryptoSystemValidate(cpriv, cpub) && pass;
749 pass = SimpleKeyAgreementValidate(ecdhc) && pass;
750 pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;
752 #if 0 // TODO: turn this back on when I make EC2N faster for pentanomial basis 753 cout <<
"Testing SEC 2 recommended curves..." << endl;
758 bool fail = !params.
Validate(GlobalRNG(), 2);
759 cout << (fail ?
"FAILED" :
"passed") <<
" " << params.GetCurve().GetField().MaxElementBitLength() <<
" bits" << endl;
760 pass = pass && !fail;
769 cout <<
"\nECDSA validation suite running...\n\n";
772 GF2NT gf2n(191, 9, 0);
773 byte a[]=
"\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67";
774 byte b[]=
"\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC";
778 ec.DecodePoint(P, (byte *)
"\x04\x36\xB3\xDA\xF8\xA2\x32\x06\xF9\xC4\xF2\x99\xD7\xB2\x1A\x9C\x36\x91\x37\xF2\xC8\x4A\xE1\xAA\x0D" 779 "\x76\x5B\xE7\x34\x33\xB3\xF9\x5E\x33\x29\x32\xE7\x0E\xA2\x45\xCA\x24\x18\xEA\x0E\xF9\x80\x18\xFB", ec.EncodedPointSize());
780 Integer n(
"40000000000000000000000004a20e90c39067c893bbb9a5H");
781 Integer d(
"340562e1dda332f9d2aec168249b5696ee39d0ed4d03760fH");
786 Integer h(
"A9993E364706816ABA3E25717850C26C9CD0D89DH");
787 Integer k(
"3eeace72b4919d991738d521879f787cb590aff8189d2b69H");
788 static const byte sig[]=
"\x03\x8e\x5a\x11\xfb\x55\xe4\xc6\x54\x71\xdc\xd4\x99\x84\x52\xb1\xe0\x2d\x8a\xf7\x09\x9b\xb9\x30" 789 "\x0c\x9a\x08\xc3\x44\x68\xc2\x44\xb4\xe5\xd6\xb2\x1b\x3c\x68\x36\x28\x07\x41\x60\x20\x32\x8b\x6e";
794 bool fail, pass=
true;
796 priv.RawSign(k, h, rOut, sOut);
797 fail = (rOut != r) || (sOut != s);
798 pass = pass && !fail;
800 cout << (fail ?
"FAILED " :
"passed ");
801 cout <<
"signature check against test vector\n";
803 fail = !pub.VerifyMessage((byte *)
"abc", 3, sig,
sizeof(sig));
804 pass = pass && !fail;
806 cout << (fail ?
"FAILED " :
"passed ");
807 cout <<
"verification check against test vector\n";
809 fail = pub.VerifyMessage((byte *)
"xyz", 3, sig,
sizeof(sig));
810 pass = pass && !fail;
812 pass = SignatureValidate(priv, pub) && pass;
819 cout <<
"\nESIGN validation suite running...\n\n";
821 bool pass =
true, fail;
823 static const char plain[] =
"test";
824 static const byte signature[] =
825 "\xA3\xE3\x20\x65\xDE\xDA\xE7\xEC\x05\xC1\xBF\xCD\x25\x79\x7D\x99\xCD\xD5\x73\x9D\x9D\xF3\xA4\xAA\x9A\xA4\x5A\xC8\x23\x3D\x0D\x37\xFE\xBC\x76\x3F\xF1\x84\xF6\x59" 826 "\x14\x91\x4F\x0C\x34\x1B\xAE\x9A\x5C\x2E\x2E\x38\x08\x78\x77\xCB\xDC\x3C\x7E\xA0\x34\x44\x5B\x0F\x67\xD9\x35\x2A\x79\x47\x1A\x52\x37\x71\xDB\x12\x67\xC1\xB6\xC6" 827 "\x66\x73\xB3\x40\x2E\xD6\xF2\x1A\x84\x0A\xB6\x7B\x0F\xEB\x8B\x88\xAB\x33\xDD\xE4\x83\x21\x90\x63\x2D\x51\x2A\xB1\x6F\xAB\xA7\x5C\xFD\x77\x99\xF2\xE1\xEF\x67\x1A" 828 "\x74\x02\x37\x0E\xED\x0A\x06\xAD\xF4\x15\x65\xB8\xE1\xD1\x45\xAE\x39\x19\xB4\xFF\x5D\xF1\x45\x7B\xE0\xFE\x72\xED\x11\x92\x8F\x61\x41\x4F\x02\x00\xF2\x76\x6F\x7C" 829 "\x79\xA2\xE5\x52\x20\x5D\x97\x5E\xFE\x39\xAE\x21\x10\xFB\x35\xF4\x80\x81\x41\x13\xDD\xE8\x5F\xCA\x1E\x4F\xF8\x9B\xB2\x68\xFB\x28";
835 fail = !SignatureValidate(signer, verifier);
836 pass = pass && !fail;
838 fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength());
839 pass = pass && !fail;
841 cout << (fail ?
"FAILED " :
"passed ");
842 cout <<
"verification check against test vector\n";
844 cout <<
"Generating signature key from seed..." << endl;
848 fail = !SignatureValidate(signer, verifier);
849 pass = pass && !fail;
used to pass byte array input as part of a NameValuePairs object
virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
generate private/public key pair
Classes for Rabin encryption and signature schemes.
virtual unsigned int StaticPublicKeyLength() const =0
return length of static public keys in this domain
virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const
sign a recoverable message
void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
Classes and functions for ElGamal key agreement and encryption schemes.
virtual DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const =0
Decrypt a byte string.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
This file contains helper classes/functions for implementing public key algorithms.
GF(2^n) with Trinomial Basis.
virtual unsigned int AgreedValueLength() const =0
return length of agreed value produced
file-based implementation of Source 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 bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const =0
derive agreed value from your private keys and couterparty's public keys, return false in case of fai...
GF(p) group parameters that default to same primes.
void Seek(lword index)
Seek to an absolute position.
Object identifiers for algorthms and schemes.
Classes for automatic resource management.
Interface for random number generators.
size_t messageLength
Recovered message length if isValidCoding is true, undefined otherwise.
SecByteBlock is a SecBlock<byte> typedef.
const CryptoMaterial & GetMaterial() const
returns a const reference to the crypto material used by this object
static const Integer & One()
Integer representing 1.
This file contains classes that implement the ESIGN signature schemes as defined in IEEE P1363a...
Polynomial with Coefficients in GF(2)
virtual unsigned int EphemeralPublicKeyLength() const =0
return length of ephemeral public keys in this domain
Classes for Elliptic Curves over binary fields.
virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0
length of longest message that can be recovered from a signature of given length, or 0 if this signat...
Interface for domains of simple key agreement protocols.
Returns a decoding results.
Classes for Rabin-Williams signature schemes.
Interface for public-key decryptors.
MQV domain for performing authenticated key agreement.
void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
XTR-DH with key validation.
virtual size_t MaxRecoverableLength() const =0
length of longest message that can be recovered, or 0 if this signature scheme does not support messa...
virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
generate private/public key pair
virtual unsigned int AgreedValueLength() const =0
return length of agreed value produced
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Classes for Diffie-Hellman key exchange.
Classes for HexEncoder and HexDecoder.
virtual size_t MaxSignatureLength(size_t recoverablePartLength=0) const
maximum signature length produced for a given length of recoverable message part
virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
generate private/public key pair
virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0
maximum length of plaintext for a given ciphertext length
Multiple precision integer with arithmetic operations.
Elliptic Curve over GF(2^n)
virtual size_t CiphertextLength(size_t plaintextLength) const =0
calculate length of ciphertext given length of plaintext
virtual DecodingResult RecoverMessage(byte *recoveredMessage, const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, const byte *signature, size_t signatureLength) const
recover a message from its signature
const CryptoMaterial & GetMaterial() const
returns a const reference to the crypto material used by this object
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Implementation of schemes based on DL over GF(p)
Classes for the DSA signature algorithm.
Miscellaneous classes for RNGs.
virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const
sign a message
virtual bool VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLength) const
check whether input signature is a valid signature for input message
virtual unsigned int PrivateKeyLength() const =0
return length of private keys in this domain
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 from your private key and couterparty's public key, return false in case of failu...
Elliptic Curve Parameters.
Implementation of BufferedTransformation's attachment interface in cryptlib.h.
"The XTR public key system" by Arjen K.
Classes for the RSA cryptosystem.
virtual bool Validate(RandomNumberGenerator &rng, unsigned int level) const =0
Check this object for errors.
Interface for public-key signature verifiers.
BlumBlumShub with factorization of the modulus.
Classes for Blum Blum Shub generator.
virtual unsigned int StaticPrivateKeyLength() const =0
return length of static private keys in this domain
void GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize)
Generate a random key or crypto parameters.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
virtual unsigned int PublicKeyLength() const =0
return length of public keys in this domain
virtual unsigned int EphemeralPrivateKeyLength() const =0
return length of ephemeral private keys in this domain
bool isValidCoding
Flag to indicate the decoding is valid.
Classes and functions for Elliptic Curves over prime and binary fields.
Crypto++ library namespace.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Interface for domains of authenticated key agreement protocols.
virtual void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters=g_nullNameValuePairs) const =0
Encrypt a byte string.
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
Classes for access to the operating system's random number generators.
the value is positive or 0
#define SIZE_MAX
The maximum value of a machine word.
A template implementing constructors for public key algorithm classes.