diff --git a/generator.cpp b/generator.cpp index ae6f07a..5f1770a 100644 --- a/generator.cpp +++ b/generator.cpp @@ -4,10 +4,9 @@ #include "generator.h" #include "util.h" -#include #include #include -#include +#include #include #include @@ -104,8 +103,7 @@ auto Generator::do_crypto() -> std::string { std::memmove(ctr, str_ctr.c_str(), ctr_length); try { - CryptoPP::CTR_Mode::Encryption e; - e.SetKeyWithIV(G.k, G.k.size(), ctr); + this->enc.SetKeyWithIV(G.k, G.k.size(), ctr); // The StreamTransformationFilter adds padding as required. ECB and // CBC Mode must be padded to the block size of the cipher. CTR @@ -116,7 +114,7 @@ auto Generator::do_crypto() -> std::string { plain, true, new CryptoPP::StreamTransformationFilter( - e, + this->enc, new CryptoPP::StringSink(cipher)) // StreamTransformationFilter ); // StringSource } diff --git a/generator.h b/generator.h index 7f8bd71..3952190 100644 --- a/generator.h +++ b/generator.h @@ -2,7 +2,9 @@ #define FORTUNA_GENERATOR_H #include +#include #include +#include #include #include @@ -42,6 +44,7 @@ public: private: + CryptoPP::CTR_Mode::Encryption enc; struct G_state { // 32*8 static constexpr const std::size_t k_length{32};