1// ttmac.h - written and placed in the public domain by Kevin Springle 2 3#ifndef CRYPTOPP_TTMAC_H 4#define CRYPTOPP_TTMAC_H 5 6#include "seckey.h" 7#include "iterhash.h" 8 9NAMESPACE_BEGIN(CryptoPP) 10 11//! _ 12class CRYPTOPP_NO_VTABLE TTMAC_Base : public FixedKeyLength<20>, public IteratedHash<word32, LittleEndian, 64, MessageAuthenticationCode> 13{ 14public: 15 static std::string StaticAlgorithmName() {return std::string("Two-Track-MAC");} 16 CRYPTOPP_CONSTANT(DIGESTSIZE=20) 17 18 unsigned int DigestSize() const {return DIGESTSIZE;}; 19 void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); 20 void TruncatedFinal(byte *mac, size_t size); 21 22protected: 23 static void Transform (word32 *digest, const word32 *X, bool last); 24 void HashEndianCorrectedBlock(const word32 *data) {Transform(m_digest, data, false);} 25 void Init(); 26 word32* StateBuf() {return m_digest;} 27 28 FixedSizeSecBlock<word32, 10> m_digest; 29 FixedSizeSecBlock<word32, 5> m_key; 30}; 31 32//! <a href="http://www.weidai.com/scan-mirror/mac.html#TTMAC">Two-Track-MAC</a> 33/*! 160 Bit MAC with 160 Bit Key */ 34DOCUMENTED_TYPEDEF(MessageAuthenticationCodeFinal<TTMAC_Base>, TTMAC) 35 36NAMESPACE_END 37 38#endif 39