md2.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // md2.h - originally written and placed in the public domain by Wei Dai
  2. /// \file md2.h
  3. /// \brief Classes for the MD2 message digest
  4. /// \since Crypto++ 3.0
  5. #ifndef CRYPTOPP_MD2_H
  6. #define CRYPTOPP_MD2_H
  7. #include "cryptlib.h"
  8. #include "secblock.h"
  9. NAMESPACE_BEGIN(CryptoPP)
  10. namespace Weak1 {
  11. /// \brief MD2 message digest
  12. /// \sa <a href="http://www.cryptolounge.org/wiki/MD2">MD2</a>
  13. /// \since Crypto++ 3.0
  14. class MD2 : public HashTransformation
  15. {
  16. public:
  17. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MD2";}
  18. MD2();
  19. void Update(const byte *input, size_t length);
  20. void TruncatedFinal(byte *hash, size_t size);
  21. unsigned int DigestSize() const {return DIGESTSIZE;}
  22. unsigned int BlockSize() const {return BLOCKSIZE;}
  23. std::string AlgorithmName() const {return StaticAlgorithmName();}
  24. CRYPTOPP_CONSTANT(DIGESTSIZE = 16);
  25. CRYPTOPP_CONSTANT(BLOCKSIZE = 16);
  26. private:
  27. void Transform();
  28. void Init();
  29. SecByteBlock m_X, m_C, m_buf;
  30. unsigned int m_count;
  31. };
  32. }
  33. #if CRYPTOPP_ENABLE_NAMESPACE_WEAK >= 1
  34. namespace Weak {using namespace Weak1;} // import Weak1 into CryptoPP::Weak
  35. #else
  36. using namespace Weak1; // import Weak1 into CryptoPP with warning
  37. #ifdef __GNUC__
  38. #warning "You may be using a weak algorithm that has been retained for backwards compatibility. Please '#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1' before including this .h file and prepend the class name with 'Weak::' to remove this warning."
  39. #else
  40. #pragma message("You may be using a weak algorithm that has been retained for backwards compatibility. Please '#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1' before including this .h file and prepend the class name with 'Weak::' to remove this warning.")
  41. #endif
  42. #endif
  43. NAMESPACE_END
  44. #endif