1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1996-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A***********************************************************************/ 1N/A/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 1N/A License to copy and use this software is granted provided that it 1N/A is identified as the "RSA Data Security, Inc. MD5 Message-Digest 1N/A Method" in all material mentioning or referencing this software 1N/A License is also granted to make and use derivative works provided 1N/A that such works are identified as "derived from the RSA Data 1N/A Security, Inc. MD5 Message-Digest Method" in all material 1N/A mentioning or referencing the derived work. 1N/A RSA Data Security, Inc. makes no representations concerning either 1N/A the merchantability of this software or the suitability of this 1N/A software for any particular purpose. It is provided "as is" 1N/A without express or implied warranty of any kind. 1N/A These notices must be retained in any copies of any part of this 1N/A "The RSA Data Security, Inc. MD5 Message-Digest Method, 1991-2, \ 1N/A used with permission. The block count is not printed." 1N/A#
define md5_options "[+(version)?md5 (RSA Data Security, Inc. MD5 Message-Digest, 1991-2) 1996-02-29]" 1N/A 0x80,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
1N/A 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00 1N/A * encode input into output 1N/A * len must be a multiple of 4 1N/A register unsigned int i;
1N/A register unsigned int j;
1N/A for (i = j = 0; j <
len; i++, j +=
4)
1N/A * decode input into output 1N/A * len must be a multiple of 4 1N/A for (i = j = 0; j <
len; i++, j +=
4)
1N/A * basic MD5 step -- transforms buf based on in 1N/A/* F, G, H and I are basic MD5 functions */ 1N/A#
define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
1N/A#
define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
1N/A#
define H(x, y, z) ((x) ^ (y) ^ (z))
1N/A#
define I(x, y, z) ((y) ^ ((x) | (~z)))
1N/A/* ROTATE_LEFT rotates x left n bits */ 1N/A/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ 1N/A/* Rotation is separate from addition to prevent recomputation */ 1N/A#
define FF(a, b, c, d, x, s,
ac) { \
1N/A#
define GG(a, b, c, d, x, s,
ac) { \
1N/A#
define HH(a, b, c, d, x, s,
ac) { \
1N/A#
define II(a, b, c, d, x, s,
ac) { \
1N/A FF (a, b, c, d, x[ 0],
S11,
0xd76aa478);
/* 1 */ 1N/A FF (d, a, b, c, x[
1],
S12,
0xe8c7b756);
/* 2 */ 1N/A FF (c, d, a, b, x[
2],
S13,
0x242070db);
/* 3 */ 1N/A FF (b, c, d, a, x[
3],
S14,
0xc1bdceee);
/* 4 */ 1N/A FF (a, b, c, d, x[
4],
S11,
0xf57c0faf);
/* 5 */ 1N/A FF (d, a, b, c, x[
5],
S12,
0x4787c62a);
/* 6 */ 1N/A FF (c, d, a, b, x[
6],
S13,
0xa8304613);
/* 7 */ 1N/A FF (b, c, d, a, x[
7],
S14,
0xfd469501);
/* 8 */ 1N/A FF (a, b, c, d, x[
8],
S11,
0x698098d8);
/* 9 */ 1N/A FF (d, a, b, c, x[
9],
S12,
0x8b44f7af);
/* 10 */ 1N/A FF (c, d, a, b, x[
10],
S13,
0xffff5bb1);
/* 11 */ 1N/A FF (b, c, d, a, x[
11],
S14,
0x895cd7be);
/* 12 */ 1N/A FF (a, b, c, d, x[
12],
S11,
0x6b901122);
/* 13 */ 1N/A FF (d, a, b, c, x[
13],
S12,
0xfd987193);
/* 14 */ 1N/A FF (c, d, a, b, x[
14],
S13,
0xa679438e);
/* 15 */ 1N/A FF (b, c, d, a, x[
15],
S14,
0x49b40821);
/* 16 */ 1N/A GG (a, b, c, d, x[
1],
S21,
0xf61e2562);
/* 17 */ 1N/A GG (d, a, b, c, x[
6],
S22,
0xc040b340);
/* 18 */ 1N/A GG (c, d, a, b, x[
11],
S23,
0x265e5a51);
/* 19 */ 1N/A GG (b, c, d, a, x[ 0],
S24,
0xe9b6c7aa);
/* 20 */ 1N/A GG (a, b, c, d, x[
5],
S21,
0xd62f105d);
/* 21 */ 1N/A GG (d, a, b, c, x[
10],
S22,
0x02441453);
/* 22 */ 1N/A GG (c, d, a, b, x[
15],
S23,
0xd8a1e681);
/* 23 */ 1N/A GG (b, c, d, a, x[
4],
S24,
0xe7d3fbc8);
/* 24 */ 1N/A GG (a, b, c, d, x[
9],
S21,
0x21e1cde6);
/* 25 */ 1N/A GG (d, a, b, c, x[
14],
S22,
0xc33707d6);
/* 26 */ 1N/A GG (c, d, a, b, x[
3],
S23,
0xf4d50d87);
/* 27 */ 1N/A GG (b, c, d, a, x[
8],
S24,
0x455a14ed);
/* 28 */ 1N/A GG (a, b, c, d, x[
13],
S21,
0xa9e3e905);
/* 29 */ 1N/A GG (d, a, b, c, x[
2],
S22,
0xfcefa3f8);
/* 30 */ 1N/A GG (c, d, a, b, x[
7],
S23,
0x676f02d9);
/* 31 */ 1N/A GG (b, c, d, a, x[
12],
S24,
0x8d2a4c8a);
/* 32 */ 1N/A HH (a, b, c, d, x[
5],
S31,
0xfffa3942);
/* 33 */ 1N/A HH (d, a, b, c, x[
8],
S32,
0x8771f681);
/* 34 */ 1N/A HH (c, d, a, b, x[
11],
S33,
0x6d9d6122);
/* 35 */ 1N/A HH (b, c, d, a, x[
14],
S34,
0xfde5380c);
/* 36 */ 1N/A HH (a, b, c, d, x[
1],
S31,
0xa4beea44);
/* 37 */ 1N/A HH (d, a, b, c, x[
4],
S32,
0x4bdecfa9);
/* 38 */ 1N/A HH (c, d, a, b, x[
7],
S33,
0xf6bb4b60);
/* 39 */ 1N/A HH (b, c, d, a, x[
10],
S34,
0xbebfbc70);
/* 40 */ 1N/A HH (a, b, c, d, x[
13],
S31,
0x289b7ec6);
/* 41 */ 1N/A HH (d, a, b, c, x[ 0],
S32,
0xeaa127fa);
/* 42 */ 1N/A HH (c, d, a, b, x[
3],
S33,
0xd4ef3085);
/* 43 */ 1N/A HH (b, c, d, a, x[
6],
S34,
0x04881d05);
/* 44 */ 1N/A HH (a, b, c, d, x[
9],
S31,
0xd9d4d039);
/* 45 */ 1N/A HH (d, a, b, c, x[
12],
S32,
0xe6db99e5);
/* 46 */ 1N/A HH (c, d, a, b, x[
15],
S33,
0x1fa27cf8);
/* 47 */ 1N/A HH (b, c, d, a, x[
2],
S34,
0xc4ac5665);
/* 48 */ 1N/A II (a, b, c, d, x[ 0],
S41,
0xf4292244);
/* 49 */ 1N/A II (d, a, b, c, x[
7],
S42,
0x432aff97);
/* 50 */ 1N/A II (c, d, a, b, x[
14],
S43,
0xab9423a7);
/* 51 */ 1N/A II (b, c, d, a, x[
5],
S44,
0xfc93a039);
/* 52 */ 1N/A II (a, b, c, d, x[
12],
S41,
0x655b59c3);
/* 53 */ 1N/A II (d, a, b, c, x[
3],
S42,
0x8f0ccc92);
/* 54 */ 1N/A II (c, d, a, b, x[
10],
S43,
0xffeff47d);
/* 55 */ 1N/A II (b, c, d, a, x[
1],
S44,
0x85845dd1);
/* 56 */ 1N/A II (a, b, c, d, x[
8],
S41,
0x6fa87e4f);
/* 57 */ 1N/A II (d, a, b, c, x[
15],
S42,
0xfe2ce6e0);
/* 58 */ 1N/A II (c, d, a, b, x[
6],
S43,
0xa3014314);
/* 59 */ 1N/A II (b, c, d, a, x[
13],
S44,
0x4e0811a1);
/* 60 */ 1N/A II (a, b, c, d, x[
4],
S41,
0xf7537e82);
/* 61 */ 1N/A II (d, a, b, c, x[
11],
S42,
0xbd3af235);
/* 62 */ 1N/A II (c, d, a, b, x[
2],
S43,
0x2ad7d2bb);
/* 63 */ 1N/A II (b, c, d, a, x[
9],
S44,
0xeb86d391);
/* 64 */ 1N/A unsigned char*
input = (
unsigned char*)s;
1N/A /* compute number of bytes mod 64 */ 1N/A /* update number of bits */ 1N/A /* transform as many times as possible */ 1N/A /* buffer remaining input */ 1N/A /* save number of bits */ 1N/A /* pad out to 56 mod 64 */ 1N/A /* append length (before padding) */ 1N/A /* store state in digest */ 1N/A /* accumulate the digests */ 1N/A register unsigned char* d;