Crypto++ 8.5 Free C++ class library of cryptographic schemes

ttmac.h
Go to the documentation of this file.
1 // ttmac.h - written and placed in the public domain by Kevin Springle
2
3 /// \file ttmac.h
4 /// \brief Classes for the TTMAC message authentication code
5
6 #ifndef CRYPTOPP_TTMAC_H
7 #define CRYPTOPP_TTMAC_H
8
9 #include "seckey.h"
10 #include "iterhash.h"
11 #include "secblock.h"
12
13 NAMESPACE_BEGIN(CryptoPP)
14
15 /// \brief TTMAC message authentication code information
16 class CRYPTOPP_NO_VTABLE TTMAC_Base : public FixedKeyLength<20>, public IteratedHash<word32, LittleEndian, 64, MessageAuthenticationCode>
17 {
18 public:
19 static std::string StaticAlgorithmName() {return std::string("Two-Track-MAC");}
20 CRYPTOPP_CONSTANT(DIGESTSIZE=20);
21
22 unsigned int DigestSize() const {return DIGESTSIZE;};
23 void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params);
24 void TruncatedFinal(byte *mac, size_t size);
25
26 protected:
27 static void Transform (word32 *digest, const word32 *X, bool last);
28 void HashEndianCorrectedBlock(const word32 *data) {Transform(m_digest, data, false);}
29 void Init();
30 word32* StateBuf() {return m_digest;}
31
32 FixedSizeSecBlock<word32, 10> m_digest;
33 FixedSizeSecBlock<word32, 5> m_key;
34 };
35
36 /// \brief Two-Track-MAC message authentication code
37 /// \tparam T HashTransformation class
38 /// \details 160-bit MAC with 160-bit key
39 /// \sa MessageAuthenticationCode(), <a href="http://www.weidai.com/scan-mirror/mac.html#TTMAC">Two-Track-MAC</a>
40 DOCUMENTED_TYPEDEF(MessageAuthenticationCodeFinal<TTMAC_Base>, TTMAC);
41
42 NAMESPACE_END
43
44 #endif
EnumToType
Converts an enumeration to a type suitable for use as a template parameter.
Definition: cryptlib.h:135
TTMAC_Base::DigestSize
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: ttmac.h:22
secblock.h
Classes and functions for secure memory allocations.
iterhash.h
Base classes for iterated hashes.
word32
unsigned int word32
32-bit unsigned datatype
Definition: config_int.h:62
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:124
TTMAC
Two-Track-MAC message authentication code.
Definition: ttmac.h:40
seckey.h
Classes and functions for implementing secret key algorithms.
FixedSizeSecBlock< word32, 10 >
TTMAC_Base
TTMAC message authentication code information.
Definition: ttmac.h:16
CryptoPP
Crypto++ library namespace.
MessageAuthenticationCode
Interface for message authentication codes.
Definition: cryptlib.h:1298
MessageAuthenticationCodeFinal< TTMAC_Base >
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:321
IteratedHash
Iterated hash base class.
Definition: iterhash.h:126