aboutsummaryrefslogtreecommitdiffstats
path: root/src/entropy/buf_es/buf_es.h
blob: 5748613da541f5f4872c03f6611366cc137cb633 (plain)
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
/*************************************************
* Buffered EntropySource Header File             *
* (C) 1999-2007 Jack Lloyd                       *
*************************************************/

#ifndef BOTAN_BUFFERED_ES_H__
#define BOTAN_BUFFERED_ES_H__

#include <botan/rng.h>
#include <botan/secmem.h>

namespace Botan {

/*************************************************
* Buffered EntropySource                         *
*************************************************/
class BOTAN_DLL Buffered_EntropySource : public EntropySource
   {
   public:
      u32bit slow_poll(byte[], u32bit);
      u32bit fast_poll(byte[], u32bit);
   protected:
      Buffered_EntropySource();
      u32bit copy_out(byte[], u32bit, u32bit);

      void add_bytes(const void*, u32bit);
      void add_bytes(u64bit);

      virtual void do_slow_poll() = 0;
      virtual void do_fast_poll();
   private:
      SecureVector<byte> buffer;
      u32bit write_pos, read_pos;
      bool done_slow_poll;
   };

}

#endif