aboutsummaryrefslogtreecommitdiffstats
path: root/include/sha1prng.h
blob: 8237f57c09d63b12fe01a2b390c80b7e61950fdd (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
40
41
/*************************************************
* SHA1PRNG RNG Header File                       *
* (C) 2007 FlexSecure GmbH / Manuel Hartl        *
* (C) 2008 Jack Lloyd                            *
*************************************************/

#ifndef BOTAN_SHA1PRNG_H__
#define BOTAN_SHA1PRNG_H__

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

namespace Botan {

/*************************************************
* SHA1PRNG                                       *
*************************************************/
class SHA1PRNG : public RandomNumberGenerator
   {
   public:
      void randomize(byte[], u32bit) throw(PRNG_Unseeded);
      bool is_seeded() const;
      void clear() throw();
      std::string name() const;

      SHA1PRNG(RandomNumberGenerator* = 0);
      ~SHA1PRNG();
   private:
      void add_randomness(const byte[], u32bit);
      void update_state(byte[]);

      RandomNumberGenerator* prng;
      HashFunction* hash;
      SecureVector<byte> buffer;
      SecureVector<byte> state;
      int buf_pos;
   };

}

#endif