77 uint4 input_index, buffer_index;
81 std::cerr <<
"MD5::update: Can't update a finalized digest!" << std::endl;
86 buffer_index = ((
count[0] >> 3) & 0x3F);
89 if ( (
count[0] += (input_length << 3))<(input_length << 3) )
92 count[1] += (input_length >> 29);
95 buffer_space = 64 - buffer_index;
98 if (input_length >= buffer_space) {
100 memcpy (
buffer + buffer_index, input, buffer_space);
104 for (input_index = buffer_space; input_index + 63 < input_length;
115 memcpy(
buffer+buffer_index, input+input_index, input_length-input_index);
126 static uint1 PADDING[64]={
127 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
133 std::cerr <<
"MD5::finalize: Already finalized this digest!" << std::endl;
141 index = (
count[0] >> 3) & 0x3f;
142 padLen = (index < 56) ? (56 - index) : (120 -
index);
161 std::array<uint8_t, 16>
s;
164 std::cerr <<
"MD5::raw_digest: Can't get digest if you haven't "<<
165 "finalized the digest!" <<std::endl;
166 throw std::logic_error(
"MD5::raw_digest: attempted to obtain digest before finalizing it");
169 memcpy(s.data(),
digest, 16);
183 state[0] = 0x67452301;
184 state[1] = 0xefcdab89;
185 state[2] = 0x98badcfe;
186 state[3] = 0x10325476;
225 FF (a, b, c, d, x[ 0],
S11, 0xd76aa478);
226 FF (d, a, b, c, x[ 1],
S12, 0xe8c7b756);
227 FF (c, d, a, b, x[ 2],
S13, 0x242070db);
228 FF (b, c, d, a, x[ 3],
S14, 0xc1bdceee);
229 FF (a, b, c, d, x[ 4],
S11, 0xf57c0faf);
230 FF (d, a, b, c, x[ 5],
S12, 0x4787c62a);
231 FF (c, d, a, b, x[ 6],
S13, 0xa8304613);
232 FF (b, c, d, a, x[ 7],
S14, 0xfd469501);
233 FF (a, b, c, d, x[ 8],
S11, 0x698098d8);
234 FF (d, a, b, c, x[ 9],
S12, 0x8b44f7af);
235 FF (c, d, a, b, x[10],
S13, 0xffff5bb1);
236 FF (b, c, d, a, x[11],
S14, 0x895cd7be);
237 FF (a, b, c, d, x[12],
S11, 0x6b901122);
238 FF (d, a, b, c, x[13],
S12, 0xfd987193);
239 FF (c, d, a, b, x[14],
S13, 0xa679438e);
240 FF (b, c, d, a, x[15],
S14, 0x49b40821);
243 GG (a, b, c, d, x[ 1],
S21, 0xf61e2562);
244 GG (d, a, b, c, x[ 6],
S22, 0xc040b340);
245 GG (c, d, a, b, x[11],
S23, 0x265e5a51);
246 GG (b, c, d, a, x[ 0],
S24, 0xe9b6c7aa);
247 GG (a, b, c, d, x[ 5],
S21, 0xd62f105d);
248 GG (d, a, b, c, x[10],
S22, 0x2441453);
249 GG (c, d, a, b, x[15],
S23, 0xd8a1e681);
250 GG (b, c, d, a, x[ 4],
S24, 0xe7d3fbc8);
251 GG (a, b, c, d, x[ 9],
S21, 0x21e1cde6);
252 GG (d, a, b, c, x[14],
S22, 0xc33707d6);
253 GG (c, d, a, b, x[ 3],
S23, 0xf4d50d87);
254 GG (b, c, d, a, x[ 8],
S24, 0x455a14ed);
255 GG (a, b, c, d, x[13],
S21, 0xa9e3e905);
256 GG (d, a, b, c, x[ 2],
S22, 0xfcefa3f8);
257 GG (c, d, a, b, x[ 7],
S23, 0x676f02d9);
258 GG (b, c, d, a, x[12],
S24, 0x8d2a4c8a);
261 HH (a, b, c, d, x[ 5],
S31, 0xfffa3942);
262 HH (d, a, b, c, x[ 8],
S32, 0x8771f681);
263 HH (c, d, a, b, x[11],
S33, 0x6d9d6122);
264 HH (b, c, d, a, x[14],
S34, 0xfde5380c);
265 HH (a, b, c, d, x[ 1],
S31, 0xa4beea44);
266 HH (d, a, b, c, x[ 4],
S32, 0x4bdecfa9);
267 HH (c, d, a, b, x[ 7],
S33, 0xf6bb4b60);
268 HH (b, c, d, a, x[10],
S34, 0xbebfbc70);
269 HH (a, b, c, d, x[13],
S31, 0x289b7ec6);
270 HH (d, a, b, c, x[ 0],
S32, 0xeaa127fa);
271 HH (c, d, a, b, x[ 3],
S33, 0xd4ef3085);
272 HH (b, c, d, a, x[ 6],
S34, 0x4881d05);
273 HH (a, b, c, d, x[ 9],
S31, 0xd9d4d039);
274 HH (d, a, b, c, x[12],
S32, 0xe6db99e5);
275 HH (c, d, a, b, x[15],
S33, 0x1fa27cf8);
276 HH (b, c, d, a, x[ 2],
S34, 0xc4ac5665);
279 II (a, b, c, d, x[ 0],
S41, 0xf4292244);
280 II (d, a, b, c, x[ 7],
S42, 0x432aff97);
281 II (c, d, a, b, x[14],
S43, 0xab9423a7);
282 II (b, c, d, a, x[ 5],
S44, 0xfc93a039);
283 II (a, b, c, d, x[12],
S41, 0x655b59c3);
284 II (d, a, b, c, x[ 3],
S42, 0x8f0ccc92);
285 II (c, d, a, b, x[10],
S43, 0xffeff47d);
286 II (b, c, d, a, x[ 1],
S44, 0x85845dd1);
287 II (a, b, c, d, x[ 8],
S41, 0x6fa87e4f);
288 II (d, a, b, c, x[15],
S42, 0xfe2ce6e0);
289 II (c, d, a, b, x[ 6],
S43, 0xa3014314);
290 II (b, c, d, a, x[13],
S44, 0x4e0811a1);
291 II (a, b, c, d, x[ 4],
S41, 0xf7537e82);
292 II (d, a, b, c, x[11],
S42, 0xbd3af235);
293 II (c, d, a, b, x[ 2],
S43, 0x2ad7d2bb);
294 II (b, c, d, a, x[ 9],
S44, 0xeb86d391);
302 memset ( reinterpret_cast<uint1*>(x), 0,
sizeof(x));
314 for (i = 0, j = 0; j <
len; i++, j += 4) {
315 output[j] =
static_cast<uint1> (input[
i] & 0xff);
316 output[j+1] =
static_cast<uint1>((input[
i] >> 8) & 0xff);
317 output[j+2] =
static_cast<uint1>((input[
i] >> 16) & 0xff);
318 output[j+3] =
static_cast<uint1>((input[
i] >> 24) & 0xff);
331 for (i = 0, j = 0; j <
len; i++, j += 4)
332 output[i] = (static_cast<uint4>(input[j]))
333 | ((
static_cast<uint4>(input[j+1])) << 8)
334 | ((static_cast<uint4>(input[j+2])) << 16)
335 | ((
static_cast<uint4>(input[j+3])) << 24);
344 return (x << n) | (x >> (32-
n)) ;
353 return (x & y) | (~x &
z);
357 return (x & z) | (y & ~z);
376 a +=
F(b, c, d) + x + ac;
382 a +=
G(b, c, d) + x + ac;
388 a +=
H(b, c, d) + x + ac;
394 a +=
I(b, c, d) + x + ac;
static void decode(uint4 *dest, const uint1 *src, uint4 length)
void update(const uint8_t *input, const uint32_t input_length)
GLenum GLenum GLenum input
static uint4 F(uint4 x, uint4 y, uint4 z)
static uint4 I(uint4 x, uint4 y, uint4 z)
static void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
GLint GLint GLint GLint GLint GLint y
void transform(const uint1 buffer[64])
static uint4 rotate_left(uint4 x, uint4 n)
GLdouble GLdouble GLdouble b
GLuint GLenum GLenum transform
static uint4 G(uint4 x, uint4 y, uint4 z)
static void encode(uint1 *dest, uint4 *src, uint4 length)
static void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
GLboolean GLboolean GLboolean GLboolean a
GLuint GLuint GLsizei count
static void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static const char * output
static void block(LexState *ls)
std::array< uint8_t, 16 > raw_digest()
GLint GLint GLint GLint GLint x
static void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static uint4 H(uint4 x, uint4 y, uint4 z)