Crypto++
eax.h
1 #ifndef CRYPTOPP_EAX_H
2 #define CRYPTOPP_EAX_H
3 
4 #include "authenc.h"
5 #include "modes.h"
6 #include "cmac.h"
7 
8 NAMESPACE_BEGIN(CryptoPP)
9 
10 //! .
11 class CRYPTOPP_NO_VTABLE EAX_Base : public AuthenticatedSymmetricCipherBase
12 {
13 public:
14  // AuthenticatedSymmetricCipher
15  std::string AlgorithmName() const
16  {return GetMAC().GetCipher().AlgorithmName() + std::string("/EAX");}
17  size_t MinKeyLength() const
18  {return GetMAC().MinKeyLength();}
19  size_t MaxKeyLength() const
20  {return GetMAC().MaxKeyLength();}
21  size_t DefaultKeyLength() const
22  {return GetMAC().DefaultKeyLength();}
23  size_t GetValidKeyLength(size_t n) const
24  {return GetMAC().GetValidKeyLength(n);}
25  bool IsValidKeyLength(size_t n) const
26  {return GetMAC().IsValidKeyLength(n);}
27  unsigned int OptimalDataAlignment() const
28  {return GetMAC().OptimalDataAlignment();}
29  IV_Requirement IVRequirement() const
30  {return UNIQUE_IV;}
31  unsigned int IVSize() const
32  {return GetMAC().TagSize();}
33  unsigned int MinIVLength() const
34  {return 0;}
35  unsigned int MaxIVLength() const
36  {return UINT_MAX;}
37  unsigned int DigestSize() const
38  {return GetMAC().TagSize();}
39  lword MaxHeaderLength() const
40  {return LWORD_MAX;}
41  lword MaxMessageLength() const
42  {return LWORD_MAX;}
43 
44 protected:
45  // AuthenticatedSymmetricCipherBase
46  bool AuthenticationIsOnPlaintext() const
47  {return false;}
48  unsigned int AuthenticationBlockSize() const
49  {return 1;}
50  void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
51  void Resync(const byte *iv, size_t len);
52  size_t AuthenticateBlocks(const byte *data, size_t len);
53  void AuthenticateLastHeaderBlock();
54  void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
55  SymmetricCipher & AccessSymmetricCipher() {return m_ctr;}
56  const CMAC_Base & GetMAC() const {return const_cast<EAX_Base *>(this)->AccessMAC();}
57  virtual CMAC_Base & AccessMAC() =0;
58 
60 };
61 
62 //! .
63 template <class T_BlockCipher, bool T_IsEncryption>
64 class EAX_Final : public EAX_Base
65 {
66 public:
67  static std::string StaticAlgorithmName()
68  {return T_BlockCipher::StaticAlgorithmName() + std::string("/EAX");}
70  {return T_IsEncryption;}
71 
72 private:
73  CMAC_Base & AccessMAC() {return m_cmac;}
74  CMAC<T_BlockCipher> m_cmac;
75 };
76 
77 #ifdef EAX // EAX is defined to 11 on GCC 3.4.3, OpenSolaris 8.11
78 #undef EAX
79 #endif
80 
81 /// <a href="http://www.cryptolounge.org/wiki/EAX">EAX</a>
82 template <class T_BlockCipher>
84 {
87 };
88 
89 NAMESPACE_END
90 
91 #endif
size_t MinKeyLength() const
returns smallest valid key length in bytes */
Definition: eax.h:17
unsigned int DigestSize() const
size of the hash/digest/MAC returned by Final()
Definition: eax.h:37
Each class derived from this one defines two types, Encryption and Decryption, both of which implemen...
Definition: seckey.h:211
Definition: eax.h:11
size_t MaxKeyLength() const
returns largest valid key length in bytes */
Definition: eax.h:19
size_t GetValidKeyLength(size_t n) const
returns the smallest valid key length in bytes that is >= min(n, GetMaxKeyLength()) ...
Definition: eax.h:23
Definition: eax.h:64
interface for one direction (encryption or decryption) of a stream cipher or cipher mode ...
Definition: cryptlib.h:610
lword MaxMessageLength() const
the maximum length of encrypted data
Definition: eax.h:41
unsigned int OptimalDataAlignment() const
returns how input should be aligned for optimal performance
Definition: eax.h:27
IV_Requirement IVRequirement() const
returns the minimal requirement for secure IVs
Definition: eax.h:29
lword MaxHeaderLength() const
the maximum length of AAD that can be input before the encrypted data
Definition: eax.h:39
size_t DefaultKeyLength() const
returns default (recommended) key length in bytes */
Definition: eax.h:21
_
Definition: cmac.h:10
unsigned int MinIVLength() const
returns minimal length of IVs accepted by this object
Definition: eax.h:33
unsigned int MaxIVLength() const
returns maximal length of IVs accepted by this object
Definition: eax.h:35
std::string AlgorithmName() const
returns name of this algorithm, not universally implemented yet
Definition: eax.h:15
bool IsForwardTransformation() const
returns whether this is an encryption object
Definition: eax.h:69
EAX
Definition: eax.h:83
bool IsValidKeyLength(size_t n) const
returns whether n is a valid key length
Definition: eax.h:25
interface for retrieving values given their names
Definition: cryptlib.h:224