Botan: Botan::FTW_EntropySource Class Reference

Botan 1.10.17

Public Member Functions | List of all members
Botan::FTW_EntropySource Class Reference

`#include <es_ftw.h>`

Inheritance diagram for Botan::FTW_EntropySource:

## Public Member Functions
| FTW_EntropySource (const std::string &root_dir)
std::string | name () const
void | poll (Entropy_Accumulator &accum)
| ~FTW_EntropySource ()

## Detailed Description

File Tree Walking Entropy Source

Definition at line 18 of file es_ftw.h.

## Constructor & Destructor Documentation

## ◆ FTW_EntropySource()

Botan::FTW_EntropySource::FTW_EntropySource | ( | const std::string & | p | ) |

FTW_EntropySource Constructor

Definition at line 136 of file es_ftw.cpp.

136 : path(p)
137 {
138 dir = 0;
139 }

## ◆ ~FTW_EntropySource()

Botan::FTW_EntropySource::~FTW_EntropySource | ( |  | ) |

FTW_EntropySource Destructor

Definition at line 144 of file es_ftw.cpp.

145 {
146 delete dir;
147 }

## Member Function Documentation

## ◆ name()

std::string Botan::FTW_EntropySource::name | ( |  | ) | const
| inlinevirtual

Returns
  name identifying this entropy source

Implements Botan::EntropySource.

Definition at line 21 of file es_ftw.h.

21 { return "Proc Walker"; }

## ◆ poll()

void Botan::FTW_EntropySource::poll | ( | Entropy_Accumulator & | accum | ) |
| virtual

Perform an entropy gathering poll

Parameters

  accum | is an accumulator object that will be given entropy

Implements Botan::EntropySource.

Definition at line 149 of file es_ftw.cpp.

References Botan::Entropy_Accumulator::add(), Botan::Entropy_Accumulator::get_io_buffer(), Botan::Entropy_Accumulator::polling_goal_achieved(), and Botan::MemoryRegion< T >::size().

150 {
151 const size_t MAX_FILES_READ_PER_POLL = 2048;
152
153 if(!dir)
154 dir = new Directory_Walker(path);
155
156 MemoryRegion<byte>& io_buffer = accum.get_io_buffer(4096);
157
158 for(size_t i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
159 {
160 int fd = dir->next_fd();
161
162 // If we've exhaused this walk of the directory, halt the poll
163 if(fd == -1)
164 {
165 delete dir;
166 dir = 0;
167 break;
168 }
169
170 ssize_t got = ::read(fd, &io_buffer[0], io_buffer.size());
171 ::close(fd);
172
173 if(got > 0)
174 accum.add(&io_buffer[0], got, .001);
175
176 if(accum.polling_goal_achieved())
177 break;
178 }
179 }

The documentation for this class was generated from the following files:

- src/entropy/proc_walk/es_ftw.h
- src/entropy/proc_walk/es_ftw.cpp