55 #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) 56 #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) 57 #define H(x, y, z) ((x) ^ (y) ^ (z)) 58 #define I(x, y, z) ((y) ^ ((x) | ~(z))) 61 #define STEP(f, a, b, c, d, x, t, s) \ 62 (a) += f((b), (c), (d)) + (x) + (t); \ 63 (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ 70 (MD5_u32plus) ptr[(n) * 4] | ((MD5_u32plus) ptr[(n) * 4 + 1] << 8) | \ 71 ((MD5_u32plus) ptr[(n) * 4 + 2] << 16) | \ 72 ((MD5_u32plus) ptr[(n) * 4 + 3] << 24)) 73 #define GET(n) (block[(n)]) 81 MD5_u32plus a, b, c, d;
82 MD5_u32plus saved_a, saved_b, saved_c, saved_d;
99 STEP(
F, a, b, c, d,
SET(0), 0xd76aa478, 7)
100 STEP(
F, d, a, b, c,
SET(1), 0xe8c7b756, 12)
101 STEP(
F, c, d, a, b,
SET(2), 0x242070db, 17)
102 STEP(
F, b, c, d, a,
SET(3), 0xc1bdceee, 22)
103 STEP(
F, a, b, c, d,
SET(4), 0xf57c0faf, 7)
104 STEP(
F, d, a, b, c,
SET(5), 0x4787c62a, 12)
105 STEP(
F, c, d, a, b,
SET(6), 0xa8304613, 17)
106 STEP(
F, b, c, d, a,
SET(7), 0xfd469501, 22)
107 STEP(
F, a, b, c, d,
SET(8), 0x698098d8, 7)
108 STEP(
F, d, a, b, c,
SET(9), 0x8b44f7af, 12)
109 STEP(
F, c, d, a, b,
SET(10), 0xffff5bb1, 17)
110 STEP(
F, b, c, d, a,
SET(11), 0x895cd7be, 22)
111 STEP(
F, a, b, c, d,
SET(12), 0x6b901122, 7)
112 STEP(
F, d, a, b, c,
SET(13), 0xfd987193, 12)
113 STEP(
F, c, d, a, b,
SET(14), 0xa679438e, 17)
114 STEP(
F, b, c, d, a,
SET(15), 0x49b40821, 22)
117 STEP(
G, a, b, c, d,
GET(1), 0xf61e2562, 5)
118 STEP(
G, d, a, b, c,
GET(6), 0xc040b340, 9)
119 STEP(
G, c, d, a, b,
GET(11), 0x265e5a51, 14)
120 STEP(
G, b, c, d, a,
GET(0), 0xe9b6c7aa, 20)
121 STEP(
G, a, b, c, d,
GET(5), 0xd62f105d, 5)
122 STEP(
G, d, a, b, c,
GET(10), 0x02441453, 9)
123 STEP(
G, c, d, a, b,
GET(15), 0xd8a1e681, 14)
124 STEP(
G, b, c, d, a,
GET(4), 0xe7d3fbc8, 20)
125 STEP(
G, a, b, c, d,
GET(9), 0x21e1cde6, 5)
126 STEP(
G, d, a, b, c,
GET(14), 0xc33707d6, 9)
127 STEP(
G, c, d, a, b,
GET(3), 0xf4d50d87, 14)
128 STEP(
G, b, c, d, a,
GET(8), 0x455a14ed, 20)
129 STEP(
G, a, b, c, d,
GET(13), 0xa9e3e905, 5)
130 STEP(
G, d, a, b, c,
GET(2), 0xfcefa3f8, 9)
131 STEP(
G, c, d, a, b,
GET(7), 0x676f02d9, 14)
132 STEP(
G, b, c, d, a,
GET(12), 0x8d2a4c8a, 20)
135 STEP(
H, a, b, c, d,
GET(5), 0xfffa3942, 4)
136 STEP(
H, d, a, b, c,
GET(8), 0x8771f681, 11)
137 STEP(
H, c, d, a, b,
GET(11), 0x6d9d6122, 16)
138 STEP(
H, b, c, d, a,
GET(14), 0xfde5380c, 23)
139 STEP(
H, a, b, c, d,
GET(1), 0xa4beea44, 4)
140 STEP(
H, d, a, b, c,
GET(4), 0x4bdecfa9, 11)
141 STEP(
H, c, d, a, b,
GET(7), 0xf6bb4b60, 16)
142 STEP(
H, b, c, d, a,
GET(10), 0xbebfbc70, 23)
143 STEP(
H, a, b, c, d,
GET(13), 0x289b7ec6, 4)
144 STEP(
H, d, a, b, c,
GET(0), 0xeaa127fa, 11)
145 STEP(
H, c, d, a, b,
GET(3), 0xd4ef3085, 16)
146 STEP(
H, b, c, d, a,
GET(6), 0x04881d05, 23)
147 STEP(
H, a, b, c, d,
GET(9), 0xd9d4d039, 4)
148 STEP(
H, d, a, b, c,
GET(12), 0xe6db99e5, 11)
149 STEP(
H, c, d, a, b,
GET(15), 0x1fa27cf8, 16)
150 STEP(
H, b, c, d, a,
GET(2), 0xc4ac5665, 23)
153 STEP(
I, a, b, c, d,
GET(0), 0xf4292244, 6)
154 STEP(
I, d, a, b, c,
GET(7), 0x432aff97, 10)
155 STEP(
I, c, d, a, b,
GET(14), 0xab9423a7, 15)
156 STEP(
I, b, c, d, a,
GET(5), 0xfc93a039, 21)
157 STEP(
I, a, b, c, d,
GET(12), 0x655b59c3, 6)
158 STEP(
I, d, a, b, c,
GET(3), 0x8f0ccc92, 10)
159 STEP(
I, c, d, a, b,
GET(10), 0xffeff47d, 15)
160 STEP(
I, b, c, d, a,
GET(1), 0x85845dd1, 21)
161 STEP(
I, a, b, c, d,
GET(8), 0x6fa87e4f, 6)
162 STEP(
I, d, a, b, c,
GET(15), 0xfe2ce6e0, 10)
163 STEP(
I, c, d, a, b,
GET(6), 0xa3014314, 15)
164 STEP(
I, b, c, d, a,
GET(13), 0x4e0811a1, 21)
165 STEP(
I, a, b, c, d,
GET(4), 0xf7537e82, 6)
166 STEP(
I, d, a, b, c,
GET(11), 0xbd3af235, 10)
167 STEP(
I, c, d, a, b,
GET(2), 0x2ad7d2bb, 15)
168 STEP(
I, b, c, d, a,
GET(9), 0xeb86d391, 21)
176 }
while (Size -= 64);
191 unsigned long used, free;
192 const uint8_t *Ptr = Data.
data();
196 if ((lo = (saved_lo + Size) & 0x1fffffff) < saved_lo)
200 used = saved_lo & 0x3f;
206 memcpy(&buffer[used], Ptr, Size);
210 memcpy(&buffer[used], Ptr, free);
217 Ptr = body(
makeArrayRef(Ptr, Size & ~(
unsigned long) 0x3f));
221 memcpy(buffer, Ptr, Size);
235 unsigned long used, free;
239 buffer[used++] = 0x80;
244 memset(&buffer[used], 0, free);
250 memset(&buffer[used], 0, free - 8);
267 for (
int i = 0; i < 16; ++i)
268 Res <<
format(
"%.2x", Bytes[i]);
This class represents lattice values for constants.
static void stringifyResult(MD5Result &Result, SmallString< 32 > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
SmallString< 32 > digest() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
A raw_ostream that writes to an SmallVector or SmallString.
void write32le(void *P, uint32_t V)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
#define STEP(f, a, b, c, d, x, t, s)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
size_t size() const
size - Get the array size.
static std::array< uint8_t, 16 > hash(ArrayRef< uint8_t > Data)
Computes the hash for a given bytes.
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
StringRef - Represent a constant reference to a string, i.e.