Security Scol plugin
randpool.h
Go to the documentation of this file.
1// randpool.h - originally written and placed in the public domain by Wei Dai
2// OldRandPool added by JW in August, 2017.
3
17
18#ifndef CRYPTOPP_RANDPOOL_H
19#define CRYPTOPP_RANDPOOL_H
20
21#include "cryptlib.h"
22#include "filters.h"
23#include "secblock.h"
24#include "smartptr.h"
25#include "aes.h"
26
27NAMESPACE_BEGIN(CryptoPP)
28
29
43class CRYPTOPP_DLL RandomPool : public RandomNumberGenerator, public NotCopyable
44{
45public:
47 RandomPool();
48
49 bool CanIncorporateEntropy() const {return true;}
50 void IncorporateEntropy(const byte *input, size_t length);
51 void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size);
52
53private:
57 bool m_keySet;
58};
59
74class CRYPTOPP_DLL OldRandomPool : public RandomNumberGenerator
75{
76public:
80 OldRandomPool(unsigned int poolSize=384);
81
82 // RandomNumberGenerator interface (Crypto++ 5.5 and above)
83 bool CanIncorporateEntropy() const {return true;}
84 void IncorporateEntropy(const byte *input, size_t length);
85 void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size);
86
87 byte GenerateByte();
88 void GenerateBlock(byte *output, size_t size);
89
90 // GenerateWord32 is overridden and provides Crypto++ 5.4 behavior.
91 // Taken from RandomNumberSource::GenerateWord32 in cryptlib.cpp.
92 word32 GenerateWord32 (word32 min=0, word32 max=0xffffffffUL);
93
94protected:
95 void Stir();
96
97private:
98 SecByteBlock pool, key;
99 size_t addPos, getPos;
100};
101
102NAMESPACE_END
103
104#endif
Class file for the AES cipher (Rijndael)
Interface for buffered transformations.
Definition cryptlib.h:1652
Fixed size stack-based SecBlock with 16-byte alignment.
Definition secblock.h:1259
Ensures an object is not copyable.
Definition misc.h:239
Randomness Pool based on PGP 2.6.x with MDC.
Definition randpool.h:75
bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
Definition randpool.h:83
Interface for random number generators.
Definition cryptlib.h:1435
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
Definition cryptlib.cpp:311
virtual void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length)
Generate random bytes into a BufferedTransformation.
Definition cryptlib.cpp:324
virtual void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
Definition cryptlib.h:1447
virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL)
Generate a random 32 bit word in the range min to max, inclusive.
Definition cryptlib.cpp:283
virtual byte GenerateByte()
Generate new random byte and return it.
Definition cryptlib.cpp:276
Randomness Pool based on AES-256.
Definition randpool.h:44
bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
Definition randpool.h:49
Pointer that overloads operator ->
Definition smartptr.h:38
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
word64 lword
Large word type.
Definition config_int.h:158
Abstract base classes that provide a uniform interface to this library.
Implementation of BufferedTransformation's attachment interface.
Classes and functions for secure memory allocations.
Classes for automatic resource management.