IVs and block keys are drawn from pseudorandom generators
This commit is contained in:
parent
e8a48afd3b
commit
97ba17fbb3
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace blockstore {
|
||||
class BlockStoreWithRandomKeys: public BlockStore {
|
||||
public:
|
||||
Key createKey() final {
|
||||
return Key::CreateRandom();
|
||||
return Key::CreatePseudoRandom();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user