diff options
author | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
commit | a2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch) | |
tree | ad3d6c4fcc8dd0f403f8105598943616246fe172 /src/es_file.cpp |
Initial checkin1.5.6
Diffstat (limited to 'src/es_file.cpp')
-rw-r--r-- | src/es_file.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/es_file.cpp b/src/es_file.cpp new file mode 100644 index 000000000..8d2ea80fc --- /dev/null +++ b/src/es_file.cpp @@ -0,0 +1,33 @@ +/************************************************* +* File EntropySource Source File * +* (C) 1999-2006 The Botan Project * +*************************************************/ + +#include <botan/es_file.h> +#include <botan/conf.h> +#include <fstream> + +namespace Botan { + +/************************************************* +* Gather Entropy from Randomness Source * +*************************************************/ +u32bit File_EntropySource::slow_poll(byte output[], u32bit length) + { + std::vector<std::string> sources = Config::get_list("rng/es_files"); + + u32bit read = 0; + for(u32bit j = 0; j != sources.size(); ++j) + { + std::ifstream random_source(sources[j].c_str(), std::ios::binary); + if(!random_source) continue; + random_source.read((char*)output + read, length); + read += random_source.gcount(); + length -= random_source.gcount(); + if(length == 0) + break; + } + return read; + } + +} |