#pragma once #ifndef MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGLOADER_H_ #define MESSMER_CRYFS_SRC_CONFIG_CRYCONFIGLOADER_H_ #include #include #include "CryConfigFile.h" #include "CryCipher.h" #include "CryConfigCreator.h" #include namespace cryfs { class CryConfigLoader final { public: CryConfigLoader(std::shared_ptr console, cpputils::RandomGenerator &keyGenerator, const cpputils::SCryptSettings &scryptSettings, std::function askPasswordForExistingFilesystem, std::function askPasswordForNewFilesystem, const boost::optional &cipherFromCommandLine, const boost::optional &blocksizeBytesFromCommandLine, const boost::optional &missingBlockIsIntegrityViolationFromCommandLine); CryConfigLoader(CryConfigLoader &&rhs) = default; struct ConfigLoadResult { CryConfigFile configFile; uint32_t myClientId; }; boost::optional loadOrCreate(boost::filesystem::path filename); private: boost::optional _loadConfig(boost::filesystem::path filename); ConfigLoadResult _createConfig(boost::filesystem::path filename); void _checkVersion(const CryConfig &config); void _checkCipher(const CryConfig &config) const; void _checkMissingBlocksAreIntegrityViolations(CryConfigFile *configFile, uint32_t myClientId); std::shared_ptr _console; CryConfigCreator _creator; cpputils::SCryptSettings _scryptSettings; std::function _askPasswordForExistingFilesystem; std::function _askPasswordForNewFilesystem; boost::optional _cipherFromCommandLine; boost::optional _blocksizeBytesFromCommandLine; boost::optional _missingBlockIsIntegrityViolationFromCommandLine; DISALLOW_COPY_AND_ASSIGN(CryConfigLoader); }; } #endif