1233d2500723e5594f3e7c70896ffeeef32b9c950ywan/*
2233d2500723e5594f3e7c70896ffeeef32b9c950ywan * This code implements the MD5 message-digest algorithm.
3233d2500723e5594f3e7c70896ffeeef32b9c950ywan * The algorithm is due to Ron Rivest.  This code was
4233d2500723e5594f3e7c70896ffeeef32b9c950ywan * written by Colin Plumb in 1993, no copyright is claimed.
5233d2500723e5594f3e7c70896ffeeef32b9c950ywan * This code is in the public domain; do with it what you wish.
6233d2500723e5594f3e7c70896ffeeef32b9c950ywan *
7233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Equivalent code is available from RSA Data Security, Inc.
8233d2500723e5594f3e7c70896ffeeef32b9c950ywan * This code has been tested against that, and is equivalent,
9233d2500723e5594f3e7c70896ffeeef32b9c950ywan * except that you don't need to include two pages of legalese
10233d2500723e5594f3e7c70896ffeeef32b9c950ywan * with every copy.
11233d2500723e5594f3e7c70896ffeeef32b9c950ywan *
12233d2500723e5594f3e7c70896ffeeef32b9c950ywan * To compute the message digest of a chunk of bytes, declare an
13233d2500723e5594f3e7c70896ffeeef32b9c950ywan * MD5Context structure, pass it to MD5Init, call MD5Update as
14233d2500723e5594f3e7c70896ffeeef32b9c950ywan * needed on buffers full of bytes, and then call MD5Final, which
15233d2500723e5594f3e7c70896ffeeef32b9c950ywan * will fill a supplied 16-byte array with the digest.
16233d2500723e5594f3e7c70896ffeeef32b9c950ywan *
17233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Changed so as no longer to depend on Colin Plumb's `usual.h' header
18233d2500723e5594f3e7c70896ffeeef32b9c950ywan * definitions
19233d2500723e5594f3e7c70896ffeeef32b9c950ywan *  - Ian Jackson <ian@chiark.greenend.org.uk>.
20233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Still in the public domain.
21233d2500723e5594f3e7c70896ffeeef32b9c950ywan */
22233d2500723e5594f3e7c70896ffeeef32b9c950ywan
23233d2500723e5594f3e7c70896ffeeef32b9c950ywan#include <string.h>   /* for memcpy() */
24233d2500723e5594f3e7c70896ffeeef32b9c950ywan
25233d2500723e5594f3e7c70896ffeeef32b9c950ywan#include "md5_utils.h"
26233d2500723e5594f3e7c70896ffeeef32b9c950ywan
27233d2500723e5594f3e7c70896ffeeef32b9c950ywanvoid
28233d2500723e5594f3e7c70896ffeeef32b9c950ywanbyteSwap(UWORD32 *buf, unsigned words) {
29233d2500723e5594f3e7c70896ffeeef32b9c950ywan  md5byte *p;
30233d2500723e5594f3e7c70896ffeeef32b9c950ywan
31233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Only swap bytes for big endian machines */
32233d2500723e5594f3e7c70896ffeeef32b9c950ywan  int i = 1;
33233d2500723e5594f3e7c70896ffeeef32b9c950ywan
34233d2500723e5594f3e7c70896ffeeef32b9c950ywan  if (*(char *)&i == 1)
35233d2500723e5594f3e7c70896ffeeef32b9c950ywan    return;
36233d2500723e5594f3e7c70896ffeeef32b9c950ywan
37233d2500723e5594f3e7c70896ffeeef32b9c950ywan  p = (md5byte *)buf;
38233d2500723e5594f3e7c70896ffeeef32b9c950ywan
39233d2500723e5594f3e7c70896ffeeef32b9c950ywan  do {
40233d2500723e5594f3e7c70896ffeeef32b9c950ywan    *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
41233d2500723e5594f3e7c70896ffeeef32b9c950ywan             ((unsigned)p[1] << 8 | p[0]);
42233d2500723e5594f3e7c70896ffeeef32b9c950ywan    p += 4;
43233d2500723e5594f3e7c70896ffeeef32b9c950ywan  } while (--words);
44233d2500723e5594f3e7c70896ffeeef32b9c950ywan}
45233d2500723e5594f3e7c70896ffeeef32b9c950ywan
46233d2500723e5594f3e7c70896ffeeef32b9c950ywan/*
47233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
48233d2500723e5594f3e7c70896ffeeef32b9c950ywan * initialization constants.
49233d2500723e5594f3e7c70896ffeeef32b9c950ywan */
50233d2500723e5594f3e7c70896ffeeef32b9c950ywanvoid
51233d2500723e5594f3e7c70896ffeeef32b9c950ywanMD5Init(struct MD5Context *ctx) {
52233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->buf[0] = 0x67452301;
53233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->buf[1] = 0xefcdab89;
54233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->buf[2] = 0x98badcfe;
55233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->buf[3] = 0x10325476;
56233d2500723e5594f3e7c70896ffeeef32b9c950ywan
57233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->bytes[0] = 0;
58233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->bytes[1] = 0;
59233d2500723e5594f3e7c70896ffeeef32b9c950ywan}
60233d2500723e5594f3e7c70896ffeeef32b9c950ywan
61233d2500723e5594f3e7c70896ffeeef32b9c950ywan/*
62233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Update context to reflect the concatenation of another buffer full
63233d2500723e5594f3e7c70896ffeeef32b9c950ywan * of bytes.
64233d2500723e5594f3e7c70896ffeeef32b9c950ywan */
65233d2500723e5594f3e7c70896ffeeef32b9c950ywanvoid
66233d2500723e5594f3e7c70896ffeeef32b9c950ywanMD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) {
67233d2500723e5594f3e7c70896ffeeef32b9c950ywan  UWORD32 t;
68233d2500723e5594f3e7c70896ffeeef32b9c950ywan
69233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Update byte count */
70233d2500723e5594f3e7c70896ffeeef32b9c950ywan
71233d2500723e5594f3e7c70896ffeeef32b9c950ywan  t = ctx->bytes[0];
72233d2500723e5594f3e7c70896ffeeef32b9c950ywan
73233d2500723e5594f3e7c70896ffeeef32b9c950ywan  if ((ctx->bytes[0] = t + len) < t)
74233d2500723e5594f3e7c70896ffeeef32b9c950ywan    ctx->bytes[1]++;  /* Carry from low to high */
75233d2500723e5594f3e7c70896ffeeef32b9c950ywan
76233d2500723e5594f3e7c70896ffeeef32b9c950ywan  t = 64 - (t & 0x3f);  /* Space available in ctx->in (at least 1) */
77233d2500723e5594f3e7c70896ffeeef32b9c950ywan
78233d2500723e5594f3e7c70896ffeeef32b9c950ywan  if (t > len) {
79233d2500723e5594f3e7c70896ffeeef32b9c950ywan    memcpy((md5byte *)ctx->in + 64 - t, buf, len);
80233d2500723e5594f3e7c70896ffeeef32b9c950ywan    return;
81233d2500723e5594f3e7c70896ffeeef32b9c950ywan  }
82233d2500723e5594f3e7c70896ffeeef32b9c950ywan
83233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* First chunk is an odd size */
84233d2500723e5594f3e7c70896ffeeef32b9c950ywan  memcpy((md5byte *)ctx->in + 64 - t, buf, t);
85233d2500723e5594f3e7c70896ffeeef32b9c950ywan  byteSwap(ctx->in, 16);
86233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5Transform(ctx->buf, ctx->in);
87233d2500723e5594f3e7c70896ffeeef32b9c950ywan  buf += t;
88233d2500723e5594f3e7c70896ffeeef32b9c950ywan  len -= t;
89233d2500723e5594f3e7c70896ffeeef32b9c950ywan
90233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Process data in 64-byte chunks */
91233d2500723e5594f3e7c70896ffeeef32b9c950ywan  while (len >= 64) {
92233d2500723e5594f3e7c70896ffeeef32b9c950ywan    memcpy(ctx->in, buf, 64);
93233d2500723e5594f3e7c70896ffeeef32b9c950ywan    byteSwap(ctx->in, 16);
94233d2500723e5594f3e7c70896ffeeef32b9c950ywan    MD5Transform(ctx->buf, ctx->in);
95233d2500723e5594f3e7c70896ffeeef32b9c950ywan    buf += 64;
96233d2500723e5594f3e7c70896ffeeef32b9c950ywan    len -= 64;
97233d2500723e5594f3e7c70896ffeeef32b9c950ywan  }
98233d2500723e5594f3e7c70896ffeeef32b9c950ywan
99233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Handle any remaining bytes of data. */
100233d2500723e5594f3e7c70896ffeeef32b9c950ywan  memcpy(ctx->in, buf, len);
101233d2500723e5594f3e7c70896ffeeef32b9c950ywan}
102233d2500723e5594f3e7c70896ffeeef32b9c950ywan
103233d2500723e5594f3e7c70896ffeeef32b9c950ywan/*
104233d2500723e5594f3e7c70896ffeeef32b9c950ywan * Final wrapup - pad to 64-byte boundary with the bit pattern
105233d2500723e5594f3e7c70896ffeeef32b9c950ywan * 1 0* (64-bit count of bits processed, MSB-first)
106233d2500723e5594f3e7c70896ffeeef32b9c950ywan */
107233d2500723e5594f3e7c70896ffeeef32b9c950ywanvoid
108233d2500723e5594f3e7c70896ffeeef32b9c950ywanMD5Final(md5byte digest[16], struct MD5Context *ctx) {
109233d2500723e5594f3e7c70896ffeeef32b9c950ywan  int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
110233d2500723e5594f3e7c70896ffeeef32b9c950ywan  md5byte *p = (md5byte *)ctx->in + count;
111233d2500723e5594f3e7c70896ffeeef32b9c950ywan
112233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Set the first char of padding to 0x80.  There is always room. */
113233d2500723e5594f3e7c70896ffeeef32b9c950ywan  *p++ = 0x80;
114233d2500723e5594f3e7c70896ffeeef32b9c950ywan
115233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Bytes of padding needed to make 56 bytes (-8..55) */
116233d2500723e5594f3e7c70896ffeeef32b9c950ywan  count = 56 - 1 - count;
117233d2500723e5594f3e7c70896ffeeef32b9c950ywan
118233d2500723e5594f3e7c70896ffeeef32b9c950ywan  if (count < 0) {  /* Padding forces an extra block */
119233d2500723e5594f3e7c70896ffeeef32b9c950ywan    memset(p, 0, count + 8);
120233d2500723e5594f3e7c70896ffeeef32b9c950ywan    byteSwap(ctx->in, 16);
121233d2500723e5594f3e7c70896ffeeef32b9c950ywan    MD5Transform(ctx->buf, ctx->in);
122233d2500723e5594f3e7c70896ffeeef32b9c950ywan    p = (md5byte *)ctx->in;
123233d2500723e5594f3e7c70896ffeeef32b9c950ywan    count = 56;
124233d2500723e5594f3e7c70896ffeeef32b9c950ywan  }
125233d2500723e5594f3e7c70896ffeeef32b9c950ywan
126233d2500723e5594f3e7c70896ffeeef32b9c950ywan  memset(p, 0, count);
127233d2500723e5594f3e7c70896ffeeef32b9c950ywan  byteSwap(ctx->in, 14);
128233d2500723e5594f3e7c70896ffeeef32b9c950ywan
129233d2500723e5594f3e7c70896ffeeef32b9c950ywan  /* Append length in bits and transform */
130233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->in[14] = ctx->bytes[0] << 3;
131233d2500723e5594f3e7c70896ffeeef32b9c950ywan  ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
132233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5Transform(ctx->buf, ctx->in);
133233d2500723e5594f3e7c70896ffeeef32b9c950ywan
134233d2500723e5594f3e7c70896ffeeef32b9c950ywan  byteSwap(ctx->buf, 4);
135233d2500723e5594f3e7c70896ffeeef32b9c950ywan  memcpy(digest, ctx->buf, 16);
136233d2500723e5594f3e7c70896ffeeef32b9c950ywan  memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
137233d2500723e5594f3e7c70896ffeeef32b9c950ywan}
138233d2500723e5594f3e7c70896ffeeef32b9c950ywan
139233d2500723e5594f3e7c70896ffeeef32b9c950ywan#ifndef ASM_MD5
140233d2500723e5594f3e7c70896ffeeef32b9c950ywan
141233d2500723e5594f3e7c70896ffeeef32b9c950ywan/* The four core functions - F1 is optimized somewhat */
142233d2500723e5594f3e7c70896ffeeef32b9c950ywan
143233d2500723e5594f3e7c70896ffeeef32b9c950ywan/* #define F1(x, y, z) (x & y | ~x & z) */
144233d2500723e5594f3e7c70896ffeeef32b9c950ywan#define F1(x, y, z) (z ^ (x & (y ^ z)))
145233d2500723e5594f3e7c70896ffeeef32b9c950ywan#define F2(x, y, z) F1(z, x, y)
146233d2500723e5594f3e7c70896ffeeef32b9c950ywan#define F3(x, y, z) (x ^ y ^ z)
147233d2500723e5594f3e7c70896ffeeef32b9c950ywan#define F4(x, y, z) (y ^ (x | ~z))
148233d2500723e5594f3e7c70896ffeeef32b9c950ywan
149233d2500723e5594f3e7c70896ffeeef32b9c950ywan/* This is the central step in the MD5 algorithm. */
150233d2500723e5594f3e7c70896ffeeef32b9c950ywan#define MD5STEP(f,w,x,y,z,in,s) \
151233d2500723e5594f3e7c70896ffeeef32b9c950ywan  (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
152233d2500723e5594f3e7c70896ffeeef32b9c950ywan
153233d2500723e5594f3e7c70896ffeeef32b9c950ywan/*
154233d2500723e5594f3e7c70896ffeeef32b9c950ywan * The core of the MD5 algorithm, this alters an existing MD5 hash to
155233d2500723e5594f3e7c70896ffeeef32b9c950ywan * reflect the addition of 16 longwords of new data.  MD5Update blocks
156233d2500723e5594f3e7c70896ffeeef32b9c950ywan * the data and converts bytes into longwords for this routine.
157233d2500723e5594f3e7c70896ffeeef32b9c950ywan */
158233d2500723e5594f3e7c70896ffeeef32b9c950ywanvoid
159233d2500723e5594f3e7c70896ffeeef32b9c950ywanMD5Transform(UWORD32 buf[4], UWORD32 const in[16]) {
160233d2500723e5594f3e7c70896ffeeef32b9c950ywan  register UWORD32 a, b, c, d;
161233d2500723e5594f3e7c70896ffeeef32b9c950ywan
162233d2500723e5594f3e7c70896ffeeef32b9c950ywan  a = buf[0];
163233d2500723e5594f3e7c70896ffeeef32b9c950ywan  b = buf[1];
164233d2500723e5594f3e7c70896ffeeef32b9c950ywan  c = buf[2];
165233d2500723e5594f3e7c70896ffeeef32b9c950ywan  d = buf[3];
166233d2500723e5594f3e7c70896ffeeef32b9c950ywan
167233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
168233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
169233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
170233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
171233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
172233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
173233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
174233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
175233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
176233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
177233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
178233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
179233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
180233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
181233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
182233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
183233d2500723e5594f3e7c70896ffeeef32b9c950ywan
184233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
185233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
186233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
187233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
188233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
189233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
190233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
191233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
192233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
193233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
194233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
195233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
196233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
197233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
198233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
199233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
200233d2500723e5594f3e7c70896ffeeef32b9c950ywan
201233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
202233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
203233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
204233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
205233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
206233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
207233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
208233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
209233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
210233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
211233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
212233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
213233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
214233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
215233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
216233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
217233d2500723e5594f3e7c70896ffeeef32b9c950ywan
218233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
219233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
220233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
221233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
222233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
223233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
224233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
225233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
226233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
227233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
228233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
229233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
230233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
231233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
232233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
233233d2500723e5594f3e7c70896ffeeef32b9c950ywan  MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
234233d2500723e5594f3e7c70896ffeeef32b9c950ywan
235233d2500723e5594f3e7c70896ffeeef32b9c950ywan  buf[0] += a;
236233d2500723e5594f3e7c70896ffeeef32b9c950ywan  buf[1] += b;
237233d2500723e5594f3e7c70896ffeeef32b9c950ywan  buf[2] += c;
238233d2500723e5594f3e7c70896ffeeef32b9c950ywan  buf[3] += d;
239233d2500723e5594f3e7c70896ffeeef32b9c950ywan}
240233d2500723e5594f3e7c70896ffeeef32b9c950ywan
241233d2500723e5594f3e7c70896ffeeef32b9c950ywan#endif
242