Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

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