Crypto++ 8.9
Free C++ class library of cryptographic schemes
|
Randomness Pool based on AES-256. More...
#include <randpool.h>
Public Member Functions | |
RandomPool () | |
Construct a RandomPool. | |
bool | CanIncorporateEntropy () const |
Determines if a generator can accept additional entropy. | |
void | IncorporateEntropy (const byte *input, size_t length) |
Update RNG state with additional unpredictable values. | |
void | GenerateIntoBufferedTransformation (BufferedTransformation &target, const std::string &channel, lword size) |
Generate random bytes into a BufferedTransformation. | |
Public Member Functions inherited from RandomNumberGenerator | |
virtual byte | GenerateByte () |
Generate new random byte and return it. | |
virtual unsigned int | GenerateBit () |
Generate new random bit and return it. | |
virtual word32 | GenerateWord32 (word32 min=0, word32 max=0xffffffffUL) |
Generate a random 32 bit word in the range min to max, inclusive. | |
virtual void | GenerateBlock (byte *output, size_t size) |
Generate random array of bytes. | |
virtual void | DiscardBytes (size_t n) |
Generate and discard n bytes. | |
template<class IT > | |
void | Shuffle (IT begin, IT end) |
Randomly shuffle the specified array. | |
Public Member Functions inherited from Algorithm | |
Algorithm (bool checkSelfTestStatus=true) | |
Interface for all crypto algorithms. | |
virtual std::string | AlgorithmName () const |
Provides the name of this algorithm. | |
virtual std::string | AlgorithmProvider () const |
Retrieve the provider of this algorithm. | |
Public Member Functions inherited from Clonable | |
virtual Clonable * | Clone () const |
Copies this object. | |
Randomness Pool based on AES-256.
RandomPool can be used to generate cryptographic quality pseudorandom bytes after seeding the pool with IncorporateEntropy(). Internally, the generator uses AES-256 to produce the stream. Entropy is stirred in using SHA-256.
RandomPool used to follow the design of randpool in PGP 2.6.x. At version 5.5 RandomPool was redesigned to reduce the risk of reusing random numbers after state rollback, which may occur when running in a virtual machine like VMware or a hosted environment.
You should reseed the generator after a fork() to avoid multiple generators with the same internal state.
If you need the pre-Crypto++ 5.5 generator then use OldRandomPool class. You should migrate away from OldRandomPool at the earliest opportunity.
Definition at line 43 of file randpool.h.
|
inlinevirtual |
Determines if a generator can accept additional entropy.
Reimplemented from RandomNumberGenerator.
Definition at line 49 of file randpool.h.
|
virtual |
Update RNG state with additional unpredictable values.
input | the entropy to add to the generator |
length | the size of the input buffer |
NotImplemented |
A generator may or may not accept additional entropy. Call CanIncorporateEntropy() to test for the ability to use additional entropy.
If a derived class does not override IncorporateEntropy(), then the base class throws NotImplemented.
Reimplemented from RandomNumberGenerator.
|
virtual |
Generate random bytes into a BufferedTransformation.
target | the BufferedTransformation object which receives the bytes |
channel | the channel on which the bytes should be pumped |
length | the number of bytes to generate |
The default implementation calls GenerateBlock() and pumps the result into the DEFAULT_CHANNEL of the target.
All generated values are uniformly distributed over the range specified within the the constraints of a particular generator.
Reimplemented from RandomNumberGenerator.