This commit is contained in:
parent
33f6620662
commit
872e6f7f9f
|
@ -181,7 +181,7 @@ add_subdirectory(lib/fmt EXCLUDE_FROM_ALL)
|
|||
endif(NOT CMAKE_EXE_LINKER_FLAGS MATCHES "-fuse-ld=lld")
|
||||
endif()
|
||||
|
||||
add_executable(fortuna main.cpp generator.cpp generator.h fortuna.cpp fortuna.h accumulator.cpp accumulator.h pool.cpp pool.h event_adder.h)
|
||||
add_executable(fortuna main.cpp generator.cpp generator.h fortuna.cpp fortuna.h accumulator.cpp accumulator.h pool.cpp pool.h event_adder.h event_adder_impl.h)
|
||||
# ref: https://cmake.org/pipermail/cmake/2016-May/063400.html
|
||||
target_link_libraries(fortuna
|
||||
PRIVATE cryptopp
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef FORTUNA_EVENT_ADDER_IMPL_H
|
||||
#define FORTUNA_EVENT_ADDER_IMPL_H
|
||||
|
||||
#include "event_adder.h"
|
||||
#include "pool.h"
|
||||
|
||||
namespace fortuna {
|
||||
namespace accumulator {
|
||||
|
||||
class EventAdderImpl final : public EventAdder {
|
||||
private:
|
||||
int pool;
|
||||
static unsigned int source_id;
|
||||
static accumulator::Pool pools[32];
|
||||
|
||||
public:
|
||||
EventAdderImpl(const unsigned int source_id, const accumulator::Pool pools[32]) {
|
||||
this->source_id = source_id;
|
||||
for (unsigned int i = 0; i < pools.size(); i++) {
|
||||
this->pools[i] = pools[i];
|
||||
}
|
||||
this->pool = 0;
|
||||
}
|
||||
|
||||
void add(std::vector<char> event) override {
|
||||
this->pool = (this->pool + 1) % pools.size();
|
||||
pools[this->pool].add_entropy(source_id, event);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} //namespace accumulator
|
||||
} //namespace fortuna
|
||||
#endif//FORTUNA_EVENT_ADDER_IMPL_H
|
Reference in New Issue