Fabcoin Core  0.16.2
P2P Digital Currency
cryptlib.h
Go to the documentation of this file.
1 // cryptlib.h - written and placed in the public domain by Wei Dai
2 
5 
83 #ifndef CRYPTOPP_CRYPTLIB_H
84 #define CRYPTOPP_CRYPTLIB_H
85 
86 #include "config.h"
87 #include "stdcpp.h"
88 #include "trap.h"
89 
90 #if CRYPTOPP_MSC_VERSION
91 # pragma warning(push)
92 # pragma warning(disable: 4127 4189 4702)
93 #endif
94 
96 
97 // forward declarations
98 class Integer;
101 
104 enum CipherDir {
109 
111 const unsigned long INFINITE_TIME = ULONG_MAX;
112 
113 // VC60 workaround: using enums as template parameters causes problems
115 template <typename ENUM_TYPE, int VALUE>
117 {
118  static ENUM_TYPE ToEnum() {return (ENUM_TYPE)VALUE;}
119 };
120 
124 enum ByteOrder {
129 
134 
140 class CRYPTOPP_DLL Exception : public std::exception
141 {
142 public:
145  enum ErrorType {
159  OTHER_ERROR
160  };
161 
162  virtual ~Exception() throw() {}
163 
165  explicit Exception(ErrorType errorType, const std::string &s) : m_errorType(errorType), m_what(s) {}
166 
168  const char *what() const throw() {return (m_what.c_str());}
170  const std::string &GetWhat() const {return m_what;}
172  void SetWhat(const std::string &s) {m_what = s;}
174  ErrorType GetErrorType() const {return m_errorType;}
176  void SetErrorType(ErrorType errorType) {m_errorType = errorType;}
177 
178 private:
180  std::string m_what;
181 };
182 
185 {
186 public:
187  explicit InvalidArgument(const std::string &s) : Exception(INVALID_ARGUMENT, s) {}
188 };
189 
192 {
193 public:
194  explicit InvalidDataFormat(const std::string &s) : Exception(INVALID_DATA_FORMAT, s) {}
195 };
196 
199 {
200 public:
201  explicit InvalidCiphertext(const std::string &s) : InvalidDataFormat(s) {}
202 };
203 
206 {
207 public:
208  explicit NotImplemented(const std::string &s) : Exception(NOT_IMPLEMENTED, s) {}
209 };
210 
213 {
214 public:
215  explicit CannotFlush(const std::string &s) : Exception(CANNOT_FLUSH, s) {}
216 };
217 
220 {
221 public:
222  virtual ~OS_Error() throw() {}
223  OS_Error(ErrorType errorType, const std::string &s, const std::string& operation, int errorCode)
224  : Exception(errorType, s), m_operation(operation), m_errorCode(errorCode) {}
225 
227  const std::string & GetOperation() const {return m_operation;}
229  int GetErrorCode() const {return m_errorCode;}
230 
231 protected:
232  std::string m_operation;
234 };
235 
239 {
242  explicit DecodingResult() : isValidCoding(false), messageLength(0) {}
246  explicit DecodingResult(size_t len) : isValidCoding(true), messageLength(len) {}
247 
251  bool operator==(const DecodingResult &rhs) const {return isValidCoding == rhs.isValidCoding && messageLength == rhs.messageLength;}
256  bool operator!=(const DecodingResult &rhs) const {return !operator==(rhs);}
257 
262 
263  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
264  //operator size_t() const {return isValidCoding ? messageLength : 0;}
265  //#endif
266 };
267 
280 {
281 public:
282  virtual ~NameValuePairs() {}
283 
288  {
289  public:
294  ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving)
295  : InvalidArgument("NameValuePairs: type mismatch for '" + name + "', stored '" + stored.name() + "', trying to retrieve '" + retrieving.name() + "'")
296  , m_stored(stored), m_retrieving(retrieving) {}
297 
300  const std::type_info & GetStoredTypeInfo() const {return m_stored;}
301 
304  const std::type_info & GetRetrievingTypeInfo() const {return m_retrieving;}
305 
306  private:
307  const std::type_info &m_stored;
308  const std::type_info &m_retrieving;
309  };
310 
314  template <class T>
315  bool GetThisObject(T &object) const
316  {
317  return GetValue((std::string("ThisObject:")+typeid(T).name()).c_str(), object);
318  }
319 
323  template <class T>
324  bool GetThisPointer(T *&ptr) const
325  {
326  return GetValue((std::string("ThisPointer:")+typeid(T).name()).c_str(), ptr);
327  }
328 
336  template <class T>
337  bool GetValue(const char *name, T &value) const
338  {
339  return GetVoidValue(name, typeid(T), &value);
340  }
341 
349  template <class T>
350  T GetValueWithDefault(const char *name, T defaultValue) const
351  {
352  T value;
353  bool result = GetValue(name, value);
354  // No assert... this recovers from failure
355  if (result) {return value;}
356  return defaultValue;
357  }
358 
362  CRYPTOPP_DLL std::string GetValueNames() const
363  {std::string result; GetValue("ValueNames", result); return result;}
364 
373  CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
374  {return GetValue(name, value);}
375 
382  CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
383  {return GetValueWithDefault(name, defaultValue);}
384 
394  CRYPTOPP_DLL static void CRYPTOPP_API ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
395  {if (stored != retrieving) throw ValueTypeMismatch(name, stored, retrieving);}
396 
407  template <class T>
408  void GetRequiredParameter(const char *className, const char *name, T &value) const
409  {
410  if (!GetValue(name, value))
411  throw InvalidArgument(std::string(className) + ": missing required parameter '" + name + "'");
412  }
413 
423  CRYPTOPP_DLL void GetRequiredIntParameter(const char *className, const char *name, int &value) const
424  {
425  if (!GetIntValue(name, value))
426  throw InvalidArgument(std::string(className) + ": missing required parameter '" + name + "'");
427  }
428 
439  CRYPTOPP_DLL virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const =0;
440 };
441 
442 #if CRYPTOPP_DOXYGEN_PROCESSING
443 
452 // more names defined in argnames.h
454 
467 
469 // weak and wounded algorithms
471 #endif
472 
475 
476 // ********************************************************
477 
483 {
484 public:
485  virtual ~Clonable() {}
486 
492  virtual Clonable* Clone() const {throw NotImplemented("Clone() is not implemented yet.");} // TODO: make this =0
493 };
494 
498 {
499 public:
500  virtual ~Algorithm() {}
501 
510  Algorithm(bool checkSelfTestStatus = true);
511 
518  virtual std::string AlgorithmName() const {return "unknown";}
519 };
520 
525 {
526 public:
528 
531  virtual size_t MinKeyLength() const =0;
534  virtual size_t MaxKeyLength() const =0;
537  virtual size_t DefaultKeyLength() const =0;
538 
547  virtual size_t GetValidKeyLength(size_t keylength) const =0;
548 
553  virtual bool IsValidKeyLength(size_t keylength) const
554  {return keylength == GetValidKeyLength(keylength);}
555 
561  virtual void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs);
562 
571  void SetKeyWithRounds(const byte *key, size_t length, int rounds);
572 
581  void SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength);
582 
590  void SetKeyWithIV(const byte *key, size_t length, const byte *iv)
591  {SetKeyWithIV(key, length, iv, IVSize());}
592 
600  UNIQUE_IV = 0,
608  NOT_RESYNCHRONIZABLE
609  };
610 
613  virtual IV_Requirement IVRequirement() const =0;
614 
619  bool IsResynchronizable() const {return IVRequirement() < NOT_RESYNCHRONIZABLE;}
620 
623  bool CanUseRandomIVs() const {return IVRequirement() <= UNPREDICTABLE_RANDOM_IV;}
624 
628  bool CanUsePredictableIVs() const {return IVRequirement() <= RANDOM_IV;}
629 
634  bool CanUseStructuredIVs() const {return IVRequirement() <= UNIQUE_IV;}
635 
640  virtual unsigned int IVSize() const
641  {throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");}
642 
645  unsigned int DefaultIVLength() const {return IVSize();}
646 
650  virtual unsigned int MinIVLength() const {return IVSize();}
651 
655  virtual unsigned int MaxIVLength() const {return IVSize();}
656 
662  virtual void Resynchronize(const byte *iv, int ivLength=-1) {
663  CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(ivLength);
664  throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");
665  }
666 
676  virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv);
677 
678 protected:
681  virtual const Algorithm & GetAlgorithm() const =0;
682 
688  virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params) =0;
689 
693  void ThrowIfInvalidKeyLength(size_t length);
694 
700  void ThrowIfResynchronizable();
701 
709  void ThrowIfInvalidIV(const byte *iv);
710 
714  size_t ThrowIfInvalidIVLength(int length);
715 
721  const byte * GetIVAndThrowIfInvalid(const NameValuePairs &params, size_t &size);
722 
725  inline void AssertValidKeyLength(size_t length) const
726  {CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(IsValidKeyLength(length));}
727 };
728 
735 {
736 public:
737  virtual ~BlockTransformation() {}
738 
748  virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0;
749 
758  void ProcessBlock(const byte *inBlock, byte *outBlock) const
759  {ProcessAndXorBlock(inBlock, NULL, outBlock);}
760 
767  void ProcessBlock(byte *inoutBlock) const
768  {ProcessAndXorBlock(inoutBlock, NULL, inoutBlock);}
769 
772  virtual unsigned int BlockSize() const =0;
773 
776  virtual unsigned int OptimalDataAlignment() const;
777 
779  virtual bool IsPermutation() const {return true;}
780 
784  virtual bool IsForwardTransformation() const =0;
785 
789  virtual unsigned int OptimalNumberOfParallelBlocks() const {return 1;}
790 
794  BT_InBlockIsCounter=1,
796  BT_DontIncrementInOutPointers=2,
798  BT_XorInput=4,
800  BT_ReverseDirection=8,
802  BT_AllowParallel=16};
803 
812  virtual size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
813 
817  inline CipherDir GetCipherDirection() const {return IsForwardTransformation() ? ENCRYPTION : DECRYPTION;}
818 };
819 
824 {
825 public:
827 
831  StreamTransformation& Ref() {return *this;}
832 
835  virtual unsigned int MandatoryBlockSize() const {return 1;}
836 
842  virtual unsigned int OptimalBlockSize() const {return MandatoryBlockSize();}
843 
846  virtual unsigned int GetOptimalBlockSizeUsed() const {return 0;}
847 
850  virtual unsigned int OptimalDataAlignment() const;
851 
857  virtual void ProcessData(byte *outString, const byte *inString, size_t length) =0;
858 
865  virtual void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
866 
871  virtual unsigned int MinLastBlockSize() const {return 0;}
872 
877  inline void ProcessString(byte *inoutString, size_t length)
878  {ProcessData(inoutString, inoutString, length);}
879 
885  inline void ProcessString(byte *outString, const byte *inString, size_t length)
886  {ProcessData(outString, inString, length);}
887 
891  inline byte ProcessByte(byte input)
892  {ProcessData(&input, &input, 1); return input;}
893 
896  virtual bool IsRandomAccess() const =0;
897 
903  virtual void Seek(lword pos)
904  {
905  CRYPTOPP_UNUSED(pos);
906  CRYPTOPP_ASSERT(!IsRandomAccess());
907  throw NotImplemented("StreamTransformation: this object doesn't support random access");
908  }
909 
914  virtual bool IsSelfInverting() const =0;
915 
919  virtual bool IsForwardTransformation() const =0;
920 };
921 
931 {
932 public:
933  virtual ~HashTransformation() {}
934 
938  HashTransformation& Ref() {return *this;}
939 
943  virtual void Update(const byte *input, size_t length) =0;
944 
953  virtual byte * CreateUpdateSpace(size_t &size) {size=0; return NULL;}
954 
960  virtual void Final(byte *digest)
961  {TruncatedFinal(digest, DigestSize());}
962 
965  virtual void Restart()
966  {TruncatedFinal(NULL, 0);}
967 
970  virtual unsigned int DigestSize() const =0;
971 
975  unsigned int TagSize() const {return DigestSize();}
976 
981  virtual unsigned int BlockSize() const {return 0;}
982 
988  virtual unsigned int OptimalBlockSize() const {return 1;}
989 
992  virtual unsigned int OptimalDataAlignment() const;
993 
1003  virtual void CalculateDigest(byte *digest, const byte *input, size_t length)
1004  {Update(input, length); Final(digest);}
1005 
1015  virtual bool Verify(const byte *digest)
1016  {return TruncatedVerify(digest, DigestSize());}
1017 
1031  virtual bool VerifyDigest(const byte *digest, const byte *input, size_t length)
1032  {Update(input, length); return Verify(digest);}
1033 
1039  virtual void TruncatedFinal(byte *digest, size_t digestSize) =0;
1040 
1051  virtual void CalculateTruncatedDigest(byte *digest, size_t digestSize, const byte *input, size_t length)
1052  {Update(input, length); TruncatedFinal(digest, digestSize);}
1053 
1064  virtual bool TruncatedVerify(const byte *digest, size_t digestLength);
1065 
1080  virtual bool VerifyTruncatedDigest(const byte *digest, size_t digestLength, const byte *input, size_t length)
1081  {Update(input, length); return TruncatedVerify(digest, digestLength);}
1082 
1083 protected:
1088  void ThrowIfInvalidTruncatedSize(size_t size) const;
1089 };
1090 
1092 
1096 {
1097 protected:
1098  const Algorithm & GetAlgorithm() const {return *this;}
1099 };
1100 
1104 {
1105 protected:
1106  const Algorithm & GetAlgorithm() const {return *this;}
1107 };
1108 
1112 {
1113 protected:
1114  const Algorithm & GetAlgorithm() const {return *this;}
1115 };
1116 
1122 {
1123 public:
1125 
1129  class BadState : public Exception
1130  {
1131  public:
1132  explicit BadState(const std::string &name, const char *message) : Exception(OTHER_ERROR, name + ": " + message) {}
1133  explicit BadState(const std::string &name, const char *function, const char *state) : Exception(OTHER_ERROR, name + ": " + function + " was called before " + state) {}
1134  };
1135 
1138  virtual lword MaxHeaderLength() const =0;
1141  virtual lword MaxMessageLength() const =0;
1144  virtual lword MaxFooterLength() const {return 0;}
1150  virtual bool NeedsPrespecifiedDataLengths() const {return false;}
1154  void SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength=0);
1159  virtual void EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength);
1164  virtual bool DecryptAndVerify(byte *message, const byte *mac, size_t macLength, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength);
1165 
1171  virtual std::string AlgorithmName() const =0;
1172 
1173 protected:
1174  const Algorithm & GetAlgorithm() const
1175  {return *static_cast<const MessageAuthenticationCode *>(this);}
1176  virtual void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
1177  {CRYPTOPP_UNUSED(headerLength); CRYPTOPP_UNUSED(messageLength); CRYPTOPP_UNUSED(footerLength);}
1178 };
1179 
1180 //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
1181 //typedef SymmetricCipher StreamCipher;
1182 //#endif
1183 
1189 {
1190 public:
1192 
1201  virtual void IncorporateEntropy(const byte *input, size_t length)
1202  {
1203  CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length);
1204  throw NotImplemented("RandomNumberGenerator: IncorporateEntropy not implemented");
1205  }
1206 
1209  virtual bool CanIncorporateEntropy() const {return false;}
1210 
1216  virtual byte GenerateByte();
1217 
1223  virtual unsigned int GenerateBit();
1224 
1233  virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL);
1234 
1242  virtual void GenerateBlock(byte *output, size_t size);
1243 
1254  virtual void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length);
1255 
1258  virtual void DiscardBytes(size_t n);
1259 
1264  template <class IT> void Shuffle(IT begin, IT end)
1265  {
1266  // TODO: What happens if there are more than 2^32 elements?
1267  for (; begin != end; ++begin)
1268  std::iter_swap(begin, begin + GenerateWord32(0, end-begin-1));
1269  }
1270 
1271  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
1272  //byte GetByte() {return GenerateByte();}
1273  //unsigned int GetBit() {return GenerateBit();}
1274  //word32 GetLong(word32 a=0, word32 b=0xffffffffL) {return GenerateWord32(a, b);}
1275  //word16 GetShort(word16 a=0, word16 b=0xffff) {return (word16)GenerateWord32(a, b);}
1276  //void GetBlock(byte *output, size_t size) {GenerateBlock(output, size);}
1277  //#endif
1278 
1279 };
1280 
1288 
1292 class CallStack;
1293 
1296 {
1297 public:
1298  virtual ~Waitable() {}
1299 
1302  virtual unsigned int GetMaxWaitObjectCount() const =0;
1303 
1312  virtual void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack) =0;
1313 
1318  bool Wait(unsigned long milliseconds, CallStack const& callStack);
1319 };
1320 
1323 extern CRYPTOPP_DLL const std::string DEFAULT_CHANNEL;
1324 
1327 extern CRYPTOPP_DLL const std::string AAD_CHANNEL;
1328 
1353 {
1354 public:
1355  // placed up here for CW8
1356  static const std::string &NULL_CHANNEL; // same as DEFAULT_CHANNEL, for backwards compatibility
1357 
1359 
1362 
1366  BufferedTransformation& Ref() {return *this;}
1367 
1369 
1370 
1376  size_t Put(byte inByte, bool blocking=true)
1377  {return Put(&inByte, 1, blocking);}
1378 
1385  size_t Put(const byte *inString, size_t length, bool blocking=true)
1386  {return Put2(inString, length, 0, blocking);}
1387 
1393  size_t PutWord16(word16 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true);
1394 
1400  size_t PutWord32(word32 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true);
1401 
1411  virtual byte * CreatePutSpace(size_t &size)
1412  {size=0; return NULL;}
1413 
1417  virtual bool CanModifyInput() const
1418  {return false;}
1419 
1426  size_t PutModifiable(byte *inString, size_t length, bool blocking=true)
1427  {return PutModifiable2(inString, length, 0, blocking);}
1428 
1434  bool MessageEnd(int propagation=-1, bool blocking=true)
1435  {return !!Put2(NULL, 0, propagation < 0 ? -1 : propagation+1, blocking);}
1436 
1447  size_t PutMessageEnd(const byte *inString, size_t length, int propagation=-1, bool blocking=true)
1448  {return Put2(inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
1449 
1456  virtual size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) =0;
1457 
1464  virtual size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
1465  {return Put2(inString, length, messageEnd, blocking);}
1466 
1471  {BlockingInputOnly(const std::string &s) : NotImplemented(s + ": Nonblocking input is not implemented by this object.") {}};
1473 
1475 
1476  unsigned int GetMaxWaitObjectCount() const;
1478 
1487  void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack);
1489 
1491 
1492 
1504  CRYPTOPP_UNUSED(parameters);
1505  throw NotImplemented("BufferedTransformation: this object can't be reinitialized");
1506  }
1507 
1512  virtual bool IsolatedFlush(bool hardFlush, bool blocking) =0;
1513 
1517  virtual bool IsolatedMessageSeriesEnd(bool blocking)
1518  {CRYPTOPP_UNUSED(blocking); return false;}
1519 
1528  virtual void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1);
1529 
1544  virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true);
1545 
1554  virtual bool MessageSeriesEnd(int propagation=-1, bool blocking=true);
1555 
1560  virtual void SetAutoSignalPropagation(int propagation)
1561  {CRYPTOPP_UNUSED(propagation);}
1562 
1566  virtual int GetAutoSignalPropagation() const {return 0;}
1567 public:
1568 
1569  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
1570  //void Close() {MessageEnd();}
1571  //#endif
1573 
1575 
1576 
1581  virtual lword MaxRetrievable() const;
1582 
1585  virtual bool AnyRetrievable() const;
1586 
1591  virtual size_t Get(byte &outByte);
1592 
1598  virtual size_t Get(byte *outString, size_t getMax);
1599 
1605  virtual size_t Peek(byte &outByte) const;
1606 
1613  virtual size_t Peek(byte *outString, size_t peekMax) const;
1614 
1620  size_t GetWord16(word16 &value, ByteOrder order=BIG_ENDIAN_ORDER);
1621 
1627  size_t GetWord32(word32 &value, ByteOrder order=BIG_ENDIAN_ORDER);
1628 
1635  size_t PeekWord16(word16 &value, ByteOrder order=BIG_ENDIAN_ORDER) const;
1636 
1643  size_t PeekWord32(word32 &value, ByteOrder order=BIG_ENDIAN_ORDER) const;
1644 
1646 
1654  lword TransferTo(BufferedTransformation &target, lword transferMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL)
1655  {TransferTo2(target, transferMax, channel); return transferMax;}
1656 
1668  virtual lword Skip(lword skipMax=LWORD_MAX);
1669 
1671 
1679  lword CopyTo(BufferedTransformation &target, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const
1680  {return CopyRangeTo(target, 0, copyMax, channel);}
1681 
1692  lword CopyRangeTo(BufferedTransformation &target, lword position, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const
1693  {lword i = position; CopyRangeTo2(target, i, i+copyMax, channel); return i-position;}
1694 
1695  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
1696  //unsigned long MaxRetrieveable() const {return MaxRetrievable();}
1697  //#endif
1699 
1701 
1702 
1705  virtual lword TotalBytesRetrievable() const;
1706 
1711  virtual unsigned int NumberOfMessages() const;
1712 
1716  virtual bool AnyMessages() const;
1717 
1722  virtual bool GetNextMessage();
1723 
1729  virtual unsigned int SkipMessages(unsigned int count=UINT_MAX);
1730 
1740  unsigned int TransferMessagesTo(BufferedTransformation &target, unsigned int count=UINT_MAX, const std::string &channel=DEFAULT_CHANNEL)
1741  {TransferMessagesTo2(target, count, channel); return count;}
1742 
1752  unsigned int CopyMessagesTo(BufferedTransformation &target, unsigned int count=UINT_MAX, const std::string &channel=DEFAULT_CHANNEL) const;
1753 
1755  virtual void SkipAll();
1756 
1763  void TransferAllTo(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL)
1764  {TransferAllTo2(target, channel);}
1765 
1770  void CopyAllTo(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL) const;
1771 
1775  virtual bool GetNextMessageSeries() {return false;}
1778  virtual unsigned int NumberOfMessagesInThisSeries() const {return NumberOfMessages();}
1781  virtual unsigned int NumberOfMessageSeries() const {return 0;}
1783 
1785 
1786 
1787  // upon return, byteCount contains number of bytes that have finished being transferred,
1788  // and returns the number of bytes left in the current transfer block
1789 
1802  virtual size_t TransferTo2(BufferedTransformation &target, lword &byteCount, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) =0;
1803 
1804  // upon return, begin contains the start position of data yet to be finished copying,
1805  // and returns the number of bytes left in the current transfer block
1806 
1821  virtual size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const =0;
1822 
1823  // upon return, messageCount contains number of messages that have finished being transferred,
1824  // and returns the number of bytes left in the current transfer block
1825 
1836  size_t TransferMessagesTo2(BufferedTransformation &target, unsigned int &messageCount, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
1837 
1838  // returns the number of bytes left in the current transfer block
1839 
1846  size_t TransferAllTo2(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
1848 
1850 
1851  struct NoChannelSupport : public NotImplemented
1853  {NoChannelSupport(const std::string &name) : NotImplemented(name + ": this object doesn't support multiple channels") {}};
1856  {InvalidChannelName(const std::string &name, const std::string &channel) : InvalidArgument(name + ": unexpected channel name \"" + channel + "\"") {}};
1857 
1864  size_t ChannelPut(const std::string &channel, byte inByte, bool blocking=true)
1865  {return ChannelPut(channel, &inByte, 1, blocking);}
1866 
1874  size_t ChannelPut(const std::string &channel, const byte *inString, size_t length, bool blocking=true)
1875  {return ChannelPut2(channel, inString, length, 0, blocking);}
1876 
1884  size_t ChannelPutModifiable(const std::string &channel, byte *inString, size_t length, bool blocking=true)
1885  {return ChannelPutModifiable2(channel, inString, length, 0, blocking);}
1886 
1894  size_t ChannelPutWord16(const std::string &channel, word16 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true);
1895 
1903  size_t ChannelPutWord32(const std::string &channel, word32 value, ByteOrder order=BIG_ENDIAN_ORDER, bool blocking=true);
1904 
1913  bool ChannelMessageEnd(const std::string &channel, int propagation=-1, bool blocking=true)
1914  {return !!ChannelPut2(channel, NULL, 0, propagation < 0 ? -1 : propagation+1, blocking);}
1915 
1925  size_t ChannelPutMessageEnd(const std::string &channel, const byte *inString, size_t length, int propagation=-1, bool blocking=true)
1926  {return ChannelPut2(channel, inString, length, propagation < 0 ? -1 : propagation+1, blocking);}
1927 
1939  virtual byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);
1940 
1948  virtual size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking);
1949 
1957  virtual size_t ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking);
1958 
1967  virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true);
1968 
1978  virtual bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true);
1979 
1983  virtual void SetRetrievalChannel(const std::string &channel);
1985 
1990 
1992  virtual bool Attachable() {return false;}
1996 
2001  virtual BufferedTransformation *AttachedTransformation() {CRYPTOPP_ASSERT(!Attachable()); return 0;}
2002 
2008  {return const_cast<BufferedTransformation *>(this)->AttachedTransformation();}
2009 
2016  virtual void Detach(BufferedTransformation *newAttachment = 0) {
2017  CRYPTOPP_UNUSED(newAttachment); CRYPTOPP_ASSERT(!Attachable());
2018  throw NotImplemented("BufferedTransformation: this object is not attachable");
2019  }
2020 
2023  virtual void Attach(BufferedTransformation *newAttachment);
2025 
2026 protected:
2029  static int DecrementPropagation(int propagation)
2030  {return propagation != 0 ? propagation - 1 : 0;}
2031 
2032 private:
2033  byte m_buf[4]; // for ChannelPutWord16 and ChannelPutWord32, to ensure buffer isn't deallocated before non-blocking operation completes
2034 };
2035 
2039 
2043 {
2044 public:
2047  {
2048  public:
2049  explicit InvalidMaterial(const std::string &s) : InvalidDataFormat(s) {}
2050  };
2051 
2052  virtual ~CryptoMaterial() {}
2053 
2056  virtual void AssignFrom(const NameValuePairs &source) =0;
2057 
2072  virtual bool Validate(RandomNumberGenerator &rng, unsigned int level) const =0;
2073 
2080  virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int level) const
2081  {if (!Validate(rng, level)) throw InvalidMaterial("CryptoMaterial: this object contains invalid values");}
2082 
2092  virtual void Save(BufferedTransformation &bt) const
2093  {CRYPTOPP_UNUSED(bt); throw NotImplemented("CryptoMaterial: this object does not support saving");}
2094 
2109  virtual void Load(BufferedTransformation &bt)
2110  {CRYPTOPP_UNUSED(bt); throw NotImplemented("CryptoMaterial: this object does not support loading");}
2111 
2115  virtual bool SupportsPrecomputation() const {return false;}
2116 
2125  virtual void Precompute(unsigned int precomputationStorage) {
2126  CRYPTOPP_UNUSED(precomputationStorage); CRYPTOPP_ASSERT(!SupportsPrecomputation());
2127  throw NotImplemented("CryptoMaterial: this object does not support precomputation");
2128  }
2129 
2134  virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation)
2135  {CRYPTOPP_UNUSED(storedPrecomputation); CRYPTOPP_ASSERT(!SupportsPrecomputation()); throw NotImplemented("CryptoMaterial: this object does not support precomputation");}
2140  virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const
2141  {CRYPTOPP_UNUSED(storedPrecomputation); CRYPTOPP_ASSERT(!SupportsPrecomputation()); throw NotImplemented("CryptoMaterial: this object does not support precomputation");}
2142 
2145  void DoQuickSanityCheck() const {ThrowIfInvalid(NullRNG(), 0);}
2146 
2147 #if (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
2148  // Sun Studio 11/CC 5.8 workaround: it generates incorrect code when casting to an empty virtual base class
2149  char m_sunCCworkaround;
2150 #endif
2151 };
2152 
2156 {
2157 public:
2159 
2167  CRYPTOPP_UNUSED(rng); CRYPTOPP_UNUSED(params);
2168  throw NotImplemented("GeneratableCryptoMaterial: this object does not support key/parameter generation");
2169  }
2170 
2177  void GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize);
2178 };
2179 
2182 {
2183 };
2184 
2187 {
2188 };
2189 
2192 {
2193 };
2194 
2197 {
2198 public:
2200 
2203  virtual CryptoMaterial & AccessMaterial() =0;
2204 
2207  virtual const CryptoMaterial & GetMaterial() const =0;
2208 
2213  {AccessMaterial().Load(bt);}
2214 
2219  {GetMaterial().Save(bt);}
2220 };
2221 
2224 {
2225 public:
2226  virtual ~PublicKeyAlgorithm() {}
2227 
2228  // VC60 workaround: no co-variant return type
2229 
2233  {return AccessPublicKey();}
2236  const CryptoMaterial & GetMaterial() const
2237  {return GetPublicKey();}
2238 
2241  virtual PublicKey & AccessPublicKey() =0;
2244  virtual const PublicKey & GetPublicKey() const
2245  {return const_cast<PublicKeyAlgorithm *>(this)->AccessPublicKey();}
2246 };
2247 
2250 {
2251 public:
2253 
2256  CryptoMaterial & AccessMaterial() {return AccessPrivateKey();}
2259  const CryptoMaterial & GetMaterial() const {return GetPrivateKey();}
2260 
2263  virtual PrivateKey & AccessPrivateKey() =0;
2266  virtual const PrivateKey & GetPrivateKey() const {return const_cast<PrivateKeyAlgorithm *>(this)->AccessPrivateKey();}
2267 };
2268 
2271 {
2272 public:
2274 
2277  CryptoMaterial & AccessMaterial() {return AccessCryptoParameters();}
2280  const CryptoMaterial & GetMaterial() const {return GetCryptoParameters();}
2281 
2284  virtual CryptoParameters & AccessCryptoParameters() =0;
2287  virtual const CryptoParameters & GetCryptoParameters() const {return const_cast<KeyAgreementAlgorithm *>(this)->AccessCryptoParameters();}
2288 };
2289 
2294 {
2295 public:
2296  virtual ~PK_CryptoSystem() {}
2297 
2301  virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0;
2302 
2306  virtual size_t CiphertextLength(size_t plaintextLength) const =0;
2307 
2313  virtual bool ParameterSupported(const char *name) const =0;
2314 
2319  virtual size_t FixedCiphertextLength() const {return 0;}
2320 
2326  virtual size_t FixedMaxPlaintextLength() const {return 0;}
2327 
2328  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
2329  //size_t MaxPlainTextLength(size_t cipherTextLength) const {return MaxPlaintextLength(cipherTextLength);}
2330  //size_t CipherTextLength(size_t plainTextLength) const {return CiphertextLength(plainTextLength);}
2331  //#endif
2332 };
2333 
2337 {
2338 public:
2341  {
2342  public:
2343  InvalidPlaintextLength() : Exception(OTHER_ERROR, "PK_Encryptor: invalid plaintext length") {}
2344  };
2345 
2356  virtual void Encrypt(RandomNumberGenerator &rng,
2357  const byte *plaintext, size_t plaintextLength,
2358  byte *ciphertext, const NameValuePairs &parameters = g_nullNameValuePairs) const =0;
2359 
2366  virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng,
2367  BufferedTransformation *attachment=NULL, const NameValuePairs &parameters = g_nullNameValuePairs) const;
2368 };
2369 
2373 {
2374 public:
2375  virtual ~PK_Decryptor() {}
2376 
2391  virtual DecodingResult Decrypt(RandomNumberGenerator &rng,
2392  const byte *ciphertext, size_t ciphertextLength,
2393  byte *plaintext, const NameValuePairs &parameters = g_nullNameValuePairs) const =0;
2394 
2401  virtual BufferedTransformation * CreateDecryptionFilter(RandomNumberGenerator &rng,
2402  BufferedTransformation *attachment=NULL, const NameValuePairs &parameters = g_nullNameValuePairs) const;
2403 
2418  {return Decrypt(rng, ciphertext, FixedCiphertextLength(), plaintext, parameters);}
2419 };
2420 
2421 //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
2422 //typedef PK_CryptoSystem PK_FixedLengthCryptoSystem;
2423 //typedef PK_Encryptor PK_FixedLengthEncryptor;
2424 //typedef PK_Decryptor PK_FixedLengthDecryptor;
2425 //#endif
2426 
2432 {
2433 public:
2439  {
2440  public:
2441  InvalidKeyLength(const std::string &message) : Exception(OTHER_ERROR, message) {}
2442  };
2443 
2449  {
2450  public:
2451  KeyTooShort() : InvalidKeyLength("PK_Signer: key too short for this signature scheme") {}
2452  };
2453 
2454  virtual ~PK_SignatureScheme() {}
2455 
2459  virtual size_t SignatureLength() const =0;
2460 
2466  virtual size_t MaxSignatureLength(size_t recoverablePartLength = 0) const
2467  {CRYPTOPP_UNUSED(recoverablePartLength); return SignatureLength();}
2468 
2473  virtual size_t MaxRecoverableLength() const =0;
2474 
2481  virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0;
2482 
2487  virtual bool IsProbabilistic() const =0;
2488 
2491  virtual bool AllowNonrecoverablePart() const =0;
2492 
2497  virtual bool SignatureUpfront() const {return false;}
2498 
2503  virtual bool RecoverablePartFirst() const =0;
2504 };
2505 
2511 {
2512 public:
2514  unsigned int DigestSize() const
2515  {throw NotImplemented("PK_MessageAccumulator: DigestSize() should not be called");}
2516 
2518  void TruncatedFinal(byte *digest, size_t digestSize)
2519  {
2520  CRYPTOPP_UNUSED(digest); CRYPTOPP_UNUSED(digestSize);
2521  throw NotImplemented("PK_MessageAccumulator: TruncatedFinal() should not be called");
2522  }
2523 };
2524 
2528 {
2529 public:
2530  virtual ~PK_Signer() {}
2531 
2537  virtual PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const =0;
2538 
2543  virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0;
2544 
2552  virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const;
2553 
2561  virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0;
2562 
2570  virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const;
2571 
2581  virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength,
2582  const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const;
2583 };
2584 
2593 {
2594 public:
2595  virtual ~PK_Verifier() {}
2596 
2601  virtual PK_MessageAccumulator * NewVerificationAccumulator() const =0;
2602 
2607  virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0;
2608 
2613  virtual bool Verify(PK_MessageAccumulator *messageAccumulator) const;
2614 
2619  virtual bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const =0;
2620 
2627  virtual bool VerifyMessage(const byte *message, size_t messageLen,
2628  const byte *signature, size_t signatureLen) const;
2629 
2636  virtual DecodingResult Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const;
2637 
2644  virtual DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0;
2645 
2654  virtual DecodingResult RecoverMessage(byte *recoveredMessage,
2655  const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength,
2656  const byte *signature, size_t signatureLength) const;
2657 };
2658 
2665 {
2666 public:
2668 
2671  virtual unsigned int AgreedValueLength() const =0;
2672 
2675  virtual unsigned int PrivateKeyLength() const =0;
2676 
2679  virtual unsigned int PublicKeyLength() const =0;
2680 
2685  virtual void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0;
2686 
2692  virtual void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0;
2693 
2701  virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
2702 
2715  virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0;
2716 
2717  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
2718  //bool ValidateDomainParameters(RandomNumberGenerator &rng) const
2719  // {return GetCryptoParameters().Validate(rng, 2);}
2720  //#endif
2721 };
2722 
2728 {
2729 public:
2731 
2734  virtual unsigned int AgreedValueLength() const =0;
2735 
2738  virtual unsigned int StaticPrivateKeyLength() const =0;
2739 
2742  virtual unsigned int StaticPublicKeyLength() const =0;
2743 
2748  virtual void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0;
2749 
2755  virtual void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0;
2756 
2764  virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
2765 
2768  virtual unsigned int EphemeralPrivateKeyLength() const =0;
2769 
2772  virtual unsigned int EphemeralPublicKeyLength() const =0;
2773 
2778  virtual void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0;
2779 
2785  virtual void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0;
2786 
2792  virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
2793 
2810  virtual bool Agree(byte *agreedValue,
2811  const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
2812  const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
2813  bool validateStaticOtherPublicKey=true) const =0;
2814 
2815  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
2816  // bool ValidateDomainParameters(RandomNumberGenerator &rng) const
2817  // {return GetCryptoParameters().Validate(rng, 2);}
2818  //#endif
2819 };
2820 
2821 // interface for password authenticated key agreement protocols, not implemented yet
2822 #if 0
2823 
2844 class ProtocolSession
2845 {
2846 public:
2848  class ProtocolError : public Exception
2849  {
2850  public:
2851  ProtocolError(ErrorType errorType, const std::string &s) : Exception(errorType, s) {}
2852  };
2853 
2855 
2856  class UnexpectedMethodCall : public Exception
2857  {
2858  public:
2859  UnexpectedMethodCall(const std::string &s) : Exception(OTHER_ERROR, s) {}
2860  };
2861 
2862  virtual ~ProtocolSession() {}
2863 
2864  ProtocolSession() : m_rng(NULL), m_throwOnProtocolError(true), m_validState(false) {}
2865 
2866  virtual void InitializeSession(RandomNumberGenerator &rng, const NameValuePairs &parameters) =0;
2867 
2868  bool GetThrowOnProtocolError() const {return m_throwOnProtocolError;}
2869  void SetThrowOnProtocolError(bool throwOnProtocolError) {m_throwOnProtocolError = throwOnProtocolError;}
2870 
2871  bool HasValidState() const {return m_validState;}
2872 
2873  virtual bool OutgoingMessageAvailable() const =0;
2874  virtual unsigned int GetOutgoingMessageLength() const =0;
2875  virtual void GetOutgoingMessage(byte *message) =0;
2876 
2877  virtual bool LastMessageProcessed() const =0;
2878  virtual void ProcessIncomingMessage(const byte *message, unsigned int messageLength) =0;
2879 
2880 protected:
2881  void HandleProtocolError(Exception::ErrorType errorType, const std::string &s) const;
2882  void CheckAndHandleInvalidState() const;
2883  void SetValidState(bool valid) {m_validState = valid;}
2884 
2885  RandomNumberGenerator *m_rng;
2886 
2887 private:
2888  bool m_throwOnProtocolError, m_validState;
2889 };
2890 
2891 class KeyAgreementSession : public ProtocolSession
2892 {
2893 public:
2894  virtual ~KeyAgreementSession() {}
2895 
2896  virtual unsigned int GetAgreedValueLength() const =0;
2897  virtual void GetAgreedValue(byte *agreedValue) const =0;
2898 };
2899 
2900 class PasswordAuthenticatedKeyAgreementSession : public KeyAgreementSession
2901 {
2902 public:
2903  virtual ~PasswordAuthenticatedKeyAgreementSession() {}
2904 
2905  void InitializePasswordAuthenticatedKeyAgreementSession(RandomNumberGenerator &rng,
2906  const byte *myId, unsigned int myIdLength,
2907  const byte *counterPartyId, unsigned int counterPartyIdLength,
2908  const byte *passwordOrVerifier, unsigned int passwordOrVerifierLength);
2909 };
2910 
2911 class PasswordAuthenticatedKeyAgreementDomain : public KeyAgreementAlgorithm
2912 {
2913 public:
2914  virtual ~PasswordAuthenticatedKeyAgreementDomain() {}
2915 
2917  virtual bool ValidateDomainParameters(RandomNumberGenerator &rng) const
2918  {return GetCryptoParameters().Validate(rng, 2);}
2919 
2920  virtual unsigned int GetPasswordVerifierLength(const byte *password, unsigned int passwordLength) const =0;
2921  virtual void GeneratePasswordVerifier(RandomNumberGenerator &rng, const byte *userId, unsigned int userIdLength, const byte *password, unsigned int passwordLength, byte *verifier) const =0;
2922 
2923  enum RoleFlags {CLIENT=1, SERVER=2, INITIATOR=4, RESPONDER=8};
2924 
2925  virtual bool IsValidRole(unsigned int role) =0;
2926  virtual PasswordAuthenticatedKeyAgreementSession * CreateProtocolSession(unsigned int role) const =0;
2927 };
2928 #endif
2929 
2932 {
2933 public:
2934  BERDecodeErr() : InvalidArgument("BER decode error") {}
2935  BERDecodeErr(const std::string &s) : InvalidArgument(s) {}
2936 };
2937 
2943 {
2944 public:
2945  virtual ~ASN1Object() {}
2946 
2950  virtual void BERDecode(BufferedTransformation &bt) =0;
2951 
2955  virtual void DEREncode(BufferedTransformation &bt) const =0;
2956 
2961  virtual void BEREncode(BufferedTransformation &bt) const {DEREncode(bt);}
2962 };
2963 
2964 //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
2965 //typedef PK_SignatureScheme PK_SignatureSystem;
2966 //typedef SimpleKeyAgreementDomain PK_SimpleKeyAgreementDomain;
2967 //typedef AuthenticatedKeyAgreementDomain PK_AuthenticatedKeyAgreementDomain;
2968 //#endif
2969 
2971 
2972 #if CRYPTOPP_MSC_VERSION
2973 # pragma warning(pop)
2974 #endif
2975 
2976 #endif
Base class for all exceptions thrown by the library.
Definition: cryptlib.h:140
Exception thrown when invalid crypto material is detected.
Definition: cryptlib.h:2046
const Algorithm & GetAlgorithm() const
Returns the base class Algorithm.
Definition: cryptlib.h:1174
virtual void Precompute(unsigned int precomputationStorage)
Perform precomputation.
Definition: cryptlib.h:2125
virtual const PublicKey & GetPublicKey() const
Retrieves a reference to a Public Key.
Definition: cryptlib.h:2244
the cipher is performing decryption
Definition: cryptlib.h:108
An invalid argument was detected.
Definition: cryptlib.h:184
void SetKeyWithIV(const byte *key, size_t length, const byte *iv)
Sets or reset the key of this object.
Definition: cryptlib.h:590
static int DecrementPropagation(int propagation)
Decrements the propagation count while clamping at 0.
Definition: cryptlib.h:2029
bool GetThisObject(T &object) const
Get a copy of this object or subobject.
Definition: cryptlib.h:315
bool CanUseRandomIVs() const
Determines if the object can use random IVs.
Definition: cryptlib.h:623
const char * what() const
Retrieves a C-string describing the exception.
Definition: cryptlib.h:168
Interface for message authentication codes.
Definition: cryptlib.h:1111
ErrorType
Error types or categories.
Definition: cryptlib.h:145
NotImplemented(const std::string &s)
Definition: cryptlib.h:208
#define function(a, b, c, d, k, s)
virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const
Save precomputation for later use.
Definition: cryptlib.h:2140
Interface for asymmetric algorithms.
Definition: cryptlib.h:2196
uint8_t byte
Definition: Common.h:57
void GetRequiredParameter(const char *className, const char *name, T &value) const
Retrieves a required name/value pair.
Definition: cryptlib.h:408
virtual ~PK_Signer()
Definition: cryptlib.h:2530
const Algorithm & GetAlgorithm() const
Returns the base class Algorithm.
Definition: cryptlib.h:1114
const std::type_info & m_stored
Definition: cryptlib.h:307
const lword LWORD_MAX
Definition: config.h:246
Interface for public-key encryptors and decryptors.
Definition: cryptlib.h:2293
ByteOrder
Provides the byte ordering.
Definition: cryptlib.h:124
virtual ~NameValuePairs()
Definition: cryptlib.h:282
The IV is set by the object.
Definition: cryptlib.h:606
The operating system reported an error.
Definition: cryptlib.h:219
virtual ~RandomNumberGenerator()
Definition: cryptlib.h:1191
CRYPTOPP_DLL const std::string AAD_CHANNEL
Channel for additional authenticated data.
Definition: cryptlib.cpp:60
Interface for one direction (encryption or decryption) of a stream cipher or block cipher mode with a...
Definition: cryptlib.h:1121
unsigned short word16
Definition: config.h:230
CRYPTOPP_DLL void GetRequiredIntParameter(const char *className, const char *name, int &value) const
Retrieves a required name/value pair.
Definition: cryptlib.h:423
InvalidDataFormat(const std::string &s)
Definition: cryptlib.h:194
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
Definition: cryptlib.h:350
virtual ~PK_Decryptor()
Definition: cryptlib.h:2375
virtual void Load(BufferedTransformation &bt)
Loads a key from a BufferedTransformation.
Definition: cryptlib.h:2109
virtual unsigned int OptimalNumberOfParallelBlocks() const
Determines the number of blocks that can be processed in parallel.
Definition: cryptlib.h:789
size_t ChannelPut(const std::string &channel, byte inByte, bool blocking=true)
Input a byte for processing on a channel.
Definition: cryptlib.h:1864
Exception(ErrorType errorType, const std::string &s)
Construct a new Exception.
Definition: cryptlib.h:165
ErrorType GetErrorType() const
Retrieves the error type for the exception.
Definition: cryptlib.h:174
virtual bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
Definition: cryptlib.h:1150
virtual void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: cryptlib.h:1503
bool operator!=(const DecodingResult &rhs) const
Compare two DecodingResult.
Definition: cryptlib.h:256
#define T(i, x)
Exception thrown when the object is in the wrong state for the operation.
Definition: cryptlib.h:1129
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
ErrorType m_errorType
Definition: cryptlib.h:179
Interface for public-key signers.
Definition: cryptlib.h:2527
virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
Definition: cryptlib.h:2080
Interface for public-key encryptors.
Definition: cryptlib.h:2336
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
Definition: cryptlib.h:373
virtual unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this hash.
Definition: cryptlib.h:988
Converts an enumeration to a type suitable for use as a template parameter.
Definition: cryptlib.h:116
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:104
size_t count
Definition: ExecStats.cpp:37
void BERDecode(BufferedTransformation &bt)
Loads this object from a BufferedTransformation.
Definition: cryptlib.h:2212
Flush(true) was called but it can&#39;t completely flush its buffers.
Definition: cryptlib.h:212
virtual void Save(BufferedTransformation &bt) const
Saves a key to a BufferedTransformation.
Definition: cryptlib.h:2092
Thrown when an unexpected type is encountered.
Definition: cryptlib.h:287
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Private Key.
Definition: cryptlib.h:2256
Interface for asymmetric algorithms using private keys.
Definition: cryptlib.h:2249
void ProcessBlock(byte *inoutBlock) const
Encrypt or decrypt a block in place.
Definition: cryptlib.h:767
virtual bool VerifyTruncatedDigest(const byte *digest, size_t digestLength, const byte *input, size_t length)
Updates the hash with additional input and verifies the hash of the current message.
Definition: cryptlib.h:1080
bool operator==(const DecodingResult &rhs) const
Compare two DecodingResult.
Definition: cryptlib.h:251
virtual bool SupportsPrecomputation() const
Determines whether the object supports precomputation.
Definition: cryptlib.h:2115
const std::string & GetWhat() const
Retrieves a string describing the exception.
Definition: cryptlib.h:170
ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving)
Construct a ValueTypeMismatch.
Definition: cryptlib.h:294
virtual ~BlockTransformation()
Definition: cryptlib.h:737
EnumToType< ByteOrder, LITTLE_ENDIAN_ORDER > LittleEndian
Provides a constant for LittleEndian.
Definition: cryptlib.h:131
BadState(const std::string &name, const char *function, const char *state)
Definition: cryptlib.h:1133
virtual ~StreamTransformation()
Definition: cryptlib.h:826
Library configuration file.
virtual bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
Definition: cryptlib.h:1209
Interface for random number generators.
Definition: cryptlib.h:1188
unsigned int TagSize() const
Provides the tag size of the hash.
Definition: cryptlib.h:975
void ProcessString(byte *inoutString, size_t length)
Encrypt or decrypt a string of bytes.
Definition: cryptlib.h:877
size_t messageLength
Recovered message length if isValidCoding is true, undefined otherwise.
Definition: cryptlib.h:261
virtual ~Exception()
Definition: cryptlib.h:162
ExecStats::duration min
Definition: ExecStats.cpp:35
virtual lword MaxFooterLength() const
Provides the the maximum length of AAD.
Definition: cryptlib.h:1144
Interface for buffered transformations.
Definition: cryptlib.h:1352
InvalidMaterial(const std::string &s)
Definition: cryptlib.h:2049
virtual int GetAutoSignalPropagation() const
Retrieve automatic signal propagation value.
Definition: cryptlib.h:1566
OS_Error(ErrorType errorType, const std::string &s, const std::string &operation, int errorCode)
Definition: cryptlib.h:223
Interface for private keys.
Definition: cryptlib.h:2186
Interface for cloning objects.
Definition: cryptlib.h:482
virtual unsigned int MinIVLength() const
Provides the minimum size of an IV.
Definition: cryptlib.h:650
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Private Key.
Definition: cryptlib.h:2259
virtual ~SimpleKeyAgreementDomain()
Definition: cryptlib.h:2667
const std::type_info & GetRetrievingTypeInfo() const
Provides the retrieveing type.
Definition: cryptlib.h:304
virtual bool CanModifyInput() const
Determines whether input can be modified by the callee.
Definition: cryptlib.h:1417
virtual ~PK_SignatureScheme()
Definition: cryptlib.h:2454
virtual ~OS_Error()
Definition: cryptlib.h:222
Data integerity check, such as CRC or MAC, failed.
Definition: cryptlib.h:153
#define DOCUMENTED_NAMESPACE_END
Definition: config.h:208
byte order is little-endian
Definition: cryptlib.h:126
bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
Definition: asn.h:558
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1095
CRYPTOPP_DLL RandomNumberGenerator &CRYPTOPP_API NullRNG()
Random Number Generator that does not produce random numbers.
Definition: cryptlib.cpp:402
const Algorithm & GetAlgorithm() const
Returns the base class Algorithm.
Definition: cryptlib.h:1098
void SetWhat(const std::string &s)
Sets the error string for the exception.
Definition: cryptlib.h:172
Interface for objects that can be waited on.
Definition: cryptlib.h:1295
the cipher is performing encryption
Definition: cryptlib.h:106
virtual unsigned int GetOptimalBlockSizeUsed() const
Provides the number of bytes used in the current block when processing at optimal block size...
Definition: cryptlib.h:846
size_t PutModifiable(byte *inString, size_t length, bool blocking=true)
Input multiple bytes that may be modified by callee.
Definition: cryptlib.h:1426
size_t ChannelPut(const std::string &channel, const byte *inString, size_t length, bool blocking=true)
Input a byte buffer for processing on a channel.
Definition: cryptlib.h:1874
bool MessageEnd(int propagation=-1, bool blocking=true)
Signals the end of messages to the object.
Definition: cryptlib.h:1434
const std::string & GetOperation() const
Retrieve the operating system API that reported the error.
Definition: cryptlib.h:227
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2664
virtual void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
Definition: cryptlib.h:1176
Exception thrown when a filter does not support named channels.
Definition: cryptlib.h:1852
Returns a decoding results.
Definition: cryptlib.h:238
virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation)
Retrieve previously saved precomputation.
Definition: cryptlib.h:2134
virtual ~PublicKeyAlgorithm()
Definition: cryptlib.h:2226
Exception thrown when trying to encrypt plaintext of invalid length.
Definition: cryptlib.h:2340
bool CanUsePredictableIVs() const
Determines if the object can use random but possibly predictable IVs.
Definition: cryptlib.h:628
DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs &parameters=g_nullNameValuePairs) const
Decrypt a fixed size ciphertext.
Definition: cryptlib.h:2417
Input data was received that did not conform to expected format.
Definition: cryptlib.h:155
const char * source
Definition: rpcconsole.cpp:60
bool GetValue(const char *name, T &value) const
Get a named value.
Definition: cryptlib.h:337
lword TransferTo(BufferedTransformation &target, lword transferMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL)
move transferMax bytes of the buffered output to target as input
Definition: cryptlib.h:1654
Interface for public-key decryptors.
Definition: cryptlib.h:2372
bool GetThisPointer(T *&ptr) const
Get a pointer to this object.
Definition: cryptlib.h:324
A method was called which was not implemented.
Definition: cryptlib.h:205
Exception throw when the private or public key is too short to sign or verify.
Definition: cryptlib.h:2448
size_t Put(byte inByte, bool blocking=true)
Input a byte for processing.
Definition: cryptlib.h:1376
virtual ~PK_CryptoSystem()
Definition: cryptlib.h:2296
virtual unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
Definition: cryptlib.h:842
virtual size_t FixedCiphertextLength() const
Provides the fixed ciphertext length, if one exists.
Definition: cryptlib.h:2319
virtual void Restart()
Restart the hash.
Definition: cryptlib.h:965
static const std::string & NULL_CHANNEL
Definition: cryptlib.h:1356
void ProcessBlock(const byte *inBlock, byte *outBlock) const
Encrypt or decrypt a block.
Definition: cryptlib.h:758
bool IsResynchronizable() const
Determines if the object can be resynchronized.
Definition: cryptlib.h:619
const CryptoMaterial & GetMaterial() const
Retrieves a reference to Crypto Parameters.
Definition: cryptlib.h:2280
const std::type_info & GetStoredTypeInfo() const
Provides the stored type.
Definition: cryptlib.h:300
Interface for encoding and decoding ASN1 objects.
Definition: cryptlib.h:2942
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:382
StreamTransformation & Ref()
Provides a reference to this object.
Definition: cryptlib.h:831
virtual unsigned int MandatoryBlockSize() const
Provides the mandatory block size of the cipher.
Definition: cryptlib.h:835
const char * name
Definition: rest.cpp:36
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Definition: cryptlib.h:662
virtual size_t MaxSignatureLength(size_t recoverablePartLength=0) const
Provides the maximum signature length produced given the length of the recoverable message part...
Definition: cryptlib.h:2466
ExecStats::duration max
Definition: ExecStats.cpp:36
virtual unsigned int NumberOfMessagesInThisSeries() const
Provides the number of messages in a series.
Definition: cryptlib.h:1778
void ProcessString(byte *outString, const byte *inString, size_t length)
Encrypt or decrypt a string of bytes.
Definition: cryptlib.h:885
size_t ChannelPutModifiable(const std::string &channel, byte *inString, size_t length, bool blocking=true)
Input multiple bytes that may be modified by callee on a channel.
Definition: cryptlib.h:1884
DecodingResult()
Constructs a DecodingResult.
Definition: cryptlib.h:242
BufferedTransformation()
Construct a BufferedTransformation.
Definition: cryptlib.h:1361
virtual ~CryptoMaterial()
Definition: cryptlib.h:2052
Exception thrown when a filter does not recognize a named channel.
Definition: cryptlib.h:1855
bool CanUseStructuredIVs() const
Determines if the object can use structured IVs.
Definition: cryptlib.h:634
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1103
bool Validate(int, bool, const char *)
Definition: test.cpp:884
virtual ~ASN1Object()
Definition: cryptlib.h:2945
lword CopyRangeTo(BufferedTransformation &target, lword position, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const
Copy bytes from this object using an index to another BufferedTransformation.
Definition: cryptlib.h:1692
Multiple precision integer with arithmetic operations.
Definition: integer.h:43
DecodingResult(size_t len)
Constructs a DecodingResult.
Definition: cryptlib.h:246
virtual ~GeneratableCryptoMaterial()
Definition: cryptlib.h:2158
virtual ~PrivateKeyAlgorithm()
Definition: cryptlib.h:2252
Exception throw when the private or public key has a length that can&#39;t be used.
Definition: cryptlib.h:2438
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:524
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: cryptlib.h:518
virtual BufferedTransformation * AttachedTransformation()
Returns the object immediately attached to this object.
Definition: cryptlib.h:2001
#define CRYPTOPP_API
Definition: config.h:705
HashTransformation & Ref()
Provides a reference to this object.
Definition: cryptlib.h:938
virtual const CryptoParameters & GetCryptoParameters() const
Retrieves a reference to Crypto Parameters.
Definition: cryptlib.h:2287
CannotFlush(const std::string &s)
Definition: cryptlib.h:215
virtual void SetAutoSignalPropagation(int propagation)
Set propagation of automatically generated and transferred signals.
Definition: cryptlib.h:1560
Interface for asymmetric algorithms using public keys.
Definition: cryptlib.h:2223
virtual size_t FixedMaxPlaintextLength() const
Provides the maximum plaintext length given a fixed ciphertext length.
Definition: cryptlib.h:2326
const CryptoMaterial & GetMaterial() const
Retrieves a reference to a Public Key.
Definition: cryptlib.h:2236
NoChannelSupport(const std::string &name)
Definition: cryptlib.h:1853
virtual unsigned int BlockSize() const
Provides the block size of the compression function.
Definition: cryptlib.h:981
CRYPTOPP_DLL const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Definition: cryptlib.cpp:76
void AssertValidKeyLength(size_t length) const
Validates the key length.
Definition: cryptlib.h:725
unsigned int DigestSize() const
Definition: cryptlib.h:2514
virtual ~AuthenticatedKeyAgreementDomain()
Definition: cryptlib.h:2730
virtual const BufferedTransformation * AttachedTransformation() const
Returns the object immediately attached to this object.
Definition: cryptlib.h:2007
Interface for public-key signers and verifiers.
Definition: cryptlib.h:2431
#define DOCUMENTED_NAMESPACE_BEGIN(x)
Definition: config.h:207
int GetErrorCode() const
Retrieve the error code returned by the operating system.
Definition: cryptlib.h:229
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:823
BadState(const std::string &name, const char *message)
Definition: cryptlib.h:1132
virtual const PrivateKey & GetPrivateKey() const
Retrieves a reference to a Private Key.
Definition: cryptlib.h:2266
byte order is big-endian
Definition: cryptlib.h:128
virtual bool Verify(const byte *digest)
Verifies the hash of the current message.
Definition: cryptlib.h:1015
InvalidKeyLength(const std::string &message)
Definition: cryptlib.h:2441
#define CRYPTOPP_ASSERT(exp)
Definition: trap.h:92
CRYPTOPP_DLL const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
Definition: cryptlib.cpp:59
virtual void CalculateTruncatedDigest(byte *digest, size_t digestSize, const byte *input, size_t length)
Updates the hash with additional input and computes the hash of the current message.
Definition: cryptlib.h:1051
HashTransformation HashFunction
Definition: cryptlib.h:1091
int m_errorCode
Definition: cryptlib.h:233
virtual bool IsolatedMessageSeriesEnd(bool blocking)
Marks the end of a series of messages, without signal propagation.
Definition: cryptlib.h:1517
const unsigned long INFINITE_TIME
Represents infinite time.
Definition: cryptlib.h:111
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
virtual unsigned int MaxIVLength() const
Provides the maximum size of an IV.
Definition: cryptlib.h:655
Interface for all crypto algorithms.
Definition: cryptlib.h:497
size_t Put(const byte *inString, size_t length, bool blocking=true)
Input a byte buffer for processing.
Definition: cryptlib.h:1385
unsigned int DefaultIVLength() const
Provides the default size of an IV.
Definition: cryptlib.h:645
virtual bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
Definition: cryptlib.h:553
virtual bool IsPermutation() const
returns true if this is a permutation (i.e. there is an inverse transformation)
Definition: cryptlib.h:779
virtual void BEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
Definition: cryptlib.h:2961
Interface for accumulating messages to be signed or verified.
Definition: cryptlib.h:2510
virtual Clonable * Clone() const
Copies this object.
Definition: cryptlib.h:492
virtual void Detach(BufferedTransformation *newAttachment=0)
Delete the current attachment chain and attach a new one.
Definition: cryptlib.h:2016
A decryption filter encountered invalid ciphertext.
Definition: cryptlib.h:198
Interface for key agreement algorithms.
Definition: cryptlib.h:2270
Exception thrown by objects that have not implemented nonblocking input processing.
Definition: cryptlib.h:1470
virtual unsigned int NumberOfMessageSeries() const
Provides the number of messages in a series.
Definition: cryptlib.h:1781
virtual void CalculateDigest(byte *digest, const byte *input, size_t length)
Updates the hash with additional input and computes the hash of the current message.
Definition: cryptlib.h:1003
virtual void Seek(lword pos)
Seek to an absolute position.
Definition: cryptlib.h:903
virtual ~AuthenticatedSymmetricCipher()
Definition: cryptlib.h:1124
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:598
CryptoMaterial & AccessMaterial()
Retrieves a reference to a Public Key.
Definition: cryptlib.h:2232
void TransferAllTo(BufferedTransformation &target, const std::string &channel=DEFAULT_CHANNEL)
Transfer all bytes from this object to another BufferedTransformation.
Definition: cryptlib.h:1763
Interface for public-key signature verifiers.
Definition: cryptlib.h:2592
BlockingInputOnly(const std::string &s)
Definition: cryptlib.h:1471
virtual ~SimpleKeyingInterface()
Definition: cryptlib.h:527
virtual byte * CreateUpdateSpace(size_t &size)
Request space which can be written into by the caller.
Definition: cryptlib.h:953
uint8_t const size_t const size
Definition: sha3.h:20
void Shuffle(IT begin, IT end)
Randomly shuffle the specified array.
Definition: cryptlib.h:1264
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
virtual bool SignatureUpfront() const
Determines whether the signature must be input before the message.
Definition: cryptlib.h:2497
Debugging and diagnostic assertions.
InvalidArgument(const std::string &s)
Definition: cryptlib.h:187
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:930
Interface for crypto material, such as public and private keys, and crypto parameters.
Definition: cryptlib.h:2042
virtual byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: cryptlib.h:1411
virtual void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &params=g_nullNameValuePairs)
Generate a random key or crypto parameters.
Definition: cryptlib.h:2166
void DEREncode(BufferedTransformation &bt) const
Saves this object to a BufferedTransformation.
Definition: cryptlib.h:2218
CryptoMaterial & AccessMaterial()
Retrieves a reference to Crypto Parameters.
Definition: cryptlib.h:2277
virtual ~HashTransformation()
Definition: cryptlib.h:933
An invalid argument was detected.
Definition: cryptlib.h:149
virtual ~Algorithm()
Definition: cryptlib.h:500
Interface for generatable crypto material, such as private keys and crypto parameters.
Definition: cryptlib.h:2155
size_t PutMessageEnd(const byte *inString, size_t length, int propagation=-1, bool blocking=true)
Input multiple bytes for processing and signal the end of a message.
Definition: cryptlib.h:1447
#define NAMESPACE_END
Definition: config.h:201
Interface for crypto prameters.
Definition: cryptlib.h:2191
CRYPTOPP_DLL BufferedTransformation & TheBitBucket()
An input discarding BufferedTransformation.
Definition: cryptlib.cpp:79
BERDecodeErr(const std::string &s)
Definition: cryptlib.h:2935
std::vector< char * > parameters
Definition: boostTest.cpp:46
bool isValidCoding
Flag to indicate the decoding is valid.
Definition: cryptlib.h:259
BufferedTransformation & Ref()
Provides a reference to this object.
Definition: cryptlib.h:1366
virtual ~Clonable()
Definition: cryptlib.h:485
BufferedTransformation received a Flush(true) signal but can&#39;t flush buffers.
Definition: cryptlib.h:151
void SetErrorType(ErrorType errorType)
Sets the error type for the exceptions.
Definition: cryptlib.h:176
CipherDir GetCipherDirection() const
Provides the direction of the cipher.
Definition: cryptlib.h:817
Interface for public keys.
Definition: cryptlib.h:2181
lword CopyTo(BufferedTransformation &target, lword copyMax=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL) const
copy copyMax bytes of the buffered output to target as input
Definition: cryptlib.h:1679
CRYPTOPP_DLL std::string GetValueNames() const
Get a list of value names that can be retrieved.
Definition: cryptlib.h:362
word64 lword
Definition: config.h:245
Interface for the data processing part of block ciphers.
Definition: cryptlib.h:734
FlagsForAdvancedProcessBlocks
Bit flags that control AdvancedProcessBlocks() behavior.
Definition: cryptlib.h:792
The IV must be random and unpredictable.
Definition: cryptlib.h:604
InvalidChannelName(const std::string &name, const std::string &channel)
Definition: cryptlib.h:1856
Interface for domains of authenticated key agreement protocols.
Definition: cryptlib.h:2727
std::string m_operation
Definition: cryptlib.h:232
virtual bool GetNextMessageSeries()
Retrieve the next message in a series.
Definition: cryptlib.h:1775
const Algorithm & GetAlgorithm() const
Returns the base class Algorithm.
Definition: cryptlib.h:1106
void TruncatedFinal(byte *digest, size_t digestSize)
Definition: cryptlib.h:2518
#define CRYPTOPP_DLL
Definition: config.h:704
A method was called which was not implemented.
Definition: cryptlib.h:147
unsigned int TransferMessagesTo(BufferedTransformation &target, unsigned int count=UINT_MAX, const std::string &channel=DEFAULT_CHANNEL)
Transfer messages from this object to another BufferedTransformation.
Definition: cryptlib.h:1740
byte ProcessByte(byte input)
Encrypt or decrypt a byte.
Definition: cryptlib.h:891
const std::type_info & m_retrieving
Definition: cryptlib.h:308
unsigned int word32
Definition: config.h:231
Error reading from input device or writing to output device.
Definition: cryptlib.h:157
size_t ChannelPutMessageEnd(const std::string &channel, const byte *inString, size_t length, int propagation=-1, bool blocking=true)
Input multiple bytes for processing and signal the end of a message.
Definition: cryptlib.h:1925
virtual size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee.
Definition: cryptlib.h:1464
virtual void Final(byte *digest)
Computes the hash of the current message.
Definition: cryptlib.h:960
virtual ~KeyAgreementAlgorithm()
Definition: cryptlib.h:2273
Input data was received that did not conform to expected format.
Definition: cryptlib.h:191
std::string m_what
Definition: cryptlib.h:180
static ENUM_TYPE ToEnum()
Definition: cryptlib.h:118
virtual ~BufferedTransformation()
Definition: cryptlib.h:1358
virtual unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: cryptlib.h:640
static CRYPTOPP_DLL void CRYPTOPP_API ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)
Ensures an expected name and type is present.
Definition: cryptlib.h:394
virtual unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: cryptlib.h:871
EnumToType< ByteOrder, BIG_ENDIAN_ORDER > BigEndian
Provides a constant for BigEndian.
Definition: cryptlib.h:133
virtual bool VerifyDigest(const byte *digest, const byte *input, size_t length)
Updates the hash with additional input and verifies the hash of the current message.
Definition: cryptlib.h:1031
Definition: panama.cpp:423
virtual void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
Definition: cryptlib.h:1201
InvalidCiphertext(const std::string &s)
Definition: cryptlib.h:201
virtual ~PK_Verifier()
Definition: cryptlib.h:2595
virtual ~AsymmetricAlgorithm()
Definition: cryptlib.h:2199
bool ChannelMessageEnd(const std::string &channel, int propagation=-1, bool blocking=true)
Signal the end of a message.
Definition: cryptlib.h:1913
Interface for retrieving values given their names.
Definition: cryptlib.h:279
Exception thrown when an ASN.1 BER decoing error is encountered.
Definition: cryptlib.h:2931
The IV must be random and possibly predictable.
Definition: cryptlib.h:602
void DoQuickSanityCheck() const
Perform a quick sanity check.
Definition: cryptlib.h:2145
virtual ~Waitable()
Definition: cryptlib.h:1298