2021-12-04 00:19:22 +01:00
|
|
|
#ifndef FORTUNA_POOL_H
|
|
|
|
#define FORTUNA_POOL_H
|
|
|
|
|
2021-12-13 02:18:37 +01:00
|
|
|
#include "util.h"
|
2021-12-11 02:53:47 +01:00
|
|
|
|
2021-12-04 00:19:22 +01:00
|
|
|
|
|
|
|
namespace fortuna {
|
|
|
|
namespace accumulator {
|
|
|
|
|
|
|
|
class Pool {
|
|
|
|
public:
|
2022-01-02 07:55:58 +01:00
|
|
|
Pool() noexcept {};
|
2022-01-03 02:49:23 +01:00
|
|
|
Pool(const Pool& pool) = delete; // no copy
|
2022-01-02 07:55:58 +01:00
|
|
|
~Pool() noexcept = default;
|
2021-12-04 00:19:22 +01:00
|
|
|
|
2022-01-17 07:49:03 +01:00
|
|
|
auto set_id(const unsigned int& id) noexcept -> void;
|
2021-12-04 00:19:22 +01:00
|
|
|
|
2022-01-17 07:49:03 +01:00
|
|
|
auto get_id() const noexcept -> unsigned int;
|
2021-12-04 00:19:22 +01:00
|
|
|
|
2022-01-17 07:49:03 +01:00
|
|
|
auto initialize_pool(const unsigned int& id) -> void;
|
2021-12-04 00:19:22 +01:00
|
|
|
|
2021-12-13 04:59:11 +01:00
|
|
|
// add entropy contained in a random event of 1 to 32 bytes
|
2022-01-10 05:07:18 +01:00
|
|
|
auto add_entropy(const uint source, const std::vector<char>& event) -> int;
|
|
|
|
|
|
|
|
auto get_s_length() const -> uint64_t;
|
|
|
|
|
|
|
|
auto get_s() const -> std::string;
|
|
|
|
|
|
|
|
auto clear_pool() -> void;
|
2021-12-13 04:59:11 +01:00
|
|
|
|
2021-12-11 02:53:47 +01:00
|
|
|
protected:
|
2022-01-10 05:07:18 +01:00
|
|
|
auto append_s(const std::string& entropy_s) -> void;
|
2021-12-11 02:53:47 +01:00
|
|
|
|
2021-12-04 00:19:22 +01:00
|
|
|
private:
|
|
|
|
unsigned int pool_id{0};
|
2021-12-11 02:53:47 +01:00
|
|
|
std::string s{""};
|
|
|
|
uint64_t size{0};
|
2021-12-04 00:19:22 +01:00
|
|
|
|
|
|
|
}; // class Pool
|
|
|
|
|
2022-01-10 04:25:03 +01:00
|
|
|
} // namespace accumulator
|
|
|
|
} // namespace fortuna
|
2021-12-04 00:19:22 +01:00
|
|
|
|
2022-01-10 04:25:03 +01:00
|
|
|
#endif // FORTUNA_POOL_H
|