Counter Strike : Global Offensive Source Code
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.

38 lines
1.1 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. NAMESPACE_BEGIN(CryptoPP)
  7. //! _
  8. class CRYPTOPP_NO_VTABLE TTMAC_Base : public FixedKeyLength<20>, public IteratedHash<word32, LittleEndian, 64, MessageAuthenticationCode>
  9. {
  10. public:
  11. static std::string StaticAlgorithmName() {return std::string("Two-Track-MAC");}
  12. CRYPTOPP_CONSTANT(DIGESTSIZE=20)
  13. unsigned int DigestSize() const {return DIGESTSIZE;};
  14. void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params);
  15. void TruncatedFinal(byte *mac, size_t size);
  16. protected:
  17. static void Transform (word32 *digest, const word32 *X, bool last);
  18. void HashEndianCorrectedBlock(const word32 *data) {Transform(m_digest, data, false);}
  19. void Init();
  20. word32* StateBuf() {return m_digest;}
  21. FixedSizeSecBlock<word32, 10> m_digest;
  22. FixedSizeSecBlock<word32, 5> m_key;
  23. };
  24. //! <a href="http://www.weidai.com/scan-mirror/mac.html#TTMAC">Two-Track-MAC</a>
  25. /*! 160 Bit MAC with 160 Bit Key */
  26. DOCUMENTED_TYPEDEF(MessageAuthenticationCodeFinal<TTMAC_Base>, TTMAC)
  27. NAMESPACE_END
  28. #endif