summaryrefslogtreecommitdiff
path: root/filters.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:38:32 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:38:32 +0000
commite893a752d7bf74c9692cad5f058a190a6a047210 (patch)
treead77c798110d040680e92eb3bf46523222bca155 /filters.h
parent0cee348b78bdb6ef7da48ae6682c17dd75dc2fd4 (diff)
downloadcryptopp-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.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/filters.h b/filters.h
index fc5c6e8..750d976 100644
--- a/filters.h
+++ b/filters.h
@@ -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 &parameters);
+ 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>
{