10Sstevel@tonic-gate /* crypto/sha/sha_locl.h */
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 <stdlib.h>
600Sstevel@tonic-gate #include <string.h>
610Sstevel@tonic-gate
620Sstevel@tonic-gate #include <openssl/opensslconf.h>
630Sstevel@tonic-gate #include <openssl/sha.h>
640Sstevel@tonic-gate
650Sstevel@tonic-gate #ifndef SHA_LONG_LOG2
660Sstevel@tonic-gate #define SHA_LONG_LOG2 2 /* default to 32 bits */
670Sstevel@tonic-gate #endif
680Sstevel@tonic-gate
690Sstevel@tonic-gate #define DATA_ORDER_IS_BIG_ENDIAN
700Sstevel@tonic-gate
710Sstevel@tonic-gate #define HASH_LONG SHA_LONG
720Sstevel@tonic-gate #define HASH_LONG_LOG2 SHA_LONG_LOG2
730Sstevel@tonic-gate #define HASH_CTX SHA_CTX
740Sstevel@tonic-gate #define HASH_CBLOCK SHA_CBLOCK
750Sstevel@tonic-gate #define HASH_LBLOCK SHA_LBLOCK
760Sstevel@tonic-gate #define HASH_MAKE_STRING(c,s) do { \
770Sstevel@tonic-gate unsigned long ll; \
780Sstevel@tonic-gate ll=(c)->h0; HOST_l2c(ll,(s)); \
790Sstevel@tonic-gate ll=(c)->h1; HOST_l2c(ll,(s)); \
800Sstevel@tonic-gate ll=(c)->h2; HOST_l2c(ll,(s)); \
810Sstevel@tonic-gate ll=(c)->h3; HOST_l2c(ll,(s)); \
820Sstevel@tonic-gate ll=(c)->h4; HOST_l2c(ll,(s)); \
830Sstevel@tonic-gate } while (0)
840Sstevel@tonic-gate
850Sstevel@tonic-gate #if defined(SHA_0)
860Sstevel@tonic-gate
870Sstevel@tonic-gate # define HASH_UPDATE SHA_Update
880Sstevel@tonic-gate # define HASH_TRANSFORM SHA_Transform
890Sstevel@tonic-gate # define HASH_FINAL SHA_Final
900Sstevel@tonic-gate # define HASH_INIT SHA_Init
910Sstevel@tonic-gate # define HASH_BLOCK_HOST_ORDER sha_block_host_order
920Sstevel@tonic-gate # define HASH_BLOCK_DATA_ORDER sha_block_data_order
930Sstevel@tonic-gate # define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id))
940Sstevel@tonic-gate
95*2139Sjp161948 void sha_block_host_order (SHA_CTX *c, const void *p,size_t num);
96*2139Sjp161948 void sha_block_data_order (SHA_CTX *c, const void *p,size_t num);
970Sstevel@tonic-gate
980Sstevel@tonic-gate #elif defined(SHA_1)
990Sstevel@tonic-gate
1000Sstevel@tonic-gate # define HASH_UPDATE SHA1_Update
1010Sstevel@tonic-gate # define HASH_TRANSFORM SHA1_Transform
1020Sstevel@tonic-gate # define HASH_FINAL SHA1_Final
1030Sstevel@tonic-gate # define HASH_INIT SHA1_Init
1040Sstevel@tonic-gate # define HASH_BLOCK_HOST_ORDER sha1_block_host_order
1050Sstevel@tonic-gate # define HASH_BLOCK_DATA_ORDER sha1_block_data_order
1060Sstevel@tonic-gate # if defined(__MWERKS__) && defined(__MC68K__)
1070Sstevel@tonic-gate /* Metrowerks for Motorola fails otherwise:-( <appro@fy.chalmers.se> */
1080Sstevel@tonic-gate # define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \
1090Sstevel@tonic-gate ix=(a)=ROTATE((a),1); \
1100Sstevel@tonic-gate } while (0)
1110Sstevel@tonic-gate # else
1120Sstevel@tonic-gate # define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
1130Sstevel@tonic-gate ix=(a)=ROTATE((a),1) \
1140Sstevel@tonic-gate )
1150Sstevel@tonic-gate # endif
1160Sstevel@tonic-gate
1170Sstevel@tonic-gate # ifdef SHA1_ASM
1180Sstevel@tonic-gate # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
119*2139Sjp161948 # if !defined(B_ENDIAN)
120*2139Sjp161948 # define sha1_block_host_order sha1_block_asm_host_order
121*2139Sjp161948 # define DONT_IMPLEMENT_BLOCK_HOST_ORDER
122*2139Sjp161948 # define sha1_block_data_order sha1_block_asm_data_order
123*2139Sjp161948 # define DONT_IMPLEMENT_BLOCK_DATA_ORDER
124*2139Sjp161948 # define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order
125*2139Sjp161948 # endif
126*2139Sjp161948 # elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
1270Sstevel@tonic-gate # define sha1_block_host_order sha1_block_asm_host_order
1280Sstevel@tonic-gate # define DONT_IMPLEMENT_BLOCK_HOST_ORDER
1290Sstevel@tonic-gate # define sha1_block_data_order sha1_block_asm_data_order
1300Sstevel@tonic-gate # define DONT_IMPLEMENT_BLOCK_DATA_ORDER
1310Sstevel@tonic-gate # endif
1320Sstevel@tonic-gate # endif
133*2139Sjp161948 void sha1_block_host_order (SHA_CTX *c, const void *p,size_t num);
134*2139Sjp161948 void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate #else
1370Sstevel@tonic-gate # error "Either SHA_0 or SHA_1 must be defined."
1380Sstevel@tonic-gate #endif
1390Sstevel@tonic-gate
1400Sstevel@tonic-gate #include "md32_common.h"
1410Sstevel@tonic-gate
1420Sstevel@tonic-gate #define INIT_DATA_h0 0x67452301UL
1430Sstevel@tonic-gate #define INIT_DATA_h1 0xefcdab89UL
1440Sstevel@tonic-gate #define INIT_DATA_h2 0x98badcfeUL
1450Sstevel@tonic-gate #define INIT_DATA_h3 0x10325476UL
1460Sstevel@tonic-gate #define INIT_DATA_h4 0xc3d2e1f0UL
1470Sstevel@tonic-gate
HASH_INIT(SHA_CTX * c)1480Sstevel@tonic-gate int HASH_INIT (SHA_CTX *c)
1490Sstevel@tonic-gate {
1500Sstevel@tonic-gate c->h0=INIT_DATA_h0;
1510Sstevel@tonic-gate c->h1=INIT_DATA_h1;
1520Sstevel@tonic-gate c->h2=INIT_DATA_h2;
1530Sstevel@tonic-gate c->h3=INIT_DATA_h3;
1540Sstevel@tonic-gate c->h4=INIT_DATA_h4;
1550Sstevel@tonic-gate c->Nl=0;
1560Sstevel@tonic-gate c->Nh=0;
1570Sstevel@tonic-gate c->num=0;
1580Sstevel@tonic-gate return 1;
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate
1610Sstevel@tonic-gate #define K_00_19 0x5a827999UL
1620Sstevel@tonic-gate #define K_20_39 0x6ed9eba1UL
1630Sstevel@tonic-gate #define K_40_59 0x8f1bbcdcUL
1640Sstevel@tonic-gate #define K_60_79 0xca62c1d6UL
1650Sstevel@tonic-gate
1660Sstevel@tonic-gate /* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
1670Sstevel@tonic-gate * simplified to the code in F_00_19. Wei attributes these optimisations
1680Sstevel@tonic-gate * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
1690Sstevel@tonic-gate * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
1700Sstevel@tonic-gate * I've just become aware of another tweak to be made, again from Wei Dai,
1710Sstevel@tonic-gate * in F_40_59, (x&a)|(y&a) -> (x|y)&a
1720Sstevel@tonic-gate */
1730Sstevel@tonic-gate #define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
1740Sstevel@tonic-gate #define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
1750Sstevel@tonic-gate #define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
1760Sstevel@tonic-gate #define F_60_79(b,c,d) F_20_39(b,c,d)
1770Sstevel@tonic-gate
178*2139Sjp161948 #ifndef OPENSSL_SMALL_FOOTPRINT
179*2139Sjp161948
1800Sstevel@tonic-gate #define BODY_00_15(i,a,b,c,d,e,f,xi) \
1810Sstevel@tonic-gate (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
1820Sstevel@tonic-gate (b)=ROTATE((b),30);
1830Sstevel@tonic-gate
1840Sstevel@tonic-gate #define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
1850Sstevel@tonic-gate Xupdate(f,xi,xa,xb,xc,xd); \
1860Sstevel@tonic-gate (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
1870Sstevel@tonic-gate (b)=ROTATE((b),30);
1880Sstevel@tonic-gate
1890Sstevel@tonic-gate #define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
1900Sstevel@tonic-gate Xupdate(f,xi,xa,xb,xc,xd); \
1910Sstevel@tonic-gate (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
1920Sstevel@tonic-gate (b)=ROTATE((b),30);
1930Sstevel@tonic-gate
1940Sstevel@tonic-gate #define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
1950Sstevel@tonic-gate Xupdate(f,xa,xa,xb,xc,xd); \
1960Sstevel@tonic-gate (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
1970Sstevel@tonic-gate (b)=ROTATE((b),30);
1980Sstevel@tonic-gate
1990Sstevel@tonic-gate #define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
2000Sstevel@tonic-gate Xupdate(f,xa,xa,xb,xc,xd); \
2010Sstevel@tonic-gate (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
2020Sstevel@tonic-gate (b)=ROTATE((b),30);
2030Sstevel@tonic-gate
2040Sstevel@tonic-gate #define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
2050Sstevel@tonic-gate Xupdate(f,xa,xa,xb,xc,xd); \
2060Sstevel@tonic-gate (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
2070Sstevel@tonic-gate (b)=ROTATE((b),30);
2080Sstevel@tonic-gate
2090Sstevel@tonic-gate #ifdef X
2100Sstevel@tonic-gate #undef X
2110Sstevel@tonic-gate #endif
2120Sstevel@tonic-gate #ifndef MD32_XARRAY
2130Sstevel@tonic-gate /*
2140Sstevel@tonic-gate * Originally X was an array. As it's automatic it's natural
2150Sstevel@tonic-gate * to expect RISC compiler to accomodate at least part of it in
2160Sstevel@tonic-gate * the register bank, isn't it? Unfortunately not all compilers
2170Sstevel@tonic-gate * "find" this expectation reasonable:-( On order to make such
2180Sstevel@tonic-gate * compilers generate better code I replace X[] with a bunch of
2190Sstevel@tonic-gate * X0, X1, etc. See the function body below...
2200Sstevel@tonic-gate * <appro@fy.chalmers.se>
2210Sstevel@tonic-gate */
2220Sstevel@tonic-gate # define X(i) XX##i
2230Sstevel@tonic-gate #else
2240Sstevel@tonic-gate /*
2250Sstevel@tonic-gate * However! Some compilers (most notably HP C) get overwhelmed by
2260Sstevel@tonic-gate * that many local variables so that we have to have the way to
2270Sstevel@tonic-gate * fall down to the original behavior.
2280Sstevel@tonic-gate */
2290Sstevel@tonic-gate # define X(i) XX[i]
2300Sstevel@tonic-gate #endif
2310Sstevel@tonic-gate
2320Sstevel@tonic-gate #ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
HASH_BLOCK_HOST_ORDER(SHA_CTX * c,const void * d,size_t num)233*2139Sjp161948 void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num)
2340Sstevel@tonic-gate {
2350Sstevel@tonic-gate const SHA_LONG *W=d;
2360Sstevel@tonic-gate register unsigned MD32_REG_T A,B,C,D,E,T;
2370Sstevel@tonic-gate #ifndef MD32_XARRAY
2380Sstevel@tonic-gate unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
2390Sstevel@tonic-gate XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
2400Sstevel@tonic-gate #else
2410Sstevel@tonic-gate SHA_LONG XX[16];
2420Sstevel@tonic-gate #endif
2430Sstevel@tonic-gate
2440Sstevel@tonic-gate A=c->h0;
2450Sstevel@tonic-gate B=c->h1;
2460Sstevel@tonic-gate C=c->h2;
2470Sstevel@tonic-gate D=c->h3;
2480Sstevel@tonic-gate E=c->h4;
2490Sstevel@tonic-gate
2500Sstevel@tonic-gate for (;;)
2510Sstevel@tonic-gate {
2520Sstevel@tonic-gate BODY_00_15( 0,A,B,C,D,E,T,W[ 0]);
2530Sstevel@tonic-gate BODY_00_15( 1,T,A,B,C,D,E,W[ 1]);
2540Sstevel@tonic-gate BODY_00_15( 2,E,T,A,B,C,D,W[ 2]);
2550Sstevel@tonic-gate BODY_00_15( 3,D,E,T,A,B,C,W[ 3]);
2560Sstevel@tonic-gate BODY_00_15( 4,C,D,E,T,A,B,W[ 4]);
2570Sstevel@tonic-gate BODY_00_15( 5,B,C,D,E,T,A,W[ 5]);
2580Sstevel@tonic-gate BODY_00_15( 6,A,B,C,D,E,T,W[ 6]);
2590Sstevel@tonic-gate BODY_00_15( 7,T,A,B,C,D,E,W[ 7]);
2600Sstevel@tonic-gate BODY_00_15( 8,E,T,A,B,C,D,W[ 8]);
2610Sstevel@tonic-gate BODY_00_15( 9,D,E,T,A,B,C,W[ 9]);
2620Sstevel@tonic-gate BODY_00_15(10,C,D,E,T,A,B,W[10]);
2630Sstevel@tonic-gate BODY_00_15(11,B,C,D,E,T,A,W[11]);
2640Sstevel@tonic-gate BODY_00_15(12,A,B,C,D,E,T,W[12]);
2650Sstevel@tonic-gate BODY_00_15(13,T,A,B,C,D,E,W[13]);
2660Sstevel@tonic-gate BODY_00_15(14,E,T,A,B,C,D,W[14]);
2670Sstevel@tonic-gate BODY_00_15(15,D,E,T,A,B,C,W[15]);
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate BODY_16_19(16,C,D,E,T,A,B,X( 0),W[ 0],W[ 2],W[ 8],W[13]);
2700Sstevel@tonic-gate BODY_16_19(17,B,C,D,E,T,A,X( 1),W[ 1],W[ 3],W[ 9],W[14]);
2710Sstevel@tonic-gate BODY_16_19(18,A,B,C,D,E,T,X( 2),W[ 2],W[ 4],W[10],W[15]);
2720Sstevel@tonic-gate BODY_16_19(19,T,A,B,C,D,E,X( 3),W[ 3],W[ 5],W[11],X( 0));
2730Sstevel@tonic-gate
2740Sstevel@tonic-gate BODY_20_31(20,E,T,A,B,C,D,X( 4),W[ 4],W[ 6],W[12],X( 1));
2750Sstevel@tonic-gate BODY_20_31(21,D,E,T,A,B,C,X( 5),W[ 5],W[ 7],W[13],X( 2));
2760Sstevel@tonic-gate BODY_20_31(22,C,D,E,T,A,B,X( 6),W[ 6],W[ 8],W[14],X( 3));
2770Sstevel@tonic-gate BODY_20_31(23,B,C,D,E,T,A,X( 7),W[ 7],W[ 9],W[15],X( 4));
2780Sstevel@tonic-gate BODY_20_31(24,A,B,C,D,E,T,X( 8),W[ 8],W[10],X( 0),X( 5));
2790Sstevel@tonic-gate BODY_20_31(25,T,A,B,C,D,E,X( 9),W[ 9],W[11],X( 1),X( 6));
2800Sstevel@tonic-gate BODY_20_31(26,E,T,A,B,C,D,X(10),W[10],W[12],X( 2),X( 7));
2810Sstevel@tonic-gate BODY_20_31(27,D,E,T,A,B,C,X(11),W[11],W[13],X( 3),X( 8));
2820Sstevel@tonic-gate BODY_20_31(28,C,D,E,T,A,B,X(12),W[12],W[14],X( 4),X( 9));
2830Sstevel@tonic-gate BODY_20_31(29,B,C,D,E,T,A,X(13),W[13],W[15],X( 5),X(10));
2840Sstevel@tonic-gate BODY_20_31(30,A,B,C,D,E,T,X(14),W[14],X( 0),X( 6),X(11));
2850Sstevel@tonic-gate BODY_20_31(31,T,A,B,C,D,E,X(15),W[15],X( 1),X( 7),X(12));
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
2880Sstevel@tonic-gate BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
2890Sstevel@tonic-gate BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
2900Sstevel@tonic-gate BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
2910Sstevel@tonic-gate BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
2920Sstevel@tonic-gate BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
2930Sstevel@tonic-gate BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
2940Sstevel@tonic-gate BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
2950Sstevel@tonic-gate
2960Sstevel@tonic-gate BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
2970Sstevel@tonic-gate BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
2980Sstevel@tonic-gate BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
2990Sstevel@tonic-gate BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
3000Sstevel@tonic-gate BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
3010Sstevel@tonic-gate BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
3020Sstevel@tonic-gate BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
3030Sstevel@tonic-gate BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
3040Sstevel@tonic-gate BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
3050Sstevel@tonic-gate BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
3060Sstevel@tonic-gate BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
3070Sstevel@tonic-gate BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
3080Sstevel@tonic-gate BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
3090Sstevel@tonic-gate BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
3100Sstevel@tonic-gate BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
3110Sstevel@tonic-gate BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
3120Sstevel@tonic-gate BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
3130Sstevel@tonic-gate BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
3140Sstevel@tonic-gate BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
3150Sstevel@tonic-gate BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
3160Sstevel@tonic-gate
3170Sstevel@tonic-gate BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
3180Sstevel@tonic-gate BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
3190Sstevel@tonic-gate BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
3200Sstevel@tonic-gate BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
3210Sstevel@tonic-gate BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
3220Sstevel@tonic-gate BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
3230Sstevel@tonic-gate BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
3240Sstevel@tonic-gate BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
3250Sstevel@tonic-gate BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
3260Sstevel@tonic-gate BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
3270Sstevel@tonic-gate BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
3280Sstevel@tonic-gate BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
3290Sstevel@tonic-gate BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
3300Sstevel@tonic-gate BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
3310Sstevel@tonic-gate BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
3320Sstevel@tonic-gate BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
3330Sstevel@tonic-gate BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
3340Sstevel@tonic-gate BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
3350Sstevel@tonic-gate BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
3360Sstevel@tonic-gate BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
3370Sstevel@tonic-gate
3380Sstevel@tonic-gate c->h0=(c->h0+E)&0xffffffffL;
3390Sstevel@tonic-gate c->h1=(c->h1+T)&0xffffffffL;
3400Sstevel@tonic-gate c->h2=(c->h2+A)&0xffffffffL;
3410Sstevel@tonic-gate c->h3=(c->h3+B)&0xffffffffL;
3420Sstevel@tonic-gate c->h4=(c->h4+C)&0xffffffffL;
3430Sstevel@tonic-gate
344*2139Sjp161948 if (--num == 0) break;
3450Sstevel@tonic-gate
3460Sstevel@tonic-gate A=c->h0;
3470Sstevel@tonic-gate B=c->h1;
3480Sstevel@tonic-gate C=c->h2;
3490Sstevel@tonic-gate D=c->h3;
3500Sstevel@tonic-gate E=c->h4;
3510Sstevel@tonic-gate
3520Sstevel@tonic-gate W+=SHA_LBLOCK;
3530Sstevel@tonic-gate }
3540Sstevel@tonic-gate }
3550Sstevel@tonic-gate #endif
3560Sstevel@tonic-gate
3570Sstevel@tonic-gate #ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
HASH_BLOCK_DATA_ORDER(SHA_CTX * c,const void * p,size_t num)358*2139Sjp161948 void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
3590Sstevel@tonic-gate {
3600Sstevel@tonic-gate const unsigned char *data=p;
3610Sstevel@tonic-gate register unsigned MD32_REG_T A,B,C,D,E,T,l;
3620Sstevel@tonic-gate #ifndef MD32_XARRAY
3630Sstevel@tonic-gate unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
3640Sstevel@tonic-gate XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
3650Sstevel@tonic-gate #else
3660Sstevel@tonic-gate SHA_LONG XX[16];
3670Sstevel@tonic-gate #endif
3680Sstevel@tonic-gate
3690Sstevel@tonic-gate A=c->h0;
3700Sstevel@tonic-gate B=c->h1;
3710Sstevel@tonic-gate C=c->h2;
3720Sstevel@tonic-gate D=c->h3;
3730Sstevel@tonic-gate E=c->h4;
3740Sstevel@tonic-gate
3750Sstevel@tonic-gate for (;;)
3760Sstevel@tonic-gate {
3770Sstevel@tonic-gate
3780Sstevel@tonic-gate HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
3790Sstevel@tonic-gate BODY_00_15( 0,A,B,C,D,E,T,X( 0)); HOST_c2l(data,l); X( 2)=l;
3800Sstevel@tonic-gate BODY_00_15( 1,T,A,B,C,D,E,X( 1)); HOST_c2l(data,l); X( 3)=l;
3810Sstevel@tonic-gate BODY_00_15( 2,E,T,A,B,C,D,X( 2)); HOST_c2l(data,l); X( 4)=l;
3820Sstevel@tonic-gate BODY_00_15( 3,D,E,T,A,B,C,X( 3)); HOST_c2l(data,l); X( 5)=l;
3830Sstevel@tonic-gate BODY_00_15( 4,C,D,E,T,A,B,X( 4)); HOST_c2l(data,l); X( 6)=l;
3840Sstevel@tonic-gate BODY_00_15( 5,B,C,D,E,T,A,X( 5)); HOST_c2l(data,l); X( 7)=l;
3850Sstevel@tonic-gate BODY_00_15( 6,A,B,C,D,E,T,X( 6)); HOST_c2l(data,l); X( 8)=l;
3860Sstevel@tonic-gate BODY_00_15( 7,T,A,B,C,D,E,X( 7)); HOST_c2l(data,l); X( 9)=l;
3870Sstevel@tonic-gate BODY_00_15( 8,E,T,A,B,C,D,X( 8)); HOST_c2l(data,l); X(10)=l;
3880Sstevel@tonic-gate BODY_00_15( 9,D,E,T,A,B,C,X( 9)); HOST_c2l(data,l); X(11)=l;
3890Sstevel@tonic-gate BODY_00_15(10,C,D,E,T,A,B,X(10)); HOST_c2l(data,l); X(12)=l;
3900Sstevel@tonic-gate BODY_00_15(11,B,C,D,E,T,A,X(11)); HOST_c2l(data,l); X(13)=l;
3910Sstevel@tonic-gate BODY_00_15(12,A,B,C,D,E,T,X(12)); HOST_c2l(data,l); X(14)=l;
3920Sstevel@tonic-gate BODY_00_15(13,T,A,B,C,D,E,X(13)); HOST_c2l(data,l); X(15)=l;
3930Sstevel@tonic-gate BODY_00_15(14,E,T,A,B,C,D,X(14));
3940Sstevel@tonic-gate BODY_00_15(15,D,E,T,A,B,C,X(15));
3950Sstevel@tonic-gate
3960Sstevel@tonic-gate BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13));
3970Sstevel@tonic-gate BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14));
3980Sstevel@tonic-gate BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15));
3990Sstevel@tonic-gate BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0));
4000Sstevel@tonic-gate
4010Sstevel@tonic-gate BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1));
4020Sstevel@tonic-gate BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2));
4030Sstevel@tonic-gate BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3));
4040Sstevel@tonic-gate BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4));
4050Sstevel@tonic-gate BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5));
4060Sstevel@tonic-gate BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6));
4070Sstevel@tonic-gate BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7));
4080Sstevel@tonic-gate BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8));
4090Sstevel@tonic-gate BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9));
4100Sstevel@tonic-gate BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10));
4110Sstevel@tonic-gate BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11));
4120Sstevel@tonic-gate BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12));
4130Sstevel@tonic-gate
4140Sstevel@tonic-gate BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
4150Sstevel@tonic-gate BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
4160Sstevel@tonic-gate BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
4170Sstevel@tonic-gate BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
4180Sstevel@tonic-gate BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
4190Sstevel@tonic-gate BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
4200Sstevel@tonic-gate BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
4210Sstevel@tonic-gate BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
4220Sstevel@tonic-gate
4230Sstevel@tonic-gate BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
4240Sstevel@tonic-gate BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
4250Sstevel@tonic-gate BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
4260Sstevel@tonic-gate BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
4270Sstevel@tonic-gate BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
4280Sstevel@tonic-gate BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
4290Sstevel@tonic-gate BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
4300Sstevel@tonic-gate BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
4310Sstevel@tonic-gate BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
4320Sstevel@tonic-gate BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
4330Sstevel@tonic-gate BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
4340Sstevel@tonic-gate BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
4350Sstevel@tonic-gate BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
4360Sstevel@tonic-gate BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
4370Sstevel@tonic-gate BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
4380Sstevel@tonic-gate BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
4390Sstevel@tonic-gate BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
4400Sstevel@tonic-gate BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
4410Sstevel@tonic-gate BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
4420Sstevel@tonic-gate BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
4430Sstevel@tonic-gate
4440Sstevel@tonic-gate BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
4450Sstevel@tonic-gate BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
4460Sstevel@tonic-gate BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
4470Sstevel@tonic-gate BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
4480Sstevel@tonic-gate BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
4490Sstevel@tonic-gate BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
4500Sstevel@tonic-gate BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
4510Sstevel@tonic-gate BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
4520Sstevel@tonic-gate BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
4530Sstevel@tonic-gate BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
4540Sstevel@tonic-gate BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
4550Sstevel@tonic-gate BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
4560Sstevel@tonic-gate BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
4570Sstevel@tonic-gate BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
4580Sstevel@tonic-gate BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
4590Sstevel@tonic-gate BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
4600Sstevel@tonic-gate BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
4610Sstevel@tonic-gate BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
4620Sstevel@tonic-gate BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
4630Sstevel@tonic-gate BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
4640Sstevel@tonic-gate
4650Sstevel@tonic-gate c->h0=(c->h0+E)&0xffffffffL;
4660Sstevel@tonic-gate c->h1=(c->h1+T)&0xffffffffL;
4670Sstevel@tonic-gate c->h2=(c->h2+A)&0xffffffffL;
4680Sstevel@tonic-gate c->h3=(c->h3+B)&0xffffffffL;
4690Sstevel@tonic-gate c->h4=(c->h4+C)&0xffffffffL;
4700Sstevel@tonic-gate
471*2139Sjp161948 if (--num == 0) break;
4720Sstevel@tonic-gate
4730Sstevel@tonic-gate A=c->h0;
4740Sstevel@tonic-gate B=c->h1;
4750Sstevel@tonic-gate C=c->h2;
4760Sstevel@tonic-gate D=c->h3;
4770Sstevel@tonic-gate E=c->h4;
4780Sstevel@tonic-gate
4790Sstevel@tonic-gate }
4800Sstevel@tonic-gate }
4810Sstevel@tonic-gate #endif
482*2139Sjp161948
483*2139Sjp161948 #else /* OPENSSL_SMALL_FOOTPRINT */
484*2139Sjp161948
485*2139Sjp161948 #define BODY_00_15(xi) do { \
486*2139Sjp161948 T=E+K_00_19+F_00_19(B,C,D); \
487*2139Sjp161948 E=D, D=C, C=ROTATE(B,30), B=A; \
488*2139Sjp161948 A=ROTATE(A,5)+T+xi; } while(0)
489*2139Sjp161948
490*2139Sjp161948 #define BODY_16_19(xa,xb,xc,xd) do { \
491*2139Sjp161948 Xupdate(T,xa,xa,xb,xc,xd); \
492*2139Sjp161948 T+=E+K_00_19+F_00_19(B,C,D); \
493*2139Sjp161948 E=D, D=C, C=ROTATE(B,30), B=A; \
494*2139Sjp161948 A=ROTATE(A,5)+T; } while(0)
495*2139Sjp161948
496*2139Sjp161948 #define BODY_20_39(xa,xb,xc,xd) do { \
497*2139Sjp161948 Xupdate(T,xa,xa,xb,xc,xd); \
498*2139Sjp161948 T+=E+K_20_39+F_20_39(B,C,D); \
499*2139Sjp161948 E=D, D=C, C=ROTATE(B,30), B=A; \
500*2139Sjp161948 A=ROTATE(A,5)+T; } while(0)
501*2139Sjp161948
502*2139Sjp161948 #define BODY_40_59(xa,xb,xc,xd) do { \
503*2139Sjp161948 Xupdate(T,xa,xa,xb,xc,xd); \
504*2139Sjp161948 T+=E+K_40_59+F_40_59(B,C,D); \
505*2139Sjp161948 E=D, D=C, C=ROTATE(B,30), B=A; \
506*2139Sjp161948 A=ROTATE(A,5)+T; } while(0)
507*2139Sjp161948
508*2139Sjp161948 #define BODY_60_79(xa,xb,xc,xd) do { \
509*2139Sjp161948 Xupdate(T,xa,xa,xb,xc,xd); \
510*2139Sjp161948 T=E+K_60_79+F_60_79(B,C,D); \
511*2139Sjp161948 E=D, D=C, C=ROTATE(B,30), B=A; \
512*2139Sjp161948 A=ROTATE(A,5)+T+xa; } while(0)
513*2139Sjp161948
514*2139Sjp161948 #ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
HASH_BLOCK_HOST_ORDER(SHA_CTX * c,const void * d,size_t num)515*2139Sjp161948 void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num)
516*2139Sjp161948 {
517*2139Sjp161948 const SHA_LONG *W=d;
518*2139Sjp161948 register unsigned MD32_REG_T A,B,C,D,E,T;
519*2139Sjp161948 int i;
520*2139Sjp161948 SHA_LONG X[16];
521*2139Sjp161948
522*2139Sjp161948 A=c->h0;
523*2139Sjp161948 B=c->h1;
524*2139Sjp161948 C=c->h2;
525*2139Sjp161948 D=c->h3;
526*2139Sjp161948 E=c->h4;
527*2139Sjp161948
528*2139Sjp161948 for (;;)
529*2139Sjp161948 {
530*2139Sjp161948 for (i=0;i<16;i++)
531*2139Sjp161948 { X[i]=W[i]; BODY_00_15(X[i]); }
532*2139Sjp161948 for (i=0;i<4;i++)
533*2139Sjp161948 { BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]); }
534*2139Sjp161948 for (;i<24;i++)
535*2139Sjp161948 { BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15],X[(i+13)&15]); }
536*2139Sjp161948 for (i=0;i<20;i++)
537*2139Sjp161948 { BODY_40_59(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
538*2139Sjp161948 for (i=4;i<24;i++)
539*2139Sjp161948 { BODY_60_79(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
540*2139Sjp161948
541*2139Sjp161948 c->h0=(c->h0+A)&0xffffffffL;
542*2139Sjp161948 c->h1=(c->h1+B)&0xffffffffL;
543*2139Sjp161948 c->h2=(c->h2+C)&0xffffffffL;
544*2139Sjp161948 c->h3=(c->h3+D)&0xffffffffL;
545*2139Sjp161948 c->h4=(c->h4+E)&0xffffffffL;
546*2139Sjp161948
547*2139Sjp161948 if (--num == 0) break;
548*2139Sjp161948
549*2139Sjp161948 A=c->h0;
550*2139Sjp161948 B=c->h1;
551*2139Sjp161948 C=c->h2;
552*2139Sjp161948 D=c->h3;
553*2139Sjp161948 E=c->h4;
554*2139Sjp161948
555*2139Sjp161948 W+=SHA_LBLOCK;
556*2139Sjp161948 }
557*2139Sjp161948 }
558*2139Sjp161948 #endif
559*2139Sjp161948
560*2139Sjp161948 #ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
HASH_BLOCK_DATA_ORDER(SHA_CTX * c,const void * p,size_t num)561*2139Sjp161948 void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
562*2139Sjp161948 {
563*2139Sjp161948 const unsigned char *data=p;
564*2139Sjp161948 register unsigned MD32_REG_T A,B,C,D,E,T,l;
565*2139Sjp161948 int i;
566*2139Sjp161948 SHA_LONG X[16];
567*2139Sjp161948
568*2139Sjp161948 A=c->h0;
569*2139Sjp161948 B=c->h1;
570*2139Sjp161948 C=c->h2;
571*2139Sjp161948 D=c->h3;
572*2139Sjp161948 E=c->h4;
573*2139Sjp161948
574*2139Sjp161948 for (;;)
575*2139Sjp161948 {
576*2139Sjp161948 for (i=0;i<16;i++)
577*2139Sjp161948 { HOST_c2l(data,l); X[i]=l; BODY_00_15(X[i]); }
578*2139Sjp161948 for (i=0;i<4;i++)
579*2139Sjp161948 { BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]); }
580*2139Sjp161948 for (;i<24;i++)
581*2139Sjp161948 { BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15],X[(i+13)&15]); }
582*2139Sjp161948 for (i=0;i<20;i++)
583*2139Sjp161948 { BODY_40_59(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
584*2139Sjp161948 for (i=4;i<24;i++)
585*2139Sjp161948 { BODY_60_79(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
586*2139Sjp161948
587*2139Sjp161948 c->h0=(c->h0+A)&0xffffffffL;
588*2139Sjp161948 c->h1=(c->h1+B)&0xffffffffL;
589*2139Sjp161948 c->h2=(c->h2+C)&0xffffffffL;
590*2139Sjp161948 c->h3=(c->h3+D)&0xffffffffL;
591*2139Sjp161948 c->h4=(c->h4+E)&0xffffffffL;
592*2139Sjp161948
593*2139Sjp161948 if (--num == 0) break;
594*2139Sjp161948
595*2139Sjp161948 A=c->h0;
596*2139Sjp161948 B=c->h1;
597*2139Sjp161948 C=c->h2;
598*2139Sjp161948 D=c->h3;
599*2139Sjp161948 E=c->h4;
600*2139Sjp161948
601*2139Sjp161948 }
602*2139Sjp161948 }
603*2139Sjp161948 #endif
604*2139Sjp161948
605*2139Sjp161948 #endif
606