ttmac.h 1.4 KB

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