xref: /illumos-gate/usr/src/lib/gss_mechs/mech_dh/backend/crypto/md5.c (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
1*ebd1706eSgtb /*
2*ebd1706eSgtb  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*ebd1706eSgtb  * Use is subject to license terms.
4*ebd1706eSgtb  */
5*ebd1706eSgtb 
67c478bd9Sstevel@tonic-gate #include "md5.h"
77c478bd9Sstevel@tonic-gate 
87c478bd9Sstevel@tonic-gate /*
97c478bd9Sstevel@tonic-gate **************************************************************************
107c478bd9Sstevel@tonic-gate ** md5.c -- the source code for MD5 routines				**
117c478bd9Sstevel@tonic-gate ** RSA Data Security, Inc. MD5 Message-Digest Algorithm			**
127c478bd9Sstevel@tonic-gate ** Created: 2/17/90 RLR							**
137c478bd9Sstevel@tonic-gate ** Revised: 1/91 SRD, AJ, BSK, JT Reference C ver., 7/10 constant corr.	**
147c478bd9Sstevel@tonic-gate **************************************************************************
157c478bd9Sstevel@tonic-gate */
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate /*
187c478bd9Sstevel@tonic-gate **************************************************************************
197c478bd9Sstevel@tonic-gate ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.	**
207c478bd9Sstevel@tonic-gate **									**
217c478bd9Sstevel@tonic-gate ** License to copy and use this software is granted provided that	**
227c478bd9Sstevel@tonic-gate ** it is identified as the "RSA Data Security, Inc. MD5 Message-	**
237c478bd9Sstevel@tonic-gate ** Digest Algorithm" in all material mentioning or referencing this	**
247c478bd9Sstevel@tonic-gate ** software or this function.						**
257c478bd9Sstevel@tonic-gate **									**
267c478bd9Sstevel@tonic-gate ** License is also granted to make and use derivative works		**
277c478bd9Sstevel@tonic-gate ** provided that such works are identified as "derived from the RSA	**
287c478bd9Sstevel@tonic-gate ** Data Security, Inc. MD5 Message-Digest Algorithm" in all		**
297c478bd9Sstevel@tonic-gate ** material mentioning or referencing the derived work.			**
307c478bd9Sstevel@tonic-gate **									**
317c478bd9Sstevel@tonic-gate ** RSA Data Security, Inc. makes no representations concerning		**
327c478bd9Sstevel@tonic-gate ** either the merchantability of this software or the suitability	**
337c478bd9Sstevel@tonic-gate ** of this software for any particular purpose.  It is provided "as	**
347c478bd9Sstevel@tonic-gate ** is" without express or implied warranty of any kind.			**
357c478bd9Sstevel@tonic-gate **									**
367c478bd9Sstevel@tonic-gate ** These notices must be retained in any copies of any part of this	**
377c478bd9Sstevel@tonic-gate ** documentation and/or software.					**
387c478bd9Sstevel@tonic-gate **************************************************************************
397c478bd9Sstevel@tonic-gate */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate **************************************************************************
447c478bd9Sstevel@tonic-gate **  Message-digest routines:						**
457c478bd9Sstevel@tonic-gate **  To form the message digest for a message M				**
467c478bd9Sstevel@tonic-gate **    (1) Initialize a context buffer mdContext using MD5Init		**
477c478bd9Sstevel@tonic-gate **    (2) Call MD5Update on mdContext and M				**
487c478bd9Sstevel@tonic-gate **    (3) Call MD5Final on mdContext					**
497c478bd9Sstevel@tonic-gate **  The message digest is now in mdContext->digest[0...15]		**
507c478bd9Sstevel@tonic-gate **************************************************************************
517c478bd9Sstevel@tonic-gate */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /* forward declaration */
547c478bd9Sstevel@tonic-gate static void Transform (UINT4 *buf, UINT4 *in);
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate static unsigned char PADDING[64] = {
577c478bd9Sstevel@tonic-gate 	0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
587c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
597c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
607c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
617c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
627c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
637c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
647c478bd9Sstevel@tonic-gate 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
657c478bd9Sstevel@tonic-gate 	};
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /* F, G, H and I are basic MD5 functions */
687c478bd9Sstevel@tonic-gate #define	F(x, y, z) (((x) & (y)) | ((~x) & (z)))
697c478bd9Sstevel@tonic-gate #define	G(x, y, z) (((x) & (z)) | ((y) & (~z)))
707c478bd9Sstevel@tonic-gate #define	H(x, y, z) ((x) ^ (y) ^ (z))
717c478bd9Sstevel@tonic-gate #define	I(x, y, z) ((y) ^ ((x) | (~z)))
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /* ROTATE_LEFT rotates x left n bits */
747c478bd9Sstevel@tonic-gate #define	ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
777c478bd9Sstevel@tonic-gate /* Rotation is separate from addition to prevent recomputation */
787c478bd9Sstevel@tonic-gate #define	FF(a, b, c, d, x, s, ac) \
797c478bd9Sstevel@tonic-gate 	{(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
807c478bd9Sstevel@tonic-gate 	(a) = ROTATE_LEFT ((a), (s)); \
817c478bd9Sstevel@tonic-gate 	(a) += (b); \
827c478bd9Sstevel@tonic-gate 	}
837c478bd9Sstevel@tonic-gate #define	GG(a, b, c, d, x, s, ac) \
847c478bd9Sstevel@tonic-gate 	{(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
857c478bd9Sstevel@tonic-gate 	(a) = ROTATE_LEFT ((a), (s)); \
867c478bd9Sstevel@tonic-gate 	(a) += (b); \
877c478bd9Sstevel@tonic-gate 	}
887c478bd9Sstevel@tonic-gate #define	HH(a, b, c, d, x, s, ac) \
897c478bd9Sstevel@tonic-gate 	{(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
907c478bd9Sstevel@tonic-gate 	(a) = ROTATE_LEFT ((a), (s)); \
917c478bd9Sstevel@tonic-gate 	(a) += (b); \
927c478bd9Sstevel@tonic-gate 	}
937c478bd9Sstevel@tonic-gate #define	II(a, b, c, d, x, s, ac) \
947c478bd9Sstevel@tonic-gate 	{(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
957c478bd9Sstevel@tonic-gate 	(a) = ROTATE_LEFT ((a), (s)); \
967c478bd9Sstevel@tonic-gate 	(a) += (b); \
977c478bd9Sstevel@tonic-gate 	}
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate * The routine MD5Init initializes the message-digest context
1017c478bd9Sstevel@tonic-gate * mdContext. All fields are set to zero.
1027c478bd9Sstevel@tonic-gate */
MD5Init(MD5_CTX * mdContext)1037c478bd9Sstevel@tonic-gate void MD5Init (MD5_CTX *mdContext)
1047c478bd9Sstevel@tonic-gate {
1057c478bd9Sstevel@tonic-gate 	mdContext->i[0] = mdContext->i[1] = (UINT4)0;
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 	/*
1087c478bd9Sstevel@tonic-gate 	* Load magic initialization constants.
1097c478bd9Sstevel@tonic-gate 	*/
1107c478bd9Sstevel@tonic-gate 	mdContext->buf[0] = (UINT4)0x67452301;
1117c478bd9Sstevel@tonic-gate 	mdContext->buf[1] = (UINT4)0xefcdab89;
1127c478bd9Sstevel@tonic-gate 	mdContext->buf[2] = (UINT4)0x98badcfe;
1137c478bd9Sstevel@tonic-gate 	mdContext->buf[3] = (UINT4)0x10325476;
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate * The routine MD5Update updates the message-digest context to
1187c478bd9Sstevel@tonic-gate * account for the presence of each of the characters inBuf[0..inLen-1]
1197c478bd9Sstevel@tonic-gate * in the message whose digest is being computed.
1207c478bd9Sstevel@tonic-gate */
MD5Update(MD5_CTX * mdContext,unsigned char * inBuf,unsigned int inLen)1217c478bd9Sstevel@tonic-gate void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
1227c478bd9Sstevel@tonic-gate {
1237c478bd9Sstevel@tonic-gate 	UINT4 in[16];
1247c478bd9Sstevel@tonic-gate 	int mdi;
1257c478bd9Sstevel@tonic-gate 	unsigned int i, ii;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	/* compute number of bytes mod 64 */
1287c478bd9Sstevel@tonic-gate 	mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	/* update number of bits */
1317c478bd9Sstevel@tonic-gate 	if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
1327c478bd9Sstevel@tonic-gate 		mdContext->i[1]++;
1337c478bd9Sstevel@tonic-gate 	mdContext->i[0] += ((UINT4)inLen << 3);
1347c478bd9Sstevel@tonic-gate 	mdContext->i[1] += ((UINT4)inLen >> 29);
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 	while (inLen--) {
1377c478bd9Sstevel@tonic-gate 		/* add new character to buffer, increment mdi */
1387c478bd9Sstevel@tonic-gate 		mdContext->in[mdi++] = *inBuf++;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 		/* transform if necessary */
1417c478bd9Sstevel@tonic-gate 		if (mdi == 0x40) {
1427c478bd9Sstevel@tonic-gate 			for (i = 0, ii = 0; i < 16; i++, ii += 4)
1437c478bd9Sstevel@tonic-gate 				in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
1447c478bd9Sstevel@tonic-gate 					(((UINT4)mdContext->in[ii+2]) << 16) |
1457c478bd9Sstevel@tonic-gate 					(((UINT4)mdContext->in[ii+1]) << 8) |
1467c478bd9Sstevel@tonic-gate 					((UINT4)mdContext->in[ii]);
1477c478bd9Sstevel@tonic-gate 			Transform (mdContext->buf, in);
1487c478bd9Sstevel@tonic-gate 			mdi = 0;
1497c478bd9Sstevel@tonic-gate 		}
1507c478bd9Sstevel@tonic-gate 	}
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate * The routine MD5Final terminates the message-digest computation and
1557c478bd9Sstevel@tonic-gate * ends with the desired message digest in mdContext->digest[0...15].
1567c478bd9Sstevel@tonic-gate */
MD5Final(MD5_CTX * mdContext)1577c478bd9Sstevel@tonic-gate void MD5Final (MD5_CTX *mdContext)
1587c478bd9Sstevel@tonic-gate {
1597c478bd9Sstevel@tonic-gate 	UINT4 in[16];
1607c478bd9Sstevel@tonic-gate 	int mdi;
1617c478bd9Sstevel@tonic-gate 	unsigned int i, ii;
1627c478bd9Sstevel@tonic-gate 	unsigned int padLen;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 	/* save number of bits */
1657c478bd9Sstevel@tonic-gate 	in[14] = mdContext->i[0];
1667c478bd9Sstevel@tonic-gate 	in[15] = mdContext->i[1];
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate 	/* compute number of bytes mod 64 */
1697c478bd9Sstevel@tonic-gate 	mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 	/* pad out to 56 mod 64 */
1727c478bd9Sstevel@tonic-gate 	padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
1737c478bd9Sstevel@tonic-gate 	MD5Update (mdContext, PADDING, padLen);
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	/* append length in bits and transform */
1767c478bd9Sstevel@tonic-gate 	for (i = 0, ii = 0; i < 14; i++, ii += 4)
1777c478bd9Sstevel@tonic-gate 		in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
1787c478bd9Sstevel@tonic-gate 			(((UINT4)mdContext->in[ii+2]) << 16) |
1797c478bd9Sstevel@tonic-gate 			(((UINT4)mdContext->in[ii+1]) << 8) |
1807c478bd9Sstevel@tonic-gate 			((UINT4)mdContext->in[ii]);
1817c478bd9Sstevel@tonic-gate 			Transform (mdContext->buf, in);
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate 	/* store buffer in digest */
1847c478bd9Sstevel@tonic-gate 	for (i = 0, ii = 0; i < 4; i++, ii += 4) {
1857c478bd9Sstevel@tonic-gate 		mdContext->digest[ii] =
1867c478bd9Sstevel@tonic-gate 				(unsigned char)(mdContext->buf[i] & 0xFF);
1877c478bd9Sstevel@tonic-gate 		mdContext->digest[ii+1] =
1887c478bd9Sstevel@tonic-gate 			(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
1897c478bd9Sstevel@tonic-gate 		mdContext->digest[ii+2] =
1907c478bd9Sstevel@tonic-gate 			(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
1917c478bd9Sstevel@tonic-gate 		mdContext->digest[ii+3] =
1927c478bd9Sstevel@tonic-gate 			(unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
1937c478bd9Sstevel@tonic-gate 	}
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate * Basic MD5 step. Transforms buf based on in.
1987c478bd9Sstevel@tonic-gate */
Transform(UINT4 * buf,UINT4 * in)1997c478bd9Sstevel@tonic-gate static void Transform (UINT4 *buf, UINT4 *in)
2007c478bd9Sstevel@tonic-gate {
2017c478bd9Sstevel@tonic-gate 	UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate /* Round 1 */
2047c478bd9Sstevel@tonic-gate #define	S11	7
2057c478bd9Sstevel@tonic-gate #define	S12	12
2067c478bd9Sstevel@tonic-gate #define	S13	17
2077c478bd9Sstevel@tonic-gate #define	S14	22
208*ebd1706eSgtb 	FF (a, b, c, d, in[ 0], S11, 3614090360U); /* 1 */
209*ebd1706eSgtb 	FF (d, a, b, c, in[ 1], S12, 3905402710U); /* 2 */
210*ebd1706eSgtb 	FF (c, d, a, b, in[ 2], S13,  606105819U); /* 3 */
211*ebd1706eSgtb 	FF (b, c, d, a, in[ 3], S14, 3250441966U); /* 4 */
212*ebd1706eSgtb 	FF (a, b, c, d, in[ 4], S11, 4118548399U); /* 5 */
213*ebd1706eSgtb 	FF (d, a, b, c, in[ 5], S12, 1200080426U); /* 6 */
214*ebd1706eSgtb 	FF (c, d, a, b, in[ 6], S13, 2821735955U); /* 7 */
215*ebd1706eSgtb 	FF (b, c, d, a, in[ 7], S14, 4249261313U); /* 8 */
216*ebd1706eSgtb 	FF (a, b, c, d, in[ 8], S11, 1770035416U); /* 9 */
217*ebd1706eSgtb 	FF (d, a, b, c, in[ 9], S12, 2336552879U); /* 10 */
218*ebd1706eSgtb 	FF (c, d, a, b, in[10], S13, 4294925233U); /* 11 */
219*ebd1706eSgtb 	FF (b, c, d, a, in[11], S14, 2304563134U); /* 12 */
220*ebd1706eSgtb 	FF (a, b, c, d, in[12], S11, 1804603682U); /* 13 */
221*ebd1706eSgtb 	FF (d, a, b, c, in[13], S12, 4254626195U); /* 14 */
222*ebd1706eSgtb 	FF (c, d, a, b, in[14], S13, 2792965006U); /* 15 */
223*ebd1706eSgtb 	FF (b, c, d, a, in[15], S14, 1236535329U); /* 16 */
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate /* Round 2 */
2267c478bd9Sstevel@tonic-gate #define	S21	5
2277c478bd9Sstevel@tonic-gate #define	S22	9
2287c478bd9Sstevel@tonic-gate #define	S23	14
2297c478bd9Sstevel@tonic-gate #define	S24	20
230*ebd1706eSgtb 	GG (a, b, c, d, in[ 1], S21, 4129170786U); /* 17 */
231*ebd1706eSgtb 	GG (d, a, b, c, in[ 6], S22, 3225465664U); /* 18 */
232*ebd1706eSgtb 	GG (c, d, a, b, in[11], S23,  643717713U); /* 19 */
233*ebd1706eSgtb 	GG (b, c, d, a, in[ 0], S24, 3921069994U); /* 20 */
234*ebd1706eSgtb 	GG (a, b, c, d, in[ 5], S21, 3593408605U); /* 21 */
235*ebd1706eSgtb 	GG (d, a, b, c, in[10], S22,   38016083U); /* 22 */
236*ebd1706eSgtb 	GG (c, d, a, b, in[15], S23, 3634488961U); /* 23 */
237*ebd1706eSgtb 	GG (b, c, d, a, in[ 4], S24, 3889429448U); /* 24 */
238*ebd1706eSgtb 	GG (a, b, c, d, in[ 9], S21,  568446438U); /* 25 */
239*ebd1706eSgtb 	GG (d, a, b, c, in[14], S22, 3275163606U); /* 26 */
240*ebd1706eSgtb 	GG (c, d, a, b, in[ 3], S23, 4107603335U); /* 27 */
241*ebd1706eSgtb 	GG (b, c, d, a, in[ 8], S24, 1163531501U); /* 28 */
242*ebd1706eSgtb 	GG (a, b, c, d, in[13], S21, 2850285829U); /* 29 */
243*ebd1706eSgtb 	GG (d, a, b, c, in[ 2], S22, 4243563512U); /* 30 */
244*ebd1706eSgtb 	GG (c, d, a, b, in[ 7], S23, 1735328473U); /* 31 */
245*ebd1706eSgtb 	GG (b, c, d, a, in[12], S24, 2368359562U); /* 32 */
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /* Round 3 */
2487c478bd9Sstevel@tonic-gate #define	S31	4
2497c478bd9Sstevel@tonic-gate #define	S32	11
2507c478bd9Sstevel@tonic-gate #define	S33	16
2517c478bd9Sstevel@tonic-gate #define	S34	23
252*ebd1706eSgtb 	HH (a, b, c, d, in[ 5], S31, 4294588738U); /* 33 */
253*ebd1706eSgtb 	HH (d, a, b, c, in[ 8], S32, 2272392833U); /* 34 */
254*ebd1706eSgtb 	HH (c, d, a, b, in[11], S33, 1839030562U); /* 35 */
255*ebd1706eSgtb 	HH (b, c, d, a, in[14], S34, 4259657740U); /* 36 */
256*ebd1706eSgtb 	HH (a, b, c, d, in[ 1], S31, 2763975236U); /* 37 */
257*ebd1706eSgtb 	HH (d, a, b, c, in[ 4], S32, 1272893353U); /* 38 */
258*ebd1706eSgtb 	HH (c, d, a, b, in[ 7], S33, 4139469664U); /* 39 */
259*ebd1706eSgtb 	HH (b, c, d, a, in[10], S34, 3200236656U); /* 40 */
260*ebd1706eSgtb 	HH (a, b, c, d, in[13], S31,  681279174U); /* 41 */
261*ebd1706eSgtb 	HH (d, a, b, c, in[ 0], S32, 3936430074U); /* 42 */
262*ebd1706eSgtb 	HH (c, d, a, b, in[ 3], S33, 3572445317U); /* 43 */
263*ebd1706eSgtb 	HH (b, c, d, a, in[ 6], S34,   76029189U); /* 44 */
264*ebd1706eSgtb 	HH (a, b, c, d, in[ 9], S31, 3654602809U); /* 45 */
265*ebd1706eSgtb 	HH (d, a, b, c, in[12], S32, 3873151461U); /* 46 */
266*ebd1706eSgtb 	HH (c, d, a, b, in[15], S33,  530742520U); /* 47 */
267*ebd1706eSgtb 	HH (b, c, d, a, in[ 2], S34, 3299628645U); /* 48 */
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /* Round 4 */
2707c478bd9Sstevel@tonic-gate #define	S41	6
2717c478bd9Sstevel@tonic-gate #define	S42	10
2727c478bd9Sstevel@tonic-gate #define	S43	15
2737c478bd9Sstevel@tonic-gate #define	S44	21
274*ebd1706eSgtb 	II (a, b, c, d, in[ 0], S41, 4096336452U); /* 49 */
275*ebd1706eSgtb 	II (d, a, b, c, in[ 7], S42, 1126891415U); /* 50 */
276*ebd1706eSgtb 	II (c, d, a, b, in[14], S43, 2878612391U); /* 51 */
277*ebd1706eSgtb 	II (b, c, d, a, in[ 5], S44, 4237533241U); /* 52 */
278*ebd1706eSgtb 	II (a, b, c, d, in[12], S41, 1700485571U); /* 53 */
279*ebd1706eSgtb 	II (d, a, b, c, in[ 3], S42, 2399980690U); /* 54 */
280*ebd1706eSgtb 	II (c, d, a, b, in[10], S43, 4293915773U); /* 55 */
281*ebd1706eSgtb 	II (b, c, d, a, in[ 1], S44, 2240044497U); /* 56 */
282*ebd1706eSgtb 	II (a, b, c, d, in[ 8], S41, 1873313359U); /* 57 */
283*ebd1706eSgtb 	II (d, a, b, c, in[15], S42, 4264355552U); /* 58 */
284*ebd1706eSgtb 	II (c, d, a, b, in[ 6], S43, 2734768916U); /* 59 */
285*ebd1706eSgtb 	II (b, c, d, a, in[13], S44, 1309151649U); /* 60 */
286*ebd1706eSgtb 	II (a, b, c, d, in[ 4], S41, 4149444226U); /* 61 */
287*ebd1706eSgtb 	II (d, a, b, c, in[11], S42, 3174756917U); /* 62 */
288*ebd1706eSgtb 	II (c, d, a, b, in[ 2], S43,  718787259U); /* 63 */
289*ebd1706eSgtb 	II (b, c, d, a, in[ 9], S44, 3951481745U); /* 64 */
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	buf[0] += a;
2927c478bd9Sstevel@tonic-gate 	buf[1] += b;
2937c478bd9Sstevel@tonic-gate 	buf[2] += c;
2947c478bd9Sstevel@tonic-gate 	buf[3] += d;
2957c478bd9Sstevel@tonic-gate }
296