Renamed class Cipher to GCipher

This commit is contained in:
Leonetienne
2022-05-22 12:51:58 +02:00
parent 1cc01a840d
commit 4e2f99c28e
9 changed files with 119 additions and 191 deletions

View File

@@ -5,32 +5,32 @@
namespace Leonetienne::GCrypt {
/** Class to apply a block/-stream cipher to messages of arbitrary length in a distributed manner
*/
class Cipher {
class GCipher {
public:
//! Describes the direction the cipher runs in
enum class CIPHER_DIRECTION {
enum class DIRECTION {
ENCIPHER,
DECIPHER
};
//! Will initialize this cipher with a key
explicit Cipher(const Block& key, const CIPHER_DIRECTION direction);
explicit GCipher(const Block& key, const DIRECTION direction);
//! Will initialize this cipher with a key
explicit Cipher(const std::string& password, const CIPHER_DIRECTION direction);
explicit GCipher(const std::string& password, const DIRECTION direction);
// Disable copying
Cipher(const Cipher& other) = delete;
Cipher(Cipher&& other) noexcept = delete;
GCipher(const GCipher& other) = delete;
GCipher(GCipher&& other) noexcept = delete;
~Cipher();
~GCipher();
//! Will digest a data block, and return it
Block Digest(const Block& input);
private:
Block key;
const CIPHER_DIRECTION direction;
const DIRECTION direction;
//! The feistel instance to be used
Feistel feistel;

View File

@@ -2,7 +2,7 @@
#include <string>
#include "GCrypt/Flexblock.h"
#include "GCrypt/Block.h"
#include "GCrypt/Cipher.h"
#include "GCrypt/GCipher.h"
namespace Leonetienne::GCrypt {
/** This class is a wrapper to make working with the GhettoCipher
@@ -31,7 +31,7 @@ namespace Leonetienne::GCrypt {
private:
//! Will digest a flexblock with a key
static Flexblock DigestFlexblock(const Flexblock& data, const Block& key, const Cipher::CIPHER_DIRECTION direction);
static Flexblock DigestFlexblock(const Flexblock& data, const Block& key, const GCipher::DIRECTION direction);
// No instanciation! >:(
GCryptWrapper();

View File

@@ -3,7 +3,7 @@
#include "GCrypt/Flexblock.h"
#include "GCrypt/Block.h"
#include "GCrypt/Cipher.h"
#include "GCrypt/GCipher.h"
namespace Leonetienne::GCrypt {
/** This class implements a hash function, based on the GCrypt cipher
@@ -12,8 +12,11 @@ namespace Leonetienne::GCrypt {
public:
Hasher();
//! Will add the hash value of `data` to the hashsum
void Digest(const Block& data);
//! Will add the hash value of the block `data` to the hashsum.
//! WARNING: If you compute hashes using this digestive method,
//! you REALLY REALLY should add a trailing block just containing the cleartext size!
//! You MOST LIKELY just want to use the wrapper function GHash::CalculateHashsum(Flexblock const&) instead!
void DigestBlock(const Block& data);
//! Will return the current hashsum
const Block& GetHashsum() const;
@@ -23,7 +26,7 @@ namespace Leonetienne::GCrypt {
private:
//! The cipher to use
Cipher cipher;
GCipher cipher;
//! The current state of the hashsum
Block block;

View File

@@ -9,7 +9,7 @@
#include "GCrypt/Block.h"
#include "GCrypt/Flexblock.h"
#include "GCrypt/Config.h"
#include "GCrypt/Cipher.h"
#include "GCrypt/GCipher.h"
#include "GCrypt/InitializationVector.h"
namespace Leonetienne::GCrypt {