51 static const char *
const test[7] = {
56 "abcdefghijklmnopqrstuvwxyz",
57 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
59 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
63 for (i = 0; i < 7; ++i) {
71 printf(
"MD5 (\"%s\") = ", test[i]);
72 for (di = 0; di < 16; ++di)
73 printf(
"%02x", digest[di]);
89 for (i = 1; i <= 64; ++i) {
90 unsigned long v = (
unsigned long)(4294967296.0 * fabs(sin((
double)i)));
91 printf(
"#define T%d 0x%08lx\n", i, v);
100 #define T2 0xe8c7b756
101 #define T3 0x242070db
102 #define T4 0xc1bdceee
103 #define T5 0xf57c0faf
104 #define T6 0x4787c62a
105 #define T7 0xa8304613
106 #define T8 0xfd469501
107 #define T9 0x698098d8
108 #define T10 0x8b44f7af
109 #define T11 0xffff5bb1
110 #define T12 0x895cd7be
111 #define T13 0x6b901122
112 #define T14 0xfd987193
113 #define T15 0xa679438e
114 #define T16 0x49b40821
115 #define T17 0xf61e2562
116 #define T18 0xc040b340
117 #define T19 0x265e5a51
118 #define T20 0xe9b6c7aa
119 #define T21 0xd62f105d
120 #define T22 0x02441453
121 #define T23 0xd8a1e681
122 #define T24 0xe7d3fbc8
123 #define T25 0x21e1cde6
124 #define T26 0xc33707d6
125 #define T27 0xf4d50d87
126 #define T28 0x455a14ed
127 #define T29 0xa9e3e905
128 #define T30 0xfcefa3f8
129 #define T31 0x676f02d9
130 #define T32 0x8d2a4c8a
131 #define T33 0xfffa3942
132 #define T34 0x8771f681
133 #define T35 0x6d9d6122
134 #define T36 0xfde5380c
135 #define T37 0xa4beea44
136 #define T38 0x4bdecfa9
137 #define T39 0xf6bb4b60
138 #define T40 0xbebfbc70
139 #define T41 0x289b7ec6
140 #define T42 0xeaa127fa
141 #define T43 0xd4ef3085
142 #define T44 0x04881d05
143 #define T45 0xd9d4d039
144 #define T46 0xe6db99e5
145 #define T47 0x1fa27cf8
146 #define T48 0xc4ac5665
147 #define T49 0xf4292244
148 #define T50 0x432aff97
149 #define T51 0xab9423a7
150 #define T52 0xfc93a039
151 #define T53 0x655b59c3
152 #define T54 0x8f0ccc92
153 #define T55 0xffeff47d
154 #define T56 0x85845dd1
155 #define T57 0x6fa87e4f
156 #define T58 0xfe2ce6e0
157 #define T59 0xa3014314
158 #define T60 0x4e0811a1
159 #define T61 0xf7537e82
160 #define T62 0xbd3af235
161 #define T63 0x2ad7d2bb
162 #define T64 0xeb86d391
172 #ifndef ARCH_IS_BIG_ENDIAN
173 # define ARCH_IS_BIG_ENDIAN 1
175 #if ARCH_IS_BIG_ENDIAN
185 for (i = 0; i < 16; ++i, xp += 4)
186 X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
202 memcpy(xbuf, data, 64);
207 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
212 #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
213 #define SET(a, b, c, d, k, s, Ti)\
214 t = a + F(b,c,d) + X[k] + Ti;\
215 a = ROTATE_LEFT(t, s) + b
238 #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
239 #define SET(a, b, c, d, k, s, Ti)\
240 t = a + G(b,c,d) + X[k] + Ti;\
241 a = ROTATE_LEFT(t, s) + b
264 #define H(x, y, z) ((x) ^ (y) ^ (z))
265 #define SET(a, b, c, d, k, s, Ti)\
266 t = a + H(b,c,d) + X[k] + Ti;\
267 a = ROTATE_LEFT(t, s) + b
290 #define I(x, y, z) ((y) ^ ((x) | ~(z)))
291 #define SET(a, b, c, d, k, s, Ti)\
292 t = a + I(b,c,d) + X[k] + Ti;\
293 a = ROTATE_LEFT(t, s) + b
326 pms->
abcd[0] = 0x67452301;
327 pms->
abcd[1] = 0xefcdab89;
328 pms->
abcd[2] = 0x98badcfe;
329 pms->
abcd[3] = 0x10325476;
344 pms->
count[1] += nbytes >> 29;
345 pms->
count[0] += nbits;
346 if (pms->
count[0] < nbits)
351 int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
353 memcpy(pms->
buf + offset, p, copy);
354 if (offset + copy < 64)
362 for (; left >= 64; p += 64, left -= 64)
367 memcpy(pms->
buf, p, left);
374 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
383 for (i = 0; i < 8; ++i)
389 for (i = 0; i < 16; ++i)