OLD | NEW |
1 /* | 1 /* |
2 * This code implements the MD5 message-digest algorithm. | 2 * This code implements the MD5 message-digest algorithm. |
3 * The algorithm is due to Ron Rivest. This code was | 3 * The algorithm is due to Ron Rivest. This code was |
4 * written by Colin Plumb in 1993, no copyright is claimed. | 4 * written by Colin Plumb in 1993, no copyright is claimed. |
5 * This code is in the public domain; do with it what you wish. | 5 * This code is in the public domain; do with it what you wish. |
6 * | 6 * |
7 * Equivalent code is available from RSA Data Security, Inc. | 7 * Equivalent code is available from RSA Data Security, Inc. |
8 * This code has been tested against that, and is equivalent, | 8 * This code has been tested against that, and is equivalent, |
9 * except that you don't need to include two pages of legalese | 9 * except that you don't need to include two pages of legalese |
10 * with every copy. | 10 * with every copy. |
11 * | 11 * |
12 * To compute the message digest of a chunk of bytes, declare an | 12 * To compute the message digest of a chunk of bytes, declare an |
13 * MD5Context structure, pass it to MD5Init, call MD5Update as | 13 * MD5Context structure, pass it to MD5Init, call MD5Update as |
14 * needed on buffers full of bytes, and then call MD5Final, which | 14 * needed on buffers full of bytes, and then call MD5Final, which |
15 * will fill a supplied 16-byte array with the digest. | 15 * will fill a supplied 16-byte array with the digest. |
16 * | 16 * |
17 * Changed so as no longer to depend on Colin Plumb's `usual.h' header | 17 * Changed so as no longer to depend on Colin Plumb's `usual.h' header |
18 * definitions | 18 * definitions |
19 * - Ian Jackson <ian@chiark.greenend.org.uk>. | 19 * - Ian Jackson <ian@chiark.greenend.org.uk>. |
20 * Still in the public domain. | 20 * Still in the public domain. |
21 */ | 21 */ |
22 | 22 |
23 #include <string.h> /* for memcpy() */ | 23 #include <string.h> /* for memcpy() */ |
24 | 24 |
25 #include "md5_utils.h" | 25 #include "md5_utils.h" |
26 | 26 |
27 void | 27 static void |
28 byteSwap(UWORD32 *buf, unsigned words) { | 28 byteSwap(UWORD32 *buf, unsigned words) { |
29 md5byte *p; | 29 md5byte *p; |
30 | 30 |
31 /* Only swap bytes for big endian machines */ | 31 /* Only swap bytes for big endian machines */ |
32 int i = 1; | 32 int i = 1; |
33 | 33 |
34 if (*(char *)&i == 1) | 34 if (*(char *)&i == 1) |
35 return; | 35 return; |
36 | 36 |
37 p = (md5byte *)buf; | 37 p = (md5byte *)buf; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); | 232 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); |
233 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); | 233 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); |
234 | 234 |
235 buf[0] += a; | 235 buf[0] += a; |
236 buf[1] += b; | 236 buf[1] += b; |
237 buf[2] += c; | 237 buf[2] += c; |
238 buf[3] += d; | 238 buf[3] += d; |
239 } | 239 } |
240 | 240 |
241 #endif | 241 #endif |
OLD | NEW |