libcryfs/implementations/encrypted/ciphers/Cipher.h
Sebastian Messmer 0042ae1cef - Run test cases for EncryptedBlockStore with different ciphers
- Implement FakeAuthenticatedCipher for use with specific EncryptedBlockStoreTest
- Write skeleton for specific EncryptedBlockStoreTest
- Fix behavior of AES256_CFB when called with too small input
- Add testcase that all ciphers (also non-authenticating ones) have to handle too small input correctly
2015-05-06 00:12:14 +02:00

34 lines
937 B
C++

#pragma once
#ifndef MESSMER_BLOCKSTORE_IMPLEMENTATIONS_ENCRYPTED_CIPHERS_CIPHER_H_
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_ENCRYPTED_CIPHERS_CIPHER_H_
#include <boost/concept_check.hpp>
#include <cstdint>
#include <messmer/cpp-utils/data/Data.h>
namespace blockstore {
namespace encrypted {
template<class X>
struct CipherConcept {
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();
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));
}
private:
// Type deduction will fail unless the arguments have the same type.
template <typename T> void same_type(T const&, T const&);
};
}
}
#endif