AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
md5.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "crypto/hash/hash.hpp"
23
24
25namespace anch::crypto {
26
27 template<typename H> H HMAC(const std::string&, const std::string&);
28
36 class MD5: public Hash<16,64> {
37
38 friend MD5 anch::crypto::HMAC<MD5>(const std::string&, const std::string&);
39
40 private:
41 struct Context {
43 uint32_t handle[2];
44
46 uint32_t buffer[4];
47
49 uint32_t input[16];
50
52 std::array<uint8_t,16> digest;
53
57 Context();
58
62 void reset();
63
64 };
65
66 // Attributes +
67 private:
69 Context _context;
70 // Attributes -
71
72 // Constructors +
73 public:
77 MD5();
78
84 MD5(const std::string& data);
85
91 MD5(std::istream& stream);
92
93 private:
100 MD5(const uint8_t* data, std::size_t len);
101 // Constructors -
102
103 // Destructor +
104 public:
108 virtual ~MD5();
109 // Destructor -
110
111 // Methods +
112 public:
118 virtual const std::array<uint8_t,16>& digest() const override;
119
120 protected:
124 virtual void reset() override;/* {
125 _context.reset();
126 }*/
127
134 virtual void addData(const uint8_t* data, std::size_t len) override;
135
139 virtual void finalize() override;
140
141 private:
145 void transform();
146 // Methods -
147
148 };
149
150 extern template class Hash<16,64>;
152 extern template MD5 HMAC<MD5>(const std::string&, const std::string&);
153
158
159}
Hash algorithm abstract class.
Definition hash.hpp:38
MD5 hash algorithm implementation.
Definition md5.hpp:36
virtual void reset() override
virtual const std::array< uint8_t, 16 > & digest() const override
MD5(std::istream &stream)
MD5(const std::string &data)
virtual void finalize() override
virtual void addData(const uint8_t *data, std::size_t len) override
Cryptography namespace.
Definition base64.hpp:28
H HMAC(const std::string &, const std::string &)
void registerMD5UUIDProvider()
template MD5 HMAC< MD5 >(const std::string &, const std::string &)