xref: /onnv-gate/usr/src/common/openssl/crypto/ripemd/rmd_dgst.c (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* crypto/ripemd/rmd_dgst.c */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #include <stdio.h>
600Sstevel@tonic-gate #include "rmd_locl.h"
610Sstevel@tonic-gate #include <openssl/opensslv.h>
620Sstevel@tonic-gate 
630Sstevel@tonic-gate const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #  ifdef RMD160_ASM
66*2139Sjp161948      void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,size_t num);
670Sstevel@tonic-gate #    define ripemd160_block ripemd160_block_x86
680Sstevel@tonic-gate #  else
69*2139Sjp161948      void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num);
700Sstevel@tonic-gate #  endif
710Sstevel@tonic-gate 
RIPEMD160_Init(RIPEMD160_CTX * c)720Sstevel@tonic-gate int RIPEMD160_Init(RIPEMD160_CTX *c)
730Sstevel@tonic-gate 	{
740Sstevel@tonic-gate 	c->A=RIPEMD160_A;
750Sstevel@tonic-gate 	c->B=RIPEMD160_B;
760Sstevel@tonic-gate 	c->C=RIPEMD160_C;
770Sstevel@tonic-gate 	c->D=RIPEMD160_D;
780Sstevel@tonic-gate 	c->E=RIPEMD160_E;
790Sstevel@tonic-gate 	c->Nl=0;
800Sstevel@tonic-gate 	c->Nh=0;
810Sstevel@tonic-gate 	c->num=0;
820Sstevel@tonic-gate 	return 1;
830Sstevel@tonic-gate 	}
840Sstevel@tonic-gate 
850Sstevel@tonic-gate #ifndef ripemd160_block_host_order
860Sstevel@tonic-gate #ifdef X
870Sstevel@tonic-gate #undef X
880Sstevel@tonic-gate #endif
890Sstevel@tonic-gate #define X(i)	XX[i]
ripemd160_block_host_order(RIPEMD160_CTX * ctx,const void * p,size_t num)90*2139Sjp161948 void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
910Sstevel@tonic-gate 	{
920Sstevel@tonic-gate 	const RIPEMD160_LONG *XX=p;
930Sstevel@tonic-gate 	register unsigned MD32_REG_T A,B,C,D,E;
940Sstevel@tonic-gate 	register unsigned MD32_REG_T a,b,c,d,e;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	for (;num--;XX+=HASH_LBLOCK)
970Sstevel@tonic-gate 		{
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL00,SL00);
1020Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL01,SL01);
1030Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL02,SL02);
1040Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL03,SL03);
1050Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL04,SL04);
1060Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL05,SL05);
1070Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL06,SL06);
1080Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL07,SL07);
1090Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL08,SL08);
1100Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL09,SL09);
1110Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL10,SL10);
1120Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL11,SL11);
1130Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL12,SL12);
1140Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL13,SL13);
1150Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL14,SL14);
1160Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL15,SL15);
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL16,SL16,KL1);
1190Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL17,SL17,KL1);
1200Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL18,SL18,KL1);
1210Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL19,SL19,KL1);
1220Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL20,SL20,KL1);
1230Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL21,SL21,KL1);
1240Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL22,SL22,KL1);
1250Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL23,SL23,KL1);
1260Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL24,SL24,KL1);
1270Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL25,SL25,KL1);
1280Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL26,SL26,KL1);
1290Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL27,SL27,KL1);
1300Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL28,SL28,KL1);
1310Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL29,SL29,KL1);
1320Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL30,SL30,KL1);
1330Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL31,SL31,KL1);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL32,SL32,KL2);
1360Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL33,SL33,KL2);
1370Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL34,SL34,KL2);
1380Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL35,SL35,KL2);
1390Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL36,SL36,KL2);
1400Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL37,SL37,KL2);
1410Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL38,SL38,KL2);
1420Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL39,SL39,KL2);
1430Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL40,SL40,KL2);
1440Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL41,SL41,KL2);
1450Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL42,SL42,KL2);
1460Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL43,SL43,KL2);
1470Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL44,SL44,KL2);
1480Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL45,SL45,KL2);
1490Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL46,SL46,KL2);
1500Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL47,SL47,KL2);
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL48,SL48,KL3);
1530Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL49,SL49,KL3);
1540Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL50,SL50,KL3);
1550Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL51,SL51,KL3);
1560Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL52,SL52,KL3);
1570Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL53,SL53,KL3);
1580Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL54,SL54,KL3);
1590Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL55,SL55,KL3);
1600Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL56,SL56,KL3);
1610Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL57,SL57,KL3);
1620Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL58,SL58,KL3);
1630Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL59,SL59,KL3);
1640Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL60,SL60,KL3);
1650Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL61,SL61,KL3);
1660Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL62,SL62,KL3);
1670Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL63,SL63,KL3);
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL64,SL64,KL4);
1700Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL65,SL65,KL4);
1710Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL66,SL66,KL4);
1720Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL67,SL67,KL4);
1730Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL68,SL68,KL4);
1740Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL69,SL69,KL4);
1750Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL70,SL70,KL4);
1760Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL71,SL71,KL4);
1770Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL72,SL72,KL4);
1780Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL73,SL73,KL4);
1790Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL74,SL74,KL4);
1800Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL75,SL75,KL4);
1810Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL76,SL76,KL4);
1820Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL77,SL77,KL4);
1830Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL78,SL78,KL4);
1840Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL79,SL79,KL4);
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	a=A; b=B; c=C; d=D; e=E;
1870Sstevel@tonic-gate 	/* Do other half */
1880Sstevel@tonic-gate 	A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR00,SR00,KR0);
1910Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR01,SR01,KR0);
1920Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR02,SR02,KR0);
1930Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR03,SR03,KR0);
1940Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR04,SR04,KR0);
1950Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR05,SR05,KR0);
1960Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR06,SR06,KR0);
1970Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR07,SR07,KR0);
1980Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR08,SR08,KR0);
1990Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR09,SR09,KR0);
2000Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR10,SR10,KR0);
2010Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR11,SR11,KR0);
2020Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR12,SR12,KR0);
2030Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR13,SR13,KR0);
2040Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR14,SR14,KR0);
2050Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR15,SR15,KR0);
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR16,SR16,KR1);
2080Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR17,SR17,KR1);
2090Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR18,SR18,KR1);
2100Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR19,SR19,KR1);
2110Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR20,SR20,KR1);
2120Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR21,SR21,KR1);
2130Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR22,SR22,KR1);
2140Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR23,SR23,KR1);
2150Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR24,SR24,KR1);
2160Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR25,SR25,KR1);
2170Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR26,SR26,KR1);
2180Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR27,SR27,KR1);
2190Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR28,SR28,KR1);
2200Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR29,SR29,KR1);
2210Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR30,SR30,KR1);
2220Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR31,SR31,KR1);
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR32,SR32,KR2);
2250Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR33,SR33,KR2);
2260Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR34,SR34,KR2);
2270Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR35,SR35,KR2);
2280Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR36,SR36,KR2);
2290Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR37,SR37,KR2);
2300Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR38,SR38,KR2);
2310Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR39,SR39,KR2);
2320Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR40,SR40,KR2);
2330Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR41,SR41,KR2);
2340Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR42,SR42,KR2);
2350Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR43,SR43,KR2);
2360Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR44,SR44,KR2);
2370Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR45,SR45,KR2);
2380Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR46,SR46,KR2);
2390Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR47,SR47,KR2);
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR48,SR48,KR3);
2420Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR49,SR49,KR3);
2430Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR50,SR50,KR3);
2440Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR51,SR51,KR3);
2450Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR52,SR52,KR3);
2460Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR53,SR53,KR3);
2470Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR54,SR54,KR3);
2480Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR55,SR55,KR3);
2490Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR56,SR56,KR3);
2500Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR57,SR57,KR3);
2510Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR58,SR58,KR3);
2520Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR59,SR59,KR3);
2530Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR60,SR60,KR3);
2540Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR61,SR61,KR3);
2550Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR62,SR62,KR3);
2560Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR63,SR63,KR3);
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR64,SR64);
2590Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR65,SR65);
2600Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR66,SR66);
2610Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR67,SR67);
2620Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR68,SR68);
2630Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR69,SR69);
2640Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR70,SR70);
2650Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR71,SR71);
2660Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR72,SR72);
2670Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR73,SR73);
2680Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR74,SR74);
2690Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR75,SR75);
2700Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR76,SR76);
2710Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR77,SR77);
2720Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR78,SR78);
2730Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR79,SR79);
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate 	D     =ctx->B+c+D;
2760Sstevel@tonic-gate 	ctx->B=ctx->C+d+E;
2770Sstevel@tonic-gate 	ctx->C=ctx->D+e+A;
2780Sstevel@tonic-gate 	ctx->D=ctx->E+a+B;
2790Sstevel@tonic-gate 	ctx->E=ctx->A+b+C;
2800Sstevel@tonic-gate 	ctx->A=D;
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 		}
2830Sstevel@tonic-gate 	}
2840Sstevel@tonic-gate #endif
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate #ifndef ripemd160_block_data_order
2870Sstevel@tonic-gate #ifdef X
2880Sstevel@tonic-gate #undef X
2890Sstevel@tonic-gate #endif
ripemd160_block_data_order(RIPEMD160_CTX * ctx,const void * p,size_t num)290*2139Sjp161948 void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
2910Sstevel@tonic-gate 	{
2920Sstevel@tonic-gate 	const unsigned char *data=p;
2930Sstevel@tonic-gate 	register unsigned MD32_REG_T A,B,C,D,E;
2940Sstevel@tonic-gate 	unsigned MD32_REG_T a,b,c,d,e,l;
2950Sstevel@tonic-gate #ifndef MD32_XARRAY
2960Sstevel@tonic-gate 	/* See comment in crypto/sha/sha_locl.h for details. */
2970Sstevel@tonic-gate 	unsigned MD32_REG_T	XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
2980Sstevel@tonic-gate 				XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
2990Sstevel@tonic-gate # define X(i)	XX##i
3000Sstevel@tonic-gate #else
3010Sstevel@tonic-gate 	RIPEMD160_LONG	XX[16];
3020Sstevel@tonic-gate # define X(i)	XX[i]
3030Sstevel@tonic-gate #endif
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate 	for (;num--;)
3060Sstevel@tonic-gate 		{
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate 	A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 	HOST_c2l(data,l); X( 0)=l;	HOST_c2l(data,l); X( 1)=l;
3110Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL00,SL00);	HOST_c2l(data,l); X( 2)=l;
3120Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL01,SL01);	HOST_c2l(data,l); X( 3)=l;
3130Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL02,SL02);	HOST_c2l(data,l); X( 4)=l;
3140Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL03,SL03);	HOST_c2l(data,l); X( 5)=l;
3150Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL04,SL04);	HOST_c2l(data,l); X( 6)=l;
3160Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL05,SL05);	HOST_c2l(data,l); X( 7)=l;
3170Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL06,SL06);	HOST_c2l(data,l); X( 8)=l;
3180Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL07,SL07);	HOST_c2l(data,l); X( 9)=l;
3190Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL08,SL08);	HOST_c2l(data,l); X(10)=l;
3200Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL09,SL09);	HOST_c2l(data,l); X(11)=l;
3210Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL10,SL10);	HOST_c2l(data,l); X(12)=l;
3220Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WL11,SL11);	HOST_c2l(data,l); X(13)=l;
3230Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WL12,SL12);	HOST_c2l(data,l); X(14)=l;
3240Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WL13,SL13);	HOST_c2l(data,l); X(15)=l;
3250Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WL14,SL14);
3260Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WL15,SL15);
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL16,SL16,KL1);
3290Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL17,SL17,KL1);
3300Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL18,SL18,KL1);
3310Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL19,SL19,KL1);
3320Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL20,SL20,KL1);
3330Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL21,SL21,KL1);
3340Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL22,SL22,KL1);
3350Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL23,SL23,KL1);
3360Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL24,SL24,KL1);
3370Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL25,SL25,KL1);
3380Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL26,SL26,KL1);
3390Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WL27,SL27,KL1);
3400Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WL28,SL28,KL1);
3410Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WL29,SL29,KL1);
3420Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WL30,SL30,KL1);
3430Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WL31,SL31,KL1);
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL32,SL32,KL2);
3460Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL33,SL33,KL2);
3470Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL34,SL34,KL2);
3480Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL35,SL35,KL2);
3490Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL36,SL36,KL2);
3500Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL37,SL37,KL2);
3510Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL38,SL38,KL2);
3520Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL39,SL39,KL2);
3530Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL40,SL40,KL2);
3540Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL41,SL41,KL2);
3550Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL42,SL42,KL2);
3560Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WL43,SL43,KL2);
3570Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WL44,SL44,KL2);
3580Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WL45,SL45,KL2);
3590Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WL46,SL46,KL2);
3600Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WL47,SL47,KL2);
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL48,SL48,KL3);
3630Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL49,SL49,KL3);
3640Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL50,SL50,KL3);
3650Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL51,SL51,KL3);
3660Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL52,SL52,KL3);
3670Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL53,SL53,KL3);
3680Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL54,SL54,KL3);
3690Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL55,SL55,KL3);
3700Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL56,SL56,KL3);
3710Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL57,SL57,KL3);
3720Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL58,SL58,KL3);
3730Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WL59,SL59,KL3);
3740Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WL60,SL60,KL3);
3750Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WL61,SL61,KL3);
3760Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WL62,SL62,KL3);
3770Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WL63,SL63,KL3);
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL64,SL64,KL4);
3800Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL65,SL65,KL4);
3810Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL66,SL66,KL4);
3820Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL67,SL67,KL4);
3830Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL68,SL68,KL4);
3840Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL69,SL69,KL4);
3850Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL70,SL70,KL4);
3860Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL71,SL71,KL4);
3870Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL72,SL72,KL4);
3880Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL73,SL73,KL4);
3890Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL74,SL74,KL4);
3900Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WL75,SL75,KL4);
3910Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WL76,SL76,KL4);
3920Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WL77,SL77,KL4);
3930Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WL78,SL78,KL4);
3940Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WL79,SL79,KL4);
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate 	a=A; b=B; c=C; d=D; e=E;
3970Sstevel@tonic-gate 	/* Do other half */
3980Sstevel@tonic-gate 	A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR00,SR00,KR0);
4010Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR01,SR01,KR0);
4020Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR02,SR02,KR0);
4030Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR03,SR03,KR0);
4040Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR04,SR04,KR0);
4050Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR05,SR05,KR0);
4060Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR06,SR06,KR0);
4070Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR07,SR07,KR0);
4080Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR08,SR08,KR0);
4090Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR09,SR09,KR0);
4100Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR10,SR10,KR0);
4110Sstevel@tonic-gate 	RIP5(E,A,B,C,D,WR11,SR11,KR0);
4120Sstevel@tonic-gate 	RIP5(D,E,A,B,C,WR12,SR12,KR0);
4130Sstevel@tonic-gate 	RIP5(C,D,E,A,B,WR13,SR13,KR0);
4140Sstevel@tonic-gate 	RIP5(B,C,D,E,A,WR14,SR14,KR0);
4150Sstevel@tonic-gate 	RIP5(A,B,C,D,E,WR15,SR15,KR0);
4160Sstevel@tonic-gate 
4170Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR16,SR16,KR1);
4180Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR17,SR17,KR1);
4190Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR18,SR18,KR1);
4200Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR19,SR19,KR1);
4210Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR20,SR20,KR1);
4220Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR21,SR21,KR1);
4230Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR22,SR22,KR1);
4240Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR23,SR23,KR1);
4250Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR24,SR24,KR1);
4260Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR25,SR25,KR1);
4270Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR26,SR26,KR1);
4280Sstevel@tonic-gate 	RIP4(D,E,A,B,C,WR27,SR27,KR1);
4290Sstevel@tonic-gate 	RIP4(C,D,E,A,B,WR28,SR28,KR1);
4300Sstevel@tonic-gate 	RIP4(B,C,D,E,A,WR29,SR29,KR1);
4310Sstevel@tonic-gate 	RIP4(A,B,C,D,E,WR30,SR30,KR1);
4320Sstevel@tonic-gate 	RIP4(E,A,B,C,D,WR31,SR31,KR1);
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR32,SR32,KR2);
4350Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR33,SR33,KR2);
4360Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR34,SR34,KR2);
4370Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR35,SR35,KR2);
4380Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR36,SR36,KR2);
4390Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR37,SR37,KR2);
4400Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR38,SR38,KR2);
4410Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR39,SR39,KR2);
4420Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR40,SR40,KR2);
4430Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR41,SR41,KR2);
4440Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR42,SR42,KR2);
4450Sstevel@tonic-gate 	RIP3(C,D,E,A,B,WR43,SR43,KR2);
4460Sstevel@tonic-gate 	RIP3(B,C,D,E,A,WR44,SR44,KR2);
4470Sstevel@tonic-gate 	RIP3(A,B,C,D,E,WR45,SR45,KR2);
4480Sstevel@tonic-gate 	RIP3(E,A,B,C,D,WR46,SR46,KR2);
4490Sstevel@tonic-gate 	RIP3(D,E,A,B,C,WR47,SR47,KR2);
4500Sstevel@tonic-gate 
4510Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR48,SR48,KR3);
4520Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR49,SR49,KR3);
4530Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR50,SR50,KR3);
4540Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR51,SR51,KR3);
4550Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR52,SR52,KR3);
4560Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR53,SR53,KR3);
4570Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR54,SR54,KR3);
4580Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR55,SR55,KR3);
4590Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR56,SR56,KR3);
4600Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR57,SR57,KR3);
4610Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR58,SR58,KR3);
4620Sstevel@tonic-gate 	RIP2(B,C,D,E,A,WR59,SR59,KR3);
4630Sstevel@tonic-gate 	RIP2(A,B,C,D,E,WR60,SR60,KR3);
4640Sstevel@tonic-gate 	RIP2(E,A,B,C,D,WR61,SR61,KR3);
4650Sstevel@tonic-gate 	RIP2(D,E,A,B,C,WR62,SR62,KR3);
4660Sstevel@tonic-gate 	RIP2(C,D,E,A,B,WR63,SR63,KR3);
4670Sstevel@tonic-gate 
4680Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR64,SR64);
4690Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR65,SR65);
4700Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR66,SR66);
4710Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR67,SR67);
4720Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR68,SR68);
4730Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR69,SR69);
4740Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR70,SR70);
4750Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR71,SR71);
4760Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR72,SR72);
4770Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR73,SR73);
4780Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR74,SR74);
4790Sstevel@tonic-gate 	RIP1(A,B,C,D,E,WR75,SR75);
4800Sstevel@tonic-gate 	RIP1(E,A,B,C,D,WR76,SR76);
4810Sstevel@tonic-gate 	RIP1(D,E,A,B,C,WR77,SR77);
4820Sstevel@tonic-gate 	RIP1(C,D,E,A,B,WR78,SR78);
4830Sstevel@tonic-gate 	RIP1(B,C,D,E,A,WR79,SR79);
4840Sstevel@tonic-gate 
4850Sstevel@tonic-gate 	D     =ctx->B+c+D;
4860Sstevel@tonic-gate 	ctx->B=ctx->C+d+E;
4870Sstevel@tonic-gate 	ctx->C=ctx->D+e+A;
4880Sstevel@tonic-gate 	ctx->D=ctx->E+a+B;
4890Sstevel@tonic-gate 	ctx->E=ctx->A+b+C;
4900Sstevel@tonic-gate 	ctx->A=D;
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate 		}
4930Sstevel@tonic-gate 	}
4940Sstevel@tonic-gate #endif
495