generator: create permanent Serpent encryption obj
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
1517b150ed
commit
c40806e68d
|
@ -4,10 +4,9 @@
|
|||
#include "generator.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <cryptopp/ccm.h>
|
||||
#include <cryptopp/filters.h>
|
||||
#include <cryptopp/hex.h>
|
||||
#include <cryptopp/serpent.h>
|
||||
#include <cryptopp/secblock.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -104,8 +103,7 @@ auto Generator::do_crypto() -> std::string {
|
|||
std::memmove(ctr, str_ctr.c_str(), ctr_length);
|
||||
|
||||
try {
|
||||
CryptoPP::CTR_Mode<CryptoPP::Serpent>::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
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#define FORTUNA_GENERATOR_H
|
||||
|
||||
#include <cryptopp/cryptlib.h>
|
||||
#include <cryptopp/modes.h>
|
||||
#include <cryptopp/secblock.h>
|
||||
#include <cryptopp/serpent.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
@ -42,6 +44,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
CryptoPP::CTR_Mode<CryptoPP::Serpent>::Encryption enc;
|
||||
struct G_state {
|
||||
// 32*8
|
||||
static constexpr const std::size_t k_length{32};
|
||||
|
|
Reference in New Issue