Botan 1.10.17
randpool.h
Go to the documentation of this file.
1/*
2* Randpool
3* (C) 1999-2008 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_RANDPOOL_H__
9#define BOTAN_RANDPOOL_H__
10
11#include <botan/rng.h>
12#include <botan/block_cipher.h>
13#include <botan/mac.h>
14#include <vector>
15
16namespace Botan {
17
18/**
19* Randpool
20*/
21class BOTAN_DLL Randpool : public RandomNumberGenerator
22 {
23 public:
24 void randomize(byte[], size_t);
25 bool is_seeded() const { return seeded; }
26 void clear();
27 std::string name() const;
28
29 void reseed(size_t bits_to_collect);
30 void add_entropy_source(EntropySource* es);
31 void add_entropy(const byte input[], size_t length);
32
33 /**
34 * @param cipher a block cipher to use
35 * @param mac a message authentication code to use
36 * @param pool_blocks how many cipher blocks to use for the pool
37 * @param iterations_before_reseed how many times we'll use the
38 * internal state to generate output before reseeding
39 */
40 Randpool(BlockCipher* cipher,
42 size_t pool_blocks = 32,
43 size_t iterations_before_reseed = 128);
44
45 ~Randpool();
46 private:
47 void update_buffer();
48 void mix_pool();
49
50 size_t ITERATIONS_BEFORE_RESEED, POOL_BLOCKS;
51 BlockCipher* cipher;
53
54 std::vector<EntropySource*> entropy_sources;
55 SecureVector<byte> pool, buffer, counter;
56 bool seeded;
57 };
58
59}
60
61#endif
void randomize(byte[], size_t)
Definition randpool.cpp:32
bool is_seeded() const
Definition randpool.h:25
Randpool(BlockCipher *cipher, MessageAuthenticationCode *mac, size_t pool_blocks=32, size_t iterations_before_reseed=128)
Definition randpool.cpp:169