Fabcoin Core  0.16.2
P2P Digital Currency
eax.h
Go to the documentation of this file.
1 // eax.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_EAX_H
7 #define CRYPTOPP_EAX_H
8 
9 #include "authenc.h"
10 #include "modes.h"
11 #include "cmac.h"
12 
14 
20 {
21 public:
22  // AuthenticatedSymmetricCipher
23  std::string AlgorithmName() const
24  {return GetMAC().GetCipher().AlgorithmName() + std::string("/EAX");}
25  size_t MinKeyLength() const
26  {return GetMAC().MinKeyLength();}
27  size_t MaxKeyLength() const
28  {return GetMAC().MaxKeyLength();}
29  size_t DefaultKeyLength() const
30  {return GetMAC().DefaultKeyLength();}
31  size_t GetValidKeyLength(size_t n) const
32  {return GetMAC().GetValidKeyLength(n);}
33  bool IsValidKeyLength(size_t n) const
34  {return GetMAC().IsValidKeyLength(n);}
35  unsigned int OptimalDataAlignment() const
36  {return GetMAC().OptimalDataAlignment();}
38  {return UNIQUE_IV;}
39  unsigned int IVSize() const
40  {return GetMAC().TagSize();}
41  unsigned int MinIVLength() const
42  {return 0;}
43  unsigned int MaxIVLength() const
44  {return UINT_MAX;}
45  unsigned int DigestSize() const
46  {return GetMAC().TagSize();}
48  {return LWORD_MAX;}
50  {return LWORD_MAX;}
51 
52 protected:
53  // AuthenticatedSymmetricCipherBase
55  {return false;}
56  unsigned int AuthenticationBlockSize() const
57  {return 1;}
58  void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params);
59  void Resync(const byte *iv, size_t len);
60  size_t AuthenticateBlocks(const byte *data, size_t len);
61  void AuthenticateLastHeaderBlock();
62  void AuthenticateLastFooterBlock(byte *mac, size_t macSize);
64  const CMAC_Base & GetMAC() const {return const_cast<EAX_Base *>(this)->AccessMAC();}
65  virtual CMAC_Base & AccessMAC() =0;
66 
68 };
69 
75 template <class T_BlockCipher, bool T_IsEncryption>
76 class EAX_Final : public EAX_Base
77 {
78 public:
79  static std::string StaticAlgorithmName()
80  {return T_BlockCipher::StaticAlgorithmName() + std::string("/EAX");}
82  {return T_IsEncryption;}
83 
84 private:
85  CMAC_Base & AccessMAC() {return m_cmac;}
87 };
88 
89 #ifdef EAX // EAX is defined to 11 on GCC 3.4.3, OpenSolaris 8.11
90 #undef EAX
91 #endif
92 
100 template <class T_BlockCipher>
102 {
105 };
106 
108 
109 #endif
uint8_t byte
Definition: Common.h:57
const lword LWORD_MAX
Definition: config.h:246
size_t MinKeyLength() const
Returns smallest valid key length.
Definition: eax.h:25
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: eax.h:45
Class file for modes of operation.
bool AuthenticationIsOnPlaintext() const
Definition: eax.h:54
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
unsigned int AuthenticationBlockSize() const
Definition: eax.h:56
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
Definition: seckey.h:437
EAX_Final< T_BlockCipher, true > Encryption
Definition: eax.h:103
EAX block cipher base implementation.
Definition: eax.h:19
size_t MaxKeyLength() const
Returns largest valid key length.
Definition: eax.h:27
const CMAC_Base & GetMAC() const
Definition: eax.h:64
Classes for CMAC message authentication code.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
Definition: eax.h:31
EAX block cipher final implementation.
Definition: eax.h:76
EAX_Final< T_BlockCipher, false > Decryption
Definition: eax.h:104
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1103
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
Definition: eax.h:49
Base implementation for one direction (encryption or decryption) of a stream cipher or block cipher m...
Definition: authenc.h:19
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: eax.h:35
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: eax.h:37
CMAC_Base & AccessMAC()
Definition: eax.h:85
SymmetricCipher & AccessSymmetricCipher()
Definition: eax.h:63
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:598
CTR_Mode_ExternalCipher::Encryption m_ctr
Definition: eax.h:67
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
Definition: eax.h:47
size_t DefaultKeyLength() const
Returns default key length.
Definition: eax.h:29
CMAC base implementation.
Definition: cmac.h:18
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: eax.h:39
#define NAMESPACE_END
Definition: config.h:201
word64 lword
Definition: config.h:245
unsigned int MinIVLength() const
Provides the minimum size of an IV.
Definition: eax.h:41
static std::string StaticAlgorithmName()
Definition: eax.h:79
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
Definition: eax.h:43
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: eax.h:23
Base classes for working with authenticated encryption modes of encryption.
CMAC< T_BlockCipher > m_cmac
Definition: eax.h:86
uint8_t const * data
Definition: sha3.h:19
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: eax.h:81
EAX block cipher mode of operation.
Definition: eax.h:101
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Definition: eax.h:33
Interface for retrieving values given their names.
Definition: cryptlib.h:279