Fabcoin Core  0.16.2
P2P Digital Currency
filters.h
Go to the documentation of this file.
1 // filters.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_FILTERS_H
7 #define CRYPTOPP_FILTERS_H
8 
9 #include "cryptlib.h"
10 
11 #if CRYPTOPP_MSC_VERSION
12 # pragma warning(push)
13 # pragma warning(disable: 4127 4189 4514)
14 #endif
15 
16 #include "cryptlib.h"
17 #include "simple.h"
18 #include "secblock.h"
19 #include "misc.h"
20 #include "smartptr.h"
21 #include "queue.h"
22 #include "algparam.h"
23 #include "stdcpp.h"
24 
26 
37 {
38 public:
39  virtual ~Filter() {}
40 
42 
43 
47  Filter(BufferedTransformation *attachment = NULL);
48 
52  bool Attachable() {return true;}
53 
56  BufferedTransformation *AttachedTransformation();
57 
60  const BufferedTransformation *AttachedTransformation() const;
61 
66  void Detach(BufferedTransformation *newAttachment = NULL);
67 
69 
70  // See the documentation for BufferedTransformation in cryptlib.h
71  size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
72  size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
73 
74  // See the documentation for BufferedTransformation in cryptlib.h
75  void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1);
76  bool Flush(bool hardFlush, int propagation=-1, bool blocking=true);
77  bool MessageSeriesEnd(int propagation=-1, bool blocking=true);
78 
79 protected:
80  virtual BufferedTransformation * NewDefaultAttachment() const;
81  void Insert(Filter *nextFilter); // insert filter after this one
82 
83  virtual bool ShouldPropagateMessageEnd() const {return true;}
84  virtual bool ShouldPropagateMessageSeriesEnd() const {return true;}
85 
86  void PropagateInitialize(const NameValuePairs &parameters, int propagation);
87 
96  size_t Output(int outputSite, const byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
97 
106  size_t OutputModifiable(int outputSite, byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
107 
116  bool OutputMessageEnd(int outputSite, int propagation, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
117 
135  bool OutputFlush(int outputSite, bool hardFlush, int propagation, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
136 
148  bool OutputMessageSeriesEnd(int outputSite, int propagation, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
149 
150 private:
152 
153 protected:
156 };
157 
161 {
163 
177  byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize)
178  {
179  CRYPTOPP_ASSERT(desiredSize >= minSize && bufferSize >= minSize);
180  if (m_tempSpace.size() < minSize)
181  {
182  byte *result = target.ChannelCreatePutSpace(channel, desiredSize);
183  if (desiredSize >= minSize)
184  {
185  bufferSize = desiredSize;
186  return result;
187  }
188  m_tempSpace.New(bufferSize);
189  }
190 
191  bufferSize = m_tempSpace.size();
192  return m_tempSpace.begin();
193  }
194 
200  byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize)
201  {return HelpCreatePutSpace(target, channel, minSize, minSize, minSize);}
202 
209  byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t bufferSize)
210  {return HelpCreatePutSpace(target, channel, minSize, minSize, bufferSize);}
211 
214 };
215 
220 class CRYPTOPP_DLL MeterFilter : public Bufferless<Filter>
221 {
222 public:
223  virtual ~MeterFilter() {}
224 
230  MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true)
231  : m_transparent(transparent), m_currentMessageBytes(0), m_totalBytes(0)
232  , m_currentSeriesMessages(0), m_totalMessages(0), m_totalMessageSeries(0)
233  , m_begin(NULL), m_length(0) {Detach(attachment); ResetMeter();}
234 
237  void SetTransparent(bool transparent) {m_transparent = transparent;}
238 
246  void AddRangeToSkip(unsigned int message, lword position, lword size, bool sortNow = true);
247 
251  void ResetMeter();
252 
254  {CRYPTOPP_UNUSED(parameters); ResetMeter();}
255 
256  lword GetCurrentMessageBytes() const {return m_currentMessageBytes;}
257  lword GetTotalBytes() const {return m_totalBytes;}
258  unsigned int GetCurrentSeriesMessages() const {return m_currentSeriesMessages;}
259  unsigned int GetTotalMessages() const {return m_totalMessages;}
260  unsigned int GetTotalMessageSeries() const {return m_totalMessageSeries;}
261 
262  byte * CreatePutSpace(size_t &size)
263  {return AttachedTransformation()->CreatePutSpace(size);}
264  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
265  size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking);
266  bool IsolatedMessageSeriesEnd(bool blocking);
267 
268 private:
269  size_t PutMaybeModifiable(byte *inString, size_t length, int messageEnd, bool blocking, bool modifiable);
270  bool ShouldPropagateMessageEnd() const {return m_transparent;}
271  bool ShouldPropagateMessageSeriesEnd() const {return m_transparent;}
272 
274  {
275  inline bool operator<(const MessageRange &b) const // BCB2006 workaround: this has to be a member function
276  {return message < b.message || (message == b.message && position < b.position);}
277  unsigned int message; lword position; lword size;
278  };
279 
281  lword m_currentMessageBytes, m_totalBytes;
282  unsigned int m_currentSeriesMessages, m_totalMessages, m_totalMessageSeries;
283  std::deque<MessageRange> m_rangesToSkip;
285  size_t m_length;
286 };
287 
292 {
293 public:
296  TransparentFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, true) {}
297 };
298 
303 {
304 public:
307  OpaqueFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, false) {}
308 };
309 
318 {
319 public:
321 
325 
332  FilterWithBufferedInput(size_t firstSize, size_t blockSize, size_t lastSize, BufferedTransformation *attachment);
333 
334  void IsolatedInitialize(const NameValuePairs &parameters);
335  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
336  {
337  return PutMaybeModifiable(const_cast<byte *>(inString), length, messageEnd, blocking, false);
338  }
339  size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
340  {
341  return PutMaybeModifiable(inString, length, messageEnd, blocking, true);
342  }
343 
349  bool IsolatedFlush(bool hardFlush, bool blocking);
350 
354  void ForceNextPut();
355 
356 protected:
357  virtual bool DidFirstPut() const {return m_firstInputDone;}
358  virtual size_t GetFirstPutSize() const {return m_firstSize;}
359  virtual size_t GetBlockPutSize() const {return m_blockSize;}
360  virtual size_t GetLastPutSize() const {return m_lastSize;}
361 
362  virtual void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize)
363  {CRYPTOPP_UNUSED(parameters); CRYPTOPP_UNUSED(firstSize); CRYPTOPP_UNUSED(blockSize); CRYPTOPP_UNUSED(lastSize); InitializeDerived(parameters);}
364  virtual void InitializeDerived(const NameValuePairs &parameters)
365  {CRYPTOPP_UNUSED(parameters);}
366  // FirstPut() is called if (firstSize != 0 and totalLength >= firstSize)
367  // or (firstSize == 0 and (totalLength > 0 or a MessageEnd() is received)).
368  // inString is m_firstSize in length.
369  virtual void FirstPut(const byte *inString) =0;
370  // NextPut() is called if totalLength >= firstSize+blockSize+lastSize
371  virtual void NextPutSingle(const byte *inString)
372  {CRYPTOPP_UNUSED(inString); CRYPTOPP_ASSERT(false);}
373  // Same as NextPut() except length can be a multiple of blockSize
374  // Either NextPut() or NextPutMultiple() must be overridden
375  virtual void NextPutMultiple(const byte *inString, size_t length);
376  // Same as NextPutMultiple(), but inString can be modified
377  virtual void NextPutModifiable(byte *inString, size_t length)
378  {NextPutMultiple(inString, length);}
389  virtual void LastPut(const byte *inString, size_t length) =0;
390  virtual void FlushDerived() {}
391 
392 protected:
393  size_t PutMaybeModifiable(byte *begin, size_t length, int messageEnd, bool blocking, bool modifiable);
394  void NextPutMaybeModifiable(byte *inString, size_t length, bool modifiable)
395  {
396  if (modifiable) NextPutModifiable(inString, length);
397  else NextPutMultiple(inString, length);
398  }
399 
400  // This function should no longer be used, put this here to cause a compiler error
401  // if someone tries to override NextPut().
402  virtual int NextPut(const byte *inString, size_t length)
403  {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(false); return 0;}
404 
406  {
407  public:
408  void ResetQueue(size_t blockSize, size_t maxBlocks);
409  byte *GetBlock();
410  byte *GetContigousBlocks(size_t &numberOfBytes);
411  size_t GetAll(byte *outString);
412  void Put(const byte *inString, size_t length);
413  size_t CurrentSize() const {return m_size;}
414  size_t MaxSize() const {return m_buffer.size();}
415 
416  private:
418  size_t m_blockSize, m_maxBlocks, m_size;
420  };
421 
422  size_t m_firstSize, m_blockSize, m_lastSize;
425 };
426 
433 {
434 public:
436 
439  FilterWithInputQueue(BufferedTransformation *attachment=NULL) : Filter(attachment) {}
440 
441  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
442  {
443  if (!blocking)
444  throw BlockingInputOnly("FilterWithInputQueue");
445 
446  m_inQueue.Put(inString, length);
447  if (messageEnd)
448  {
449  IsolatedMessageEnd(blocking);
450  Output(0, NULL, 0, messageEnd, blocking);
451  }
452  return 0;
453  }
454 
455 protected:
456  virtual bool IsolatedMessageEnd(bool blocking) =0;
458  {CRYPTOPP_UNUSED(parameters); m_inQueue.Clear();}
459 
461 };
462 
466 {
484  DEFAULT_PADDING
485  };
486 };
487 
492 {
493 public:
495 
501  StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment = NULL, BlockPaddingScheme padding = DEFAULT_PADDING, bool allowAuthenticatedSymmetricCipher = false);
502 
503  std::string AlgorithmName() const {return m_cipher.AlgorithmName();}
504 
505 protected:
506  void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);
507  void FirstPut(const byte *inString);
508  void NextPutMultiple(const byte *inString, size_t length);
509  void NextPutModifiable(byte *inString, size_t length);
510  void LastPut(const byte *inString, size_t length);
511 
512  static size_t LastBlockSize(StreamTransformation &c, BlockPaddingScheme padding);
513 
515  BlockPaddingScheme m_padding;
516  unsigned int m_optimalBufferSize;
517 };
518 
522 {
523 public:
524  virtual ~HashFilter() {}
525 
533  HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL);
534 
535  std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}
536  void IsolatedInitialize(const NameValuePairs &parameters);
537  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
538  byte * CreatePutSpace(size_t &size) {return m_hashModule.CreateUpdateSpace(size);}
539 
540 private:
543  unsigned int m_digestSize;
545  std::string m_messagePutChannel, m_hashPutChannel;
546 };
547 
551 {
552 public:
554 
558  {
559  public:
561  : Exception(DATA_INTEGRITY_CHECK_FAILED, "HashVerificationFilter: message hash or MAC not valid") {}
562  };
563 
567  enum Flags {
569  HASH_AT_END=0,
571  HASH_AT_BEGIN=1,
573  PUT_MESSAGE=2,
575  PUT_HASH=4,
577  PUT_RESULT=8,
581  DEFAULT_FLAGS = HASH_AT_BEGIN | PUT_RESULT
582  };
583 
590  HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1);
591 
592  std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}
593  bool GetLastResult() const {return m_verified;}
594 
595 protected:
596  void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);
597  void FirstPut(const byte *inString);
598  void NextPutMultiple(const byte *inString, size_t length);
599  void LastPut(const byte *inString, size_t length);
600 
601 private:
603 
606  unsigned int m_digestSize;
609 };
610 
618 {
619 public:
621 
631  AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING);
632 
633  void IsolatedInitialize(const NameValuePairs &parameters);
634  byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);
635  size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking);
636 
647  void LastPut(const byte *inString, size_t length);
648 
649 protected:
651 };
652 
660 {
661 public:
665  enum Flags {
667  MAC_AT_END=0,
669  MAC_AT_BEGIN=1,
673  DEFAULT_FLAGS = THROW_EXCEPTION
674  };
675 
677 
687  AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING);
688 
689  std::string AlgorithmName() const {return m_hashVerifier.AlgorithmName();}
690  byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);
691  size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking);
692  bool GetLastResult() const {return m_hashVerifier.GetLastResult();}
693 
694 protected:
695  void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);
696  void FirstPut(const byte *inString);
697  void NextPutMultiple(const byte *inString, size_t length);
698 
709  void LastPut(const byte *inString, size_t length);
710 
713 };
714 
717 class CRYPTOPP_DLL SignerFilter : public Unflushable<Filter>
718 {
719 public:
720  virtual ~SignerFilter() {}
721 
727  SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false)
728  : m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {Detach(attachment);}
729 
730  std::string AlgorithmName() const {return m_signer.AlgorithmName();}
731 
732  void IsolatedInitialize(const NameValuePairs &parameters);
733  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
734 
735 private:
741 };
742 
746 {
747 public:
750  {
751  public:
753  : Exception(DATA_INTEGRITY_CHECK_FAILED, "VerifierFilter: digital signature not valid") {}
754  };
755 
759  enum Flags {
761  SIGNATURE_AT_END=0,
763  SIGNATURE_AT_BEGIN=1,
765  PUT_MESSAGE=2,
767  PUT_SIGNATURE=4,
769  PUT_RESULT=8,
773  DEFAULT_FLAGS = SIGNATURE_AT_BEGIN | PUT_RESULT
774  };
775 
777 
782  SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS);
783 
784  std::string AlgorithmName() const {return m_verifier.AlgorithmName();}
785 
788  bool GetLastResult() const {return m_verified;}
789 
790 protected:
791  void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);
792  void FirstPut(const byte *inString);
793  void NextPutMultiple(const byte *inString, size_t length);
794  void LastPut(const byte *inString, size_t length);
795 
796 private:
802 };
803 
804 typedef SignatureVerificationFilter VerifierFilter; // for backwards compatibility
805 
809 {
810 public:
813  enum Behavior
814  {
816  DATA_ONLY = 0x00,
818  PASS_SIGNALS = 0x01,
820  PASS_WAIT_OBJECTS = 0x02,
823  PASS_EVERYTHING = PASS_SIGNALS | PASS_WAIT_OBJECTS
824  };
825 
826  virtual ~Redirector() {}
827 
829  Redirector() : m_target(NULL), m_behavior(PASS_EVERYTHING) {}
830 
834  Redirector(BufferedTransformation &target, Behavior behavior=PASS_EVERYTHING)
835  : m_target(&target), m_behavior(behavior) {}
836 
839  void Redirect(BufferedTransformation &target) {m_target = &target;}
841  void StopRedirection() {m_target = NULL;}
842 
843  Behavior GetBehavior() {return (Behavior) m_behavior;}
844  void SetBehavior(Behavior behavior) {m_behavior=behavior;}
845  bool GetPassSignals() const {return (m_behavior & PASS_SIGNALS) != 0;}
846  void SetPassSignals(bool pass) { if (pass) m_behavior |= PASS_SIGNALS; else m_behavior &= ~(word32) PASS_SIGNALS; }
847  bool GetPassWaitObjects() const {return (m_behavior & PASS_WAIT_OBJECTS) != 0;}
848  void SetPassWaitObjects(bool pass) { if (pass) m_behavior |= PASS_WAIT_OBJECTS; else m_behavior &= ~(word32) PASS_WAIT_OBJECTS; }
849 
850  bool CanModifyInput() const
851  {return m_target ? m_target->CanModifyInput() : false;}
852 
853  void Initialize(const NameValuePairs &parameters, int propagation);
855  {
856  if (m_target)
857  return m_target->CreatePutSpace(size);
858  else
859  {
860  size = 0;
861  return NULL;
862  }
863  }
864  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
865  {return m_target ? m_target->Put2(inString, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}
866  bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
867  {return m_target && GetPassSignals() ? m_target->Flush(hardFlush, propagation, blocking) : false;}
868  bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
869  {return m_target && GetPassSignals() ? m_target->MessageSeriesEnd(propagation, blocking) : false;}
870 
871  byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
872  {
873  if (m_target)
874  return m_target->ChannelCreatePutSpace(channel, size);
875  else
876  {
877  size = 0;
878  return NULL;
879  }
880  }
881  size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
882  {return m_target ? m_target->ChannelPut2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}
883  size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
884  {return m_target ? m_target->ChannelPutModifiable2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}
885  bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)
886  {return m_target && GetPassSignals() ? m_target->ChannelFlush(channel, completeFlush, propagation, blocking) : false;}
887  bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)
888  {return m_target && GetPassSignals() ? m_target->ChannelMessageSeriesEnd(channel, propagation, blocking) : false;}
889 
890  unsigned int GetMaxWaitObjectCount() const
891  { return m_target && GetPassWaitObjects() ? m_target->GetMaxWaitObjectCount() : 0; }
892  void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack)
893  { if (m_target && GetPassWaitObjects()) m_target->GetWaitObjects(container, callStack); }
894 
895 private:
898 };
899 
904 {
905 public:
906  virtual ~OutputProxy() {}
907 
911  OutputProxy(BufferedTransformation &owner, bool passSignal) : m_owner(owner), m_passSignal(passSignal) {}
912 
915  bool GetPassSignal() const {return m_passSignal;}
918  void SetPassSignal(bool passSignal) {m_passSignal = passSignal;}
919 
921  {return m_owner.AttachedTransformation()->CreatePutSpace(size);}
922  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
923  {return m_owner.AttachedTransformation()->Put2(inString, length, m_passSignal ? messageEnd : 0, blocking);}
924  size_t PutModifiable2(byte *begin, size_t length, int messageEnd, bool blocking)
925  {return m_owner.AttachedTransformation()->PutModifiable2(begin, length, m_passSignal ? messageEnd : 0, blocking);}
926  void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1)
927  {if (m_passSignal) m_owner.AttachedTransformation()->Initialize(parameters, propagation);}
928  bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
929  {return m_passSignal ? m_owner.AttachedTransformation()->Flush(hardFlush, propagation, blocking) : false;}
930  bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
931  {return m_passSignal ? m_owner.AttachedTransformation()->MessageSeriesEnd(propagation, blocking) : false;}
932 
933  byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
934  {return m_owner.AttachedTransformation()->ChannelCreatePutSpace(channel, size);}
935  size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
936  {return m_owner.AttachedTransformation()->ChannelPut2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);}
937  size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
938  {return m_owner.AttachedTransformation()->ChannelPutModifiable2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);}
939  bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)
940  {return m_passSignal ? m_owner.AttachedTransformation()->ChannelFlush(channel, completeFlush, propagation, blocking) : false;}
941  bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)
942  {return m_passSignal ? m_owner.AttachedTransformation()->ChannelMessageSeriesEnd(channel, propagation, blocking) : false;}
943 
944 private:
947 };
948 
952 {
953 public:
954  virtual ~ProxyFilter() {}
955 
961  ProxyFilter(BufferedTransformation *filter, size_t firstSize, size_t lastSize, BufferedTransformation *attachment);
962 
963  bool IsolatedFlush(bool hardFlush, bool blocking);
964 
967  void SetFilter(Filter *filter);
968  void NextPutMultiple(const byte *s, size_t len);
969  void NextPutModifiable(byte *inString, size_t length);
970 
971 protected:
973 };
974 
978 {
979 public:
984  : ProxyFilter(filter, 0, 0, attachment) {}
985 
986  void FirstPut(const byte * inString)
987  {CRYPTOPP_UNUSED(inString);}
988 
999  void LastPut(const byte *inString, size_t length)
1000  {CRYPTOPP_UNUSED(inString), CRYPTOPP_UNUSED(length); m_filter->MessageEnd();}
1001 };
1002 
1008 {
1009 public:
1015  : SimpleProxyFilter(encryptor.CreateEncryptionFilter(rng), attachment) {}
1016 };
1017 
1023 {
1024 public:
1030  : SimpleProxyFilter(decryptor.CreateDecryptionFilter(rng), attachment) {}
1031 };
1032 
1037 template <class T>
1038 class StringSinkTemplate : public Bufferless<Sink>
1039 {
1040 public:
1041  virtual ~StringSinkTemplate() {}
1042 
1046  : m_output(&output) {CRYPTOPP_ASSERT(sizeof(output[0])==1);}
1047 
1049  {if (!parameters.GetValue("OutputStringPointer", m_output)) throw InvalidArgument("StringSink: OutputStringPointer not specified");}
1050 
1051  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
1052  {
1053  CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
1054  typedef typename T::traits_type::char_type char_type;
1055 
1056  if (length > 0)
1057  {
1058  typename T::size_type size = m_output->size();
1059  if (length < size && size + length > m_output->capacity())
1060  m_output->reserve(2*size);
1061  m_output->append((const char_type *)inString, (const char_type *)inString+length);
1062  }
1063  return 0;
1064  }
1065 
1066 private:
1068 };
1069 
1075 
1078 class RandomNumberSink : public Bufferless<Sink>
1079 {
1080 public:
1081  virtual ~RandomNumberSink() {}
1082 
1085  : m_rng(NULL) {}
1086 
1090  : m_rng(&rng) {}
1091 
1092  void IsolatedInitialize(const NameValuePairs &parameters);
1093  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
1094 
1095 private:
1097 };
1098 
1101 class CRYPTOPP_DLL ArraySink : public Bufferless<Sink>
1102 {
1103 public:
1104  virtual ~ArraySink() {}
1105 
1110  : m_buf(NULL), m_size(0), m_total(0) {IsolatedInitialize(parameters);}
1111 
1115  ArraySink(byte *buf, size_t size)
1116  : m_buf(buf), m_size(size), m_total(0) {}
1117 
1120  size_t AvailableSize() {return SaturatingSubtract(m_size, m_total);}
1121 
1124  lword TotalPutLength() {return m_total;}
1125 
1126  void IsolatedInitialize(const NameValuePairs &parameters);
1127  byte * CreatePutSpace(size_t &size);
1128  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
1129 
1130 protected:
1132  size_t m_size;
1134 };
1135 
1139 {
1140 public:
1141  virtual ~ArrayXorSink() {}
1142 
1146  ArrayXorSink(byte *buf, size_t size)
1147  : ArraySink(buf, size) {}
1148 
1149  size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
1151 };
1152 
1155 class StringStore : public Store
1156 {
1157 public:
1160  StringStore(const char *string = NULL)
1161  {StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
1162 
1166  StringStore(const byte *string, size_t length)
1167  {StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));}
1168 
1172  template <class T> StringStore(const T &string)
1173  {StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
1174 
1175  CRYPTOPP_DLL size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
1176  CRYPTOPP_DLL size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
1177 
1178 private:
1179  CRYPTOPP_DLL void StoreInitialize(const NameValuePairs &parameters);
1180 
1181  const byte *m_store;
1182  size_t m_length, m_count;
1183 };
1184 
1187 {
1188 public:
1189  virtual ~RandomNumberStore() {}
1190 
1192  : m_rng(NULL), m_length(0), m_count(0) {}
1193 
1195  : m_rng(&rng), m_length(length), m_count(0) {}
1196 
1197  bool AnyRetrievable() const {return MaxRetrievable() != 0;}
1198  lword MaxRetrievable() const {return m_length-m_count;}
1199 
1200  size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
1201  size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const
1202  {
1203  CRYPTOPP_UNUSED(target); CRYPTOPP_UNUSED(begin); CRYPTOPP_UNUSED(end); CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(blocking);
1204  throw NotImplemented("RandomNumberStore: CopyRangeTo2() is not supported by this store");
1205  }
1206 
1207 private:
1208  void StoreInitialize(const NameValuePairs &parameters);
1209 
1211  lword m_length, m_count;
1212 };
1213 
1216 {
1217 public:
1218  NullStore(lword size = ULONG_MAX) : m_size(size) {}
1220  {CRYPTOPP_UNUSED(parameters);}
1221  lword MaxRetrievable() const {return m_size;}
1222  size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
1223  size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
1224 
1225 private:
1227 };
1228 
1240 {
1241 public:
1242  virtual ~Source() {}
1243 
1246  Source(BufferedTransformation *attachment = NULL)
1247  {Source::Detach(attachment);}
1248 
1250 
1251 
1258  lword Pump(lword pumpMax=(size_t)SIZE_MAX)
1259  {Pump2(pumpMax); return pumpMax;}
1260 
1265  unsigned int PumpMessages(unsigned int count=UINT_MAX)
1266  {PumpMessages2(count); return count;}
1267 
1270  void PumpAll()
1271  {PumpAll2();}
1272 
1280  virtual size_t Pump2(lword &byteCount, bool blocking=true) =0;
1281 
1286  virtual size_t PumpMessages2(unsigned int &messageCount, bool blocking=true) =0;
1287 
1291  virtual size_t PumpAll2(bool blocking=true);
1292 
1295  virtual bool SourceExhausted() const =0;
1296 
1298 
1299 protected:
1300  void SourceInitialize(bool pumpAll, const NameValuePairs &parameters)
1301  {
1302  IsolatedInitialize(parameters);
1303  if (pumpAll)
1304  PumpAll();
1305  }
1306 };
1307 
1311 template <class T>
1312 class SourceTemplate : public Source
1313 {
1314 public:
1315  virtual ~SourceTemplate() {}
1316 
1321  : Source(attachment) {}
1323  {m_store.IsolatedInitialize(parameters);}
1324  size_t Pump2(lword &byteCount, bool blocking=true)
1325  {return m_store.TransferTo2(*AttachedTransformation(), byteCount, DEFAULT_CHANNEL, blocking);}
1326  size_t PumpMessages2(unsigned int &messageCount, bool blocking=true)
1327  {return m_store.TransferMessagesTo2(*AttachedTransformation(), messageCount, DEFAULT_CHANNEL, blocking);}
1328  size_t PumpAll2(bool blocking=true)
1329  {return m_store.TransferAllTo2(*AttachedTransformation(), DEFAULT_CHANNEL, blocking);}
1330  bool SourceExhausted() const
1331  {return !m_store.AnyRetrievable() && !m_store.AnyMessages();}
1332  void SetAutoSignalPropagation(int propagation)
1333  {m_store.SetAutoSignalPropagation(propagation);}
1335  {return m_store.GetAutoSignalPropagation();}
1336 
1337 protected:
1339 };
1340 
1343 class CRYPTOPP_DLL StringSource : public SourceTemplate<StringStore>
1344 {
1345 public:
1349  : SourceTemplate<StringStore>(attachment) {}
1350 
1355  StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULL)
1356  : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
1357 
1363  StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULL)
1364  : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));}
1365 
1370  StringSource(const std::string &string, bool pumpAll, BufferedTransformation *attachment = NULL)
1371  : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
1372 };
1373 
1380 
1382 class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate<RandomNumberStore>
1383 {
1384 public:
1385  RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment = NULL)
1386  : SourceTemplate<RandomNumberStore>(attachment)
1387  {SourceInitialize(pumpAll, MakeParameters("RandomNumberGeneratorPointer", &rng)("RandomNumberStoreSize", length));}
1388 };
1389 
1391 
1392 #if CRYPTOPP_MSC_VERSION
1393 # pragma warning(pop)
1394 #endif
1395 
1396 #endif
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:29
Create a working space in a BufferedTransformation.
Definition: filters.h:160
Base class for all exceptions thrown by the library.
Definition: cryptlib.h:140
lword m_total
Definition: filters.h:1133
Append input to a string object.
lword m_size
Definition: filters.h:1226
virtual ~ArraySink()
Definition: filters.h:1104
An invalid argument was detected.
Definition: cryptlib.h:184
byte * HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t bufferSize)
Create a working space in a BufferedTransformation.
Definition: filters.h:209
StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment=NULL)
Construct a StringSource.
Definition: filters.h:1355
SimpleProxyFilter(BufferedTransformation *filter, BufferedTransformation *attachment)
Construct a SimpleProxyFilter.
Definition: filters.h:983
HashTransformation & m_hashModule
Definition: filters.h:541
Pointer-based implementation of the Source interface.
DOCUMENTED_TYPEDEF(StringSinkTemplate< std::string >, StringSink)
Classes for working with NameValuePairs.
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:262
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const
Copy bytes from this object to another BufferedTransformation.
Definition: filters.h:1201
Filter wrapper for PK_Verifier.
Definition: filters.h:745
Base class for Filter classes that are proxies for a chain of other filters.
Definition: filters.h:951
byte * m_space
Definition: filters.h:544
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: filters.h:457
Implementation of BufferedTransformation&#39;s attachment interface.
Definition: filters.h:1239
uint8_t byte
Definition: Common.h:57
const lword LWORD_MAX
Definition: config.h:246
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:784
Classes providing basic library services.
Utility functions for the Crypto++ library.
const byte * m_store
Definition: filters.h:1181
PK_DecryptorFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment=NULL)
Construct a PK_DecryptorFilter.
Definition: filters.h:1029
MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true)
Construct a MeterFilter.
Definition: filters.h:230
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:535
virtual int NextPut(const byte *inString, size_t length)
Definition: filters.h:402
bool operator<(const MessageRange &b) const
Definition: filters.h:275
unsigned int GetTotalMessages() const
Definition: filters.h:259
void SetAutoSignalPropagation(int propagation)
Set propagation of automatically generated and transferred signals.
Definition: filters.h:1332
BlockPaddingScheme
Padding schemes used for block ciphers.
Definition: filters.h:474
member_ptr< BufferedTransformation > m_filter
Definition: filters.h:972
Interface for one direction (encryption or decryption) of a stream cipher or block cipher mode with a...
Definition: cryptlib.h:1121
virtual ~StreamTransformationFilter()
Definition: filters.h:494
virtual size_t GetLastPutSize() const
Definition: filters.h:360
SecByteBlock m_expectedHash
Definition: filters.h:608
RandomNumberGenerator & m_rng
Definition: filters.h:736
bool GetLastResult() const
Definition: filters.h:593
Filter class that is a proxy for a sink.
Definition: filters.h:903
#define T(i, x)
size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee on a channel.
Definition: filters.h:937
size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing on a channel.
Definition: filters.h:935
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
virtual void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize)
Definition: filters.h:362
byte * HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize)
Create a working space in a BufferedTransformation.
Definition: filters.h:200
Interface for public-key signers.
Definition: cryptlib.h:2527
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Definition: config.h:720
size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing on a channel.
Definition: filters.h:881
Behavior GetBehavior()
Definition: filters.h:843
Interface for public-key encryptors.
Definition: cryptlib.h:2336
void PumpAll()
Pump all data to attached transformation.
Definition: filters.h:1270
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Definition: filters.h:922
unsigned int PumpMessages(unsigned int count=UINT_MAX)
Pump messages to attached transformation.
Definition: filters.h:1265
size_t count
Definition: ExecStats.cpp:37
Abstract base classes that provide a uniform interface to this library.
member_ptr< BufferedTransformation > m_attachment
Definition: filters.h:151
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:730
void SetPassWaitObjects(bool pass)
Definition: filters.h:848
bool GetPassSignal() const
Retrieve passSignal flag.
Definition: filters.h:915
bool ShouldPropagateMessageSeriesEnd() const
Definition: filters.h:271
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: filters.h:1322
size_t PumpAll2(bool blocking=true)
Pump all data to attached transformation.
Definition: filters.h:1328
virtual void NextPutSingle(const byte *inString)
Definition: filters.h:371
Classes for automatic resource management.
Filter wrapper for PK_Signer.
Definition: filters.h:717
bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)
Marks the end of a series of messages on a channel.
Definition: filters.h:941
#define c(i)
size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee.
Definition: filters.h:339
Acts as a Source for pre-existing, static data.
Definition: simple.h:299
StringStore(const T &string)
Construct a StringStore.
Definition: filters.h:1172
StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment=NULL)
Construct a StringSource.
Definition: filters.h:1363
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:503
Interface for random number generators.
Definition: cryptlib.h:1188
StreamTransformationFilter m_streamFilter
Definition: filters.h:712
Base class for input rejecting filters.
Definition: simple.h:121
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Definition: filters.h:864
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:854
Append input to a string object.
Definition: filters.h:1038
BufferedTransformation & m_owner
Definition: filters.h:945
StringSource(const std::string &string, bool pumpAll, BufferedTransformation *attachment=NULL)
Construct a StringSource.
Definition: filters.h:1370
Interface for buffered transformations.
Definition: cryptlib.h:1352
Exception thrown when an invalid signature is encountered.
Definition: filters.h:749
Flags
Flags controlling filter behavior.
Definition: filters.h:759
virtual ~Filter()
Definition: filters.h:39
virtual bool ShouldPropagateMessageSeriesEnd() const
Definition: filters.h:84
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:592
StringStore(const byte *string, size_t length)
Construct a StringStore.
Definition: filters.h:1166
bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output on a channel.
Definition: filters.h:939
byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:933
HashTransformation & m_hashModule
Definition: filters.h:604
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
Definition: cryptlib.cpp:59
Exception thrown when a data integrity check failure is encountered.
Definition: filters.h:557
Classes and functions for secure memory allocations.
1 and 0&#39;s padding added to a block
Definition: filters.h:482
void SetPassSignals(bool pass)
Definition: filters.h:846
Redirector(BufferedTransformation &target, Behavior behavior=PASS_EVERYTHING)
Construct a Redirector.
Definition: filters.h:834
void StoreInitialize(const NameValuePairs &parameters)
Definition: filters.h:1219
virtual size_t GetBlockPutSize() const
Definition: filters.h:359
Copy input to a memory buffer.
Definition: filters.h:1101
bool m_putMessage
Definition: filters.h:542
empty store
Definition: filters.h:1215
unsigned int GetTotalMessageSeries() const
Definition: filters.h:260
virtual ~HashFilter()
Definition: filters.h:524
virtual ~AuthenticatedEncryptionFilter()
Definition: filters.h:620
Flags
Flags controlling filter behavior.
Definition: filters.h:665
byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:871
Transform a Store into a Source.
Definition: filters.h:1312
Classes for an unlimited queue to store bytes.
Xor input to a memory buffer.
Definition: filters.h:1138
RandomNumberSink(RandomNumberGenerator &rng)
Construct a RandomNumberSink.
Definition: filters.h:1089
bool GetValue(const char *name, T &value) const
Get a named value.
Definition: cryptlib.h:337
bool CanModifyInput() const
Determines whether input can be modified by the callee.
Definition: filters.h:850
Interface for public-key decryptors.
Definition: cryptlib.h:2372
A method was called which was not implemented.
Definition: cryptlib.h:205
bool GetLastResult() const
Definition: filters.h:692
Filter wrapper for HashTransformation.
Definition: filters.h:550
Filter wrapper for HashTransformation.
Definition: filters.h:521
size_t m_length
Definition: filters.h:1182
RNG-based implementation of Source interface.
Definition: filters.h:1186
int m_continueAt
Definition: filters.h:155
Filter wrapper for decrypting with AuthenticatedSymmetricCipher.
Definition: filters.h:659
const PK_Verifier & m_verifier
Definition: filters.h:797
void Detach(BufferedTransformation *newAttachment=NULL)
Replace an attached transformation.
Definition: filters.cpp:50
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:498
NullStore(lword size=ULONG_MAX)
Definition: filters.h:1218
word32 m_behavior
Definition: filters.h:897
bool GetPassSignals() const
Definition: filters.h:845
StreamTransformation & m_cipher
Definition: filters.h:514
lword MaxRetrievable() const
Provides the number of bytes ready for retrieval.
Definition: filters.h:1221
OutputProxy(BufferedTransformation &owner, bool passSignal)
Construct an OutputProxy.
Definition: filters.h:911
A non-transparent MeterFilter.
Definition: filters.h:302
virtual ~StringSinkTemplate()
Definition: filters.h:1041
Filter wrapper for encrypting with AuthenticatedSymmetricCipher.
Definition: filters.h:617
size_t PumpMessages2(unsigned int &messageCount, bool blocking=true)
Pump messages to attached transformation.
Definition: filters.h:1326
void NextPutMaybeModifiable(byte *inString, size_t length, bool modifiable)
Definition: filters.h:394
virtual void FlushDerived()
Definition: filters.h:390
Flags
Flags controlling filter behavior.
Definition: filters.h:567
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: filters.h:689
Proxy filter that doesn&#39;t modify the underlying filter&#39;s input or output.
Definition: filters.h:977
virtual byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
Definition: cryptlib.cpp:456
void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1)
Initialize or reinitialize this object, with signal propagation.
Definition: filters.h:926
bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
Marks the end of a series of messages, with signal propagation.
Definition: filters.h:930
unsigned int GetMaxWaitObjectCount() const
Retrieves the maximum number of waitable objects.
Definition: filters.h:890
virtual void NextPutModifiable(byte *inString, size_t length)
Definition: filters.h:377
virtual bool ShouldPropagateMessageEnd() const
Definition: filters.h:83
virtual ~OutputProxy()
Definition: filters.h:906
A filter that buffers input using a ByteQueue.
Definition: filters.h:432
bool m_putMessage
Definition: filters.h:739
unsigned int m_digestSize
Definition: filters.h:606
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
Definition: misc.h:847
RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment=NULL)
Definition: filters.h:1385
void StopRedirection()
Stop redirecting input.
Definition: filters.h:841
size_t AvailableSize()
Provides the size remaining in the Sink.
Definition: filters.h:1120
Filter wrapper for PK_Decryptor.
Definition: filters.h:1022
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Definition: filters.h:1051
lword Pump(lword pumpMax=(size_t) SIZE_MAX)
Pump data to attached transformation.
Definition: filters.h:1258
void FirstPut(const byte *inString)
Definition: filters.h:986
void SetBehavior(Behavior behavior)
Definition: filters.h:844
bool m_transparent
Definition: filters.h:280
BufferedTransformation * m_target
Definition: filters.h:896
member_ptr< PK_MessageAccumulator > m_messageAccumulator
Definition: filters.h:798
Incorporates input into RNG as additional entropy.
Definition: filters.h:1078
virtual ~HashVerificationFilter()
Definition: filters.h:553
virtual ~AuthenticatedDecryptionFilter()
Definition: filters.h:676
#define THROW_EXCEPTION(X)
Definition: VMConfig.h:120
RandomNumberGenerator * m_rng
Definition: filters.h:1210
unsigned int m_digestSize
Definition: filters.h:543
lword GetTotalBytes() const
Definition: filters.h:257
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:823
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: filters.h:1048
virtual ~MeterFilter()
Definition: filters.h:223
virtual ~FilterWithInputQueue()
Definition: filters.h:435
RandomNumberSink()
Construct a RandomNumberSink.
Definition: filters.h:1084
Divides an input stream into discrete blocks.
Definition: filters.h:317
StringSource(BufferedTransformation *attachment=NULL)
Construct a StringSource.
Definition: filters.h:1348
#define b(i, j)
String-based implementation of Store interface.
Definition: filters.h:1155
#define CRYPTOPP_ASSERT(exp)
Definition: trap.h:92
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Definition: cryptlib.cpp:76
int GetAutoSignalPropagation() const
Retrieve automatic signal propagation value.
Definition: filters.h:1334
virtual ~SignatureVerificationFilter()
Definition: filters.h:776
BlockPaddingScheme m_padding
Definition: filters.h:515
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Definition: filters.h:441
Redirect input to another BufferedTransformation without owning it.
Definition: filters.h:808
virtual ~FilterPutSpaceHelper()
Definition: filters.h:162
size_t Pump2(lword &byteCount, bool blocking=true)
Pump data to attached transformation.
Definition: filters.h:1324
Data structure used to store byte strings.
Definition: queue.h:20
TransparentFilter(BufferedTransformation *attachment=NULL)
Construct a TransparentFilter.
Definition: filters.h:296
virtual ~Source()
Definition: filters.h:1242
Redirector()
Construct a Redirector.
Definition: filters.h:829
bool GetLastResult() const
Retrieves the result of the last verification.
Definition: filters.h:788
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
void SourceInitialize(bool pumpAll, const NameValuePairs &parameters)
Definition: filters.h:1300
bool AnyRetrievable() const
Determines whether bytes are ready for retrieval.
Definition: filters.h:1197
virtual ~ArrayXorSink()
Definition: filters.h:1141
RandomNumberStore(RandomNumberGenerator &rng, lword length)
Definition: filters.h:1194
Filter wrapper for PK_Encryptor.
Definition: filters.h:1007
Exception thrown by objects that have not implemented nonblocking input processing.
Definition: cryptlib.h:1470
Filter wrapper for StreamTransformation.
Definition: filters.h:491
void Redirect(BufferedTransformation &target)
Redirect input to another BufferedTransformation.
Definition: filters.h:839
Behavior
Controls signal propagation behavior.
Definition: filters.h:813
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:538
#define pass(a, b, c, mul, X)
Base class for unflushable filters.
Definition: simple.h:94
virtual ~ProxyFilter()
Definition: filters.h:954
Interface for public-key signature verifiers.
Definition: cryptlib.h:2592
bool Attachable()
Determine if attachable.
Definition: filters.h:52
uint8_t const size_t const size
Definition: sha3.h:20
A transparent MeterFilter.
Definition: filters.h:291
SecByteBlock m_tempSpace
Temporay working space.
Definition: filters.h:213
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
bool SourceExhausted() const
Determines if the Source is exhausted.
Definition: filters.h:1330
HashVerificationFilter m_hashVerifier
Definition: filters.h:711
lword GetCurrentMessageBytes() const
Definition: filters.h:256
void SetPassSignal(bool passSignal)
Set passSignal flag.
Definition: filters.h:918
SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment=NULL, bool putMessage=false)
Construct a SignerFilter.
Definition: filters.h:727
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:930
virtual byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: cryptlib.h:1411
bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output on a channel.
Definition: filters.h:885
0&#39;s padding added to a block
Definition: filters.h:478
lword MaxRetrievable() const
Provides the number of bytes ready for retrieval.
Definition: filters.h:1198
void SetTransparent(bool transparent)
Set or change the transparent mode of this object.
Definition: filters.h:237
SignatureVerificationFilter VerifierFilter
Definition: filters.h:804
ArraySink(const NameValuePairs &parameters=g_nullNameValuePairs)
Construct an ArraySink.
Definition: filters.h:1109
Implementation of BufferedTransformation&#39;s attachment interface.
Definition: filters.h:36
virtual size_t GetFirstPutSize() const
Definition: filters.h:358
unsigned int m_optimalBufferSize
Definition: filters.h:516
size_t m_inputPosition
Definition: filters.h:154
bool ShouldPropagateMessageEnd() const
Definition: filters.h:270
Access a block of memory.
Definition: misc.h:2153
void IsolatedInitialize(const NameValuePairs &parameters)
Initialize or reinitialize this object, without signal propagation.
Definition: filters.h:253
Measure how many bytes and messages pass through the filter.
Definition: filters.h:220
const PK_Signer & m_signer
Definition: filters.h:737
BlockQueue m_queue
Definition: filters.h:424
#define NAMESPACE_END
Definition: config.h:201
byte * m_buf
Definition: filters.h:1131
void GetWaitObjects(WaitObjectContainer &container, CallStack const &callStack)
Retrieves waitable objects.
Definition: filters.h:892
std::vector< char * > parameters
Definition: boostTest.cpp:46
virtual ~Redirector()
Definition: filters.h:826
No padding added to a block.
Definition: filters.h:476
ArrayXorSink(byte *buf, size_t size)
Construct an ArrayXorSink.
Definition: filters.h:1146
PKCS #5 padding added to a block.
Definition: filters.h:480
virtual bool DidFirstPut() const
Definition: filters.h:357
Padding schemes used for block ciphers.
Definition: filters.h:465
word64 lword
Definition: config.h:245
PK_EncryptorFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment=NULL)
Construct a PK_EncryptorFilter.
Definition: filters.h:1014
std::deque< MessageRange > m_rangesToSkip
Definition: filters.h:283
size_t m_length
Definition: filters.h:285
ArraySink(byte *buf, size_t size)
Construct an ArraySink.
Definition: filters.h:1115
SecByteBlock m_buf
Definition: filters.h:740
StringSinkTemplate(T &output)
Construct a StringSinkTemplate.
Definition: filters.h:1045
virtual ~SourceTemplate()
Definition: filters.h:1315
RNG-based implementation of Source interface.
Definition: filters.h:1382
#define CRYPTOPP_DLL
Definition: config.h:704
bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)
Marks the end of a series of messages on a channel.
Definition: filters.h:887
unsigned int word32
Definition: config.h:231
member_ptr< PK_MessageAccumulator > m_messageAccumulator
Definition: filters.h:738
virtual ~RandomNumberSink()
Definition: filters.h:1081
virtual ~SignerFilter()
Definition: filters.h:720
size_t PutModifiable2(byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee.
Definition: filters.h:924
virtual ~RandomNumberStore()
Definition: filters.h:1189
unsigned int m_totalMessageSeries
Definition: filters.h:282
byte * HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize)
Create a working space in a BufferedTransformation.
Definition: filters.h:177
FilterWithInputQueue(BufferedTransformation *attachment=NULL)
Construct a FilterWithInputQueue.
Definition: filters.h:439
OpaqueFilter(BufferedTransformation *attachment=NULL)
Construct an OpaqueFilter.
Definition: filters.h:307
Ensures an object is not copyable.
Definition: misc.h:217
virtual ~FilterWithBufferedInput()
Definition: filters.h:320
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Definition: filters.h:335
std::string m_messagePutChannel
Definition: filters.h:545
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
Definition: filters.h:866
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:1150
StringStore(const char *string=NULL)
Construct a StringStore.
Definition: filters.h:1160
Interface for custom flush signals.
Definition: simple.h:192
ByteQueue m_inQueue
Definition: filters.h:460
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
Definition: filters.h:928
size_t m_size
Definition: filters.h:1132
bool GetPassWaitObjects() const
Definition: filters.h:847
size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee on a channel.
Definition: filters.h:883
RandomNumberGenerator * m_rng
Definition: filters.h:1096
lword TotalPutLength()
Provides the number of bytes written to the Sink.
Definition: filters.h:1124
virtual void InitializeDerived(const NameValuePairs &parameters)
Definition: filters.h:364
void LastPut(const byte *inString, size_t length)
Input the last block of data.
Definition: filters.h:999
Base class for bufferless filters.
Definition: simple.h:83
lword m_totalBytes
Definition: filters.h:281
byte * m_begin
Definition: filters.h:284
#define SIZE_MAX
Definition: misc.h:113
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Definition: filters.h:920
Interface for retrieving values given their names.
Definition: cryptlib.h:279
SecByteBlock m_signature
Definition: filters.h:800
bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
Marks the end of a series of messages, with signal propagation.
Definition: filters.h:868
unsigned int GetCurrentSeriesMessages() const
Definition: filters.h:258
bool m_passSignal
Definition: filters.h:946
Source(BufferedTransformation *attachment=NULL)
Construct a Source.
Definition: filters.h:1246