Botan  1.11.15
src/lib/rng/auto_rng/auto_rng.h
Go to the documentation of this file.
00001 /*
00002 * Auto Seeded RNG
00003 * (C) 2008 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_AUTO_SEEDING_RNG_H__
00009 #define BOTAN_AUTO_SEEDING_RNG_H__
00010 
00011 #include <botan/rng.h>
00012 #include <string>
00013 
00014 namespace Botan {
00015 
00016 class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator
00017    {
00018    public:
00019       void randomize(byte out[], size_t len)
00020          { m_rng->randomize(out, len); }
00021 
00022       bool is_seeded() const { return m_rng->is_seeded(); }
00023 
00024       void clear() { m_rng->clear(); }
00025 
00026       std::string name() const { return m_rng->name(); }
00027 
00028       void reseed(size_t poll_bits = 256) { m_rng->reseed(poll_bits); }
00029 
00030       void add_entropy(const byte in[], size_t len)
00031          { m_rng->add_entropy(in, len); }
00032 
00033       AutoSeeded_RNG() : m_rng(RandomNumberGenerator::make_rng()) {}
00034    private:
00035       std::unique_ptr<RandomNumberGenerator> m_rng;
00036    };
00037 
00038 }
00039 
00040 #endif