Add Cipher::NAME to CipherConcept

This commit is contained in:
Sebastian Messmer 2015-10-28 01:49:12 +01:00
parent 926d1ce7a4
commit 3e01c56ad4
5 changed files with 6 additions and 4 deletions

View File

@ -14,8 +14,6 @@ namespace cpputils {
template<typename BlockCipher, unsigned int KeySize>
class CFB_Cipher {
public:
BOOST_CONCEPT_ASSERT((CipherConcept<CFB_Cipher<BlockCipher, KeySize>>));
using EncryptionKey = FixedSizeData<KeySize>;
static EncryptionKey CreateKey(RandomGenerator &randomGenerator) {

View File

@ -7,6 +7,8 @@
#include "../../data/Data.h"
#include "../../random/Random.h"
using std::string;
namespace cpputils {
template<class X>
@ -18,6 +20,7 @@ public:
typename X::EncryptionKey key = X::CreateKey(Random::OSRandom());
same_type(Data(0), X::encrypt((uint8_t*)nullptr, UINT32_C(0), key));
same_type(boost::optional<Data>(Data(0)), X::decrypt((uint8_t*)nullptr, UINT32_C(0), key));
string name = X::NAME;
}
private:

View File

@ -13,8 +13,6 @@ namespace cpputils {
template<typename BlockCipher, unsigned int KeySize>
class GCM_Cipher {
public:
BOOST_CONCEPT_ASSERT((CipherConcept<GCM_Cipher<BlockCipher, KeySize>>));
using EncryptionKey = FixedSizeData<KeySize>;
static EncryptionKey CreateKey(RandomGenerator &randomGenerator) {

View File

@ -13,6 +13,7 @@
#define DEFINE_CIPHER(InstanceName, StringName, Mode, Base, Keysize) \
class InstanceName final: public Mode<Base, Keysize> { \
public: \
BOOST_CONCEPT_ASSERT((CipherConcept<InstanceName>)); \
static constexpr const char *NAME = StringName; \
} \

View File

@ -85,6 +85,8 @@ namespace cpputils {
return std::move(result);
}
static constexpr const char *NAME = "FakeAuthenticatedCipher";
private:
static int32_t _parity(const byte *data, unsigned int size) {
int32_t parity = 34343435; // some init value