2015-06-16 18:20:31 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CRYFS_SRC_CRYCONFIGLOADER_H_
|
|
|
|
#define MESSMER_CRYFS_SRC_CRYCONFIGLOADER_H_
|
|
|
|
|
2015-06-21 17:44:45 +02:00
|
|
|
#include <messmer/cpp-utils/pointer/unique_ref.h>
|
2015-06-16 18:20:31 +02:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include "CryConfig.h"
|
2015-09-01 00:25:14 +02:00
|
|
|
#include "CryCipher.h"
|
|
|
|
#include <messmer/blockstore/implementations/encrypted/ciphers/ciphers.h>
|
2015-09-12 20:16:13 +02:00
|
|
|
#include <messmer/cpp-utils/io/Console.h>
|
2015-06-16 18:20:31 +02:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
class CryConfigLoader {
|
|
|
|
public:
|
2015-07-26 13:09:55 +02:00
|
|
|
CryConfigLoader();
|
2015-09-12 20:16:13 +02:00
|
|
|
explicit CryConfigLoader(cpputils::unique_ref<cpputils::Console> console);
|
2015-06-16 18:20:31 +02:00
|
|
|
|
2015-07-26 13:09:55 +02:00
|
|
|
cpputils::unique_ref<CryConfig> loadOrCreate(const boost::filesystem::path &filename);
|
|
|
|
|
|
|
|
cpputils::unique_ref<CryConfig> createNew(const boost::filesystem::path &filename);
|
|
|
|
boost::optional<cpputils::unique_ref<CryConfig>> loadExisting(const boost::filesystem::path &filename);
|
2015-06-16 18:20:31 +02:00
|
|
|
|
2015-06-17 12:28:18 +02:00
|
|
|
//This method is only for testing purposes, because creating weak keys is much faster than creating strong keys.
|
2015-07-26 13:09:55 +02:00
|
|
|
cpputils::unique_ref<CryConfig> loadOrCreateWithWeakKey(const boost::filesystem::path &filename);
|
|
|
|
cpputils::unique_ref<CryConfig> createNewWithWeakKey(const boost::filesystem::path &filename);
|
2015-06-17 12:28:18 +02:00
|
|
|
|
2015-06-16 18:20:31 +02:00
|
|
|
private:
|
2015-07-26 13:09:55 +02:00
|
|
|
void _initializeConfig(CryConfig *config);
|
|
|
|
void _generateCipher(CryConfig *config);
|
|
|
|
void _generateEncKey(CryConfig *config);
|
|
|
|
void _generateRootBlobKey(CryConfig *config);
|
|
|
|
|
|
|
|
void _initializeConfigWithWeakKey(CryConfig *config); // TODO Rename to _initializeConfigForTest
|
|
|
|
void _generateWeakEncKey(CryConfig *config); // TODO Rename to _generateTestEncKey
|
|
|
|
void _generateTestCipher(CryConfig *config);
|
|
|
|
|
2015-09-04 16:02:55 +02:00
|
|
|
bool _showWarningForCipherAndReturnIfOk(const std::string &cipherName);
|
|
|
|
|
2015-09-12 20:16:13 +02:00
|
|
|
cpputils::unique_ref<cpputils::Console> _console;
|
2015-06-16 18:20:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|