2015-08-31 23:04:56 +02:00
|
|
|
#include "../../../implementations/encrypted/ciphers/ciphers.h"
|
2015-05-06 00:09:11 +02:00
|
|
|
#include "../../../implementations/encrypted/ciphers/Cipher.h"
|
|
|
|
#include "../../../implementations/encrypted/EncryptedBlockStore.h"
|
|
|
|
#include "../../../implementations/testfake/FakeBlockStore.h"
|
|
|
|
#include "../../testutils/BlockStoreTest.h"
|
|
|
|
#include "testutils/FakeAuthenticatedCipher.h"
|
|
|
|
#include "google/gtest/gtest.h"
|
|
|
|
|
|
|
|
using ::testing::Test;
|
|
|
|
|
|
|
|
using blockstore::BlockStore;
|
|
|
|
using blockstore::encrypted::EncryptedBlockStore;
|
|
|
|
using blockstore::testfake::FakeBlockStore;
|
|
|
|
using blockstore::encrypted::AES256_GCM;
|
|
|
|
using blockstore::encrypted::AES256_CFB;
|
|
|
|
|
|
|
|
using cpputils::Data;
|
|
|
|
using cpputils::DataFixture;
|
2015-07-21 18:19:34 +02:00
|
|
|
using cpputils::make_unique_ref;
|
|
|
|
using cpputils::unique_ref;
|
2015-05-06 00:09:11 +02:00
|
|
|
|
|
|
|
template<class Cipher>
|
|
|
|
class EncryptedBlockStoreTestFixture: public BlockStoreTestFixture {
|
|
|
|
public:
|
2015-07-21 18:19:34 +02:00
|
|
|
unique_ref<BlockStore> createBlockStore() override {
|
|
|
|
return make_unique_ref<EncryptedBlockStore<Cipher>>(make_unique_ref<FakeBlockStore>(), createKeyFixture());
|
2015-05-06 00:09:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static typename Cipher::EncryptionKey createKeyFixture(int seed = 0) {
|
|
|
|
Data data = DataFixture::generate(Cipher::EncryptionKey::BINARY_LENGTH, seed);
|
|
|
|
return Cipher::EncryptionKey::FromBinary(data.data());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TYPED_TEST_CASE_P(Encrypted_FakeCipher, BlockStoreTest, EncryptedBlockStoreTestFixture<FakeAuthenticatedCipher>);
|
|
|
|
INSTANTIATE_TYPED_TEST_CASE_P(Encrypted_AES256_GCM, BlockStoreTest, EncryptedBlockStoreTestFixture<AES256_GCM>);
|
|
|
|
INSTANTIATE_TYPED_TEST_CASE_P(Encrypted_AES256_CFB, BlockStoreTest, EncryptedBlockStoreTestFixture<AES256_CFB>);
|