From aceeb2644fa59494d0d24f8367c04bf8fb843847 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 26 Oct 2015 18:14:27 +0100 Subject: [PATCH] Refactor folder structure and put classes in own files --- src/config/CryConfigEncryptor.cpp | 5 - src/config/CryConfigEncryptor.h | 159 ------------------ src/config/CryConfigFile.cpp | 6 +- src/config/CryConfigFile.h | 2 +- .../crypto/ConcreteCryConfigEncryptor.cpp | 1 + .../crypto/ConcreteCryConfigEncryptor.h | 91 ++++++++++ src/config/crypto/CryConfigEncryptor.cpp | 22 +++ src/config/crypto/CryConfigEncryptor.h | 36 ++++ .../crypto/CryConfigEncryptorFactory.cpp | 41 +++++ src/config/crypto/CryConfigEncryptorFactory.h | 34 ++++ src/config/{ => crypto}/RandomPadding.cpp | 0 src/config/{ => crypto}/RandomPadding.h | 4 +- src/config/crypto/{ => kdf}/DerivedKey.cpp | 0 src/config/crypto/{ => kdf}/DerivedKey.h | 4 +- .../crypto/{ => kdf}/DerivedKeyConfig.cpp | 0 .../crypto/{ => kdf}/DerivedKeyConfig.h | 4 +- src/config/crypto/{ => kdf}/Scrypt.cpp | 0 src/config/crypto/{ => kdf}/Scrypt.h | 4 +- .../crypto/{ => kdf}/DerivedKeyConfigTest.cpp | 2 +- .../crypto/{ => kdf}/DerivedKeyTest.cpp | 2 +- test/config/crypto/{ => kdf}/SCryptTest.cpp | 2 +- 21 files changed, 240 insertions(+), 179 deletions(-) delete mode 100644 src/config/CryConfigEncryptor.cpp delete mode 100644 src/config/CryConfigEncryptor.h create mode 100644 src/config/crypto/ConcreteCryConfigEncryptor.cpp create mode 100644 src/config/crypto/ConcreteCryConfigEncryptor.h create mode 100644 src/config/crypto/CryConfigEncryptor.cpp create mode 100644 src/config/crypto/CryConfigEncryptor.h create mode 100644 src/config/crypto/CryConfigEncryptorFactory.cpp create mode 100644 src/config/crypto/CryConfigEncryptorFactory.h rename src/config/{ => crypto}/RandomPadding.cpp (100%) rename src/config/{ => crypto}/RandomPadding.h (77%) rename src/config/crypto/{ => kdf}/DerivedKey.cpp (100%) rename src/config/crypto/{ => kdf}/DerivedKey.h (86%) rename src/config/crypto/{ => kdf}/DerivedKeyConfig.cpp (100%) rename src/config/crypto/{ => kdf}/DerivedKeyConfig.h (90%) rename src/config/crypto/{ => kdf}/Scrypt.cpp (100%) rename src/config/crypto/{ => kdf}/Scrypt.h (94%) rename test/config/crypto/{ => kdf}/DerivedKeyConfigTest.cpp (97%) rename test/config/crypto/{ => kdf}/DerivedKeyTest.cpp (92%) rename test/config/crypto/{ => kdf}/SCryptTest.cpp (96%) diff --git a/src/config/CryConfigEncryptor.cpp b/src/config/CryConfigEncryptor.cpp deleted file mode 100644 index e2de56f7..00000000 --- a/src/config/CryConfigEncryptor.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "CryConfigEncryptor.h" - -namespace cryfs { - const std::string CryConfigEncryptor::HEADER = "cryfs.config;0.8.1;scrypt"; -} \ No newline at end of file diff --git a/src/config/CryConfigEncryptor.h b/src/config/CryConfigEncryptor.h deleted file mode 100644 index 0eb2e182..00000000 --- a/src/config/CryConfigEncryptor.h +++ /dev/null @@ -1,159 +0,0 @@ -#pragma once -#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGENCRYPTOR_H -#define MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGENCRYPTOR_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "crypto/Scrypt.h" -#include "RandomPadding.h" -#include - -namespace cryfs { - //TODO Test - //TODO Test that encrypted config data always has the same size, no matter how big the plaintext config data - //TODO Don't only encrypt with the main cipher, but also use user specified cipher. - //TODO Use own exception for cpputils::Serializer/cpputils::Deserializer errors and only catch them - class CryConfigEncryptor { - public: - template static cpputils::unique_ref deriveKey(const std::string &password); - static boost::optional> loadKey(const cpputils::Data &ciphertext, const std::string &password); - - virtual cpputils::Data encrypt(const cpputils::Data &plaintext) = 0; - virtual boost::optional decrypt(const cpputils::Data &plaintext) = 0; - - protected: - static void _checkHeader(cpputils::Deserializer *deserializer); - - private: - template static DerivedKey _loadKey(cpputils::Deserializer *deserializer, const std::string &password); - - static const std::string HEADER; - }; - - template - class ConcreteCryConfigEncryptor: public CryConfigEncryptor { - public: - using ConfigEncryptionKey = DerivedKey; - static constexpr size_t CONFIG_SIZE = 1024; // Config data is grown to this size before encryption to hide its actual size - - ConcreteCryConfigEncryptor(ConfigEncryptionKey key); - - cpputils::Data encrypt(const cpputils::Data &plaintext) override; - boost::optional decrypt(const cpputils::Data &ciphertext) override; - private: - void _ignoreKey(cpputils::Deserializer *deserializer); - cpputils::Data _loadAndDecryptConfigData(cpputils::Deserializer *deserializer); - cpputils::Data _serialize(const cpputils::Data &ciphertext); - - ConfigEncryptionKey _key; - }; - - template - cpputils::unique_ref CryConfigEncryptor::deriveKey(const std::string &password) { - //TODO This is only kept here to recognize when this is run in tests. After tests are faster, replace this with something in main(), saying something like "Loading configuration file..." - std::cout << "Deriving secure key for config file..." << std::flush; - auto key = SCrypt().generateKey(password); - std::cout << "done" << std::endl; - return cpputils::make_unique_ref>(std::move(key)); - } - - inline boost::optional> CryConfigEncryptor::loadKey(const cpputils::Data &ciphertext, const std::string &password) { - cpputils::Deserializer deserializer(&ciphertext); - try { - _checkHeader(&deserializer); - auto key = _loadKey(&deserializer, password); //TODO Allow other ciphers - return boost::optional>(cpputils::make_unique_ref>(std::move(key))); //TODO Allow other ciphers - } catch (const std::exception &e) { - cpputils::logging::LOG(cpputils::logging::ERROR) << "Error loading configuration: " << e.what(); - return boost::none; // This can be caused by invalid loaded data and is not necessarily a programming logic error. Don't throw exception. - } - } - - inline void CryConfigEncryptor::_checkHeader(cpputils::Deserializer *deserializer) { - std::string header = deserializer->readString(); - if (header != HEADER) { - throw std::runtime_error("Invalid header"); - } - } - - template - DerivedKey CryConfigEncryptor::_loadKey(cpputils::Deserializer *deserializer, const std::string &password) { - auto keyConfig = DerivedKeyConfig::load(deserializer); - //TODO This is only kept here to recognize when this is run in tests. After tests are faster, replace this with something in main(), saying something like "Loading configuration file..." - std::cout << "Deriving secure key for config file..." << std::flush; - auto key = SCrypt().generateKeyFromConfig(password, keyConfig); - std::cout << "done" << std::endl; - return DerivedKey(std::move(keyConfig), std::move(key)); - } - - - - template - ConcreteCryConfigEncryptor::ConcreteCryConfigEncryptor(ConfigEncryptionKey key): _key(std::move(key)) { - } - - template - boost::optional ConcreteCryConfigEncryptor::decrypt(const cpputils::Data &data) { - cpputils::Deserializer deserializer(&data); - try { - _checkHeader(&deserializer); - _ignoreKey(&deserializer); - return _loadAndDecryptConfigData(&deserializer); - } catch (const std::exception &e) { - cpputils::logging::LOG(cpputils::logging::ERROR) << "Error loading configuration: " << e.what(); - return boost::none; // This can be caused by invalid loaded data and is not necessarily a programming logic error. Don't throw exception. - } - } - - template - void ConcreteCryConfigEncryptor::_ignoreKey(cpputils::Deserializer *deserializer) { - DerivedKeyConfig::load(deserializer); - } - - template - cpputils::Data ConcreteCryConfigEncryptor::_loadAndDecryptConfigData(cpputils::Deserializer *deserializer) { - auto ciphertext = deserializer->readData(); - auto decrypted = Cipher::decrypt(static_cast(ciphertext.data()), ciphertext.size(), _key.key()); - if (decrypted == boost::none) { - throw std::runtime_error("Couldn't decrypt config file. Wrong password?"); - } - auto configData = RandomPadding::remove(*decrypted); - if (configData == boost::none) { - throw std::runtime_error("Couldn't decrypt config file because of wrong padding"); - } - return std::move(*configData); - } - - template - cpputils::Data ConcreteCryConfigEncryptor::encrypt(const cpputils::Data &plaintext) { - auto paddedPlaintext = RandomPadding::add(plaintext, CONFIG_SIZE); - auto ciphertext = Cipher::encrypt(static_cast(paddedPlaintext.data()), paddedPlaintext.size(), _key.key()); - return _serialize(ciphertext); - } - - template - cpputils::Data ConcreteCryConfigEncryptor::_serialize(const cpputils::Data &ciphertext) { - try { - cpputils::Serializer serializer(cpputils::Serializer::StringSize(HEADER) - + _key.config().serializedSize() - + cpputils::Serializer::DataSize(ciphertext)); - serializer.writeString(HEADER); - _key.config().serialize(&serializer); - serializer.writeData(ciphertext); - return serializer.finished(); - } catch (const std::exception &e) { - cpputils::logging::LOG(cpputils::logging::ERROR) << "Error serializing CryConfigEncryptor: " << e.what(); - throw; // This is a programming logic error. Pass through exception. - } - } -} - -#endif diff --git a/src/config/CryConfigFile.cpp b/src/config/CryConfigFile.cpp index f9200536..5ff14ef0 100644 --- a/src/config/CryConfigFile.cpp +++ b/src/config/CryConfigFile.cpp @@ -2,8 +2,8 @@ #include #include #include -#include "crypto/Scrypt.h" #include +#include "crypto/CryConfigEncryptorFactory.h" using boost::optional; using boost::none; @@ -30,7 +30,7 @@ CryConfigFile CryConfigFile::create(const bf::path &path, CryConfig config, cons if (bf::exists(path)) { throw std::runtime_error("Config file exists already."); } - auto result = CryConfigFile(path, std::move(config), CryConfigEncryptor::deriveKey(password)); + auto result = CryConfigFile(path, std::move(config), CryConfigEncryptorFactory::deriveKey(password)); result.save(); return result; } @@ -41,7 +41,7 @@ optional CryConfigFile::load(const bf::path &path, const string & LOG(ERROR) << "Config file not found"; return none; } - auto encryptor = CryConfigEncryptor::loadKey(*encryptedConfigData, password); + auto encryptor = CryConfigEncryptorFactory::loadKey(*encryptedConfigData, password); if (encryptor == none) { return none; } diff --git a/src/config/CryConfigFile.h b/src/config/CryConfigFile.h index c9e88ff0..6b48fd90 100644 --- a/src/config/CryConfigFile.h +++ b/src/config/CryConfigFile.h @@ -5,7 +5,7 @@ #include #include #include "CryConfig.h" -#include "CryConfigEncryptor.h" +#include "crypto/CryConfigEncryptor.h" #include namespace cryfs { diff --git a/src/config/crypto/ConcreteCryConfigEncryptor.cpp b/src/config/crypto/ConcreteCryConfigEncryptor.cpp new file mode 100644 index 00000000..accdf1e0 --- /dev/null +++ b/src/config/crypto/ConcreteCryConfigEncryptor.cpp @@ -0,0 +1 @@ +#include "ConcreteCryConfigEncryptor.h" diff --git a/src/config/crypto/ConcreteCryConfigEncryptor.h b/src/config/crypto/ConcreteCryConfigEncryptor.h new file mode 100644 index 00000000..6df2e216 --- /dev/null +++ b/src/config/crypto/ConcreteCryConfigEncryptor.h @@ -0,0 +1,91 @@ +#pragma once +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CONCRETECRYCONFIGENCRYPTOR_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CONCRETECRYCONFIGENCRYPTOR_H + +#include +#include +#include "RandomPadding.h" +#include "CryConfigEncryptor.h" + +namespace cryfs { + template + class ConcreteCryConfigEncryptor: public CryConfigEncryptor { + public: + using ConfigEncryptionKey = DerivedKey; + static constexpr size_t CONFIG_SIZE = 1024; // Config data is grown to this size before encryption to hide its actual size + + ConcreteCryConfigEncryptor(ConfigEncryptionKey key); + + cpputils::Data encrypt(const cpputils::Data &plaintext) override; + boost::optional decrypt(const cpputils::Data &ciphertext) override; + private: + void _ignoreKey(cpputils::Deserializer *deserializer); + cpputils::Data _loadAndDecryptConfigData(cpputils::Deserializer *deserializer); + cpputils::Data _serialize(const cpputils::Data &ciphertext); + + ConfigEncryptionKey _key; + }; + + + + template + ConcreteCryConfigEncryptor::ConcreteCryConfigEncryptor(ConfigEncryptionKey key): _key(std::move(key)) { + } + + template + boost::optional ConcreteCryConfigEncryptor::decrypt(const cpputils::Data &data) { + cpputils::Deserializer deserializer(&data); + try { + checkHeader(&deserializer); + _ignoreKey(&deserializer); + return _loadAndDecryptConfigData(&deserializer); + } catch (const std::exception &e) { + cpputils::logging::LOG(cpputils::logging::ERROR) << "Error loading configuration: " << e.what(); + return boost::none; // This can be caused by invalid loaded data and is not necessarily a programming logic error. Don't throw exception. + } + } + + template + void ConcreteCryConfigEncryptor::_ignoreKey(cpputils::Deserializer *deserializer) { + DerivedKeyConfig::load(deserializer); + } + + template + cpputils::Data ConcreteCryConfigEncryptor::_loadAndDecryptConfigData(cpputils::Deserializer *deserializer) { + auto ciphertext = deserializer->readData(); + auto decrypted = Cipher::decrypt(static_cast(ciphertext.data()), ciphertext.size(), _key.key()); + if (decrypted == boost::none) { + throw std::runtime_error("Couldn't decrypt config file. Wrong password?"); + } + auto configData = RandomPadding::remove(*decrypted); + if (configData == boost::none) { + throw std::runtime_error("Couldn't decrypt config file because of wrong padding"); + } + return std::move(*configData); + } + + template + cpputils::Data ConcreteCryConfigEncryptor::encrypt(const cpputils::Data &plaintext) { + auto paddedPlaintext = RandomPadding::add(plaintext, CONFIG_SIZE); + auto ciphertext = Cipher::encrypt(static_cast(paddedPlaintext.data()), paddedPlaintext.size(), _key.key()); + return _serialize(ciphertext); + } + + template + cpputils::Data ConcreteCryConfigEncryptor::_serialize(const cpputils::Data &ciphertext) { + try { + cpputils::Serializer serializer(cpputils::Serializer::StringSize(HEADER) + + _key.config().serializedSize() + + cpputils::Serializer::DataSize(ciphertext)); + writeHeader(&serializer); + _key.config().serialize(&serializer); + serializer.writeData(ciphertext); + return serializer.finished(); + } catch (const std::exception &e) { + cpputils::logging::LOG(cpputils::logging::ERROR) << "Error serializing CryConfigEncryptor: " << e.what(); + throw; // This is a programming logic error. Pass through exception. + } + } +} + +#endif diff --git a/src/config/crypto/CryConfigEncryptor.cpp b/src/config/crypto/CryConfigEncryptor.cpp new file mode 100644 index 00000000..6d4320da --- /dev/null +++ b/src/config/crypto/CryConfigEncryptor.cpp @@ -0,0 +1,22 @@ +#include "CryConfigEncryptor.h" +#include + +using std::string; +using cpputils::Deserializer; +using cpputils::Serializer; + +namespace cryfs { + const string CryConfigEncryptor::HEADER = "cryfs.config;0.8.1;scrypt"; + + void CryConfigEncryptor::checkHeader(Deserializer *deserializer) { + string header = deserializer->readString(); + if (header != HEADER) { + throw std::runtime_error("Invalid header"); + } + } + + void CryConfigEncryptor::writeHeader(Serializer *serializer) { + serializer->writeString(HEADER); + } + +} \ No newline at end of file diff --git a/src/config/crypto/CryConfigEncryptor.h b/src/config/crypto/CryConfigEncryptor.h new file mode 100644 index 00000000..5da28090 --- /dev/null +++ b/src/config/crypto/CryConfigEncryptor.h @@ -0,0 +1,36 @@ +#pragma once +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CRYCONFIGENCRYPTOR_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CRYCONFIGENCRYPTOR_H + +#include +#include +#include +#include +#include "kdf/DerivedKey.h" +#include +#include + +namespace cryfs { + //TODO Test + //TODO Test that encrypted config data always has the same size, no matter how big the plaintext config data + //TODO Don't only encrypt with the main cipher, but also use user specified cipher. + //TODO Use own exception for cpputils::Serializer/cpputils::Deserializer errors and only catch them + class CryConfigEncryptor { + public: + virtual cpputils::Data encrypt(const cpputils::Data &plaintext) = 0; + + virtual boost::optional decrypt(const cpputils::Data &plaintext) = 0; + + static void checkHeader(cpputils::Deserializer *deserializer); + static void writeHeader(cpputils::Serializer *serializer); + + private: + template + static DerivedKey _loadKey(cpputils::Deserializer *deserializer, + const std::string &password); + + static const std::string HEADER; + }; +} + +#endif diff --git a/src/config/crypto/CryConfigEncryptorFactory.cpp b/src/config/crypto/CryConfigEncryptorFactory.cpp new file mode 100644 index 00000000..81712b58 --- /dev/null +++ b/src/config/crypto/CryConfigEncryptorFactory.cpp @@ -0,0 +1,41 @@ +#include "CryConfigEncryptorFactory.h" +#include + +using namespace cpputils::logging; +using boost::optional; +using boost::none; +using cpputils::unique_ref; +using cpputils::make_unique_ref; +using cpputils::Data; +using cpputils::Deserializer; +using std::string; + +namespace cryfs { + + template + DerivedKey CryConfigEncryptorFactory::_loadKey(cpputils::Deserializer *deserializer, + const std::string &password) { + auto keyConfig = DerivedKeyConfig::load(deserializer); + //TODO This is only kept here to recognize when this is run in tests. After tests are faster, replace this with something in main(), saying something like "Loading configuration file..." + std::cout << "Deriving secure key for config file..." << std::flush; + auto key = SCrypt().generateKeyFromConfig(password, keyConfig); + std::cout << "done" << std::endl; + return DerivedKey(std::move(keyConfig), std::move(key)); + } + + optional > CryConfigEncryptorFactory::loadKey(const Data &ciphertext, + const string &password) { + Deserializer deserializer(&ciphertext); + try { + CryConfigEncryptor::checkHeader(&deserializer); + auto key = _loadKey(&deserializer, password); //TODO Allow other ciphers + return optional < unique_ref < CryConfigEncryptor >> (make_unique_ref < ConcreteCryConfigEncryptor < + blockstore::encrypted::AES256_GCM >> + (std::move(key))); //TODO Allow other ciphers + } catch (const std::exception &e) { + LOG(ERROR) << "Error loading configuration: " << e.what(); + return none; // This can be caused by invalid loaded data and is not necessarily a programming logic error. Don't throw exception. + } + } + +} \ No newline at end of file diff --git a/src/config/crypto/CryConfigEncryptorFactory.h b/src/config/crypto/CryConfigEncryptorFactory.h new file mode 100644 index 00000000..82c63b5e --- /dev/null +++ b/src/config/crypto/CryConfigEncryptorFactory.h @@ -0,0 +1,34 @@ +#pragma once +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CRYCONFIGENCRYPTORFACTORY_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_CRYCONFIGENCRYPTORFACTORY_H + +#include "ConcreteCryConfigEncryptor.h" +#include +#include "kdf/Scrypt.h" + +namespace cryfs { + class CryConfigEncryptorFactory { + public: + template + static cpputils::unique_ref deriveKey(const std::string &password); + + static boost::optional > loadKey(const cpputils::Data &ciphertext, + const std::string &password); + + private: + template + static DerivedKey _loadKey(cpputils::Deserializer *deserializer, + const std::string &password); + }; + + template + cpputils::unique_ref CryConfigEncryptorFactory::deriveKey(const std::string &password) { + //TODO This is only kept here to recognize when this is run in tests. After tests are faster, replace this with something in main(), saying something like "Loading configuration file..." + std::cout << "Deriving secure key for config file..." << std::flush; + auto key = SCrypt().generateKey(password); + std::cout << "done" << std::endl; + return cpputils::make_unique_ref>(std::move(key)); + } +} + +#endif diff --git a/src/config/RandomPadding.cpp b/src/config/crypto/RandomPadding.cpp similarity index 100% rename from src/config/RandomPadding.cpp rename to src/config/crypto/RandomPadding.cpp diff --git a/src/config/RandomPadding.h b/src/config/crypto/RandomPadding.h similarity index 77% rename from src/config/RandomPadding.h rename to src/config/crypto/RandomPadding.h index dfbad19c..0ad83945 100644 --- a/src/config/RandomPadding.h +++ b/src/config/crypto/RandomPadding.h @@ -1,6 +1,6 @@ #pragma once -#ifndef MESSMER_CRYFS_SRC_CONFIG_PADDING_H -#define MESSMER_CRYFS_SRC_CONFIG_PADDING_H +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_PADDING_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_PADDING_H #include #include diff --git a/src/config/crypto/DerivedKey.cpp b/src/config/crypto/kdf/DerivedKey.cpp similarity index 100% rename from src/config/crypto/DerivedKey.cpp rename to src/config/crypto/kdf/DerivedKey.cpp diff --git a/src/config/crypto/DerivedKey.h b/src/config/crypto/kdf/DerivedKey.h similarity index 86% rename from src/config/crypto/DerivedKey.h rename to src/config/crypto/kdf/DerivedKey.h index b6b77c0b..9c1e1981 100644 --- a/src/config/crypto/DerivedKey.h +++ b/src/config/crypto/kdf/DerivedKey.h @@ -1,6 +1,6 @@ #pragma once -#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_DERIVEDKEY_H -#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_DERIVEDKEY_H +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_DERIVEDKEY_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_DERIVEDKEY_H #include #include "DerivedKeyConfig.h" diff --git a/src/config/crypto/DerivedKeyConfig.cpp b/src/config/crypto/kdf/DerivedKeyConfig.cpp similarity index 100% rename from src/config/crypto/DerivedKeyConfig.cpp rename to src/config/crypto/kdf/DerivedKeyConfig.cpp diff --git a/src/config/crypto/DerivedKeyConfig.h b/src/config/crypto/kdf/DerivedKeyConfig.h similarity index 90% rename from src/config/crypto/DerivedKeyConfig.h rename to src/config/crypto/kdf/DerivedKeyConfig.h index b9ac0d6e..5b4b289e 100644 --- a/src/config/crypto/DerivedKeyConfig.h +++ b/src/config/crypto/kdf/DerivedKeyConfig.h @@ -1,6 +1,6 @@ #pragma once -#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KEYCONFIG_H -#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KEYCONFIG_H +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_KEYCONFIG_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_KEYCONFIG_H #include #include diff --git a/src/config/crypto/Scrypt.cpp b/src/config/crypto/kdf/Scrypt.cpp similarity index 100% rename from src/config/crypto/Scrypt.cpp rename to src/config/crypto/kdf/Scrypt.cpp diff --git a/src/config/crypto/Scrypt.h b/src/config/crypto/kdf/Scrypt.h similarity index 94% rename from src/config/crypto/Scrypt.h rename to src/config/crypto/kdf/Scrypt.h index 2639a791..b9e5ed1a 100644 --- a/src/config/crypto/Scrypt.h +++ b/src/config/crypto/kdf/Scrypt.h @@ -1,6 +1,6 @@ #pragma once -#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_SCRYPT_H -#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_SCRYPT_H +#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_SCRYPT_H +#define MESSMER_CRYFS_SRC_CONFIG_CRYPTO_KDF_SCRYPT_H #include #include diff --git a/test/config/crypto/DerivedKeyConfigTest.cpp b/test/config/crypto/kdf/DerivedKeyConfigTest.cpp similarity index 97% rename from test/config/crypto/DerivedKeyConfigTest.cpp rename to test/config/crypto/kdf/DerivedKeyConfigTest.cpp index 37d9fbcc..fb8706d6 100644 --- a/test/config/crypto/DerivedKeyConfigTest.cpp +++ b/test/config/crypto/kdf/DerivedKeyConfigTest.cpp @@ -1,5 +1,5 @@ #include -#include "../../../src/config/crypto/DerivedKeyConfig.h" +#include "../../../../src/config/crypto/kdf/DerivedKeyConfig.h" #include #include diff --git a/test/config/crypto/DerivedKeyTest.cpp b/test/config/crypto/kdf/DerivedKeyTest.cpp similarity index 92% rename from test/config/crypto/DerivedKeyTest.cpp rename to test/config/crypto/kdf/DerivedKeyTest.cpp index 8dcce5e1..92db4234 100644 --- a/test/config/crypto/DerivedKeyTest.cpp +++ b/test/config/crypto/kdf/DerivedKeyTest.cpp @@ -1,5 +1,5 @@ #include -#include "../../../src/config/crypto/DerivedKey.h" +#include "../../../../src/config/crypto/kdf/DerivedKey.h" #include using namespace cryfs; diff --git a/test/config/crypto/SCryptTest.cpp b/test/config/crypto/kdf/SCryptTest.cpp similarity index 96% rename from test/config/crypto/SCryptTest.cpp rename to test/config/crypto/kdf/SCryptTest.cpp index 49ede455..39b68a33 100644 --- a/test/config/crypto/SCryptTest.cpp +++ b/test/config/crypto/kdf/SCryptTest.cpp @@ -1,5 +1,5 @@ #include -#include "../../../src/config/crypto/Scrypt.h" +#include "../../../../src/config/crypto/kdf/Scrypt.h" using namespace cryfs;