Crypto++  8.8
Free C++ class library of cryptographic schemes
md2.h
Go to the documentation of this file.
1 // md2.h - originally written and placed in the public domain by Wei Dai
2 
3 /// \file md2.h
4 /// \brief Classes for the MD2 message digest
5 /// \since Crypto++ 3.0
6 
7 #ifndef CRYPTOPP_MD2_H
8 #define CRYPTOPP_MD2_H
9 
10 #include "cryptlib.h"
11 #include "secblock.h"
12 
13 NAMESPACE_BEGIN(CryptoPP)
14 
15 namespace Weak1 {
16 
17 /// \brief MD2 message digest
18 /// \sa <a href="http://www.cryptolounge.org/wiki/MD2">MD2</a>
19 /// \since Crypto++ 3.0
20 class MD2 : public HashTransformation
21 {
22 public:
23  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MD2";}
24 
25  MD2();
26  void Update(const byte *input, size_t length);
27  void TruncatedFinal(byte *hash, size_t size);
28  unsigned int DigestSize() const {return DIGESTSIZE;}
29  unsigned int BlockSize() const {return BLOCKSIZE;}
30  std::string AlgorithmName() const {return StaticAlgorithmName();}
31 
32  CRYPTOPP_CONSTANT(DIGESTSIZE = 16);
33  CRYPTOPP_CONSTANT(BLOCKSIZE = 16);
34 
35 private:
36  void Transform();
37  void Init();
38  SecByteBlock m_X, m_C, m_buf;
39  unsigned int m_count;
40 };
41 
42 }
43 #if CRYPTOPP_ENABLE_NAMESPACE_WEAK >= 1
44 namespace Weak {using namespace Weak1;} // import Weak1 into CryptoPP::Weak
45 #else
46 using namespace Weak1; // import Weak1 into CryptoPP with warning
47 #ifdef __GNUC__
48 #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."
49 #else
50 #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.")
51 #endif
52 #endif
53 
54 NAMESPACE_END
55 
56 #endif
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:1118
SecBlock<byte> typedef.
Definition: secblock.h:1226
MD2 message digest.
Definition: md2.h:21
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: md2.h:28
unsigned int BlockSize() const
Provides the block size of the compression function.
Definition: md2.h:29
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: md2.h:30
Abstract base classes that provide a uniform interface to this library.
Crypto++ library namespace.
Namespace containing weak and wounded algorithms.
Definition: arc4.cpp:14
Classes and functions for secure memory allocations.