Fabcoin Core  0.16.2
P2P Digital Currency
cbcmac.h
Go to the documentation of this file.
1 // cbcmac.h - written and placed in the public domain by Wei Dai
2 
6 
7 #ifndef CRYPTOPP_CBCMAC_H
8 #define CRYPTOPP_CBCMAC_H
9 
10 #include "seckey.h"
11 #include "secblock.h"
12 
14 
17 {
18 public:
19  CBC_MAC_Base() : m_counter(0) {}
20 
21  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
22  void Update(const byte *input, size_t length);
23  void TruncatedFinal(byte *mac, size_t size);
24  unsigned int DigestSize() const {return const_cast<CBC_MAC_Base*>(this)->AccessCipher().BlockSize();}
25 
26 protected:
27  virtual BlockCipher & AccessCipher() =0;
28 
29 private:
30  void ProcessBuf();
32  unsigned int m_counter;
33 };
34 
36 
39 template <class T>
40 class CBC_MAC : public MessageAuthenticationCodeImpl<CBC_MAC_Base, CBC_MAC<T> >, public SameKeyLengthAs<T>
41 {
42 public:
43  CBC_MAC() {}
45  {this->SetKey(key, length);}
46 
47  static std::string StaticAlgorithmName() {return std::string("CBC-MAC(") + T::StaticAlgorithmName() + ")";}
48 
49 private:
51  typename T::Encryption m_cipher;
52 };
53 
55 
56 #endif
Interface for message authentication codes.
Definition: cryptlib.h:1111
uint8_t byte
Definition: Common.h:57
virtual void SetKey(const byte *key, size_t length, const NameValuePairs &params=g_nullNameValuePairs)
Sets or reset the key of this object.
Definition: cryptlib.cpp:97
SecByteBlock m_reg
Definition: cbcmac.h:31
BlockCipher & AccessCipher()
Definition: cbcmac.h:50
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: cbcmac.h:24
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1095
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
static std::string StaticAlgorithmName()
Definition: cbcmac.h:47
Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication code...
Definition: seckey.h:370
virtual unsigned int BlockSize() const
Provides the block size of the compression function.
Definition: cryptlib.h:981
Provides key lengths based on another class&#39;s key length.
Definition: seckey.h:222
CBC_MAC(const byte *key, size_t length=SameKeyLengthAs< T >::DEFAULT_KEYLENGTH)
Definition: cbcmac.h:44
unsigned int m_counter
Definition: cbcmac.h:32
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
uint8_t const size_t const size
Definition: sha3.h:20
CBC_MAC_Base()
Definition: cbcmac.h:19
#define NAMESPACE_END
Definition: config.h:201
#define CRYPTOPP_DLL
Definition: config.h:704
CBC-MAC
Definition: cbcmac.h:40
T::Encryption m_cipher
Definition: cbcmac.h:51
Interface for retrieving values given their names.
Definition: cryptlib.h:279
CBC_MAC()
Definition: cbcmac.h:43