1*0Sstevel@tonic-gate /* crypto/ripemd/rmd_dgst.c */ 2*0Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3*0Sstevel@tonic-gate * All rights reserved. 4*0Sstevel@tonic-gate * 5*0Sstevel@tonic-gate * This package is an SSL implementation written 6*0Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com). 7*0Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as 10*0Sstevel@tonic-gate * the following conditions are aheared to. The following conditions 11*0Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA, 12*0Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13*0Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms 14*0Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15*0Sstevel@tonic-gate * 16*0Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in 17*0Sstevel@tonic-gate * the code are not to be removed. 18*0Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution 19*0Sstevel@tonic-gate * as the author of the parts of the library used. 20*0Sstevel@tonic-gate * This can be in the form of a textual message at program startup or 21*0Sstevel@tonic-gate * in documentation (online or textual) provided with the package. 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 24*0Sstevel@tonic-gate * modification, are permitted provided that the following conditions 25*0Sstevel@tonic-gate * are met: 26*0Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright 27*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 28*0Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 29*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 30*0Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 31*0Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 32*0Sstevel@tonic-gate * must display the following acknowledgement: 33*0Sstevel@tonic-gate * "This product includes cryptographic software written by 34*0Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)" 35*0Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library 36*0Sstevel@tonic-gate * being used are not cryptographic related :-). 37*0Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from 38*0Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement: 39*0Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42*0Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43*0Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44*0Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45*0Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46*0Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47*0Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48*0Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49*0Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50*0Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51*0Sstevel@tonic-gate * SUCH DAMAGE. 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * The licence and distribution terms for any publically available version or 54*0Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be 55*0Sstevel@tonic-gate * copied and put under another distribution licence 56*0Sstevel@tonic-gate * [including the GNU Public Licence.] 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #include <stdio.h> 60*0Sstevel@tonic-gate #include "rmd_locl.h" 61*0Sstevel@tonic-gate #include <openssl/opensslv.h> 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate # ifdef RMD160_ASM 66*0Sstevel@tonic-gate void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num); 67*0Sstevel@tonic-gate # define ripemd160_block ripemd160_block_x86 68*0Sstevel@tonic-gate # else 69*0Sstevel@tonic-gate void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num); 70*0Sstevel@tonic-gate # endif 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate int RIPEMD160_Init(RIPEMD160_CTX *c) 73*0Sstevel@tonic-gate { 74*0Sstevel@tonic-gate c->A=RIPEMD160_A; 75*0Sstevel@tonic-gate c->B=RIPEMD160_B; 76*0Sstevel@tonic-gate c->C=RIPEMD160_C; 77*0Sstevel@tonic-gate c->D=RIPEMD160_D; 78*0Sstevel@tonic-gate c->E=RIPEMD160_E; 79*0Sstevel@tonic-gate c->Nl=0; 80*0Sstevel@tonic-gate c->Nh=0; 81*0Sstevel@tonic-gate c->num=0; 82*0Sstevel@tonic-gate return 1; 83*0Sstevel@tonic-gate } 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate #ifndef ripemd160_block_host_order 86*0Sstevel@tonic-gate #ifdef X 87*0Sstevel@tonic-gate #undef X 88*0Sstevel@tonic-gate #endif 89*0Sstevel@tonic-gate #define X(i) XX[i] 90*0Sstevel@tonic-gate void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) 91*0Sstevel@tonic-gate { 92*0Sstevel@tonic-gate const RIPEMD160_LONG *XX=p; 93*0Sstevel@tonic-gate register unsigned MD32_REG_T A,B,C,D,E; 94*0Sstevel@tonic-gate register unsigned MD32_REG_T a,b,c,d,e; 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate for (;num--;XX+=HASH_LBLOCK) 97*0Sstevel@tonic-gate { 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL00,SL00); 102*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL01,SL01); 103*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL02,SL02); 104*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL03,SL03); 105*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL04,SL04); 106*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL05,SL05); 107*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL06,SL06); 108*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL07,SL07); 109*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL08,SL08); 110*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL09,SL09); 111*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL10,SL10); 112*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL11,SL11); 113*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL12,SL12); 114*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL13,SL13); 115*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL14,SL14); 116*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL15,SL15); 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL16,SL16,KL1); 119*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL17,SL17,KL1); 120*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL18,SL18,KL1); 121*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL19,SL19,KL1); 122*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL20,SL20,KL1); 123*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL21,SL21,KL1); 124*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL22,SL22,KL1); 125*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL23,SL23,KL1); 126*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL24,SL24,KL1); 127*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL25,SL25,KL1); 128*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL26,SL26,KL1); 129*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL27,SL27,KL1); 130*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL28,SL28,KL1); 131*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL29,SL29,KL1); 132*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL30,SL30,KL1); 133*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL31,SL31,KL1); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL32,SL32,KL2); 136*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL33,SL33,KL2); 137*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL34,SL34,KL2); 138*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL35,SL35,KL2); 139*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL36,SL36,KL2); 140*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL37,SL37,KL2); 141*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL38,SL38,KL2); 142*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL39,SL39,KL2); 143*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL40,SL40,KL2); 144*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL41,SL41,KL2); 145*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL42,SL42,KL2); 146*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL43,SL43,KL2); 147*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL44,SL44,KL2); 148*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL45,SL45,KL2); 149*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL46,SL46,KL2); 150*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL47,SL47,KL2); 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL48,SL48,KL3); 153*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL49,SL49,KL3); 154*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL50,SL50,KL3); 155*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL51,SL51,KL3); 156*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL52,SL52,KL3); 157*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL53,SL53,KL3); 158*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL54,SL54,KL3); 159*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL55,SL55,KL3); 160*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL56,SL56,KL3); 161*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL57,SL57,KL3); 162*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL58,SL58,KL3); 163*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL59,SL59,KL3); 164*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL60,SL60,KL3); 165*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL61,SL61,KL3); 166*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL62,SL62,KL3); 167*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL63,SL63,KL3); 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL64,SL64,KL4); 170*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL65,SL65,KL4); 171*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL66,SL66,KL4); 172*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL67,SL67,KL4); 173*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL68,SL68,KL4); 174*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL69,SL69,KL4); 175*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL70,SL70,KL4); 176*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL71,SL71,KL4); 177*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL72,SL72,KL4); 178*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL73,SL73,KL4); 179*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL74,SL74,KL4); 180*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL75,SL75,KL4); 181*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL76,SL76,KL4); 182*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL77,SL77,KL4); 183*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL78,SL78,KL4); 184*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL79,SL79,KL4); 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate a=A; b=B; c=C; d=D; e=E; 187*0Sstevel@tonic-gate /* Do other half */ 188*0Sstevel@tonic-gate A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR00,SR00,KR0); 191*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR01,SR01,KR0); 192*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR02,SR02,KR0); 193*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR03,SR03,KR0); 194*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR04,SR04,KR0); 195*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR05,SR05,KR0); 196*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR06,SR06,KR0); 197*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR07,SR07,KR0); 198*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR08,SR08,KR0); 199*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR09,SR09,KR0); 200*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR10,SR10,KR0); 201*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR11,SR11,KR0); 202*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR12,SR12,KR0); 203*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR13,SR13,KR0); 204*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR14,SR14,KR0); 205*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR15,SR15,KR0); 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR16,SR16,KR1); 208*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR17,SR17,KR1); 209*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR18,SR18,KR1); 210*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR19,SR19,KR1); 211*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR20,SR20,KR1); 212*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR21,SR21,KR1); 213*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR22,SR22,KR1); 214*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR23,SR23,KR1); 215*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR24,SR24,KR1); 216*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR25,SR25,KR1); 217*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR26,SR26,KR1); 218*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR27,SR27,KR1); 219*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR28,SR28,KR1); 220*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR29,SR29,KR1); 221*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR30,SR30,KR1); 222*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR31,SR31,KR1); 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR32,SR32,KR2); 225*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR33,SR33,KR2); 226*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR34,SR34,KR2); 227*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR35,SR35,KR2); 228*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR36,SR36,KR2); 229*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR37,SR37,KR2); 230*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR38,SR38,KR2); 231*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR39,SR39,KR2); 232*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR40,SR40,KR2); 233*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR41,SR41,KR2); 234*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR42,SR42,KR2); 235*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR43,SR43,KR2); 236*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR44,SR44,KR2); 237*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR45,SR45,KR2); 238*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR46,SR46,KR2); 239*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR47,SR47,KR2); 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR48,SR48,KR3); 242*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR49,SR49,KR3); 243*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR50,SR50,KR3); 244*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR51,SR51,KR3); 245*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR52,SR52,KR3); 246*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR53,SR53,KR3); 247*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR54,SR54,KR3); 248*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR55,SR55,KR3); 249*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR56,SR56,KR3); 250*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR57,SR57,KR3); 251*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR58,SR58,KR3); 252*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR59,SR59,KR3); 253*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR60,SR60,KR3); 254*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR61,SR61,KR3); 255*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR62,SR62,KR3); 256*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR63,SR63,KR3); 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR64,SR64); 259*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR65,SR65); 260*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR66,SR66); 261*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR67,SR67); 262*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR68,SR68); 263*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR69,SR69); 264*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR70,SR70); 265*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR71,SR71); 266*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR72,SR72); 267*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR73,SR73); 268*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR74,SR74); 269*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR75,SR75); 270*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR76,SR76); 271*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR77,SR77); 272*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR78,SR78); 273*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR79,SR79); 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate D =ctx->B+c+D; 276*0Sstevel@tonic-gate ctx->B=ctx->C+d+E; 277*0Sstevel@tonic-gate ctx->C=ctx->D+e+A; 278*0Sstevel@tonic-gate ctx->D=ctx->E+a+B; 279*0Sstevel@tonic-gate ctx->E=ctx->A+b+C; 280*0Sstevel@tonic-gate ctx->A=D; 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate } 283*0Sstevel@tonic-gate } 284*0Sstevel@tonic-gate #endif 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate #ifndef ripemd160_block_data_order 287*0Sstevel@tonic-gate #ifdef X 288*0Sstevel@tonic-gate #undef X 289*0Sstevel@tonic-gate #endif 290*0Sstevel@tonic-gate void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num) 291*0Sstevel@tonic-gate { 292*0Sstevel@tonic-gate const unsigned char *data=p; 293*0Sstevel@tonic-gate register unsigned MD32_REG_T A,B,C,D,E; 294*0Sstevel@tonic-gate unsigned MD32_REG_T a,b,c,d,e,l; 295*0Sstevel@tonic-gate #ifndef MD32_XARRAY 296*0Sstevel@tonic-gate /* See comment in crypto/sha/sha_locl.h for details. */ 297*0Sstevel@tonic-gate unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 298*0Sstevel@tonic-gate XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 299*0Sstevel@tonic-gate # define X(i) XX##i 300*0Sstevel@tonic-gate #else 301*0Sstevel@tonic-gate RIPEMD160_LONG XX[16]; 302*0Sstevel@tonic-gate # define X(i) XX[i] 303*0Sstevel@tonic-gate #endif 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate for (;num--;) 306*0Sstevel@tonic-gate { 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l; 311*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL00,SL00); HOST_c2l(data,l); X( 2)=l; 312*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL01,SL01); HOST_c2l(data,l); X( 3)=l; 313*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL02,SL02); HOST_c2l(data,l); X( 4)=l; 314*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL03,SL03); HOST_c2l(data,l); X( 5)=l; 315*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL04,SL04); HOST_c2l(data,l); X( 6)=l; 316*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL05,SL05); HOST_c2l(data,l); X( 7)=l; 317*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL06,SL06); HOST_c2l(data,l); X( 8)=l; 318*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL07,SL07); HOST_c2l(data,l); X( 9)=l; 319*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL08,SL08); HOST_c2l(data,l); X(10)=l; 320*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL09,SL09); HOST_c2l(data,l); X(11)=l; 321*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL10,SL10); HOST_c2l(data,l); X(12)=l; 322*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WL11,SL11); HOST_c2l(data,l); X(13)=l; 323*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WL12,SL12); HOST_c2l(data,l); X(14)=l; 324*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WL13,SL13); HOST_c2l(data,l); X(15)=l; 325*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WL14,SL14); 326*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WL15,SL15); 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL16,SL16,KL1); 329*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL17,SL17,KL1); 330*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL18,SL18,KL1); 331*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL19,SL19,KL1); 332*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL20,SL20,KL1); 333*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL21,SL21,KL1); 334*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL22,SL22,KL1); 335*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL23,SL23,KL1); 336*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL24,SL24,KL1); 337*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL25,SL25,KL1); 338*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL26,SL26,KL1); 339*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WL27,SL27,KL1); 340*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WL28,SL28,KL1); 341*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WL29,SL29,KL1); 342*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WL30,SL30,KL1); 343*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WL31,SL31,KL1); 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL32,SL32,KL2); 346*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL33,SL33,KL2); 347*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL34,SL34,KL2); 348*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL35,SL35,KL2); 349*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL36,SL36,KL2); 350*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL37,SL37,KL2); 351*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL38,SL38,KL2); 352*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL39,SL39,KL2); 353*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL40,SL40,KL2); 354*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL41,SL41,KL2); 355*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL42,SL42,KL2); 356*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WL43,SL43,KL2); 357*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WL44,SL44,KL2); 358*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WL45,SL45,KL2); 359*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WL46,SL46,KL2); 360*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WL47,SL47,KL2); 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL48,SL48,KL3); 363*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL49,SL49,KL3); 364*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL50,SL50,KL3); 365*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL51,SL51,KL3); 366*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL52,SL52,KL3); 367*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL53,SL53,KL3); 368*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL54,SL54,KL3); 369*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL55,SL55,KL3); 370*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL56,SL56,KL3); 371*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL57,SL57,KL3); 372*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL58,SL58,KL3); 373*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WL59,SL59,KL3); 374*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WL60,SL60,KL3); 375*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WL61,SL61,KL3); 376*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WL62,SL62,KL3); 377*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WL63,SL63,KL3); 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL64,SL64,KL4); 380*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL65,SL65,KL4); 381*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL66,SL66,KL4); 382*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL67,SL67,KL4); 383*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL68,SL68,KL4); 384*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL69,SL69,KL4); 385*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL70,SL70,KL4); 386*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL71,SL71,KL4); 387*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL72,SL72,KL4); 388*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL73,SL73,KL4); 389*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL74,SL74,KL4); 390*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WL75,SL75,KL4); 391*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WL76,SL76,KL4); 392*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WL77,SL77,KL4); 393*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WL78,SL78,KL4); 394*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WL79,SL79,KL4); 395*0Sstevel@tonic-gate 396*0Sstevel@tonic-gate a=A; b=B; c=C; d=D; e=E; 397*0Sstevel@tonic-gate /* Do other half */ 398*0Sstevel@tonic-gate A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; 399*0Sstevel@tonic-gate 400*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR00,SR00,KR0); 401*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR01,SR01,KR0); 402*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR02,SR02,KR0); 403*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR03,SR03,KR0); 404*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR04,SR04,KR0); 405*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR05,SR05,KR0); 406*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR06,SR06,KR0); 407*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR07,SR07,KR0); 408*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR08,SR08,KR0); 409*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR09,SR09,KR0); 410*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR10,SR10,KR0); 411*0Sstevel@tonic-gate RIP5(E,A,B,C,D,WR11,SR11,KR0); 412*0Sstevel@tonic-gate RIP5(D,E,A,B,C,WR12,SR12,KR0); 413*0Sstevel@tonic-gate RIP5(C,D,E,A,B,WR13,SR13,KR0); 414*0Sstevel@tonic-gate RIP5(B,C,D,E,A,WR14,SR14,KR0); 415*0Sstevel@tonic-gate RIP5(A,B,C,D,E,WR15,SR15,KR0); 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR16,SR16,KR1); 418*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR17,SR17,KR1); 419*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR18,SR18,KR1); 420*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR19,SR19,KR1); 421*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR20,SR20,KR1); 422*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR21,SR21,KR1); 423*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR22,SR22,KR1); 424*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR23,SR23,KR1); 425*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR24,SR24,KR1); 426*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR25,SR25,KR1); 427*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR26,SR26,KR1); 428*0Sstevel@tonic-gate RIP4(D,E,A,B,C,WR27,SR27,KR1); 429*0Sstevel@tonic-gate RIP4(C,D,E,A,B,WR28,SR28,KR1); 430*0Sstevel@tonic-gate RIP4(B,C,D,E,A,WR29,SR29,KR1); 431*0Sstevel@tonic-gate RIP4(A,B,C,D,E,WR30,SR30,KR1); 432*0Sstevel@tonic-gate RIP4(E,A,B,C,D,WR31,SR31,KR1); 433*0Sstevel@tonic-gate 434*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR32,SR32,KR2); 435*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR33,SR33,KR2); 436*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR34,SR34,KR2); 437*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR35,SR35,KR2); 438*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR36,SR36,KR2); 439*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR37,SR37,KR2); 440*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR38,SR38,KR2); 441*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR39,SR39,KR2); 442*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR40,SR40,KR2); 443*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR41,SR41,KR2); 444*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR42,SR42,KR2); 445*0Sstevel@tonic-gate RIP3(C,D,E,A,B,WR43,SR43,KR2); 446*0Sstevel@tonic-gate RIP3(B,C,D,E,A,WR44,SR44,KR2); 447*0Sstevel@tonic-gate RIP3(A,B,C,D,E,WR45,SR45,KR2); 448*0Sstevel@tonic-gate RIP3(E,A,B,C,D,WR46,SR46,KR2); 449*0Sstevel@tonic-gate RIP3(D,E,A,B,C,WR47,SR47,KR2); 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR48,SR48,KR3); 452*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR49,SR49,KR3); 453*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR50,SR50,KR3); 454*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR51,SR51,KR3); 455*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR52,SR52,KR3); 456*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR53,SR53,KR3); 457*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR54,SR54,KR3); 458*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR55,SR55,KR3); 459*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR56,SR56,KR3); 460*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR57,SR57,KR3); 461*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR58,SR58,KR3); 462*0Sstevel@tonic-gate RIP2(B,C,D,E,A,WR59,SR59,KR3); 463*0Sstevel@tonic-gate RIP2(A,B,C,D,E,WR60,SR60,KR3); 464*0Sstevel@tonic-gate RIP2(E,A,B,C,D,WR61,SR61,KR3); 465*0Sstevel@tonic-gate RIP2(D,E,A,B,C,WR62,SR62,KR3); 466*0Sstevel@tonic-gate RIP2(C,D,E,A,B,WR63,SR63,KR3); 467*0Sstevel@tonic-gate 468*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR64,SR64); 469*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR65,SR65); 470*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR66,SR66); 471*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR67,SR67); 472*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR68,SR68); 473*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR69,SR69); 474*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR70,SR70); 475*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR71,SR71); 476*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR72,SR72); 477*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR73,SR73); 478*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR74,SR74); 479*0Sstevel@tonic-gate RIP1(A,B,C,D,E,WR75,SR75); 480*0Sstevel@tonic-gate RIP1(E,A,B,C,D,WR76,SR76); 481*0Sstevel@tonic-gate RIP1(D,E,A,B,C,WR77,SR77); 482*0Sstevel@tonic-gate RIP1(C,D,E,A,B,WR78,SR78); 483*0Sstevel@tonic-gate RIP1(B,C,D,E,A,WR79,SR79); 484*0Sstevel@tonic-gate 485*0Sstevel@tonic-gate D =ctx->B+c+D; 486*0Sstevel@tonic-gate ctx->B=ctx->C+d+E; 487*0Sstevel@tonic-gate ctx->C=ctx->D+e+A; 488*0Sstevel@tonic-gate ctx->D=ctx->E+a+B; 489*0Sstevel@tonic-gate ctx->E=ctx->A+b+C; 490*0Sstevel@tonic-gate ctx->A=D; 491*0Sstevel@tonic-gate 492*0Sstevel@tonic-gate } 493*0Sstevel@tonic-gate } 494*0Sstevel@tonic-gate #endif 495