xref: /aosp_15_r20/external/libaom/common/md5_utils.c (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * This code implements the MD5 message-digest algorithm.
3*77c1e3ccSAndroid Build Coastguard Worker  * The algorithm is due to Ron Rivest.  This code was
4*77c1e3ccSAndroid Build Coastguard Worker  * written by Colin Plumb in 1993, no copyright is claimed.
5*77c1e3ccSAndroid Build Coastguard Worker  * This code is in the public domain; do with it what you wish.
6*77c1e3ccSAndroid Build Coastguard Worker  *
7*77c1e3ccSAndroid Build Coastguard Worker  * Equivalent code is available from RSA Data Security, Inc.
8*77c1e3ccSAndroid Build Coastguard Worker  * This code has been tested against that, and is equivalent,
9*77c1e3ccSAndroid Build Coastguard Worker  * except that you don't need to include two pages of legalese
10*77c1e3ccSAndroid Build Coastguard Worker  * with every copy.
11*77c1e3ccSAndroid Build Coastguard Worker  *
12*77c1e3ccSAndroid Build Coastguard Worker  * To compute the message digest of a chunk of bytes, declare an
13*77c1e3ccSAndroid Build Coastguard Worker  * MD5Context structure, pass it to MD5Init, call MD5Update as
14*77c1e3ccSAndroid Build Coastguard Worker  * needed on buffers full of bytes, and then call MD5Final, which
15*77c1e3ccSAndroid Build Coastguard Worker  * will fill a supplied 16-byte array with the digest.
16*77c1e3ccSAndroid Build Coastguard Worker  *
17*77c1e3ccSAndroid Build Coastguard Worker  * Changed so as no longer to depend on Colin Plumb's `usual.h' header
18*77c1e3ccSAndroid Build Coastguard Worker  * definitions
19*77c1e3ccSAndroid Build Coastguard Worker  *  - Ian Jackson <[email protected]>.
20*77c1e3ccSAndroid Build Coastguard Worker  * Still in the public domain.
21*77c1e3ccSAndroid Build Coastguard Worker  */
22*77c1e3ccSAndroid Build Coastguard Worker 
23*77c1e3ccSAndroid Build Coastguard Worker #include <string.h> /* for memcpy() */
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker #include "common/md5_utils.h"
26*77c1e3ccSAndroid Build Coastguard Worker 
byteSwap(UWORD32 * buf,unsigned words)27*77c1e3ccSAndroid Build Coastguard Worker static void byteSwap(UWORD32 *buf, unsigned words) {
28*77c1e3ccSAndroid Build Coastguard Worker   md5byte *p;
29*77c1e3ccSAndroid Build Coastguard Worker 
30*77c1e3ccSAndroid Build Coastguard Worker   /* Only swap bytes for big endian machines */
31*77c1e3ccSAndroid Build Coastguard Worker   int i = 1;
32*77c1e3ccSAndroid Build Coastguard Worker 
33*77c1e3ccSAndroid Build Coastguard Worker   if (*(char *)&i == 1) return;
34*77c1e3ccSAndroid Build Coastguard Worker 
35*77c1e3ccSAndroid Build Coastguard Worker   p = (md5byte *)buf;
36*77c1e3ccSAndroid Build Coastguard Worker 
37*77c1e3ccSAndroid Build Coastguard Worker   do {
38*77c1e3ccSAndroid Build Coastguard Worker     *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
39*77c1e3ccSAndroid Build Coastguard Worker              ((unsigned)p[1] << 8 | p[0]);
40*77c1e3ccSAndroid Build Coastguard Worker     p += 4;
41*77c1e3ccSAndroid Build Coastguard Worker   } while (--words);
42*77c1e3ccSAndroid Build Coastguard Worker }
43*77c1e3ccSAndroid Build Coastguard Worker 
44*77c1e3ccSAndroid Build Coastguard Worker /*
45*77c1e3ccSAndroid Build Coastguard Worker  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
46*77c1e3ccSAndroid Build Coastguard Worker  * initialization constants.
47*77c1e3ccSAndroid Build Coastguard Worker  */
MD5Init(struct MD5Context * ctx)48*77c1e3ccSAndroid Build Coastguard Worker void MD5Init(struct MD5Context *ctx) {
49*77c1e3ccSAndroid Build Coastguard Worker   ctx->buf[0] = 0x67452301;
50*77c1e3ccSAndroid Build Coastguard Worker   ctx->buf[1] = 0xefcdab89;
51*77c1e3ccSAndroid Build Coastguard Worker   ctx->buf[2] = 0x98badcfe;
52*77c1e3ccSAndroid Build Coastguard Worker   ctx->buf[3] = 0x10325476;
53*77c1e3ccSAndroid Build Coastguard Worker 
54*77c1e3ccSAndroid Build Coastguard Worker   ctx->bytes[0] = 0;
55*77c1e3ccSAndroid Build Coastguard Worker   ctx->bytes[1] = 0;
56*77c1e3ccSAndroid Build Coastguard Worker }
57*77c1e3ccSAndroid Build Coastguard Worker 
58*77c1e3ccSAndroid Build Coastguard Worker /*
59*77c1e3ccSAndroid Build Coastguard Worker  * Update context to reflect the concatenation of another buffer full
60*77c1e3ccSAndroid Build Coastguard Worker  * of bytes.
61*77c1e3ccSAndroid Build Coastguard Worker  */
MD5Update(struct MD5Context * ctx,md5byte const * buf,unsigned len)62*77c1e3ccSAndroid Build Coastguard Worker void MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) {
63*77c1e3ccSAndroid Build Coastguard Worker   UWORD32 t;
64*77c1e3ccSAndroid Build Coastguard Worker 
65*77c1e3ccSAndroid Build Coastguard Worker   /* Update byte count */
66*77c1e3ccSAndroid Build Coastguard Worker 
67*77c1e3ccSAndroid Build Coastguard Worker   t = ctx->bytes[0];
68*77c1e3ccSAndroid Build Coastguard Worker 
69*77c1e3ccSAndroid Build Coastguard Worker   if ((ctx->bytes[0] = t + len) < t)
70*77c1e3ccSAndroid Build Coastguard Worker     ctx->bytes[1]++; /* Carry from low to high */
71*77c1e3ccSAndroid Build Coastguard Worker 
72*77c1e3ccSAndroid Build Coastguard Worker   t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
73*77c1e3ccSAndroid Build Coastguard Worker 
74*77c1e3ccSAndroid Build Coastguard Worker   if (t > len) {
75*77c1e3ccSAndroid Build Coastguard Worker     memcpy((md5byte *)ctx->in + 64 - t, buf, len);
76*77c1e3ccSAndroid Build Coastguard Worker     return;
77*77c1e3ccSAndroid Build Coastguard Worker   }
78*77c1e3ccSAndroid Build Coastguard Worker 
79*77c1e3ccSAndroid Build Coastguard Worker   /* First chunk is an odd size */
80*77c1e3ccSAndroid Build Coastguard Worker   memcpy((md5byte *)ctx->in + 64 - t, buf, t);
81*77c1e3ccSAndroid Build Coastguard Worker   byteSwap(ctx->in, 16);
82*77c1e3ccSAndroid Build Coastguard Worker   MD5Transform(ctx->buf, ctx->in);
83*77c1e3ccSAndroid Build Coastguard Worker   buf += t;
84*77c1e3ccSAndroid Build Coastguard Worker   len -= t;
85*77c1e3ccSAndroid Build Coastguard Worker 
86*77c1e3ccSAndroid Build Coastguard Worker   /* Process data in 64-byte chunks */
87*77c1e3ccSAndroid Build Coastguard Worker   while (len >= 64) {
88*77c1e3ccSAndroid Build Coastguard Worker     memcpy(ctx->in, buf, 64);
89*77c1e3ccSAndroid Build Coastguard Worker     byteSwap(ctx->in, 16);
90*77c1e3ccSAndroid Build Coastguard Worker     MD5Transform(ctx->buf, ctx->in);
91*77c1e3ccSAndroid Build Coastguard Worker     buf += 64;
92*77c1e3ccSAndroid Build Coastguard Worker     len -= 64;
93*77c1e3ccSAndroid Build Coastguard Worker   }
94*77c1e3ccSAndroid Build Coastguard Worker 
95*77c1e3ccSAndroid Build Coastguard Worker   /* Handle any remaining bytes of data. */
96*77c1e3ccSAndroid Build Coastguard Worker   memcpy(ctx->in, buf, len);
97*77c1e3ccSAndroid Build Coastguard Worker }
98*77c1e3ccSAndroid Build Coastguard Worker 
99*77c1e3ccSAndroid Build Coastguard Worker /*
100*77c1e3ccSAndroid Build Coastguard Worker  * Final wrapup - pad to 64-byte boundary with the bit pattern
101*77c1e3ccSAndroid Build Coastguard Worker  * 1 0* (64-bit count of bits processed, MSB-first)
102*77c1e3ccSAndroid Build Coastguard Worker  */
MD5Final(md5byte digest[16],struct MD5Context * ctx)103*77c1e3ccSAndroid Build Coastguard Worker void MD5Final(md5byte digest[16], struct MD5Context *ctx) {
104*77c1e3ccSAndroid Build Coastguard Worker   int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
105*77c1e3ccSAndroid Build Coastguard Worker   md5byte *p = (md5byte *)ctx->in + count;
106*77c1e3ccSAndroid Build Coastguard Worker 
107*77c1e3ccSAndroid Build Coastguard Worker   /* Set the first char of padding to 0x80.  There is always room. */
108*77c1e3ccSAndroid Build Coastguard Worker   *p++ = 0x80;
109*77c1e3ccSAndroid Build Coastguard Worker 
110*77c1e3ccSAndroid Build Coastguard Worker   /* Bytes of padding needed to make 56 bytes (-8..55) */
111*77c1e3ccSAndroid Build Coastguard Worker   count = 56 - 1 - count;
112*77c1e3ccSAndroid Build Coastguard Worker 
113*77c1e3ccSAndroid Build Coastguard Worker   if (count < 0) { /* Padding forces an extra block */
114*77c1e3ccSAndroid Build Coastguard Worker     memset(p, 0, count + 8);
115*77c1e3ccSAndroid Build Coastguard Worker     byteSwap(ctx->in, 16);
116*77c1e3ccSAndroid Build Coastguard Worker     MD5Transform(ctx->buf, ctx->in);
117*77c1e3ccSAndroid Build Coastguard Worker     p = (md5byte *)ctx->in;
118*77c1e3ccSAndroid Build Coastguard Worker     count = 56;
119*77c1e3ccSAndroid Build Coastguard Worker   }
120*77c1e3ccSAndroid Build Coastguard Worker 
121*77c1e3ccSAndroid Build Coastguard Worker   memset(p, 0, count);
122*77c1e3ccSAndroid Build Coastguard Worker   byteSwap(ctx->in, 14);
123*77c1e3ccSAndroid Build Coastguard Worker 
124*77c1e3ccSAndroid Build Coastguard Worker   /* Append length in bits and transform */
125*77c1e3ccSAndroid Build Coastguard Worker   ctx->in[14] = ctx->bytes[0] << 3;
126*77c1e3ccSAndroid Build Coastguard Worker   ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
127*77c1e3ccSAndroid Build Coastguard Worker   MD5Transform(ctx->buf, ctx->in);
128*77c1e3ccSAndroid Build Coastguard Worker 
129*77c1e3ccSAndroid Build Coastguard Worker   byteSwap(ctx->buf, 4);
130*77c1e3ccSAndroid Build Coastguard Worker   memcpy(digest, ctx->buf, 16);
131*77c1e3ccSAndroid Build Coastguard Worker   memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
132*77c1e3ccSAndroid Build Coastguard Worker }
133*77c1e3ccSAndroid Build Coastguard Worker 
134*77c1e3ccSAndroid Build Coastguard Worker #ifndef ASM_MD5
135*77c1e3ccSAndroid Build Coastguard Worker 
136*77c1e3ccSAndroid Build Coastguard Worker /* The four core functions - F1 is optimized somewhat */
137*77c1e3ccSAndroid Build Coastguard Worker 
138*77c1e3ccSAndroid Build Coastguard Worker /* #define F1(x, y, z) (x & y | ~x & z) */
139*77c1e3ccSAndroid Build Coastguard Worker #define F1(x, y, z) (z ^ (x & (y ^ z)))
140*77c1e3ccSAndroid Build Coastguard Worker #define F2(x, y, z) F1(z, x, y)
141*77c1e3ccSAndroid Build Coastguard Worker #define F3(x, y, z) (x ^ y ^ z)
142*77c1e3ccSAndroid Build Coastguard Worker #define F4(x, y, z) (y ^ (x | ~z))
143*77c1e3ccSAndroid Build Coastguard Worker 
144*77c1e3ccSAndroid Build Coastguard Worker /* This is the central step in the MD5 algorithm. */
145*77c1e3ccSAndroid Build Coastguard Worker #define MD5STEP(f, w, x, y, z, in, s) \
146*77c1e3ccSAndroid Build Coastguard Worker   (w += f(x, y, z) + in, w = (w << s | w >> (32 - s)) + x)
147*77c1e3ccSAndroid Build Coastguard Worker 
148*77c1e3ccSAndroid Build Coastguard Worker #if defined(__clang__) && defined(__has_attribute)
149*77c1e3ccSAndroid Build Coastguard Worker #if __has_attribute(no_sanitize)
150*77c1e3ccSAndroid Build Coastguard Worker #define AOM_NO_UNSIGNED_OVERFLOW_CHECK \
151*77c1e3ccSAndroid Build Coastguard Worker   __attribute__((no_sanitize("unsigned-integer-overflow")))
152*77c1e3ccSAndroid Build Coastguard Worker #endif
153*77c1e3ccSAndroid Build Coastguard Worker #if __clang_major__ >= 12
154*77c1e3ccSAndroid Build Coastguard Worker #define VPX_NO_UNSIGNED_SHIFT_CHECK \
155*77c1e3ccSAndroid Build Coastguard Worker   __attribute__((no_sanitize("unsigned-shift-base")))
156*77c1e3ccSAndroid Build Coastguard Worker #endif  // __clang__ >= 12
157*77c1e3ccSAndroid Build Coastguard Worker #endif  // __clang__
158*77c1e3ccSAndroid Build Coastguard Worker 
159*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_NO_UNSIGNED_OVERFLOW_CHECK
160*77c1e3ccSAndroid Build Coastguard Worker #define AOM_NO_UNSIGNED_OVERFLOW_CHECK
161*77c1e3ccSAndroid Build Coastguard Worker #endif
162*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_NO_UNSIGNED_SHIFT_CHECK
163*77c1e3ccSAndroid Build Coastguard Worker #define AOM_NO_UNSIGNED_SHIFT_CHECK
164*77c1e3ccSAndroid Build Coastguard Worker #endif
165*77c1e3ccSAndroid Build Coastguard Worker 
166*77c1e3ccSAndroid Build Coastguard Worker /*
167*77c1e3ccSAndroid Build Coastguard Worker  * The core of the MD5 algorithm, this alters an existing MD5 hash to
168*77c1e3ccSAndroid Build Coastguard Worker  * reflect the addition of 16 longwords of new data.  MD5Update blocks
169*77c1e3ccSAndroid Build Coastguard Worker  * the data and converts bytes into longwords for this routine.
170*77c1e3ccSAndroid Build Coastguard Worker  */
MD5Transform(UWORD32 buf[4],UWORD32 const in[16])171*77c1e3ccSAndroid Build Coastguard Worker AOM_NO_UNSIGNED_OVERFLOW_CHECK AOM_NO_UNSIGNED_SHIFT_CHECK void MD5Transform(
172*77c1e3ccSAndroid Build Coastguard Worker     UWORD32 buf[4], UWORD32 const in[16]) {
173*77c1e3ccSAndroid Build Coastguard Worker   register UWORD32 a, b, c, d;
174*77c1e3ccSAndroid Build Coastguard Worker 
175*77c1e3ccSAndroid Build Coastguard Worker   a = buf[0];
176*77c1e3ccSAndroid Build Coastguard Worker   b = buf[1];
177*77c1e3ccSAndroid Build Coastguard Worker   c = buf[2];
178*77c1e3ccSAndroid Build Coastguard Worker   d = buf[3];
179*77c1e3ccSAndroid Build Coastguard Worker 
180*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
181*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
182*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
183*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
184*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
185*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
186*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
187*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
188*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
189*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
190*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
191*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
192*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
193*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
194*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
195*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
196*77c1e3ccSAndroid Build Coastguard Worker 
197*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
198*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
199*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
200*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
201*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
202*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
203*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
204*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
205*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
206*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
207*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
208*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
209*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
210*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
211*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
212*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
213*77c1e3ccSAndroid Build Coastguard Worker 
214*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
215*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
216*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
217*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
218*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
219*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
220*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
221*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
222*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
223*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
224*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
225*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
226*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
227*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
228*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
229*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
230*77c1e3ccSAndroid Build Coastguard Worker 
231*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
232*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
233*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
234*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
235*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
236*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
237*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
238*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
239*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
240*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
241*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
242*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
243*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
244*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
245*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
246*77c1e3ccSAndroid Build Coastguard Worker   MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
247*77c1e3ccSAndroid Build Coastguard Worker 
248*77c1e3ccSAndroid Build Coastguard Worker   buf[0] += a;
249*77c1e3ccSAndroid Build Coastguard Worker   buf[1] += b;
250*77c1e3ccSAndroid Build Coastguard Worker   buf[2] += c;
251*77c1e3ccSAndroid Build Coastguard Worker   buf[3] += d;
252*77c1e3ccSAndroid Build Coastguard Worker }
253*77c1e3ccSAndroid Build Coastguard Worker 
254*77c1e3ccSAndroid Build Coastguard Worker #undef AOM_NO_UNSIGNED_OVERFLOW_CHECK
255*77c1e3ccSAndroid Build Coastguard Worker #undef AOM_NO_UNSIGNED_SHIFT_CHECK
256*77c1e3ccSAndroid Build Coastguard Worker 
257*77c1e3ccSAndroid Build Coastguard Worker #endif
258