Crypto++ 8.4 Free C++ class library of cryptographic schemes

Public Member Functions | List of all members
X917RNG Class Reference

ANSI X9.17 RNG. More...

Inheritance diagram for X917RNG:

## Public Member Functions
| X917RNG (BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector=NULL)
| Construct a X917RNG. More...
void | GenerateIntoBufferedTransformation (BufferedTransformation &target, const std::string &channel, lword size)
| Generate random bytes into a BufferedTransformation. More...
Public Member Functions inherited from RandomNumberGenerator
virtual void | IncorporateEntropy (const byte *input, size_t length)
| Update RNG state with additional unpredictable values. More...
virtual bool | CanIncorporateEntropy () const
| Determines if a generator can accept additional entropy. 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...
Public Member Functions inherited from Algorithm
| Algorithm (bool checkSelfTestStatus=true)
| Interface for all crypto algorithms. More...
virtual std::string | AlgorithmName () const
| Provides the name of this algorithm. More...
virtual std::string | AlgorithmProvider () const
| Retrieve the provider of this algorithm. More...
Public Member Functions inherited from Clonable
virtual Clonable * | Clone () const
| Copies this object. More...

## Detailed Description

ANSI X9.17 RNG.

X917RNG is from ANSI X9.17 Appendix C, and it uses a 64-bit block cipher, like TripleDES. If you use a 128-bit block cipher, like AES, then you are effectively using an ANSI X9.31 generator.

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

See also
  AutoSeededX917RNG, DefaultAutoSeededRNG

Definition at line 49 of file rng.h.

## Constructor & Destructor Documentation

## ◆ X917RNG()

X917RNG::X917RNG | ( | BlockTransformation * | cipher,
|  | const byte * | seed,
|  | const byte * | deterministicTimeVector = `NULL`
| ) |  |

Construct a X917RNG.

Parameters

  cipher | the block cipher to use for the generator
  seed | a byte buffer to use as a seed
  deterministicTimeVector | additional entropy

`cipher` will be deleted by the destructor. `seed` must be at least BlockSize() in length. `deterministicTimeVector = 0` means obtain time vector from the system.

When constructing a X917RNG, the generator must be keyed or an access violation will occur because the time vector is encrypted using the block cipher. To key the generator during constructions, perform the following:

     SecByteBlock key(AES::DEFAULT_KEYLENGTH), seed(AES::BLOCKSIZE);
     OS_GenerateRandomBlock(false, key, key.size());
     OS_GenerateRandomBlock(false, seed, seed.size());
     X917RNG prng(new AES::Encryption(key, AES::DEFAULT_KEYLENGTH), seed, NULLPTR);

See also
  AutoSeededX917RNG

## Member Function Documentation

## ◆ GenerateIntoBufferedTransformation()

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

Generate random bytes into a BufferedTransformation.

Parameters

  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.

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

Reimplemented from RandomNumberGenerator.

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

- rng.h