本文整理汇总了C++中CryConfig类的典型用法代码示例。如果您正苦于以下问题:C++ CryConfig类的具体用法?C++ CryConfig怎么用?C++ CryConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CryConfig类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(CryConfigFileTest, Cipher_CreateAndLoad) {
CryConfig cfg = Config();
cfg.SetCipher("twofish-128-cfb");
Create(std::move(cfg));
CryConfigFile loaded = Load().value();
EXPECT_EQ("twofish-128-cfb", loaded.config()->Cipher());
}
示例2: create
CryConfig CryConfigCreator::create(const optional<string> &cipherFromCommandLine) {
CryConfig config;
config.SetCipher(_generateCipher(cipherFromCommandLine));
config.SetEncryptionKey(_generateEncKey(config.Cipher()));
config.SetRootBlob(_generateRootBlobKey());
return config;
}
示例3: _checkVersion
void CryConfigLoader::_checkVersion(const CryConfig &config) {
if (gitversion::VersionCompare::isOlderThan(gitversion::VersionString(), config.Version())) {
if (!_console->askYesNo("This filesystem is for CryFS " + config.Version() + " and should not be opened with older versions. It is strongly recommended to update your CryFS version. However, if you have backed up your base directory and know what you're doing, you can continue trying to load it. Do you want to continue?")) {
throw std::runtime_error("Not trying to load file system.");
}
}
if (gitversion::VersionCompare::isOlderThan(config.Version(), gitversion::VersionString())) {
if (!_console->askYesNo("This filesystem is for CryFS " + config.Version() + ". It can be migrated to CryFS " + gitversion::VersionString() + ", but afterwards couldn't be opened anymore with older versions. Do you want to migrate it?")) {
throw std::runtime_error(string() + "Not migrating file system.");
}
}
}
示例4: TEST_P
TEST_P(CryConfigCreatorTest_ChooseCipher, ChoosesCipherCorrectly) {
if (cipherWarning == none) {
EXPECT_DONT_SHOW_WARNING();
} else {
EXPECT_SHOW_WARNING(*cipherWarning);
}
EXPECT_ASK_FOR_CIPHER().WillOnce(ChooseCipher(cipherName));
CryConfig config = creator.create(none);
EXPECT_EQ(cipherName, config.Cipher());
}
示例5: create
CryConfig CryConfigCreator::create(const optional<string> &cipherFromCommandLine, const optional<uint32_t> &blocksizeBytesFromCommandLine) {
CryConfig config;
config.SetCipher(_generateCipher(cipherFromCommandLine));
config.SetVersion(gitversion::VersionString());
config.SetCreatedWithVersion(gitversion::VersionString());
config.SetBlocksizeBytes(_generateBlocksizeBytes(blocksizeBytesFromCommandLine));
config.SetRootBlob(_generateRootBlobKey());
config.SetEncryptionKey(_generateEncKey(config.Cipher()));
config.SetFilesystemId(_generateFilesystemID());
return config;
}
示例6: LOG
optional<CryConfigFile> CryConfigFile::load(const bf::path &path, const string &password) {
auto encryptedConfigData = Data::LoadFromFile(path);
if (encryptedConfigData == none) {
LOG(ERROR) << "Config file not found";
return none;
}
auto encryptor = CryConfigEncryptorFactory::loadKey(*encryptedConfigData, password);
if (encryptor == none) {
return none;
}
auto decrypted = (*encryptor)->decrypt(*encryptedConfigData);
if (decrypted == none) {
return none;
}
CryConfig config = CryConfig::load(decrypted->data);
if (config.Cipher() != decrypted->cipherName) {
LOG(ERROR) << "Inner cipher algorithm used to encrypt config file doesn't match config value";
return none;
}
return CryConfigFile(path, std::move(config), std::move(*encryptor));
}
示例7: TEST_F
TEST_F(CryConfigTest, Cipher_AfterSaveAndLoad) {
cfg.SetCipher("mycipher");
CryConfig loaded = SaveAndLoad(std::move(cfg));
EXPECT_EQ("mycipher", loaded.Cipher());
}
示例8: TEST_F
TEST_F(CryConfigCreatorTest, ChoosesValidEncryptionKey_256) {
AnswerNoToDefaultSettings();
EXPECT_ASK_FOR_CIPHER().WillOnce(ChooseCipher("aes-256-gcm"));
CryConfig config = creator.create(none, none);
cpputils::AES256_GCM::EncryptionKey::FromString(config.EncryptionKey()); // This crashes if invalid
}
示例9: find
cpputils::unique_ref<blockstore::BlockStore> CryDevice::CreateEncryptedBlockStore(const CryConfig &config, unique_ref<BlockStore> baseBlockStore) {
//TODO Test that CryFS is using the specified cipher
return CryCiphers::find(config.Cipher()).createEncryptedBlockstore(std::move(baseBlockStore), config.EncryptionKey());
}
示例10: Config
CryConfig Config() {
CryConfig result;
result.SetCipher("aes-256-gcm");
return result;
}
示例11: SaveAndLoad
CryConfig SaveAndLoad(CryConfig cfg) {
Data configData = cfg.save();
return CryConfig::load(configData);
}
示例12: _checkCipher
void CryConfigLoader::_checkCipher(const CryConfig &config) const {
if (_cipherFromCommandLine != none && config.Cipher() != *_cipherFromCommandLine) {
throw std::runtime_error(string() + "Filesystem uses " + config.Cipher() + " cipher and not " + *_cipherFromCommandLine + " as specified.");
}
}
示例13: TEST_F
TEST_F(CryConfigCreatorTest, ChoosesValidEncryptionKey_128) {
EXPECT_ASK_FOR_CIPHER().WillOnce(ChooseCipher("aes-128-gcm"));
CryConfig config = creator.create(none);
cpputils::AES128_GCM::EncryptionKey::FromString(config.EncryptionKey()); // This crashes if invalid
}
示例14: CreateWithCipher
void CreateWithCipher(const string &cipher, const TempFile &tempFile) {
CryConfig cfg;
cfg.SetCipher(cipher);
CryConfigFile::create(tempFile.path(), std::move(cfg), "mypassword", SCrypt::TestSettings);
}