Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

cryptlib.cpp

00001 // cryptlib.cpp - written and placed in the public domain by Wei Dai
00002 
00003 #include "pch.h"
00004 
00005 #ifndef CRYPTOPP_IMPORTS
00006 
00007 #include "cryptlib.h"
00008 #include "misc.h"
00009 #include "filters.h"
00010 #include "algparam.h"
00011 #include "fips140.h"
00012 #include "argnames.h"
00013 
00014 #include <memory>
00015 
00016 NAMESPACE_BEGIN(CryptoPP)
00017 
00018 CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1);
00019 CRYPTOPP_COMPILE_ASSERT(sizeof(word16) == 2);
00020 CRYPTOPP_COMPILE_ASSERT(sizeof(word32) == 4);
00021 #ifdef WORD64_AVAILABLE
00022 CRYPTOPP_COMPILE_ASSERT(sizeof(word64) == 8);
00023 #endif
00024 CRYPTOPP_COMPILE_ASSERT(sizeof(dword) == 2*sizeof(word));
00025 
00026 const std::string BufferedTransformation::NULL_CHANNEL;
00027 const NullNameValuePairs g_nullNameValuePairs;
00028 
00029 BufferedTransformation & TheBitBucket()
00030 {
00031         static BitBucket bitBucket;
00032         return bitBucket;
00033 }
00034 
00035 Algorithm::Algorithm(bool checkSelfTestStatus)
00036 {
00037         if (checkSelfTestStatus && FIPS_140_2_ComplianceEnabled())
00038         {
00039                 if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_NOT_DONE && !PowerUpSelfTestInProgressOnThisThread())
00040                         throw SelfTestFailure("Cryptographic algorithms are disabled before the power-up self tests are performed.");
00041 
00042                 if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_FAILED)
00043                         throw SelfTestFailure("Cryptographic algorithms are disabled after a power-up self test failed.");
00044         }
00045 }
00046 
00047 void SimpleKeyingInterface::SetKeyWithRounds(const byte *key, unsigned int length, int rounds)
00048 {
00049         SetKey(key, length, MakeParameters(Name::Rounds(), rounds));
00050 }
00051 
00052 void SimpleKeyingInterface::SetKeyWithIV(const byte *key, unsigned int length, const byte *iv)
00053 {
00054         SetKey(key, length, MakeParameters(Name::IV(), iv));
00055 }
00056 
00057 void SimpleKeyingInterface::ThrowIfInvalidKeyLength(const Algorithm &algorithm, unsigned int length)
00058 {
00059         if (!IsValidKeyLength(length))
00060                 throw InvalidKeyLength(algorithm.AlgorithmName(), length);
00061 }
00062 
00063 void BlockTransformation::ProcessAndXorMultipleBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, unsigned int numberOfBlocks) const
00064 {
00065         unsigned int blockSize = BlockSize();
00066         while (numberOfBlocks--)
00067         {
00068                 ProcessAndXorBlock(inBlocks, xorBlocks, outBlocks);
00069                 inBlocks += blockSize;
00070                 outBlocks += blockSize;
00071                 if (xorBlocks)
00072                         xorBlocks += blockSize;
00073         }
00074 }
00075 
00076 void StreamTransformation::ProcessLastBlock(byte *outString, const byte *inString, unsigned int length)
00077 {
00078         assert(MinLastBlockSize() == 0);        // this function should be overriden otherwise
00079 
00080         if (length == MandatoryBlockSize())
00081                 ProcessData(outString, inString, length);
00082         else if (length != 0)
00083                 throw NotImplemented("StreamTransformation: this object does't support a special last block");
00084 }
00085 
00086 unsigned int RandomNumberGenerator::GenerateBit()
00087 {
00088         return Parity(GenerateByte());
00089 }
00090 
00091 void RandomNumberGenerator::GenerateBlock(byte *output, unsigned int size)
00092 {
00093         while (size--)
00094                 *output++ = GenerateByte();
00095 }
00096 
00097 word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max)
00098 {
00099         word32 range = max-min;
00100         const int maxBytes = BytePrecision(range);
00101         const int maxBits = BitPrecision(range);
00102 
00103         word32 value;
00104 
00105         do
00106         {
00107                 value = 0;
00108                 for (int i=0; i<maxBytes; i++)
00109                         value = (value << 8) | GenerateByte();
00110 
00111                 value = Crop(value, maxBits);
00112         } while (value > range);
00113 
00114         return value+min;
00115 }
00116 
00117 void RandomNumberGenerator::DiscardBytes(unsigned int n)
00118 {
00119         while (n--)
00120                 GenerateByte();
00121 }
00122 
00123 RandomNumberGenerator & NullRNG()
00124 {
00125         class NullRNG : public RandomNumberGenerator
00126         {
00127         public:
00128                 std::string AlgorithmName() const {return "NullRNG";}
00129                 byte GenerateByte() {throw NotImplemented("NullRNG: NullRNG should only be passed to functions that don't need to generate random bytes");}
00130         };
00131 
00132         static NullRNG s_nullRNG;
00133         return s_nullRNG;
00134 }
00135 
00136 bool HashTransformation::TruncatedVerify(const byte *digestIn, unsigned int digestLength)
00137 {
00138         ThrowIfInvalidTruncatedSize(digestLength);
00139         SecByteBlock digest(digestLength);
00140         TruncatedFinal(digest, digestLength);
00141         return memcmp(digest, digestIn, digestLength) == 0;
00142 }
00143 
00144 void HashTransformation::ThrowIfInvalidTruncatedSize(unsigned int size) const
00145 {
00146         if (size > DigestSize())
00147                 throw InvalidArgument("HashTransformation: can't truncate a " + IntToString(DigestSize()) + " byte digest to " + IntToString(size) + " bytes");
00148 }
00149 
00150 unsigned int BufferedTransformation::GetMaxWaitObjectCount() const
00151 {
00152         const BufferedTransformation *t = AttachedTransformation();
00153         return t ? t->GetMaxWaitObjectCount() : 0;
00154 }
00155 
00156 void BufferedTransformation::GetWaitObjects(WaitObjectContainer &container)
00157 {
00158         BufferedTransformation *t = AttachedTransformation();
00159         if (t)
00160                 t->GetWaitObjects(container);
00161 }
00162 
00163 void BufferedTransformation::Initialize(const NameValuePairs &parameters, int propagation)
00164 {
00165         assert(!AttachedTransformation());
00166         IsolatedInitialize(parameters);
00167 }
00168 
00169 bool BufferedTransformation::Flush(bool hardFlush, int propagation, bool blocking)
00170 {
00171         assert(!AttachedTransformation());
00172         return IsolatedFlush(hardFlush, blocking);
00173 }
00174 
00175 bool BufferedTransformation::MessageSeriesEnd(int propagation, bool blocking)
00176 {
00177         assert(!AttachedTransformation());
00178         return IsolatedMessageSeriesEnd(blocking);
00179 }
00180 
00181 byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, unsigned int &size)
00182 {
00183         if (channel.empty())
00184                 return CreatePutSpace(size);
00185         else
00186                 throw NoChannelSupport();
00187 }
00188 
00189 unsigned int BufferedTransformation::ChannelPut2(const std::string &channel, const byte *begin, unsigned int length, int messageEnd, bool blocking)
00190 {
00191         if (channel.empty())
00192                 return Put2(begin, length, messageEnd, blocking);
00193         else
00194                 throw NoChannelSupport();
00195 }
00196 
00197 unsigned int BufferedTransformation::ChannelPutModifiable2(const std::string &channel, byte *begin, unsigned int length, int messageEnd, bool blocking)
00198 {
00199         if (channel.empty())
00200                 return PutModifiable2(begin, length, messageEnd, blocking);
00201         else
00202                 return ChannelPut2(channel, begin, length, messageEnd, blocking);
00203 }
00204 
00205 void BufferedTransformation::ChannelInitialize(const std::string &channel, const NameValuePairs &parameters, int propagation)
00206 {
00207         if (channel.empty())
00208                 Initialize(parameters, propagation);
00209         else
00210                 throw NoChannelSupport();
00211 }
00212 
00213 bool BufferedTransformation::ChannelFlush(const std::string &channel, bool completeFlush, int propagation, bool blocking)
00214 {
00215         if (channel.empty())
00216                 return Flush(completeFlush, propagation, blocking);
00217         else
00218                 throw NoChannelSupport();
00219 }
00220 
00221 bool BufferedTransformation::ChannelMessageSeriesEnd(const std::string &channel, int propagation, bool blocking)
00222 {
00223         if (channel.empty())
00224                 return MessageSeriesEnd(propagation, blocking);
00225         else
00226                 throw NoChannelSupport();
00227 }
00228 
00229 unsigned long BufferedTransformation::MaxRetrievable() const
00230 {
00231         if (AttachedTransformation())
00232                 return AttachedTransformation()->MaxRetrievable();
00233         else
00234                 return CopyTo(TheBitBucket());
00235 }
00236 
00237 bool BufferedTransformation::AnyRetrievable() const
00238 {
00239         if (AttachedTransformation())
00240                 return AttachedTransformation()->AnyRetrievable();
00241         else
00242         {
00243                 byte b;
00244                 return Peek(b) != 0;
00245         }
00246 }
00247 
00248 unsigned int BufferedTransformation::Get(byte &outByte)
00249 {
00250         if (AttachedTransformation())
00251                 return AttachedTransformation()->Get(outByte);
00252         else
00253                 return Get(&outByte, 1);
00254 }
00255 
00256 unsigned int BufferedTransformation::Get(byte *outString, unsigned int getMax)
00257 {
00258         if (AttachedTransformation())
00259                 return AttachedTransformation()->Get(outString, getMax);
00260         else
00261         {
00262                 ArraySink arraySink(outString, getMax);
00263                 return TransferTo(arraySink, getMax);
00264         }
00265 }
00266 
00267 unsigned int BufferedTransformation::Peek(byte &outByte) const
00268 {
00269         if (AttachedTransformation())
00270                 return AttachedTransformation()->Peek(outByte);
00271         else
00272                 return Peek(&outByte, 1);
00273 }
00274 
00275 unsigned int BufferedTransformation::Peek(byte *outString, unsigned int peekMax) const
00276 {
00277         if (AttachedTransformation())
00278                 return AttachedTransformation()->Peek(outString, peekMax);
00279         else
00280         {
00281                 ArraySink arraySink(outString, peekMax);
00282                 return CopyTo(arraySink, peekMax);
00283         }
00284 }
00285 
00286 unsigned long BufferedTransformation::Skip(unsigned long skipMax)
00287 {
00288         if (AttachedTransformation())
00289                 return AttachedTransformation()->Skip(skipMax);
00290         else
00291                 return TransferTo(TheBitBucket(), skipMax);
00292 }
00293 
00294 unsigned long BufferedTransformation::TotalBytesRetrievable() const
00295 {
00296         if (AttachedTransformation())
00297                 return AttachedTransformation()->TotalBytesRetrievable();
00298         else
00299                 return MaxRetrievable();
00300 }
00301 
00302 unsigned int BufferedTransformation::NumberOfMessages() const
00303 {
00304         if (AttachedTransformation())
00305                 return AttachedTransformation()->NumberOfMessages();
00306         else
00307                 return CopyMessagesTo(TheBitBucket());
00308 }
00309 
00310 bool BufferedTransformation::AnyMessages() const
00311 {
00312         if (AttachedTransformation())
00313                 return AttachedTransformation()->AnyMessages();
00314         else
00315                 return NumberOfMessages() != 0;
00316 }
00317 
00318 bool BufferedTransformation::GetNextMessage()
00319 {
00320         if (AttachedTransformation())
00321                 return AttachedTransformation()->GetNextMessage();
00322         else
00323         {
00324                 assert(!AnyMessages());
00325                 return false;
00326         }
00327 }
00328 
00329 unsigned int BufferedTransformation::SkipMessages(unsigned int count)
00330 {
00331         if (AttachedTransformation())
00332                 return AttachedTransformation()->SkipMessages(count);
00333         else
00334                 return TransferMessagesTo(TheBitBucket(), count);
00335 }
00336 
00337 unsigned int BufferedTransformation::TransferMessagesTo2(BufferedTransformation &target, unsigned int &messageCount, const std::string &channel, bool blocking)
00338 {
00339         if (AttachedTransformation())
00340                 return AttachedTransformation()->TransferMessagesTo2(target, messageCount, channel, blocking);
00341         else
00342         {
00343                 unsigned int maxMessages = messageCount;
00344                 for (messageCount=0; messageCount < maxMessages && AnyMessages(); messageCount++)
00345                 {
00346                         unsigned int blockedBytes;
00347                         unsigned long transferedBytes;
00348 
00349                         while (AnyRetrievable())
00350                         {
00351                                 transferedBytes = ULONG_MAX;
00352                                 blockedBytes = TransferTo2(target, transferedBytes, channel, blocking);
00353                                 if (blockedBytes > 0)
00354                                         return blockedBytes;
00355                         }
00356 
00357                         if (target.ChannelMessageEnd(channel, GetAutoSignalPropagation(), blocking))
00358                                 return 1;
00359 
00360                         bool result = GetNextMessage();
00361                         assert(result);
00362                 }
00363                 return 0;
00364         }
00365 }
00366 
00367 unsigned int BufferedTransformation::CopyMessagesTo(BufferedTransformation &target, unsigned int count, const std::string &channel) const
00368 {
00369         if (AttachedTransformation())
00370                 return AttachedTransformation()->CopyMessagesTo(target, count, channel);
00371         else
00372                 return 0;
00373 }
00374 
00375 void BufferedTransformation::SkipAll()
00376 {
00377         if (AttachedTransformation())
00378                 AttachedTransformation()->SkipAll();
00379         else
00380         {
00381                 while (SkipMessages()) {}
00382                 while (Skip()) {}
00383         }
00384 }
00385 
00386 unsigned int BufferedTransformation::TransferAllTo2(BufferedTransformation &target, const std::string &channel, bool blocking)
00387 {
00388         if (AttachedTransformation())
00389                 return AttachedTransformation()->TransferAllTo2(target, channel, blocking);
00390         else
00391         {
00392                 assert(!NumberOfMessageSeries());
00393 
00394                 unsigned int messageCount;
00395                 do
00396                 {
00397                         messageCount = UINT_MAX;
00398                         unsigned int blockedBytes = TransferMessagesTo2(target, messageCount, channel, blocking);
00399                         if (blockedBytes)
00400                                 return blockedBytes;
00401                 }
00402                 while (messageCount != 0);
00403 
00404                 unsigned long byteCount;
00405                 do
00406                 {
00407                         byteCount = ULONG_MAX;
00408                         unsigned int blockedBytes = TransferTo2(target, byteCount, channel, blocking);
00409                         if (blockedBytes)
00410                                 return blockedBytes;
00411                 }
00412                 while (byteCount != 0);
00413 
00414                 return 0;
00415         }
00416 }
00417 
00418 void BufferedTransformation::CopyAllTo(BufferedTransformation &target, const std::string &channel) const
00419 {
00420         if (AttachedTransformation())
00421                 AttachedTransformation()->CopyAllTo(target, channel);
00422         else
00423         {
00424                 assert(!NumberOfMessageSeries());
00425                 while (CopyMessagesTo(target, UINT_MAX, channel)) {}
00426         }
00427 }
00428 
00429 void BufferedTransformation::SetRetrievalChannel(const std::string &channel)
00430 {
00431         if (AttachedTransformation())
00432                 AttachedTransformation()->SetRetrievalChannel(channel);
00433 }
00434 
00435 unsigned int BufferedTransformation::ChannelPutWord16(const std::string &channel, word16 value, ByteOrder order, bool blocking)
00436 {
00437         FixedSizeSecBlock<byte, 2> buf;
00438         PutWord(false, order, buf, value);
00439         return ChannelPut(channel, buf, 2, blocking);
00440 }
00441 
00442 unsigned int BufferedTransformation::ChannelPutWord32(const std::string &channel, word32 value, ByteOrder order, bool blocking)
00443 {
00444         FixedSizeSecBlock<byte, 4> buf;
00445         PutWord(false, order, buf, value);
00446         return ChannelPut(channel, buf, 4, blocking);
00447 }
00448 
00449 unsigned int BufferedTransformation::PutWord16(word16 value, ByteOrder order, bool blocking)
00450 {
00451         return ChannelPutWord16(NULL_CHANNEL, value, order, blocking);
00452 }
00453 
00454 unsigned int BufferedTransformation::PutWord32(word32 value, ByteOrder order, bool blocking)
00455 {
00456         return ChannelPutWord32(NULL_CHANNEL, value, order, blocking);
00457 }
00458 
00459 unsigned int BufferedTransformation::PeekWord16(word16 &value, ByteOrder order)
00460 {
00461         byte buf[2] = {0, 0};
00462         unsigned int len = Peek(buf, 2);
00463 
00464         if (order)
00465                 value = (buf[0] << 8) | buf[1];
00466         else
00467                 value = (buf[1] << 8) | buf[0];
00468 
00469         return len;
00470 }
00471 
00472 unsigned int BufferedTransformation::PeekWord32(word32 &value, ByteOrder order)
00473 {
00474         byte buf[4] = {0, 0, 0, 0};
00475         unsigned int len = Peek(buf, 4);
00476 
00477         if (order)
00478                 value = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf [3];
00479         else
00480                 value = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf [0];
00481 
00482         return len;
00483 }
00484 
00485 unsigned int BufferedTransformation::GetWord16(word16 &value, ByteOrder order)
00486 {
00487         return Skip(PeekWord16(value, order));
00488 }
00489 
00490 unsigned int BufferedTransformation::GetWord32(word32 &value, ByteOrder order)
00491 {
00492         return Skip(PeekWord32(value, order));
00493 }
00494 
00495 void BufferedTransformation::Attach(BufferedTransformation *newOut)
00496 {
00497         if (AttachedTransformation() && AttachedTransformation()->Attachable())
00498                 AttachedTransformation()->Attach(newOut);
00499         else
00500                 Detach(newOut);
00501 }
00502 
00503 void GeneratableCryptoMaterial::GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize)
00504 {
00505         GenerateRandom(rng, MakeParameters("KeySize", (int)keySize));
00506 }
00507 
00508 BufferedTransformation * PK_Encryptor::CreateEncryptionFilter(RandomNumberGenerator &rng, BufferedTransformation *attachment) const
00509 {
00510         struct EncryptionFilter : public Unflushable<FilterWithInputQueue>
00511         {
00512                 // VC60 complains if this function is missing
00513                 EncryptionFilter(const EncryptionFilter &x) : Unflushable<FilterWithInputQueue>(NULL), m_rng(x.m_rng), m_encryptor(x.m_encryptor) {}
00514 
00515                 EncryptionFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment)
00516                         : Unflushable<FilterWithInputQueue>(attachment), m_rng(rng), m_encryptor(encryptor)
00517                 {
00518                 }
00519 
00520                 bool IsolatedMessageEnd(bool blocking)
00521                 {
00522                         switch (m_continueAt)
00523                         {
00524                         case 0:
00525                                 {
00526                                 unsigned int plaintextLength = m_inQueue.CurrentSize();
00527                                 m_ciphertextLength = m_encryptor.CiphertextLength(plaintextLength);
00528 
00529                                 SecByteBlock plaintext(plaintextLength);
00530                                 m_inQueue.Get(plaintext, plaintextLength);
00531                                 m_ciphertext.resize(m_ciphertextLength);
00532                                 m_encryptor.Encrypt(m_rng, plaintext, plaintextLength, m_ciphertext);
00533                                 }
00534 
00535                         case 1:
00536                                 if (!Output(1, m_ciphertext, m_ciphertextLength, 0, blocking))
00537                                         return false;
00538                         };
00539                         return true;
00540                 }
00541 
00542                 RandomNumberGenerator &m_rng;
00543                 const PK_Encryptor &m_encryptor;
00544                 unsigned int m_ciphertextLength;
00545                 SecByteBlock m_ciphertext;
00546         };
00547 
00548         return new EncryptionFilter(rng, *this, attachment);
00549 }
00550 
00551 BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(BufferedTransformation *attachment) const
00552 {
00553         struct DecryptionFilter : public Unflushable<FilterWithInputQueue>
00554         {
00555                 // VC60 complains if this function is missing
00556                 DecryptionFilter(const DecryptionFilter &x) : Unflushable<FilterWithInputQueue>(NULL), m_decryptor(x.m_decryptor) {}
00557 
00558                 DecryptionFilter(const PK_Decryptor &decryptor, BufferedTransformation *attachment)
00559                         : Unflushable<FilterWithInputQueue>(attachment), m_decryptor(decryptor)
00560                 {
00561                 }
00562 
00563                 bool IsolatedMessageEnd(bool blocking)
00564                 {
00565                         switch (m_continueAt)
00566                         {
00567                         case 0:
00568                                 {
00569                                 unsigned int ciphertextLength = m_inQueue.CurrentSize();
00570                                 unsigned int maxPlaintextLength = m_decryptor.MaxPlaintextLength(ciphertextLength);
00571 
00572                                 SecByteBlock ciphertext(ciphertextLength);
00573                                 m_inQueue.Get(ciphertext, ciphertextLength);
00574                                 m_plaintext.resize(maxPlaintextLength);
00575                                 m_result = m_decryptor.Decrypt(ciphertext, ciphertextLength, m_plaintext);
00576                                 if (!m_result.isValidCoding)
00577                                         throw InvalidCiphertext(m_decryptor.AlgorithmName() + ": invalid ciphertext");
00578                                 }
00579 
00580                         case 1:
00581                                 if (!Output(1, m_plaintext, m_result.messageLength, 0, blocking))
00582                                         return false;
00583                         }
00584                         return true;
00585                 }
00586 
00587                 const PK_Decryptor &m_decryptor;
00588                 SecByteBlock m_plaintext;
00589                 DecodingResult m_result;
00590         };
00591 
00592         return new DecryptionFilter(*this, attachment);
00593 }
00594 
00595 unsigned int PK_FixedLengthCryptoSystem::MaxPlaintextLength(unsigned int cipherTextLength) const
00596 {
00597         if (cipherTextLength == FixedCiphertextLength())
00598                 return FixedMaxPlaintextLength();
00599         else
00600                 return 0;
00601 }
00602 
00603 unsigned int PK_FixedLengthCryptoSystem::CiphertextLength(unsigned int plainTextLength) const
00604 {
00605         if (plainTextLength <= FixedMaxPlaintextLength())
00606                 return FixedCiphertextLength();
00607         else
00608                 return 0;
00609 }
00610 
00611 DecodingResult PK_FixedLengthDecryptor::Decrypt(const byte *cipherText, unsigned int cipherTextLength, byte *plainText) const
00612 {
00613         if (cipherTextLength != FixedCiphertextLength())
00614                 return DecodingResult();
00615 
00616         return FixedLengthDecrypt(cipherText, plainText);
00617 }
00618 
00619 void PK_Signer::Sign(RandomNumberGenerator &rng, HashTransformation *messageAccumulator, byte *signature) const
00620 {
00621         std::auto_ptr<HashTransformation> m(messageAccumulator);
00622         SignAndRestart(rng, *m, signature);
00623 }
00624 
00625 void PK_Signer::SignMessage(RandomNumberGenerator &rng, const byte *message, unsigned int messageLen, byte *signature) const
00626 {
00627         std::auto_ptr<HashTransformation> accumulator(NewSignatureAccumulator());
00628         accumulator->Update(message, messageLen);
00629         SignAndRestart(rng, *accumulator, signature);
00630 }
00631 
00632 bool PK_Verifier::Verify(HashTransformation *messageAccumulator, const byte *signature) const
00633 {
00634         std::auto_ptr<HashTransformation> m(messageAccumulator);
00635         return VerifyAndRestart(*m, signature);
00636 }
00637 
00638 bool PK_Verifier::VerifyMessage(const byte *message, unsigned int messageLen, const byte *sig) const
00639 {
00640         std::auto_ptr<HashTransformation> accumulator(NewVerificationAccumulator());
00641         accumulator->Update(message, messageLen);
00642         return VerifyAndRestart(*accumulator, sig);
00643 }
00644 
00645 void SimpleKeyAgreementDomain::GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
00646 {
00647         GeneratePrivateKey(rng, privateKey);
00648         GeneratePublicKey(rng, privateKey, publicKey);
00649 }
00650 
00651 void AuthenticatedKeyAgreementDomain::GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
00652 {
00653         GenerateStaticPrivateKey(rng, privateKey);
00654         GenerateStaticPublicKey(rng, privateKey, publicKey);
00655 }
00656 
00657 void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
00658 {
00659         GenerateEphemeralPrivateKey(rng, privateKey);
00660         GenerateEphemeralPublicKey(rng, privateKey, publicKey);
00661 }
00662 
00663 NAMESPACE_END
00664 
00665 #endif

Generated on Tue Jul 8 23:34:11 2003 for Crypto++ by doxygen 1.3.2