summaryrefslogtreecommitdiff
path: root/randpool.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:37:46 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:37:46 +0000
commit48e0b8231e112953680cacd9fa2bb6157184a657 (patch)
tree5c790bf6c465f48e0dca552dfff508cda8f7235f /randpool.h
parentd37d0425edebab09ec1ff767e9b89b68db52533d (diff)
downloadcryptopp-48e0b8231e112953680cacd9fa2bb6157184a657.tar.gz
reduce risk of reusing random numbers after VM state rollback
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@340 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'randpool.h')
-rw-r--r--randpool.h39
1 files changed, 13 insertions, 26 deletions
diff --git a/randpool.h b/randpool.h
index e4157f3..c25bc9b 100644
--- a/randpool.h
+++ b/randpool.h
@@ -7,38 +7,25 @@
NAMESPACE_BEGIN(CryptoPP)
//! Randomness Pool
-/*! This class can be used to generate
- pseudorandom bytes after seeding the pool with
- the Put() methods */
-class CRYPTOPP_DLL RandomPool : public RandomNumberGenerator,
- public Bufferless<BufferedTransformation>
+/*! This class can be used to generate cryptographic quality
+ pseudorandom bytes after seeding the pool with IncorporateEntropy() */
+class CRYPTOPP_DLL RandomPool : public RandomNumberGenerator, public NotCopyable
{
public:
- //! poolSize must be greater than 16
- RandomPool(unsigned int poolSize=384);
+ RandomPool();
- size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
+ bool CanIncorporateEntropy() const {return true;}
+ void IncorporateEntropy(const byte *input, size_t length);
+ void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size);
- bool AnyRetrievable() const {return true;}
- lword MaxRetrievable() const {return ULONG_MAX;}
-
- size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=NULL_CHANNEL, bool blocking=true);
- size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_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, size_t size);
-
- void IsolatedInitialize(const NameValuePairs &parameters) {}
-
-protected:
- void Stir();
+ // for backwards compatibility. use RandomNumberSource, RandomNumberStore, and RandomNumberSink for other BufferTransformation functionality
+ void Put(const byte *input, size_t length) {IncorporateEntropy(input, length);}
private:
- SecByteBlock pool, key;
- size_t addPos, getPos;
+ FixedSizeSecBlock<byte, 32> m_key;
+ FixedSizeSecBlock<byte, 16> m_seed;
+ member_ptr<BlockCipher> m_pCipher;
+ bool m_keySet;
};
NAMESPACE_END