libcryfs/src/config/CryConfigLoader.h

46 lines
1.6 KiB
C
Raw Normal View History

#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>
#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>
namespace cryfs {
class CryConfigLoader {
public:
CryConfigLoader();
2015-09-12 20:16:13 +02:00
explicit CryConfigLoader(cpputils::unique_ref<cpputils::Console> console);
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-17 12:28:18 +02:00
//This method is only for testing purposes, because creating weak keys is much faster than creating strong keys.
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
private:
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);
bool _showWarningForCipherAndReturnIfOk(const std::string &cipherName);
2015-09-12 20:16:13 +02:00
cpputils::unique_ref<cpputils::Console> _console;
};
}
#endif