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"
|
|
|
|
#include <messmer/blockstore/implementations/encrypted/ciphers/AES256_GCM.h>
|
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
class CryConfigLoader {
|
|
|
|
public:
|
|
|
|
using Cipher = blockstore::encrypted::AES256_GCM;
|
|
|
|
|
2015-06-18 13:45:08 +02:00
|
|
|
static cpputils::unique_ref<CryConfig> loadOrCreate(const boost::filesystem::path &filename);
|
2015-06-16 18:20:31 +02:00
|
|
|
|
2015-06-18 13:45:08 +02:00
|
|
|
static cpputils::unique_ref<CryConfig> createNew(const boost::filesystem::path &filename);
|
|
|
|
static 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-06-18 13:45:08 +02:00
|
|
|
static cpputils::unique_ref<CryConfig> loadOrCreateWithWeakKey(const boost::filesystem::path &filename);
|
|
|
|
static 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:
|
|
|
|
static void _initializeConfig(CryConfig *config);
|
2015-07-01 14:33:18 +02:00
|
|
|
static void _generateCipher(CryConfig *config);
|
2015-06-16 18:20:31 +02:00
|
|
|
static void _generateEncKey(CryConfig *config);
|
|
|
|
static void _generateRootBlobKey(CryConfig *config);
|
2015-06-17 12:28:18 +02:00
|
|
|
|
2015-07-01 14:33:18 +02:00
|
|
|
static void _initializeConfigWithWeakKey(CryConfig *config); // TODO Rename to _initializeConfigForTest
|
|
|
|
static void _generateWeakEncKey(CryConfig *config); // TODO Rename to _generateTestEncKey
|
|
|
|
static void _generateTestCipher(CryConfig *config);
|
2015-06-16 18:20:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|