Botan 1.10.17

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

`#include <entropy_src.h>`

Inheritance diagram for Botan::Entropy_Accumulator_BufferedComputation:

## Public Member Functions
void | add (const void *bytes, size_t length, double entropy_bits_per_byte)
template<typename T >
void | add (const T &v, double entropy_bits_per_byte)
size_t | bits_collected () const
size_t | desired_remaining_bits () const
| Entropy_Accumulator_BufferedComputation (Buffered_Computation &sink, size_t goal)
MemoryRegion< byte > & | get_io_buffer (size_t size)
bool | polling_goal_achieved () const

## Detailed Description

Entropy accumulator that puts the input into a Buffered_Computation

Definition at line 98 of file entropy_src.h.

## Constructor & Destructor Documentation

## ◆ Entropy_Accumulator_BufferedComputation()

Botan::Entropy_Accumulator_BufferedComputation::Entropy_Accumulator_BufferedComputation | ( | Buffered_Computation & | sink,
|  | size_t | goal
| ) |  |
| inline

Parameters

  sink | the hash or MAC we are feeding the poll data into
  goal | is how many bits we want to collect in this poll

Definition at line 106 of file entropy_src.h.

107 :
108 Entropy_Accumulator(goal), entropy_sink(sink) {}
Botan::Entropy_Accumulator::Entropy_Accumulator
Entropy_Accumulator(size_t goal)
Definition: entropy_src.h:26

## Member Function Documentation

## ◆ add() [1/2]

void Botan::Entropy_Accumulator::add | ( | const void * | bytes,
|  | size_t | length,
|  | double | entropy_bits_per_byte
| ) |  |
| inline inherited

Add entropy to the accumulator

Parameters

  bytes | the input bytes
  length | specifies how many bytes the input is
  entropy_bits_per_byte | is a best guess at how much entropy per byte is in this input

Definition at line 70 of file entropy_src.h.

Referenced by Botan::Win32_EntropySource::poll(), Botan::FTW_EntropySource::poll(), Botan::Win32_CAPI_EntropySource::poll(), Botan::High_Resolution_Timestamp::poll(), Botan::Device_EntropySource::poll(), Botan::EGD_EntropySource::poll(), and Botan::Unix_EntropySource::poll().

71 {
72 add_bytes(reinterpret_cast<const byte*>(bytes), length);
73 collected_bits += entropy_bits_per_byte * length;
74 }

## ◆ add() [2/2]

template<typename T >

void Botan::Entropy_Accumulator::add | ( | const T & | v,
|  | double | entropy_bits_per_byte
| ) |  |
| inline inherited

Add entropy to the accumulator

Parameters

  v | is some value
  entropy_bits_per_byte | is a best guess at how much entropy per byte is in this input

Definition at line 83 of file entropy_src.h.

84 {
85 add(&v, sizeof(T), entropy_bits_per_byte);
86 }
Botan::Entropy_Accumulator::add
void add(const void *bytes, size_t length, double entropy_bits_per_byte)
Definition: entropy_src.h:70

## ◆ bits_collected()

size_t Botan::Entropy_Accumulator::bits_collected | ( |  | ) | const
| inline inherited

Returns
  number of bits collected so far

Definition at line 44 of file entropy_src.h.

Referenced by Botan::Randpool::reseed(), and Botan::HMAC_RNG::reseed().

45 { return static_cast<size_t>(collected_bits); }

## ◆ desired_remaining_bits()

size_t Botan::Entropy_Accumulator::desired_remaining_bits | ( |  | ) | const
| inline inherited

Returns
  how many bits we need to reach our polling goal

Definition at line 56 of file entropy_src.h.

Referenced by Botan::Device_EntropySource::poll(), and Botan::EGD_EntropySource::poll().

57 {
58 if(collected_bits >= entropy_goal)
59 return 0;
60 return static_cast<size_t>(entropy_goal - collected_bits);
61 }

## ◆ get_io_buffer()

MemoryRegion<byte>& Botan::Entropy_Accumulator::get_io_buffer | ( | size_t | size | ) |
| inline inherited

Get a cached I/O buffer (purely for minimizing allocation overhead to polls)

Parameters

  size | requested size for the I/O buffer

Returns
  cached I/O buffer for repeated polls

Definition at line 38 of file entropy_src.h.

References Botan::MemoryRegion< T >::resize().

Referenced by Botan::FTW_EntropySource::poll(), Botan::Win32_CAPI_EntropySource::poll(), Botan::EGD_EntropySource::poll(), Botan::Device_EntropySource::poll(), and Botan::Unix_EntropySource::poll().

39 { io_buffer.resize(size); return io_buffer; }
Botan::MemoryRegion::resize
void resize(size_t n)
Definition: secmem.h:217

## ◆ polling_goal_achieved()

bool Botan::Entropy_Accumulator::polling_goal_achieved | ( |  | ) | const
| inline inherited

Returns
  if our polling goal has been achieved

Definition at line 50 of file entropy_src.h.

Referenced by Botan::Win32_EntropySource::poll(), Botan::FTW_EntropySource::poll(), Botan::Randpool::reseed(), and Botan::HMAC_RNG::reseed().

51 { return (collected_bits >= entropy_goal); }

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

- src/entropy/entropy_src.h