Interface for random number generators.
The library provides a number of random number generators, from software based to hardware based generators. All generated values are uniformly distributed over the range specified.
- Since
- Crypto++ 3.1
- See also
- RandomNumberGenerator on the Crypto++ wiki
Definition at line 1434 of file cryptlib.h.
virtual void RandomNumberGenerator::IncorporateEntropy |
( |
const byte * |
input, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
Update RNG state with additional unpredictable values.
- Parameters
-
input | the entropy to add to the generator |
length | the size of the input buffer |
- Exceptions
-
Reimplemented in NIST_DRBG, RDSEED, RDRAND, OldRandomPool, RandomPool, PadlockRNG, AutoSeededX917RNG< BLOCK_CIPHER >, MersenneTwister< K, M, N, F, S >, MersenneTwister< 0x9908B0DF, 397, 624, 0x6C078965, 5489 >, MersenneTwister< 0x9908B0DF, 397, 624, 0x10DCD, 4537 >, HMAC_DRBG< HASH, STRENGTH, SEEDLENGTH >, Hash_DRBG< HASH, STRENGTH, SEEDLENGTH >, and DARN.
Definition at line 1447 of file cryptlib.h.
virtual word32 RandomNumberGenerator::GenerateWord32 |
( |
word32 |
min = 0 , |
|
|
word32 |
max = 0xffffffffUL |
|
) |
| |
|
virtual |
Generate a random 32 bit word in the range min to max, inclusive.
- Parameters
-
min | the lower bound of the range |
max | the 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 in OldRandomPool, MersenneTwister< K, M, N, F, S >, MersenneTwister< 0x9908B0DF, 397, 624, 0x6C078965, 5489 >, and MersenneTwister< 0x9908B0DF, 397, 624, 0x10DCD, 4537 >.
virtual void RandomNumberGenerator::GenerateBlock |
( |
byte * |
output, |
|
|
size_t |
size |
|
) |
| |
|
virtual |
Generate random array of bytes.
- Parameters
-
output | the byte buffer |
size | the 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 in NIST_DRBG, AdditiveCipherTemplate< BASE >, AdditiveCipherTemplate<>, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, CTR_ModePolicy > >, LC_RNG, RDSEED, RDRAND, OldRandomPool, PadlockRNG, BlockingRng, NonblockingRng, MersenneTwister< K, M, N, F, S >, MersenneTwister< 0x9908B0DF, 397, 624, 0x6C078965, 5489 >, MersenneTwister< 0x9908B0DF, 397, 624, 0x10DCD, 4537 >, HMAC_DRBG< HASH, STRENGTH, SEEDLENGTH >, Hash_DRBG< HASH, STRENGTH, SEEDLENGTH >, DARN, PublicBlumBlumShub, and Weak::ARC4_Base.