diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-05-04 15:38:32 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-05-04 15:38:32 +0000 |
commit | e893a752d7bf74c9692cad5f058a190a6a047210 (patch) | |
tree | ad77c798110d040680e92eb3bf46523222bca155 /filters.h | |
parent | 0cee348b78bdb6ef7da48ae6682c17dd75dc2fd4 (diff) | |
download | cryptopp-e893a752d7bf74c9692cad5f058a190a6a047210.tar.gz |
add IncorporateEntropy and GenerateIntoBufferedTransformation to RNG interface
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@342 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'filters.h')
-rw-r--r-- | filters.h | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -565,6 +565,23 @@ private: CRYPTOPP_DLL_TEMPLATE_CLASS StringSinkTemplate<std::string>; typedef StringSinkTemplate<std::string> StringSink; +//! incorporates input into RNG as additional entropy +class RandomNumberSink : public Bufferless<Sink> +{ +public: + RandomNumberSink() + : m_rng(NULL) {} + + RandomNumberSink(RandomNumberGenerator &rng) + : m_rng(&rng) {} + + void IsolatedInitialize(const NameValuePairs ¶meters); + size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + +private: + RandomNumberGenerator *m_rng; +}; + //! Copy input to a memory buffer class CRYPTOPP_DLL ArraySink : public Bufferless<Sink> { @@ -716,14 +733,20 @@ class CRYPTOPP_DLL StringSource : public SourceTemplate<StringStore> public: StringSource(BufferedTransformation *attachment = NULL) : SourceTemplate<StringStore>(attachment) {} + //! zero terminated string as source StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULL) : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));} + //! binary byte array as source StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULL) : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));} + //! std::string as source StringSource(const std::string &string, bool pumpAll, BufferedTransformation *attachment = NULL) : SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));} }; +//! use the third constructor for an array source +typedef StringSource ArraySource; + //! RNG-based implementation of Source interface class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate<RandomNumberStore> { |