monotone

monotone Mtn Source Tree

Root/botan/es_file.cpp

1/*************************************************
2* File EntropySource Source File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#include <botan/es_file.h>
7#include <botan/config.h>
8#include <fstream>
9
10namespace Botan {
11
12/*************************************************
13* Gather Entropy from Randomness Source *
14*************************************************/
15u32bit File_EntropySource::slow_poll(byte output[], u32bit length)
16 {
17 std::vector<std::string> sources =
18 global_config().option_as_list("rng/es_files");
19
20 u32bit read = 0;
21 for(u32bit j = 0; j != sources.size(); ++j)
22 {
23 std::ifstream random_source(sources[j].c_str(), std::ios::binary);
24 if(!random_source) continue;
25 random_source.read((char*)output + read, length);
26 read += random_source.gcount();
27 length -= random_source.gcount();
28 if(length == 0)
29 break;
30 }
31 return read;
32 }
33
34}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status