Crypto++
5.6.4
Free C++ class library of cryptographic schemes
|
Automatically Seeded X9.17 RNG. More...
Public Member Functions | |
AutoSeededX917RNG (bool blocking=false, bool autoSeed=true) | |
Construct an AutoSeededX917RNG. More... | |
void | Reseed (bool blocking=false, const byte *additionalEntropy=NULL, size_t length=0) |
Reseed an AutoSeededX917RNG. More... | |
void | Reseed (const byte *key, size_t keylength, const byte *seed, const byte *timeVector) |
Deterministically reseed an AutoSeededX917RNG for testing. More... | |
bool | CanIncorporateEntropy () const |
Determines if a generator can accept additional entropy. More... | |
void | IncorporateEntropy (const byte *input, size_t length) |
Update RNG state with additional unpredictable values. More... | |
void | GenerateIntoBufferedTransformation (BufferedTransformation &target, const std::string &channel, lword length) |
Generate random bytes into a BufferedTransformation. More... | |
![]() | |
virtual byte | GenerateByte () |
Generate new random byte and return it. More... | |
virtual unsigned int | GenerateBit () |
Generate new random bit and return it. More... | |
virtual word32 | GenerateWord32 (word32 min=0, word32 max=0xffffffffUL) |
Generate a random 32 bit word in the range min to max, inclusive. More... | |
virtual void | GenerateBlock (byte *output, size_t size) |
Generate random array of bytes. More... | |
virtual void | DiscardBytes (size_t n) |
Generate and discard n bytes. More... | |
template<class IT > | |
void | Shuffle (IT begin, IT end) |
Randomly shuffle the specified array. More... | |
![]() | |
Algorithm (bool checkSelfTestStatus=true) | |
Interface for all crypto algorithms. More... | |
virtual std::string | AlgorithmName () const |
Provides the name of this algorithm. More... | |
![]() | |
virtual Clonable * | Clone () const |
Copies this object. More... | |
Automatically Seeded X9.17 RNG.
BLOCK_CIPHER | a block cipher |
AutoSeededX917RNG is from ANSI X9.17 Appendix C, seeded using an OS provided RNG. If 3-key TripleDES (DES_EDE3) is used, then its a X9.17 conforming generator. If AES is used, then its a X9.31 conforming generator.
Though ANSI X9 prescribes 3-key TripleDES, the template parameter BLOCK_CIPHER can be any BlockTransformation derived class.
|
inlineexplicit |
Construct an AutoSeededX917RNG.
blocking | controls seeding with BlockingRng or NonblockingRng |
autoSeed | controls auto seeding of the generator |
Use blocking to choose seeding with BlockingRng or NonblockingRng. The parameter is ignored if only one of these is available.
void AutoSeededX917RNG< BLOCK_CIPHER >::Reseed | ( | bool | blocking = false , |
const byte * | additionalEntropy = NULL , |
||
size_t | length = 0 |
||
) |
Reseed an AutoSeededX917RNG.
blocking | controls seeding with BlockingRng or NonblockingRng |
additionalEntropy | additional entropy to add to the generator |
length | the size of the additional entropy, in bytes |
Internally, the generator uses SHA256 to extract the entropy from from the seed and then stretch the material for the block cipher's key and initialization vector.
void AutoSeededX917RNG< BLOCK_CIPHER >::Reseed | ( | const byte * | key, |
size_t | keylength, | ||
const byte * | seed, | ||
const byte * | timeVector | ||
) |
Deterministically reseed an AutoSeededX917RNG for testing.
key | the key to use for the deterministic reseeding |
keylength | the size of the key, in bytes |
seed | the seed to use for the deterministic reseeding |
timeVector | a time vector to use for deterministic reseeding |
This is a testing interface for testing purposes, and should NOT be used in production.
|
inlinevirtual |
Determines if a generator can accept additional entropy.
Reimplemented from RandomNumberGenerator.
|
inlinevirtual |
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.
|
inlinevirtual |
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 contraints of a particular generator.
Reimplemented from RandomNumberGenerator.