2021-12-11 02:24:40 +01:00
|
|
|
#ifndef FORTUNA_URANDOM_ENTROPY_SRC_H
|
|
|
|
#define FORTUNA_URANDOM_ENTROPY_SRC_H
|
|
|
|
|
|
|
|
#include "entropy_src.h"
|
2022-01-13 05:40:33 +01:00
|
|
|
#include "event_adder_impl.h"
|
2021-12-11 02:24:40 +01:00
|
|
|
|
|
|
|
#include <fmt/core.h>
|
2022-01-13 05:40:33 +01:00
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2021-12-11 02:24:40 +01:00
|
|
|
#include <fstream>
|
2022-01-17 08:27:24 +01:00
|
|
|
#include <mutex>
|
2022-01-13 05:40:33 +01:00
|
|
|
#include <vector>
|
2021-12-11 02:24:40 +01:00
|
|
|
|
|
|
|
namespace fortuna {
|
|
|
|
namespace accumulator {
|
|
|
|
|
|
|
|
class UrandomEntropySrc : public EntropySrc {
|
2022-01-13 05:40:33 +01:00
|
|
|
private:
|
2022-01-17 08:27:24 +01:00
|
|
|
std::vector<char> bytes{0};
|
|
|
|
std::mutex mtx;
|
2022-01-13 05:40:33 +01:00
|
|
|
|
2021-12-11 02:24:40 +01:00
|
|
|
public:
|
2022-02-03 01:17:47 +01:00
|
|
|
auto event(accumulator::EventAdderImpl& adder) -> void override;
|
2022-01-02 07:46:28 +01:00
|
|
|
|
2022-01-13 05:40:33 +01:00
|
|
|
auto urandom_entropy_src_service() -> int;
|
2022-01-17 08:27:24 +01:00
|
|
|
|
|
|
|
UrandomEntropySrc();
|
|
|
|
~UrandomEntropySrc() noexcept;
|
2021-12-11 02:24:40 +01:00
|
|
|
};
|
|
|
|
|
2022-01-10 04:25:03 +01:00
|
|
|
} // namespace accumulator
|
|
|
|
} // namespace fortuna
|
|
|
|
#endif // FORTUNA_URANDOM_ENTROPY_SRC_H
|