Crypto++ 8.9
Free C++ class library of cryptographic schemes
Public Member Functions | Static Public Member Functions | List of all members
AutoSeededX917RNG< BLOCK_CIPHER > Class Template Reference

Automatically Seeded X9.17 RNG. More...

#include <osrng.h>

+ Inheritance diagram for AutoSeededX917RNG< BLOCK_CIPHER >:

Public Member Functions

 AutoSeededX917RNG (bool blocking=false, bool autoSeed=true)
 Construct an AutoSeededX917RNG.
 
void Reseed (bool blocking=false, const byte *input=NULL, size_t length=0)
 Reseed an AutoSeededX917RNG.
 
void Reseed (const byte *key, size_t keylength, const byte *seed, const byte *timeVector)
 Deterministically reseed an AutoSeededX917RNG for testing.
 
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 length)
 Generate random bytes into a BufferedTransformation.
 
std::string AlgorithmProvider () const
 Retrieve the provider of this algorithm.
 
- 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.
 
- Public Member Functions inherited from Clonable
virtual ClonableClone () const
 Copies this object.
 

Static Public Member Functions

static std::string StaticAlgorithmName ()
 

Detailed Description

template<class BLOCK_CIPHER>
class AutoSeededX917RNG< BLOCK_CIPHER >

Automatically Seeded X9.17 RNG.

Template Parameters
BLOCK_CIPHERa 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.

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

See also
X917RNG, DefaultAutoSeededRNG

Definition at line 190 of file osrng.h.

Constructor & Destructor Documentation

◆ ~AutoSeededX917RNG()

template<class BLOCK_CIPHER >
AutoSeededX917RNG< BLOCK_CIPHER >::~AutoSeededX917RNG ( )
inline

Definition at line 197 of file osrng.h.

◆ AutoSeededX917RNG()

template<class BLOCK_CIPHER >
AutoSeededX917RNG< BLOCK_CIPHER >::AutoSeededX917RNG ( bool blocking = false,
bool autoSeed = true )
inlineexplicit

Construct an AutoSeededX917RNG.

Parameters
blockingcontrols seeding with BlockingRng or NonblockingRng
autoSeedcontrols 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.

See also
X917RNG

Definition at line 205 of file osrng.h.

Member Function Documentation

◆ StaticAlgorithmName()

template<class BLOCK_CIPHER >
static std::string AutoSeededX917RNG< BLOCK_CIPHER >::StaticAlgorithmName ( )
inlinestatic

Definition at line 193 of file osrng.h.

◆ Reseed() [1/2]

template<class BLOCK_CIPHER >
void AutoSeededX917RNG< BLOCK_CIPHER >::Reseed ( bool blocking = false,
const byte * input = NULL,
size_t length = 0 )

Reseed an AutoSeededX917RNG.

Parameters
blockingcontrols seeding with BlockingRng or NonblockingRng
inputadditional entropy to add to the generator
lengththe 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.

Definition at line 244 of file osrng.h.

◆ Reseed() [2/2]

template<class BLOCK_CIPHER >
void AutoSeededX917RNG< BLOCK_CIPHER >::Reseed ( const byte * key,
size_t keylength,
const byte * seed,
const byte * timeVector )

Deterministically reseed an AutoSeededX917RNG for testing.

Parameters
keythe key to use for the deterministic reseeding
keylengththe size of the key, in bytes
seedthe seed to use for the deterministic reseeding
timeVectora time vector to use for deterministic reseeding

This is a testing interface for testing purposes, and should NOT be used in production.

Definition at line 238 of file osrng.h.

◆ CanIncorporateEntropy()

template<class BLOCK_CIPHER >
bool AutoSeededX917RNG< BLOCK_CIPHER >::CanIncorporateEntropy ( ) const
inlinevirtual

Determines if a generator can accept additional entropy.

Returns
true if IncorporateEntropy() is implemented

Reimplemented from RandomNumberGenerator.

Definition at line 226 of file osrng.h.

◆ IncorporateEntropy()

template<class BLOCK_CIPHER >
void AutoSeededX917RNG< BLOCK_CIPHER >::IncorporateEntropy ( const byte * input,
size_t length )
inlinevirtual

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.

Definition at line 227 of file osrng.h.

◆ GenerateIntoBufferedTransformation()

template<class BLOCK_CIPHER >
void AutoSeededX917RNG< BLOCK_CIPHER >::GenerateIntoBufferedTransformation ( BufferedTransformation & target,
const std::string & channel,
lword length )
inlinevirtual

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.

Definition at line 228 of file osrng.h.

◆ AlgorithmProvider()

template<class BLOCK_CIPHER >
std::string AutoSeededX917RNG< BLOCK_CIPHER >::AlgorithmProvider ( ) const
virtual

Retrieve the provider of this algorithm.

Returns
the algorithm provider

The algorithm provider can be a name like "C++", "SSE", "NEON", "AESNI", "ARMv8" and "Power8". C++ is standard C++ code. Other labels, like SSE, usually indicate a specialized implementation using instructions from a higher instruction set architecture (ISA). Future labels may include external hardware like a hardware security module (HSM).

Generally speaking Wei Dai's original IA-32 ASM code falls under "SSE2". Labels like "SSSE3" and "SSE4.1" follow after Wei's code and use intrinsics instead of ASM.

Algorithms which combine different instructions or ISAs provide the dominant one. For example on x86 AES/GCM returns "AESNI" rather than "CLMUL" or "AES+SSE4.1" or "AES+CLMUL" or "AES+SSE4.1+CLMUL".

Note
Provider is not universally implemented yet.
Since
Crypto++ 8.0

Reimplemented from Algorithm.

Definition at line 274 of file osrng.h.


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