X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fsha%2Fsha_locl.h;h=471dfb9f8f28aee97a34763fd8ea99932c0c1db3;hb=02cbedc387e5f6aee8886a02e64db9bb42f73ff7;hp=80e70f046f7e0be46fb92e3311c93b93c9b1283e;hpb=232616efce79504eb0a950ff45960049ed92f230;p=oweals%2Fopenssl.git diff --git a/crypto/sha/sha_locl.h b/crypto/sha/sha_locl.h index 80e70f046f..471dfb9f8f 100644 --- a/crypto/sha/sha_locl.h +++ b/crypto/sha/sha_locl.h @@ -103,12 +103,19 @@ # define HASH_INIT SHA1_Init # define HASH_BLOCK_HOST_ORDER sha1_block_host_order # define HASH_BLOCK_DATA_ORDER sha1_block_data_order -# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ +# if defined(__MWERKS__) && defined(__MC68K__) + /* Metrowerks for Motorola fails otherwise:-( */ +# define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \ + ix=(a)=ROTATE((a),1); \ + } while (0) +# else +# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ ix=(a)=ROTATE((a),1) \ ) +# endif # ifdef SHA1_ASM -# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) +# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) # define sha1_block_host_order sha1_block_asm_host_order # define DONT_IMPLEMENT_BLOCK_HOST_ORDER # define sha1_block_data_order sha1_block_asm_data_order @@ -123,11 +130,7 @@ # error "Either SHA_0 or SHA_1 must be defined." #endif -#ifndef FLAT_INC -#include "../md32_common.h" -#else #include "md32_common.h" -#endif #define INIT_DATA_h0 0x67452301UL #define INIT_DATA_h1 0xefcdab89UL @@ -135,7 +138,7 @@ #define INIT_DATA_h3 0x10325476UL #define INIT_DATA_h4 0xc3d2e1f0UL -void HASH_INIT (SHA_CTX *c) +int HASH_INIT (SHA_CTX *c) { c->h0=INIT_DATA_h0; c->h1=INIT_DATA_h1; @@ -145,6 +148,7 @@ void HASH_INIT (SHA_CTX *c) c->Nl=0; c->Nh=0; c->num=0; + return 1; } #define K_00_19 0x5a827999UL @@ -193,18 +197,39 @@ void HASH_INIT (SHA_CTX *c) (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ (b)=ROTATE((b),30); +#ifdef X +#undef X +#endif +#ifndef MD32_XARRAY + /* + * Originally X was an array. As it's automatic it's natural + * to expect RISC compiler to accomodate at least part of it in + * the register bank, isn't it? Unfortunately not all compilers + * "find" this expectation reasonable:-( On order to make such + * compilers generate better code I replace X[] with a bunch of + * X0, X1, etc. See the function body below... + * + */ +# define X(i) XX##i +#else + /* + * However! Some compilers (most notably HP C) get overwhelmed by + * that many local variables so that we have to have the way to + * fall down to the original behavior. + */ +# define X(i) XX[i] +#endif + #ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) { const SHA_LONG *W=d; register unsigned long A,B,C,D,E,T; -#ifdef SHA_XARRAY - SHA_LONG X[16]; -# define X(i) X[(i)] +#ifndef MD32_XARRAY + unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; #else - unsigned long X0, X1, X2, X3, X4, X5, X6, X7, - X8, X9,X10,X11,X12,X13,X14,X15; -# define X(i) X##i + SHA_LONG XX[16]; #endif A=c->h0; @@ -325,13 +350,11 @@ void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) { const unsigned char *data=p; register unsigned long A,B,C,D,E,T,l; -#ifdef SHA_XARRAY - SHA_LONG X[16]; -# define X(i) X[(i)] +#ifndef MD32_XARRAY + unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; #else - unsigned long X0, X1, X2, X3, X4, X5, X6, X7, - X8, X9,X10,X11,X12,X13,X14,X15; -# define X(i) X##i + SHA_LONG XX[16]; #endif A=c->h0;