| 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 | 17 |
| 18 // Changes from original C code: | 18 // Changes from original C code: |
| 19 // Ported to C++, type casting, Google code style. | 19 // Ported to C++, type casting, Google code style. |
| 20 | 20 |
| 21 #include "webrtc/base/md5.h" | 21 #include "webrtc/rtc_base/md5.h" |
| 22 | 22 |
| 23 // TODO: Avoid memcmpy - hash directly from memory. | 23 // TODO: Avoid memcmpy - hash directly from memory. |
| 24 #include <string.h> // for memcpy(). | 24 #include <string.h> // for memcpy(). |
| 25 | 25 |
| 26 #include "webrtc/base/byteorder.h" // for RTC_ARCH_CPU_LITTLE_ENDIAN. | 26 #include "webrtc/rtc_base/byteorder.h" // for RTC_ARCH_CPU_LITTLE_ENDIAN. |
| 27 | 27 |
| 28 namespace rtc { | 28 namespace rtc { |
| 29 | 29 |
| 30 #ifdef RTC_ARCH_CPU_LITTLE_ENDIAN | 30 #ifdef RTC_ARCH_CPU_LITTLE_ENDIAN |
| 31 #define ByteReverse(buf, len) // Nothing. | 31 #define ByteReverse(buf, len) // Nothing. |
| 32 #else // RTC_ARCH_CPU_BIG_ENDIAN | 32 #else // RTC_ARCH_CPU_BIG_ENDIAN |
| 33 static void ByteReverse(uint32_t* buf, int len) { | 33 static void ByteReverse(uint32_t* buf, int len) { |
| 34 for (int i = 0; i < len; ++i) { | 34 for (int i = 0; i < len; ++i) { |
| 35 buf[i] = rtc::GetLE32(&buf[i]); | 35 buf[i] = rtc::GetLE32(&buf[i]); |
| 36 } | 36 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); | 213 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); |
| 214 MD5STEP(F4, c, d, a, b, in[ 2] + 0x2ad7d2bb, 15); | 214 MD5STEP(F4, c, d, a, b, in[ 2] + 0x2ad7d2bb, 15); |
| 215 MD5STEP(F4, b, c, d, a, in[ 9] + 0xeb86d391, 21); | 215 MD5STEP(F4, b, c, d, a, in[ 9] + 0xeb86d391, 21); |
| 216 buf[0] += a; | 216 buf[0] += a; |
| 217 buf[1] += b; | 217 buf[1] += b; |
| 218 buf[2] += c; | 218 buf[2] += c; |
| 219 buf[3] += d; | 219 buf[3] += d; |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace rtc | 222 } // namespace rtc |
| OLD | NEW |