IVs and block keys are drawn from pseudorandom generators

This commit is contained in:
Sebastian Messmer 2015-06-16 16:52:23 +02:00
parent e8a48afd3b
commit 97ba17fbb3
4 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@ namespace encrypted {
constexpr unsigned int AES256_CFB::IV_SIZE;
Data AES256_CFB::encrypt(const byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) {
FixedSizeData<IV_SIZE> iv = FixedSizeData<IV_SIZE>::CreateRandom();
FixedSizeData<IV_SIZE> iv = FixedSizeData<IV_SIZE>::CreatePseudoRandom();
auto encryption = CFB_Mode<AES>::Encryption(encKey.data(), encKey.BINARY_LENGTH, iv.data());
Data ciphertext(ciphertextSize(plaintextSize));
std::memcpy(ciphertext.data(), iv.data(), IV_SIZE);

View File

@ -18,7 +18,7 @@ namespace encrypted {
constexpr unsigned int AES256_GCM::IV_SIZE;
Data AES256_GCM::encrypt(const byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) {
FixedSizeData<IV_SIZE> iv = FixedSizeData<IV_SIZE>::CreateRandom();
FixedSizeData<IV_SIZE> iv = FixedSizeData<IV_SIZE>::CreatePseudoRandom();
GCM<AES, GCM_64K_Tables>::Encryption encryption;
encryption.SetKeyWithIV(encKey.data(), encKey.BINARY_LENGTH, iv.data(), IV_SIZE);
Data ciphertext(ciphertextSize(plaintextSize));

View File

@ -15,7 +15,7 @@ public:
BOOST_CONCEPT_USAGE(CipherConcept) {
same_type(UINT32_C(0), X::ciphertextSize(UINT32_C(5)));
same_type(UINT32_C(0), X::plaintextSize(UINT32_C(5)));
typename X::EncryptionKey key = X::EncryptionKey::CreateRandom();
typename X::EncryptionKey key = X::EncryptionKey::CreateOSRandom();
same_type(cpputils::Data(0), X::encrypt((uint8_t*)nullptr, UINT32_C(0), key));
same_type(boost::optional<cpputils::Data>(cpputils::Data(0)), X::decrypt((uint8_t*)nullptr, UINT32_C(0), key));
}

View File

@ -13,7 +13,7 @@ namespace blockstore {
class BlockStoreWithRandomKeys: public BlockStore {
public:
Key createKey() final {
return Key::CreateRandom();
return Key::CreatePseudoRandom();
}
};