blob: 8d2ea80fc6c282f9bd3f049822ee0472e64663ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
}
}
|