7 #ifndef CRYPTOPP_OSRNG_H 8 #define CRYPTOPP_OSRNG_H 12 #ifdef OS_RNG_AVAILABLE 34 #ifdef NONBLOCKING_RNG_AVAILABLE 36 #ifdef CRYPTOPP_WIN32_AVAILABLE 48 #if defined(__CYGWIN__) && defined(__x86_64__) 49 typedef unsigned long long ProviderHandle;
50 #elif defined(WIN64) || defined(_WIN64) 51 typedef unsigned __int64 ProviderHandle;
53 typedef unsigned long ProviderHandle;
63 ProviderHandle m_hProvider;
67 # pragma comment(lib, "advapi32.lib") 70 #endif //CRYPTOPP_WIN32_AVAILABLE 89 #ifdef CRYPTOPP_WIN32_AVAILABLE 90 # ifndef WORKAROUND_MS_BUG_Q258000 100 #if defined(BLOCKING_RNG_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) 149 {Reseed(blocking, seedSize);}
154 void Reseed(
bool blocking =
false,
unsigned int seedSize = 32);
166 template <
class BLOCK_CIPHER>
177 {
if (autoSeed) Reseed(blocking);}
186 void Reseed(
bool blocking =
false,
const byte *additionalEntropy = NULL,
size_t length = 0);
195 void Reseed(
const byte *key,
size_t keylength,
const byte *seed,
const byte *timeVector);
200 {m_rng->GenerateIntoBufferedTransformation(target, channel, length);}
206 template <
class BLOCK_CIPHER>
209 m_rng.reset(
new X917RNG(
new typename BLOCK_CIPHER::Encryption(key, keylength), seed, timeVector));
212 template <
class BLOCK_CIPHER>
215 SecByteBlock seed(BLOCK_CIPHER::BLOCKSIZE + BLOCK_CIPHER::DEFAULT_KEYLENGTH);
223 hash.Update(seed, seed.
size());
224 hash.Update(input, length);
227 key = seed + BLOCK_CIPHER::BLOCKSIZE;
229 while (memcmp(key, seed,
STDMIN((
unsigned int)BLOCK_CIPHER::BLOCKSIZE, (
unsigned int)BLOCK_CIPHER::DEFAULT_KEYLENGTH)) == 0);
231 Reseed(key, BLOCK_CIPHER::DEFAULT_KEYLENGTH, seed, NULL);
236 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) 245 #if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 250 #endif // CRYPTOPP_DOXYGEN_PROCESSING Base class for all exceptions thrown by Crypto++.
AutoSeededRandomPool(bool blocking=false, unsigned int seedSize=32)
Construct an AutoSeededRandomPool.
Wrapper for Microsoft crypto service provider.
implements the SHA-256 standard
Wrapper class for /dev/random and /dev/srandom.
void Reseed(bool blocking=false, const byte *additionalEntropy=NULL, size_t length=0)
Reseed an AutoSeededX917RNG.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
Abstract base classes that provide a uniform interface to this library.
size_type size() const
Provides the count of elements in the SecBlock.
Classes for automatic resource management.
Library configuration file.
Interface for random number generators.
SecByteBlock is a SecBlock<byte> typedef.
void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length)
Generate random bytes into a BufferedTransformation.
Exception thrown when an operating system error is encountered.
Automatically Seeded Randomness Pool.
Class file for the AES cipher (Rijndael)
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be neagtive and incorrectly promoted.
Miscellaneous classes for RNGs.
Automatically Seeded X9.17 RNG.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
Classes for SHA-1 and SHA-2 family of message digests.
Wrapper class for /dev/random and /dev/srandom.
Classes and functions for the FIPS 140-2 validated library.
bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
void OS_GenerateRandomBlock(bool blocking, byte *output, size_t size)
OS_GenerateRandomBlock.
AutoSeededX917RNG(bool blocking=false, bool autoSeed=true)
Construct an AutoSeededX917RNG.
ProviderHandle GetProviderHandle() const
Retrieves the CryptoAPI provider handle.
Crypto++ library namespace.
Ensures an object is not copyable.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
A typedef providing a default generator.