Botan
1.11.15
|
00001 /* 00002 * ANSI X9.31 RNG 00003 * (C) 1999-2009 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 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[], size_t); 00023 bool is_seeded() const; 00024 void clear(); 00025 std::string name() const; 00026 00027 void reseed(size_t poll_bits); 00028 void add_entropy(const byte[], size_t); 00029 00030 /** 00031 * @param cipher the block cipher to use in this PRNG 00032 * @param rng the underlying PRNG for generating inputs 00033 * (eg, an HMAC_RNG) 00034 */ 00035 ANSI_X931_RNG(BlockCipher* cipher, 00036 RandomNumberGenerator* rng); 00037 00038 private: 00039 void rekey(); 00040 void update_buffer(); 00041 00042 std::unique_ptr<BlockCipher> m_cipher; 00043 std::unique_ptr<RandomNumberGenerator> m_prng; 00044 secure_vector<byte> m_V, m_R; 00045 size_t m_R_pos; 00046 }; 00047 00048 } 00049 00050 #endif