libcryfs/src/cryfs/impl/config/CryConfigCreator.h

42 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#ifndef MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGCREATOR_H
#define MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGCREATOR_H
2015-10-19 02:46:47 +02:00
2016-02-11 16:39:42 +01:00
#include <cpp-utils/pointer/unique_ref.h>
#include <cpp-utils/random/RandomGenerator.h>
#include <cpp-utils/io/Console.h>
2019-01-26 08:38:34 +01:00
#include <cryfs/impl/localstate/LocalStateDir.h>
2015-10-19 02:46:47 +02:00
#include "CryConfig.h"
#include "CryConfigConsole.h"
2015-10-19 02:46:47 +02:00
namespace cryfs {
class CryConfigCreator final {
public:
2022-06-18 21:11:24 +02:00
CryConfigCreator(cpputils::RandomGenerator &encryptionKeyGenerator, LocalStateDir localStateDir);
CryConfigCreator(CryConfigCreator &&rhs) = default;
2015-10-19 02:46:47 +02:00
struct ConfigCreateResult {
CryConfig config;
uint32_t myClientId;
};
ConfigCreateResult create(const boost::optional<std::string> &cipherFromCommandLine, const boost::optional<uint32_t> &blocksizeBytesFromCommandLine, const boost::optional<bool> &missingBlockIsIntegrityViolationFromCommandLine, bool allowReplacedFilesystem);
2015-10-19 02:46:47 +02:00
private:
std::string _generateCipher(const boost::optional<std::string> &cipherFromCommandLine);
2015-10-19 02:46:47 +02:00
std::string _generateEncKey(const std::string &cipher);
std::string _generateRootBlobId();
uint32_t _generateBlocksizeBytes(const boost::optional<uint32_t> &blocksizeBytesFromCommandLine);
CryConfig::FilesystemID _generateFilesystemID();
boost::optional<uint32_t> _generateExclusiveClientId(const boost::optional<bool> &missingBlockIsIntegrityViolationFromCommandLine, uint32_t myClientId);
bool _generateMissingBlockIsIntegrityViolation(const boost::optional<bool> &missingBlockIsIntegrityViolationFromCommandLine);
2015-10-19 02:46:47 +02:00
CryConfigConsole _configConsole;
2015-10-22 18:48:04 +02:00
cpputils::RandomGenerator &_encryptionKeyGenerator;
LocalStateDir _localStateDir;
2015-10-19 02:46:47 +02:00
DISALLOW_COPY_AND_ASSIGN(CryConfigCreator);
};
}
#endif