File: randpool.h

package info (click to toggle)
libcrypto%2B%2B 5.2.1c2a-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,192 kB
  • ctags: 6,735
  • sloc: cpp: 48,392; sh: 976; makefile: 423
file content (46 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef CRYPTOPP_RANDPOOL_H
#define CRYPTOPP_RANDPOOL_H

#include "cryptlib.h"
#include "filters.h"

NAMESPACE_BEGIN(CryptoPP)

//! Randomness Pool
/*! This class can be used to generate
	pseudorandom bytes after seeding the pool with
	the Put() methods */
class CRYPTOPP_DLL RandomPool : public RandomNumberGenerator,
				   public Bufferless<BufferedTransformation>
{
public:
	//! poolSize must be greater than 16
	RandomPool(unsigned int poolSize=384);

	unsigned int Put2(const byte *begin, unsigned int, int messageEnd, bool blocking);

	bool AnyRetrievable() const {return true;}
	unsigned long MaxRetrievable() const {return ULONG_MAX;}

	unsigned int TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel=NULL_CHANNEL, bool blocking=true);
	unsigned int CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end=ULONG_MAX, const std::string &channel=NULL_CHANNEL, bool blocking=true) const
	{
		throw NotImplemented("RandomPool: CopyRangeTo2() is not supported by this store");
	}

	byte GenerateByte();
	void GenerateBlock(byte *output, unsigned int size);

	void IsolatedInitialize(const NameValuePairs &parameters) {}

protected:
	void Stir();

private:
	SecByteBlock pool, key;
	unsigned int addPos, getPos;
};

NAMESPACE_END

#endif