Crypto++
8.4
Free C++ class library of cryptographic schemes
|
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());
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();
108 void OldRandomPool::Stir()
112 for (
int i=0; i<2; i++)
114 cipher.SetKeyWithIV(key, key.
size(), pool.
end()-cipher.IVSize());
115 cipher.ProcessString(pool, pool.
size());
116 std::memcpy(key, pool, key.
size());
127 if (getPos == pool.
size())
138 if (getPos == pool.
size())
141 return pool[getPos++];
virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sets or reset the key of this object.
OldRandomPool(unsigned int poolSize=384)
Construct an OldRandomPool.
Debugging and diagnostic assertions.
Classes for block cipher modes of operation.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be neagtive and incorrectly promoted.
word64 TimerWord
TimerWord is a 64-bit word.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
unsigned long long word64
64-bit unsigned datatype
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
iterator end()
Provides an iterator pointing beyond the last element in the memory block.
Class file for Randomness Pool.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
Class file for the AES cipher (Rijndael)
Classes for SHA-1 and SHA-2 family of message digests.
Copy input to a memory buffer.
Classes for the MDC message digest.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
TimerWord GetCurrentTimerValue()
Retrieve the current timer value.
Block cipher mode of operation aggregate.
size_type size() const
Provides the count of elements in the SecBlock.
word64 lword
Large word type.
void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size)
Generate random bytes into a BufferedTransformation.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
RandomPool()
Construct a RandomPool.
Crypto++ library namespace.
void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size)
Generate random bytes into a BufferedTransformation.
CRYPTOPP_DLL void xorbuf(byte *buf, const byte *mask, size_t count)
Performs an XOR of a buffer with a mask.
A::pointer data()
Provides a pointer to the first element in the memory block.
AES block cipher (Rijndael)
byte GenerateByte()
Generate new random byte and return it.