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 "generator.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <cryptopp/ccm.h>
|
|
||||||
#include <cryptopp/filters.h>
|
#include <cryptopp/filters.h>
|
||||||
#include <cryptopp/hex.h>
|
#include <cryptopp/hex.h>
|
||||||
#include <cryptopp/serpent.h>
|
#include <cryptopp/secblock.h>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -104,8 +103,7 @@ auto Generator::do_crypto() -> std::string {
|
||||||
std::memmove(ctr, str_ctr.c_str(), ctr_length);
|
std::memmove(ctr, str_ctr.c_str(), ctr_length);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CryptoPP::CTR_Mode<CryptoPP::Serpent>::Encryption e;
|
this->enc.SetKeyWithIV(G.k, G.k.size(), ctr);
|
||||||
e.SetKeyWithIV(G.k, G.k.size(), ctr);
|
|
||||||
|
|
||||||
// The StreamTransformationFilter adds padding as required. ECB and
|
// The StreamTransformationFilter adds padding as required. ECB and
|
||||||
// CBC Mode must be padded to the block size of the cipher. CTR
|
// CBC Mode must be padded to the block size of the cipher. CTR
|
||||||
|
@ -116,7 +114,7 @@ auto Generator::do_crypto() -> std::string {
|
||||||
plain,
|
plain,
|
||||||
true,
|
true,
|
||||||
new CryptoPP::StreamTransformationFilter(
|
new CryptoPP::StreamTransformationFilter(
|
||||||
e,
|
this->enc,
|
||||||
new CryptoPP::StringSink(cipher)) // StreamTransformationFilter
|
new CryptoPP::StringSink(cipher)) // StreamTransformationFilter
|
||||||
); // StringSource
|
); // StringSource
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#define FORTUNA_GENERATOR_H
|
#define FORTUNA_GENERATOR_H
|
||||||
|
|
||||||
#include <cryptopp/cryptlib.h>
|
#include <cryptopp/cryptlib.h>
|
||||||
|
#include <cryptopp/modes.h>
|
||||||
#include <cryptopp/secblock.h>
|
#include <cryptopp/secblock.h>
|
||||||
|
#include <cryptopp/serpent.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -42,6 +44,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CryptoPP::CTR_Mode<CryptoPP::Serpent>::Encryption enc;
|
||||||
struct G_state {
|
struct G_state {
|
||||||
// 32*8
|
// 32*8
|
||||||
static constexpr const std::size_t k_length{32};
|
static constexpr const std::size_t k_length{32};
|
||||||
|
|
Reference in New Issue