#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); CryConfigLoader(CryConfigLoader &&rhs) = default; boost::optional loadOrCreate(const boost::filesystem::path &filename); private: boost::optional _loadConfig(const boost::filesystem::path &filename); CryConfigFile _createConfig(const boost::filesystem::path &filename); void _checkVersion(const CryConfig &config); void _checkCipher(const CryConfig &config) const; std::shared_ptr _console; CryConfigCreator _creator; cpputils::SCryptSettings _scryptSettings; std::function _askPasswordForExistingFilesystem; std::function _askPasswordForNewFilesystem; boost::optional _cipherFromCommandLine; boost::optional _blocksizeBytesFromCommandLine; DISALLOW_COPY_AND_ASSIGN(CryConfigLoader); }; } #endif