generator: add ctr_inc() fun
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
715523eb1a
commit
1a02256b2b
|
@ -10,6 +10,7 @@
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -216,6 +217,22 @@ auto Generator::generate_random_data(const unsigned int& n) -> std::string {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Generator::ctr_inc() -> void {
|
||||||
|
// increment the least-significant-byte-first ctr
|
||||||
|
|
||||||
|
std::atomic<uint8_t> i{0};
|
||||||
|
while (true) {
|
||||||
|
this->G.counter.at(i) = static_cast<std::byte>(
|
||||||
|
static_cast<uint8_t>(this->G.counter.at(i)) + 0x01);
|
||||||
|
|
||||||
|
if (this->G.counter.at(i) == static_cast<std::byte>(0x00) &&
|
||||||
|
++i < this->G.counter.size()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace generator
|
} // namespace generator
|
||||||
} // namespace fortuna
|
} // namespace fortuna
|
||||||
|
|
|
@ -66,6 +66,8 @@ private:
|
||||||
|
|
||||||
auto generate_blocks(unsigned int k_blocks) -> std::string;
|
auto generate_blocks(unsigned int k_blocks) -> std::string;
|
||||||
|
|
||||||
|
auto ctr_inc() -> void;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
auto get_state() const -> Generator::G_state;
|
auto get_state() const -> Generator::G_state;
|
||||||
|
|
||||||
|
|
Reference in New Issue