2021-12-06 00:39:58 +01:00
|
|
|
#pragma once
|
|
|
|
#include "Feistel.h"
|
|
|
|
#include "Flexblock.h"
|
|
|
|
|
|
|
|
/** Class to apply a block cipher to messages of arbitrary length in a distributed manner
|
|
|
|
*/
|
|
|
|
class FeistelMan
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit FeistelMan(const Block& key);
|
|
|
|
explicit FeistelMan(const std::string& password);
|
|
|
|
|
|
|
|
FeistelMan(const FeistelMan& other) = delete;
|
|
|
|
FeistelMan(FeistelMan&& other) noexcept = delete;
|
|
|
|
|
|
|
|
~FeistelMan();
|
|
|
|
|
|
|
|
//! Will set the key
|
|
|
|
void SetKey(const Block& key);
|
|
|
|
|
|
|
|
//! Will set the key from a password
|
|
|
|
void SetPassword(const std::string& password);
|
|
|
|
|
|
|
|
//! Will encipher a flexblock of data
|
2021-12-06 01:33:55 +01:00
|
|
|
Flexblock Encipher(const Flexblock& data, bool printReports = false) const;
|
2021-12-06 00:39:58 +01:00
|
|
|
|
|
|
|
//! Will decipher a flexblock of data
|
2021-12-06 01:33:55 +01:00
|
|
|
Flexblock Decipher(const Flexblock& data, bool printReports = false) const;
|
2021-12-06 00:39:58 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Block key;
|
|
|
|
|
|
|
|
//! Will zero the memory used by the key
|
|
|
|
void ZeroKeyMemory();
|
|
|
|
|
|
|
|
// Initial value for cipher block chaining
|
|
|
|
static const Block emptyBlock;
|
|
|
|
};
|