| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
md5.hpp
1/* MD5
2 converted to C++ class by Frank Thilo (thilo@unix-ag.org)
3 for bzflag (http://www.bzflag.org)
4
5 based on:
6
7 md5.h and md5.c
8 reference implementation of RFC 1321
9
10 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
11 rights reserved.
12
13 License to copy and use this software is granted provided that it
14 is identified as the "RSA Data Security, Inc. MD5 Message-Digest
15 Algorithm" in all material mentioning or referencing this software
16 or this function.
17
18 License is also granted to make and use derivative works provided
19 that such works are identified as "derived from the RSA Data
20 Security, Inc. MD5 Message-Digest Algorithm" in all material
21 mentioning or referencing the derived work.
22
23 RSA Data Security, Inc. makes no representations concerning either
24 the merchantability of this software or the suitability of this
25 software for any particular purpose. It is provided "as is"
26 without express or implied warranty of any kind.
27
28 These notices must be retained in any copies of any part of this
29 documentation and/or software.
30
31 */
32
37
38#ifndef FASTDDS_UTILS__MD5_HPP
39#define FASTDDS_UTILS__MD5_HPP
40
41#include <cstring>
42#include <iostream>
43
44#include <fastdds/fastdds_dll.hpp>
45
46 namespace eprosima {
47 namespace fastdds {
48
62 class FASTDDS_EXPORTED_API MD5
63{
64 public:
65
66 typedef unsigned char uint1; // 8bit
67 typedef unsigned int size_type; // must be 32bit
68
69 MD5();
70 MD5(
71 const std::string& text);
72 void update(
73 const unsigned char* buf,
74 size_type length);
75 void update(
76 const char* buf,
77 size_type length);
78 MD5& finalize();
79 std::string hexdigest() const;
80 friend std::ostream& operator <<(
81 std::ostream&,
82 MD5& md5);
83 uint1 digest[16]; // the result
84
85 void init();
86
87 private:
88
89 typedef unsigned int uint4; // 32bit
90 enum
91 {
92 blocksize = 64
93 }; // VC6 won't eat a const static int here
94
95 void transform(
96 const uint1 block[blocksize]);
97 static void decode(
98 uint4 output[],
99 const uint1 input[],
100 size_type len);
101 static void encode(
102 uint1 output[],
103 const uint4 input[],
104 size_type len);
105
106 bool finalized;
107 uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
108 uint4 count[2]; // 64bit counter for number of bits (lo, hi)
109 uint4 state[4]; // digest so far
110
111 // low level logic operations
112 static inline uint4 F(
113 uint4 x,
114 uint4 y,
115 uint4 z);
116 static inline uint4 G(
117 uint4 x,
118 uint4 y,
119 uint4 z);
120 static inline uint4 H(
121 uint4 x,
122 uint4 y,
123 uint4 z);
124 static inline uint4 I(
125 uint4 x,
126 uint4 y,
127 uint4 z);
128 static inline uint4 rotate_left(
129 uint4 x,
130 int n);
131 static inline void FF(
132 uint4& a,
133 uint4 b,
134 uint4 c,
135 uint4 d,
136 uint4 x,
137 uint4 s,
138 uint4 ac);
139 static inline void GG(
140 uint4& a,
141 uint4 b,
142 uint4 c,
143 uint4 d,
144 uint4 x,
145 uint4 s,
146 uint4 ac);
147 static inline void HH(
148 uint4& a,
149 uint4 b,
150 uint4 c,
151 uint4 d,
152 uint4 x,
153 uint4 s,
154 uint4 ac);
155 static inline void II(
156 uint4& a,
157 uint4 b,
158 uint4 c,
159 uint4 d,
160 uint4 x,
161 uint4 s,
162 uint4 ac);
163};
164
165std::string md5(
166 const std::string str);
167
168} // namespace fastdds
169} // namespace eprosima
170
171#endif // FASTDDS_UTILS__MD5_HPP
172
eprosima::fastdds::MD5::uint1
unsigned char uint1
Definition md5.hpp:66
eprosima::fastdds::MD5::init
void init()
eprosima::fastdds::MD5::update
void update(const unsigned char *buf, size_type length)
eprosima::fastdds::MD5::finalize
MD5 & finalize()
eprosima::fastdds::MD5::update
void update(const char *buf, size_type length)
eprosima::fastdds::MD5::MD5
MD5()
eprosima::fastdds::MD5::MD5
MD5(const std::string &text)
eprosima::fastdds::MD5::size_type
unsigned int size_type
Definition md5.hpp:67
eprosima::fastdds::MD5::digest
uint1 digest[16]
Definition md5.hpp:83
eprosima::fastdds::MD5::hexdigest
std::string hexdigest() const
eprosima::fastdds
eprosima::fastdds::md5
std::string md5(const std::string str)
eprosima
eProsima namespace.