summaryrefslogtreecommitdiff
path: root/randpool.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
committerweidai <weidai11@users.noreply.github.com>2002-10-04 17:31:41 +0000
commita3b6ece7ab341b5b14135baeccea7d5e4c086771 (patch)
tree8b045309c238226c32a563b1df6b9c30a2f0e0b3 /randpool.h
downloadcryptopp-git-a3b6ece7ab341b5b14135baeccea7d5e4c086771.tar.gz
Initial revision
Diffstat (limited to 'randpool.h')
-rw-r--r--randpool.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/randpool.h b/randpool.h
new file mode 100644
index 00000000..6bbe32f7
--- /dev/null
+++ b/randpool.h
@@ -0,0 +1,46 @@
+#ifndef CRYPTOPP_RANDPOOL_H
+#define CRYPTOPP_RANDPOOL_H
+
+#include "cryptlib.h"
+#include "filters.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! Randomness Pool
+/*! This class can be used to generate
+ pseudorandom bytes after seeding the pool with
+ the Put() methods */
+class RandomPool : public RandomNumberGenerator,
+ public Bufferless<BufferedTransformation>
+{
+public:
+ //! poolSize must be greater than 16
+ RandomPool(unsigned int poolSize=384);
+
+ unsigned int Put2(const byte *begin, unsigned int, int messageEnd, bool blocking);
+
+ bool AnyRetrievable() const {return true;}
+ unsigned long MaxRetrievable() const {return ULONG_MAX;}
+
+ unsigned int TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel=NULL_CHANNEL, bool blocking=true);
+ unsigned int CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end=ULONG_MAX, const std::string &channel=NULL_CHANNEL, bool blocking=true) const
+ {
+ throw NotImplemented("RandomPool: CopyRangeTo2() is not supported by this store");
+ }
+
+ byte GenerateByte();
+ void GenerateBlock(byte *output, unsigned int size);
+
+ void IsolatedInitialize(const NameValuePairs &parameters) {}
+
+protected:
+ void Stir();
+
+private:
+ SecByteBlock pool, key;
+ unsigned int addPos, getPos;
+};
+
+NAMESPACE_END
+
+#endif