Small fix in AES256_GCM

This commit is contained in:
Sebastian Messmer 2015-04-27 17:58:34 +02:00
parent bc33f69877
commit bf77e0ffa7
3 changed files with 6 additions and 10 deletions

View File

@ -52,12 +52,7 @@ std::unique_ptr<Block> EncryptedBlockStore<Cipher>::load(const Key &key) {
if (block.get() == nullptr) {
return nullptr;
}
auto encBlock = EncryptedBlock<Cipher>::TryDecrypt(std::move(block), _encKey);
if (encBlock.get() == nullptr) {
//TODO Think about how to do logging
}
return std::move(encBlock);
return EncryptedBlock<Cipher>::TryDecrypt(std::move(block), _encKey);
}
template<class Cipher>

View File

@ -47,7 +47,8 @@ boost::optional<Data> AES256_GCM::decrypt(const byte *ciphertext, unsigned int c
try {
ArraySource((byte*)ciphertextData, ciphertextSize - IV_SIZE, true,
new AuthenticatedDecryptionFilter(decryption,
new ArraySink((byte*)plaintext.data(), plaintext.size())
new ArraySink((byte*)plaintext.data(), plaintext.size()),
AuthenticatedDecryptionFilter::DEFAULT_FLAGS, TAG_SIZE
)
);
return std::move(plaintext);

View File

@ -1,4 +1,4 @@
#include "../../../implementations/encrypted/ciphers/AES256_CFB.h"
#include "../../../implementations/encrypted/ciphers/AES256_GCM.h"
#include "../../../implementations/encrypted/EncryptedBlockStore.h"
#include "../../../implementations/testfake/FakeBlockStore.h"
#include "../../testutils/BlockStoreTest.h"
@ -8,7 +8,7 @@
using blockstore::BlockStore;
using blockstore::encrypted::EncryptedBlockStore;
using blockstore::testfake::FakeBlockStore;
using blockstore::encrypted::AES256_CFB;
using blockstore::encrypted::AES256_GCM;
using std::unique_ptr;
using std::make_unique;
@ -16,7 +16,7 @@ using std::make_unique;
class EncryptedBlockStoreTestFixture: public BlockStoreTestFixture {
public:
unique_ptr<BlockStore> createBlockStore() override {
return make_unique<EncryptedBlockStore<AES256_CFB>>(make_unique<FakeBlockStore>(), AES256_CFB::EncryptionKey::FromString("1491BB4932A389EE14BC7090A272EE5517627CFA147A971A8E6E747E0C772972"));
return make_unique<EncryptedBlockStore<AES256_GCM>>(make_unique<FakeBlockStore>(), AES256_GCM::EncryptionKey::FromString("1491BB4932A389EE14BC7090A272EE5517627CFA147A971A8E6E747E0C772972"));
}
};