00001 /* 00002 * ANSI X9.31 RNG 00003 * (C) 1999-2009 Jack Lloyd 00004 * 00005 * Distributed under the terms of the Botan license 00006 */ 00007 00008 #ifndef BOTAN_ANSI_X931_RNG_H__ 00009 #define BOTAN_ANSI_X931_RNG_H__ 00010 00011 #include <botan/rng.h> 00012 #include <botan/block_cipher.h> 00013 00014 namespace Botan { 00015 00016 /** 00017 * ANSI X9.31 RNG 00018 */ 00019 class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator 00020 { 00021 public: 00022 void randomize(byte[], u32bit); 00023 bool is_seeded() const; 00024 void clear(); 00025 std::string name() const; 00026 00027 void reseed(u32bit poll_bits); 00028 void add_entropy_source(EntropySource*); 00029 void add_entropy(const byte[], u32bit); 00030 00031 /** 00032 * @param cipher the block cipher to use in this PRNG 00033 * @param rng the underlying PRNG for generating inputs 00034 * (eg, an HMAC_RNG) 00035 */ 00036 ANSI_X931_RNG(BlockCipher* cipher, 00037 RandomNumberGenerator* rng); 00038 ~ANSI_X931_RNG(); 00039 private: 00040 void rekey(); 00041 void update_buffer(); 00042 00043 BlockCipher* cipher; 00044 RandomNumberGenerator* prng; 00045 SecureVector<byte> V, R; 00046 u32bit position; 00047 }; 00048 00049 } 00050 00051 #endif
1.5.8