diff --git a/GCryptLib/include/GCrypt/GCryptWrapper.h b/GCryptLib/include/GCrypt/GCryptWrapper.h index 664323e..bf56ada 100644 --- a/GCryptLib/include/GCrypt/GCryptWrapper.h +++ b/GCryptLib/include/GCrypt/GCryptWrapper.h @@ -28,10 +28,11 @@ namespace Leonetienne::GCrypt { //! @filename_out The file the decrypted version should be saved in. static bool DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport = false); + //! Will enncrypt or decrypt an entire flexblock of binary data, given a key. + static Flexblock CipherFlexblock(const Flexblock& data, const Block& key, const GCipher::DIRECTION direction); + private: - //! Will digest a flexblock with a key - static Flexblock DigestFlexblock(const Flexblock& data, const Block& key, const GCipher::DIRECTION direction); // No instanciation! >:( GCryptWrapper(); diff --git a/GCryptLib/src/GCryptWrapper.cpp b/GCryptLib/src/GCryptWrapper.cpp index 1ae321b..9161f0a 100644 --- a/GCryptLib/src/GCryptWrapper.cpp +++ b/GCryptLib/src/GCryptWrapper.cpp @@ -12,7 +12,7 @@ namespace Leonetienne::GCrypt { const Flexblock cleartext_bits = StringToBits(cleartext); // Encrypt our cleartext bits - const Flexblock ciphertext_bits = DigestFlexblock(cleartext_bits, key, GCipher::DIRECTION::ENCIPHER); + const Flexblock ciphertext_bits = CipherFlexblock(cleartext_bits, key, GCipher::DIRECTION::ENCIPHER); // Recode the ciphertext bits to a hex-string const std::string ciphertext = BitsToHexstring(ciphertext_bits); @@ -29,7 +29,7 @@ namespace Leonetienne::GCrypt { const Flexblock ciphertext_bits = HexstringToBits(ciphertext); // Decrypt the ciphertext bits - const std::string cleartext_bits = DigestFlexblock(ciphertext_bits, key, GCipher::DIRECTION::DECIPHER); + const std::string cleartext_bits = CipherFlexblock(ciphertext_bits, key, GCipher::DIRECTION::DECIPHER); // Recode the cleartext bits to an ascii-string const std::string cleartext = BitsToString(cleartext_bits); @@ -47,7 +47,7 @@ namespace Leonetienne::GCrypt { const Block key = PasswordToKey(password); // Encrypt our cleartext bits - const Flexblock ciphertext_bits = DigestFlexblock(cleartext_bits, key, GCipher::DIRECTION::ENCIPHER); + const Flexblock ciphertext_bits = CipherFlexblock(cleartext_bits, key, GCipher::DIRECTION::ENCIPHER); // Write our ciphertext bits to file WriteBitsToFile(filename_out, ciphertext_bits); @@ -68,7 +68,7 @@ namespace Leonetienne::GCrypt { const Block key = PasswordToKey(password); // Decrypt the ciphertext bits - const Flexblock cleartext_bits = DigestFlexblock(ciphertext_bits, key, GCipher::DIRECTION::DECIPHER); + const Flexblock cleartext_bits = CipherFlexblock(ciphertext_bits, key, GCipher::DIRECTION::DECIPHER); // Write our cleartext bits to file WriteBitsToFile(filename_out, cleartext_bits); @@ -80,7 +80,11 @@ namespace Leonetienne::GCrypt { } } - Flexblock GCryptWrapper::DigestFlexblock(const Flexblock& data, const Block& key, const GCipher::DIRECTION direction) { + Flexblock GCryptWrapper::CipherFlexblock( + const Flexblock& data, + const Block& key, + const GCipher::DIRECTION direction) + { // Split input into blocks std::vector blocks;