Crypto++ 8.9
Free C++ class library of cryptographic schemes
Public Member Functions | List of all members
OldRandomPool Class Reference

Randomness Pool based on PGP 2.6.x with MDC. More...

#include <randpool.h>

+ Inheritance diagram for OldRandomPool:

Public Member Functions

 OldRandomPool (unsigned int poolSize=384)
 Construct an OldRandomPool.
 
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.
 
byte GenerateByte ()
 Generate new random byte and return it.
 
void GenerateBlock (byte *output, size_t size)
 Generate random array of bytes.
 
word32 GenerateWord32 (word32 min=0, word32 max=0xffffffffUL)
 Generate a random 32 bit word in the range min to max, inclusive.
 
- Public Member Functions inherited from RandomNumberGenerator
virtual unsigned int GenerateBit ()
 Generate new random bit and return it.
 
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 ClonableClone () const
 Copies this object.
 

Detailed Description

Randomness Pool based on PGP 2.6.x with MDC.

If you need the pre-Crypto++ 5.5 generator then use OldRandomPool class. The OldRandomPool also provides the modern interface, including CanIncorporateEntropy, IncorporateEntropy and GenerateIntoBufferedTransformation.

You should reseed the generator after a fork() to avoid multiple generators with the same internal state.

You should migrate away from OldRandomPool at the earliest opportunity. Use a modern random number generator or key derivation function, like AutoSeededRandomPool or HKDF.

Warning
This class uses an old style PGP 2.6.x with MDC. The generator risks reusing random numbers after state rollback. You should migrate away from OldRandomPool at the earliest opportunity.
See also
RandomPool, AutoSeededRandomPool, HKDF, P1363_KDF2, PKCS12_PBKDF, PKCS5_PBKDF2_HMAC
Since
Crypto++ 6.0

Definition at line 74 of file randpool.h.

Constructor & Destructor Documentation

◆ OldRandomPool()

OldRandomPool::OldRandomPool ( unsigned int poolSize = 384)

Construct an OldRandomPool.

Parameters
poolSizeinternal pool size of the generator

poolSize must be greater than 16

Member Function Documentation

◆ CanIncorporateEntropy()

bool OldRandomPool::CanIncorporateEntropy ( ) const
inlinevirtual

Determines if a generator can accept additional entropy.

Returns
true if IncorporateEntropy() is implemented

Reimplemented from RandomNumberGenerator.

Definition at line 83 of file randpool.h.

◆ IncorporateEntropy()

void OldRandomPool::IncorporateEntropy ( const byte * input,
size_t length )
virtual

Update RNG state with additional unpredictable values.

Parameters
inputthe entropy to add to the generator
lengththe size of the input buffer
Exceptions
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.

◆ GenerateIntoBufferedTransformation()

void OldRandomPool::GenerateIntoBufferedTransformation ( BufferedTransformation & target,
const std::string & channel,
lword length )
virtual

Generate random bytes into a BufferedTransformation.

Parameters
targetthe BufferedTransformation object which receives the bytes
channelthe channel on which the bytes should be pumped
lengththe 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.

Note
A derived generator must override either GenerateBlock() or GenerateIntoBufferedTransformation(). They can override both, or have one call the other.

Reimplemented from RandomNumberGenerator.

◆ GenerateByte()

byte OldRandomPool::GenerateByte ( )
virtual

Generate new random byte and return it.

Returns
a random 8-bit byte

Default implementation calls GenerateBlock() with one byte.

All generated values are uniformly distributed over the range specified within the the constraints of a particular generator.

Reimplemented from RandomNumberGenerator.

◆ GenerateBlock()

void OldRandomPool::GenerateBlock ( byte * output,
size_t size )
virtual

Generate random array of bytes.

Parameters
outputthe byte buffer
sizethe length of the buffer, in bytes

All generated values are uniformly distributed over the range specified within the the constraints of a particular generator.

Note
A derived generator must override either GenerateBlock() or GenerateIntoBufferedTransformation(). They can override both, or have one call the other.

Reimplemented from RandomNumberGenerator.

◆ GenerateWord32()

word32 OldRandomPool::GenerateWord32 ( word32 min = 0,
word32 max = 0xffffffffUL )
virtual

Generate a random 32 bit word in the range min to max, inclusive.

Parameters
minthe lower bound of the range
maxthe upper bound of the range
Returns
a random 32-bit word

The default implementation calls Crop() on the difference between max and min, and then returns the result added to min.

All generated values are uniformly distributed over the range specified within the the constraints of a particular generator.

Reimplemented from RandomNumberGenerator.


The documentation for this class was generated from the following file: