eax.h
Go to the documentation of this file.
// eax.h - written and placed in the public domain by Wei Dai
//! \file eax.h
//! \brief EAX block cipher mode of operation
#ifndef CRYPTOPP_EAX_H
#define CRYPTOPP_EAX_H
#include "authenc.h"
#include "modes.h"
#include "cmac.h"
NAMESPACE_BEGIN(CryptoPP)
//! \class EAX_Base
//! \brief EAX block cipher base implementation
//! \details Base implementation of the AuthenticatedSymmetricCipher interface
//! \since Crypto++ 5.6.0
class CRYPTOPP_NO_VTABLE EAX_Base : public AuthenticatedSymmetricCipherBase
{
public:
// AuthenticatedSymmetricCipher
std::string AlgorithmName() const
{return GetMAC().GetCipher().AlgorithmName() + std::string("/EAX");}
size_t MinKeyLength() const
{return GetMAC().MinKeyLength();}
size_t MaxKeyLength() const
{return GetMAC().MaxKeyLength();}
size_t DefaultKeyLength() const
{return GetMAC().DefaultKeyLength();}
size_t GetValidKeyLength(size_t n) const
{return GetMAC().GetValidKeyLength(n);}
bool IsValidKeyLength(size_t n) const
{return GetMAC().IsValidKeyLength(n);}
unsigned int OptimalDataAlignment() const
{return GetMAC().OptimalDataAlignment();}
IV_Requirement IVRequirement() const
{return UNIQUE_IV;}
unsigned int IVSize() const
{return GetMAC().TagSize();}
unsigned int MinIVLength() const
{return 0;}
unsigned int MaxIVLength() const
{return UINT_MAX;}
unsigned int DigestSize() const
{return GetMAC().TagSize();}
lword MaxHeaderLength() const
{return LWORD_MAX;}
lword MaxMessageLength() const
{return LWORD_MAX;}
protected:
// AuthenticatedSymmetricCipherBase
bool AuthenticationIsOnPlaintext() const
{return false;}
unsigned int AuthenticationBlockSize() const
{return 1;}
void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
void Resync(const byte *iv, size_t len);
size_t AuthenticateBlocks(const byte *data, size_t len);
void AuthenticateLastHeaderBlock();
void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
const CMAC_Base & GetMAC() const {return const_cast<EAX_Base *>(this)->AccessMAC();}
virtual CMAC_Base & AccessMAC() =0;
CTR_Mode_ExternalCipher::Encryption m_ctr;
};
//! \class EAX_Final
//! \brief EAX block cipher final implementation
//! \tparam T_BlockCipher block cipher
//! \tparam T_IsEncryption direction in which to operate the cipher
//! \since Crypto++ 5.6.0
template <class T_BlockCipher, bool T_IsEncryption>
class EAX_Final : public EAX_Base
{
public:
static std::string StaticAlgorithmName()
{return T_BlockCipher::StaticAlgorithmName() + std::string("/EAX");}
bool IsForwardTransformation() const
{return T_IsEncryption;}
private:
CMAC_Base & AccessMAC() {return m_cmac;}
CMAC<T_BlockCipher> m_cmac;
};
#ifdef EAX // EAX is defined to 11 on GCC 3.4.3, OpenSolaris 8.11
#undef EAX
#endif
//! \class EAX
//! \brief EAX block cipher mode of operation
//! \tparam T_BlockCipher block cipher
//! \details \p EAX provides the \p Encryption and \p Decryption typedef. See EAX_Base
//! and EAX_Final for the AuthenticatedSymmetricCipher implementation.
//! \sa <a href="http://www.cryptolounge.org/wiki/EAX">EAX</a> at the Crypto Lounge
//! \since Crypto++ 5.6.0
template <class T_BlockCipher>
struct EAX : public AuthenticatedSymmetricCipherDocumentation
{
typedef EAX_Final<T_BlockCipher, true> Encryption;
typedef EAX_Final<T_BlockCipher, false> Decryption;
};
NAMESPACE_END
#endif
EAX
EAX block cipher mode of operation.
Definition: eax.h:101
EAX_Base::DigestSize
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: eax.h:45
EAX_Base::OptimalDataAlignment
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: eax.h:35
EAX_Base::IVRequirement
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: eax.h:37
modes.h
Class file for modes of operation.
CMAC< T_BlockCipher >
EAX_Base::MinIVLength
unsigned int MinIVLength() const
Provides the minimum size of an IV.
Definition: eax.h:41
SymmetricCipher
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
Definition: cryptlib.h:1099
EAX_Base::MaxIVLength
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
Definition: eax.h:43
AuthenticatedSymmetricCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
Definition: seckey.h:452
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, CTR_ModePolicy > > > >
EAX_Base::AlgorithmName
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: eax.h:23
SimpleKeyingInterface::IV_Requirement
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:590
EAX_Base::IsValidKeyLength
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Definition: eax.h:33
EAX_Base::GetValidKeyLength
size_t GetValidKeyLength(size_t n) const
Definition: eax.h:31
EAX_Base::MaxHeaderLength
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
Definition: eax.h:47
EAX_Final::IsForwardTransformation
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: eax.h:81
authenc.h
Base classes for working with authenticated encryption modes of encryption.
AuthenticatedSymmetricCipherBase
Base implementation for one direction (encryption or decryption) of a stream cipher or block cipher m...
Definition: authenc.h:19
EAX_Base::MaxKeyLength
size_t MaxKeyLength() const
Returns largest valid key length in bytes.
Definition: eax.h:27
EAX_Base::MinKeyLength
size_t MinKeyLength() const
Returns smallest valid key length in bytes.
Definition: eax.h:25
CMAC_Base
CMAC base implementation.
Definition: cmac.h:18
EAX_Base::MaxMessageLength
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
Definition: eax.h:49
CryptoPP
Crypto++ library namespace.
EAX_Base::IVSize
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: eax.h:39
EAX_Base
EAX block cipher base implementation.
Definition: eax.h:19
cmac.h
Classes for CMAC message authentication code.
EAX_Base::DefaultKeyLength
size_t DefaultKeyLength() const
Returns default (recommended) key length in bytes.
Definition: eax.h:29
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:277
EAX_Final
EAX block cipher final implementation.
Definition: eax.h:76