fix line ending
parent
f299d530ce
commit
63c53605a5
174
eax.h
174
eax.h
|
|
@ -1,91 +1,91 @@
|
||||||
#ifndef CRYPTOPP_EAX_H
|
#ifndef CRYPTOPP_EAX_H
|
||||||
#define CRYPTOPP_EAX_H
|
#define CRYPTOPP_EAX_H
|
||||||
|
|
||||||
#include "authenc.h"
|
#include "authenc.h"
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
#include "cmac.h"
|
#include "cmac.h"
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
//! .
|
//! .
|
||||||
class CRYPTOPP_NO_VTABLE EAX_Base : public AuthenticatedSymmetricCipherBase
|
class CRYPTOPP_NO_VTABLE EAX_Base : public AuthenticatedSymmetricCipherBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// AuthenticatedSymmetricCipher
|
// AuthenticatedSymmetricCipher
|
||||||
std::string AlgorithmName() const
|
std::string AlgorithmName() const
|
||||||
{return GetMAC().GetCipher().AlgorithmName() + std::string("/EAX");}
|
{return GetMAC().GetCipher().AlgorithmName() + std::string("/EAX");}
|
||||||
size_t MinKeyLength() const
|
size_t MinKeyLength() const
|
||||||
{return GetMAC().MinKeyLength();}
|
{return GetMAC().MinKeyLength();}
|
||||||
size_t MaxKeyLength() const
|
size_t MaxKeyLength() const
|
||||||
{return GetMAC().MaxKeyLength();}
|
{return GetMAC().MaxKeyLength();}
|
||||||
size_t DefaultKeyLength() const
|
size_t DefaultKeyLength() const
|
||||||
{return GetMAC().DefaultKeyLength();}
|
{return GetMAC().DefaultKeyLength();}
|
||||||
size_t GetValidKeyLength(size_t n) const
|
size_t GetValidKeyLength(size_t n) const
|
||||||
{return GetMAC().GetValidKeyLength(n);}
|
{return GetMAC().GetValidKeyLength(n);}
|
||||||
bool IsValidKeyLength(size_t n) const
|
bool IsValidKeyLength(size_t n) const
|
||||||
{return GetMAC().IsValidKeyLength(n);}
|
{return GetMAC().IsValidKeyLength(n);}
|
||||||
unsigned int OptimalDataAlignment() const
|
unsigned int OptimalDataAlignment() const
|
||||||
{return GetMAC().OptimalDataAlignment();}
|
{return GetMAC().OptimalDataAlignment();}
|
||||||
IV_Requirement IVRequirement() const
|
IV_Requirement IVRequirement() const
|
||||||
{return UNIQUE_IV;}
|
{return UNIQUE_IV;}
|
||||||
unsigned int IVSize() const
|
unsigned int IVSize() const
|
||||||
{return GetMAC().TagSize();}
|
{return GetMAC().TagSize();}
|
||||||
unsigned int MinIVLength() const
|
unsigned int MinIVLength() const
|
||||||
{return 0;}
|
{return 0;}
|
||||||
unsigned int MaxIVLength() const
|
unsigned int MaxIVLength() const
|
||||||
{return UINT_MAX;}
|
{return UINT_MAX;}
|
||||||
unsigned int DigestSize() const
|
unsigned int DigestSize() const
|
||||||
{return GetMAC().TagSize();}
|
{return GetMAC().TagSize();}
|
||||||
lword MaxHeaderLength() const
|
lword MaxHeaderLength() const
|
||||||
{return LWORD_MAX;}
|
{return LWORD_MAX;}
|
||||||
lword MaxMessageLength() const
|
lword MaxMessageLength() const
|
||||||
{return LWORD_MAX;}
|
{return LWORD_MAX;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// AuthenticatedSymmetricCipherBase
|
// AuthenticatedSymmetricCipherBase
|
||||||
bool AuthenticationIsOnPlaintext() const
|
bool AuthenticationIsOnPlaintext() const
|
||||||
{return false;}
|
{return false;}
|
||||||
unsigned int AuthenticationBlockSize() const
|
unsigned int AuthenticationBlockSize() const
|
||||||
{return 1;}
|
{return 1;}
|
||||||
void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms);
|
void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms);
|
||||||
void Resync(const byte *iv, size_t len);
|
void Resync(const byte *iv, size_t len);
|
||||||
size_t AuthenticateBlocks(const byte *data, size_t len);
|
size_t AuthenticateBlocks(const byte *data, size_t len);
|
||||||
void AuthenticateLastHeaderBlock();
|
void AuthenticateLastHeaderBlock();
|
||||||
void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
|
void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
|
||||||
SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
|
SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
|
||||||
const CMAC_Base & GetMAC() const {return const_cast<EAX_Base *>(this)->AccessMAC();}
|
const CMAC_Base & GetMAC() const {return const_cast<EAX_Base *>(this)->AccessMAC();}
|
||||||
virtual CMAC_Base & AccessMAC() =0;
|
virtual CMAC_Base & AccessMAC() =0;
|
||||||
|
|
||||||
CTR_Mode_ExternalCipher::Encryption m_ctr;
|
CTR_Mode_ExternalCipher::Encryption m_ctr;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! .
|
//! .
|
||||||
template <class T_BlockCipher, bool T_IsEncryption>
|
template <class T_BlockCipher, bool T_IsEncryption>
|
||||||
class EAX_Final : public EAX_Base
|
class EAX_Final : public EAX_Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string StaticAlgorithmName()
|
static std::string StaticAlgorithmName()
|
||||||
{return T_BlockCipher::StaticAlgorithmName() + std::string("/EAX");}
|
{return T_BlockCipher::StaticAlgorithmName() + std::string("/EAX");}
|
||||||
bool IsForwardTransformation() const
|
bool IsForwardTransformation() const
|
||||||
{return T_IsEncryption;}
|
{return T_IsEncryption;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMAC_Base & AccessMAC() {return m_cmac;}
|
CMAC_Base & AccessMAC() {return m_cmac;}
|
||||||
CMAC<T_BlockCipher> m_cmac;
|
CMAC<T_BlockCipher> m_cmac;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EAX // EAX is defined to 11 on GCC 3.4.3, OpenSolaris 8.11
|
#ifdef EAX // EAX is defined to 11 on GCC 3.4.3, OpenSolaris 8.11
|
||||||
#undef EAX
|
#undef EAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <a href="http://www.cryptolounge.org/wiki/EAX">EAX</a>
|
/// <a href="http://www.cryptolounge.org/wiki/EAX">EAX</a>
|
||||||
template <class T_BlockCipher>
|
template <class T_BlockCipher>
|
||||||
struct EAX : public AuthenticatedSymmetricCipherDocumentation
|
struct EAX : public AuthenticatedSymmetricCipherDocumentation
|
||||||
{
|
{
|
||||||
typedef EAX_Final<T_BlockCipher, true> Encryption;
|
typedef EAX_Final<T_BlockCipher, true> Encryption;
|
||||||
typedef EAX_Final<T_BlockCipher, false> Decryption;
|
typedef EAX_Final<T_BlockCipher, false> Decryption;
|
||||||
};
|
};
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue