~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to src/es_file.cpp

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*************************************************
2
 
* File EntropySource Source File                 *
3
 
* (C) 1999-2007 The Botan Project                *
4
 
*************************************************/
5
 
 
6
 
#include <botan/es_file.h>
7
 
#include <botan/config.h>
8
 
#include <fstream>
9
 
 
10
 
namespace Botan {
11
 
 
12
 
/*************************************************
13
 
* Gather Entropy from Randomness Source          *
14
 
*************************************************/
15
 
u32bit 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
 
}