9#ifndef CRYPTOPP_IMPORTS
26 : m_pCipher(new
AES::Encryption), m_keySet(false)
28 std::memset(m_key, 0, m_key.SizeInBytes());
29 std::memset(m_seed, 0, m_seed.SizeInBytes());
35 hash.Update(m_key, 32);
36 hash.Update(input, length);
46 m_pCipher->
SetKey(m_key, 32);
55 time_t t = time(NULLPTR);
60 std::memcpy(&tt1, m_seed.
data()+8, 8);
61 std::memcpy(m_seed.
data()+8, &(tt2 += tt1), 8);
65 *((
volatile word64*)&tt1) = 0;
66 *((
volatile word64*)&tt2) = 0;
82 : pool(poolSize), key(OldRandomPoolCipher::DEFAULT_KEYLENGTH), addPos(0), getPos(poolSize)
85 std::memset(pool, 0, poolSize);
86 std::memset(key, 0, key.size());
92 while (length > (t = pool.
size() - addPos))
94 xorbuf(pool+addPos, input, t);
102 xorbuf(pool+addPos, input, length);
104 getPos = pool.
size();
112 const word32 range = max-min;
121 for (
unsigned int i=0; i<maxBytes; i++)
124 value =
Crop(value, maxBits);
125 }
while (value > range);
130void OldRandomPool::Stir()
134 for (
int i=0; i<2; i++)
136 cipher.SetKeyWithIV(key, key.
size(), pool.
end()-cipher.IVSize());
137 cipher.ProcessString(pool, pool.
size());
138 std::memcpy(key, pool, key.
size());
149 if (getPos == pool.
size())
160 if (getPos == pool.
size())
163 return pool[getPos++];
Class file for the AES cipher (Rijndael)
AES block cipher (Rijndael)
Copy input to a memory buffer.
Block cipher mode of operation aggregate.
void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size)
Generate random bytes into a BufferedTransformation.
word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL)
Generate a random 32 bit word in the range min to max, inclusive.
byte GenerateByte()
Generate new random byte and return it.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
OldRandomPool(unsigned int poolSize=384)
Construct an OldRandomPool.
RandomPool()
Construct a RandomPool.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size)
Generate random bytes into a BufferedTransformation.
iterator end()
Provides an iterator pointing beyond the last element in the memory block.
A::pointer data()
Provides a pointer to the first element in the memory block.
size_type size() const
Provides the count of elements in the SecBlock.
virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sets or reset the key of this object.
TimerWord GetCurrentTimerValue()
Retrieve the current timer value.
unsigned int word32
32-bit unsigned datatype
unsigned long long word64
64-bit unsigned datatype
word64 lword
Large word type.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
word64 TimerWord
TimerWord is a 64-bit word.
Classes for the MDC message digest.
unsigned int BitPrecision(const T &value)
Returns the number of bits required for a value.
unsigned int BytePrecision(const T &value)
Returns the number of 8-bit bytes or octets required for a value.
T Crop(T value, size_t bits)
Truncates the value to the specified number of bits.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be negative and incorrectly promoted.
CRYPTOPP_DLL void xorbuf(byte *buf, const byte *mask, size_t count)
Performs an XOR of a buffer with a mask.
Classes for block cipher modes of operation.
Crypto++ library namespace.
Class file for Randomness Pool.
Classes for SHA-1 and SHA-2 family of message digests.
Debugging and diagnostic assertions.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.