libcryfs/src/CryConfigLoader.h

39 lines
1.5 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"
#include <messmer/blockstore/implementations/encrypted/ciphers/AES256_GCM.h>
namespace cryfs {
class CryConfigLoader {
public:
using Cipher = blockstore::encrypted::AES256_GCM;
static cpputils::unique_ref<CryConfig> loadOrCreate(const boost::filesystem::path &filename);
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-17 12:28:18 +02:00
//This method is only for testing purposes, because creating weak keys is much faster than creating strong keys.
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
private:
static void _initializeConfig(CryConfig *config);
static void _generateCipher(CryConfig *config);
static void _generateEncKey(CryConfig *config);
static void _generateRootBlobKey(CryConfig *config);
2015-06-17 12:28: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);
};
}
#endif