#include <x931_rng.h>

Public Member Functions | |
| void | add_entropy (const byte[], u32bit) |
| void | add_entropy_source (EntropySource *) |
| ANSI_X931_RNG (BlockCipher *cipher, RandomNumberGenerator *rng) | |
| void | clear () |
| bool | is_seeded () const |
| std::string | name () const |
| byte | next_byte () |
| void | randomize (byte[], u32bit) |
| void | reseed (u32bit poll_bits) |
| ~ANSI_X931_RNG () | |
Static Public Member Functions | |
| static RandomNumberGenerator * | make_rng () |
Definition at line 19 of file x931_rng.h.
| Botan::ANSI_X931_RNG::ANSI_X931_RNG | ( | BlockCipher * | cipher, | |
| RandomNumberGenerator * | rng | |||
| ) |
| cipher | the block cipher to use in this PRNG | |
| rng | the underlying PRNG for generating inputs (eg, an HMAC_RNG) |
Definition at line 132 of file x931_rng.cpp.
References Botan::BlockCipher::BLOCK_SIZE, and Botan::MemoryRegion< T >::resize().
00134 { 00135 if(!prng_in || !cipher_in) 00136 throw Invalid_Argument("ANSI_X931_RNG constructor: NULL arguments"); 00137 00138 cipher = cipher_in; 00139 prng = prng_in; 00140 00141 R.resize(cipher->BLOCK_SIZE); 00142 position = 0; 00143 }
| Botan::ANSI_X931_RNG::~ANSI_X931_RNG | ( | ) |
| void Botan::ANSI_X931_RNG::add_entropy | ( | const | in[], | |
| u32bit | length | |||
| ) | [virtual] |
Add entropy to this RNG.
| in | a byte array containg the entropy to be added | |
| length | the length of the byte array in |
Implements Botan::RandomNumberGenerator.
Definition at line 94 of file x931_rng.cpp.
References Botan::RandomNumberGenerator::add_entropy().
| void Botan::ANSI_X931_RNG::add_entropy_source | ( | EntropySource * | source | ) | [virtual] |
Add this entropy source to the RNG object
| source | the entropy source which will be retained and used by RNG |
Implements Botan::RandomNumberGenerator.
Definition at line 86 of file x931_rng.cpp.
References Botan::RandomNumberGenerator::add_entropy_source().
| void Botan::ANSI_X931_RNG::clear | ( | ) | [virtual] |
Clear all internally held values of this RNG.
Implements Botan::RandomNumberGenerator.
Definition at line 111 of file x931_rng.cpp.
References Botan::MemoryRegion< T >::clear(), Botan::RandomNumberGenerator::clear(), Botan::BlockCipher::clear(), and Botan::MemoryRegion< T >::destroy().
00112 { 00113 cipher->clear(); 00114 prng->clear(); 00115 R.clear(); 00116 V.destroy(); 00117 00118 position = 0; 00119 }
| bool Botan::ANSI_X931_RNG::is_seeded | ( | ) | const [virtual] |
Check whether this RNG is seeded.
Reimplemented from Botan::RandomNumberGenerator.
Definition at line 103 of file x931_rng.cpp.
References Botan::MemoryRegion< T >::size().
Referenced by randomize().
| RandomNumberGenerator * Botan::RandomNumberGenerator::make_rng | ( | ) | [static, inherited] |
Create a seeded and active RNG object for general application use
Definition at line 29 of file rng.cpp.
00030 { 00031 #if defined(BOTAN_HAS_AUTO_SEEDING_RNG) 00032 return new AutoSeeded_RNG; 00033 #endif 00034 00035 throw Algorithm_Not_Found("RandomNumberGenerator::make_rng - no RNG found"); 00036 }
| std::string Botan::ANSI_X931_RNG::name | ( | ) | const [virtual] |
Return the name of this object
Implements Botan::RandomNumberGenerator.
Definition at line 124 of file x931_rng.cpp.
References Botan::SymmetricAlgorithm::name().
Referenced by randomize().
| byte Botan::RandomNumberGenerator::next_byte | ( | ) | [inherited] |
Return a random byte
Definition at line 19 of file rng.cpp.
References Botan::RandomNumberGenerator::randomize().
Referenced by Botan::random_prime().
Randomize a byte array.
| output | the byte array to hold the random output. | |
| length | the length of the byte array output. |
Implements Botan::RandomNumberGenerator.
Definition at line 17 of file x931_rng.cpp.
References Botan::copy_mem(), is_seeded(), name(), and Botan::MemoryRegion< T >::size().
00018 { 00019 if(!is_seeded()) 00020 throw PRNG_Unseeded(name()); 00021 00022 while(length) 00023 { 00024 if(position == R.size()) 00025 update_buffer(); 00026 00027 const u32bit copied = std::min(length, R.size() - position); 00028 00029 copy_mem(out, R + position, copied); 00030 out += copied; 00031 length -= copied; 00032 position += copied; 00033 } 00034 }
| void Botan::ANSI_X931_RNG::reseed | ( | u32bit | bits_to_collect | ) | [virtual] |
Seed this RNG using the entropy sources it contains.
| bits_to_collect | is the number of bits of entropy to attempt to gather from the entropy sources |
Implements Botan::RandomNumberGenerator.
Definition at line 77 of file x931_rng.cpp.
References Botan::RandomNumberGenerator::reseed().
1.5.8