Botan 1.10.17
Botan::EGD_EntropySource Class Reference

#include <es_egd.h>

Inheritance diagram for Botan::EGD_EntropySource:
Botan::EntropySource

Public Member Functions

 EGD_EntropySource (const std::vector< std::string > &)
std::string name () const
void poll (Entropy_Accumulator &accum)
 ~EGD_EntropySource ()

Detailed Description

EGD Entropy Source

Definition at line 20 of file es_egd.h.

Constructor & Destructor Documentation

◆ EGD_EntropySource()

Botan::EGD_EntropySource::EGD_EntropySource ( const std::vector< std::string > & paths)

EGD_EntropySource constructor

Definition at line 122 of file es_egd.cpp.

123 {
124 for(size_t i = 0; i != paths.size(); ++i)
125 sockets.push_back(EGD_Socket(paths[i]));
126 }

◆ ~EGD_EntropySource()

Botan::EGD_EntropySource::~EGD_EntropySource ( )

Definition at line 128 of file es_egd.cpp.

129 {
130 for(size_t i = 0; i != sockets.size(); ++i)
131 sockets[i].close();
132 sockets.clear();
133 }

Member Function Documentation

◆ name()

std::string Botan::EGD_EntropySource::name ( ) const
inlinevirtual
Returns
name identifying this entropy source

Implements Botan::EntropySource.

Definition at line 23 of file es_egd.h.

23{ return "EGD/PRNGD"; }

◆ poll()

void Botan::EGD_EntropySource::poll ( Entropy_Accumulator & accum)
virtual

Gather Entropy from EGD

Implements Botan::EntropySource.

Definition at line 138 of file es_egd.cpp.

139 {
140 size_t go_get = std::min<size_t>(accum.desired_remaining_bits() / 8, 32);
141
142 MemoryRegion<byte>& io_buffer = accum.get_io_buffer(go_get);
143
144 for(size_t i = 0; i != sockets.size(); ++i)
145 {
146 size_t got = sockets[i].read(&io_buffer[0], io_buffer.size());
147
148 if(got)
149 {
150 accum.add(&io_buffer[0], got, 6);
151 break;
152 }
153 }
154 }

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


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