Use BlockHash as base class of MD5 as well
[libs/crypto.git] / source / md5.h
1 #ifndef MSP_CRYPTO_MD5_H_
2 #define MSP_CRYPTO_MD5_H_
3
4 #include <msp/core/inttypes.h>
5 #include "blockhash.h"
6
7 namespace Msp {
8 namespace Crypto {
9
10 class MD5: public BlockHash<64>
11 {
12 private:
13         UInt32 buffer[4];
14         UInt64 processed_bytes;
15
16         static UInt32 sin_table[64];
17         static unsigned rotate_table[16];
18
19 public:
20         MD5();
21         MD5(const char *, unsigned);
22         MD5(const std::string &);
23 private:
24         void init();
25
26 public:
27         virtual unsigned get_digest_size() const { return 16; }
28
29         virtual unsigned get_digest(char *, unsigned) const;
30
31 private:
32         virtual void process_block(const char *);
33
34         template<unsigned, unsigned, unsigned>
35         static void perform_round(UInt32 *, const UInt32 *);
36 };
37
38 } // namespace Crypto
39 } // namespace Msp
40
41 #endif