Fabcoin Core
0.16.2
P2P Digital Currency
|
ANSI X9.17 RNG. More...
#include <rng.h>
Public Member Functions | |
X917RNG (BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector=0) | |
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 | ~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 | |
virtual | ~Algorithm () |
Algorithm (bool checkSelfTestStatus=true) | |
Interface for all crypto algorithms. More... | |
virtual std::string | AlgorithmName () const |
Provides the name of this algorithm. More... | |
Public Member Functions inherited from Clonable | |
virtual | ~Clonable () |
virtual Clonable * | Clone () const |
Copies this object. More... | |
Public Member Functions inherited from NotCopyable | |
NotCopyable () | |
Private Attributes | |
member_ptr< BlockTransformation > | m_cipher |
const unsigned int | m_size |
SecByteBlock | m_datetime |
SecByteBlock | m_randseed |
SecByteBlock | m_lastBlock |
SecByteBlock | m_deterministicTimeVector |
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.
X917RNG::X917RNG | ( | BlockTransformation * | cipher, |
const byte * | seed, | ||
const byte * | deterministicTimeVector = 0 |
||
) |
Construct a X917RNG.
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, NULL);
Definition at line 61 of file rng.cpp.
|
virtual |
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 constraints of a particular generator.
Reimplemented from RandomNumberGenerator.
Definition at line 91 of file rng.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |