当前位置: 首页>>代码示例>>C++>>正文


C++ CryConfig类代码示例

本文整理汇总了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());
}
开发者ID:kjdyck,项目名称:cryfs,代码行数:7,代码来源:CryConfigFileTest.cpp

示例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;
 }
开发者ID:syrix,项目名称:cryfs,代码行数:7,代码来源:CryConfigCreator.cpp

示例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.");
    }
  }
}
开发者ID:franciscoluiz,项目名称:cryfs,代码行数:12,代码来源:CryConfigLoader.cpp

示例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());
}
开发者ID:smessmer,项目名称:cryfs,代码行数:12,代码来源:CryConfigCreatorTest.cpp

示例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;
 }
开发者ID:franciscoluiz,项目名称:cryfs,代码行数:11,代码来源:CryConfigCreator.cpp

示例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));
}
开发者ID:syrix,项目名称:cryfs,代码行数:21,代码来源:CryConfigFile.cpp

示例7: TEST_F

TEST_F(CryConfigTest, Cipher_AfterSaveAndLoad) {
    cfg.SetCipher("mycipher");
    CryConfig loaded = SaveAndLoad(std::move(cfg));
    EXPECT_EQ("mycipher", loaded.Cipher());
}
开发者ID:syrix,项目名称:cryfs,代码行数:5,代码来源:CryConfigTest.cpp

示例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
}
开发者ID:cryfs,项目名称:cryfs,代码行数:6,代码来源:CryConfigCreatorTest.cpp

示例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());
}
开发者ID:cryfs,项目名称:cryfs,代码行数:4,代码来源:CryDevice.cpp

示例10: Config

 CryConfig Config() {
     CryConfig result;
     result.SetCipher("aes-256-gcm");
     return result;
 }
开发者ID:kjdyck,项目名称:cryfs,代码行数:5,代码来源:CryConfigFileTest.cpp

示例11: SaveAndLoad

 CryConfig SaveAndLoad(CryConfig cfg) {
     Data configData = cfg.save();
     return CryConfig::load(configData);
 }
开发者ID:syrix,项目名称:cryfs,代码行数:4,代码来源:CryConfigTest.cpp

示例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.");
  }
}
开发者ID:franciscoluiz,项目名称:cryfs,代码行数:5,代码来源:CryConfigLoader.cpp

示例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
}
开发者ID:smessmer,项目名称:cryfs,代码行数:5,代码来源:CryConfigCreatorTest.cpp

示例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);
 }
开发者ID:kjdyck,项目名称:cryfs,代码行数:5,代码来源:CryConfigFileTest.cpp


注:本文中的CryConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。