#pragma once #ifndef MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGCREATOR_H #define MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGCREATOR_H #include #include #include #include #include "CryConfig.h" #include "CryConfigConsole.h" namespace cryfs { class CryConfigCreator final { public: CryConfigCreator(cpputils::RandomGenerator &encryptionKeyGenerator, LocalStateDir localStateDir); CryConfigCreator(CryConfigCreator &&rhs) = default; struct ConfigCreateResult { CryConfig config; uint32_t myClientId; }; ConfigCreateResult create(const boost::optional &cipherFromCommandLine, const boost::optional &blocksizeBytesFromCommandLine, const boost::optional &missingBlockIsIntegrityViolationFromCommandLine, bool allowReplacedFilesystem); private: std::string _generateCipher(const boost::optional &cipherFromCommandLine); std::string _generateEncKey(const std::string &cipher); std::string _generateRootBlobId(); uint32_t _generateBlocksizeBytes(const boost::optional &blocksizeBytesFromCommandLine); CryConfig::FilesystemID _generateFilesystemID(); boost::optional _generateExclusiveClientId(const boost::optional &missingBlockIsIntegrityViolationFromCommandLine, uint32_t myClientId); bool _generateMissingBlockIsIntegrityViolation(const boost::optional &missingBlockIsIntegrityViolationFromCommandLine); CryConfigConsole _configConsole; cpputils::RandomGenerator &_encryptionKeyGenerator; LocalStateDir _localStateDir; DISALLOW_COPY_AND_ASSIGN(CryConfigCreator); }; } #endif