From 930c56fd76017b058cc6c163a58bb711f073c608 Mon Sep 17 00:00:00 2001 From: miod <> Date: Fri, 18 Apr 2014 19:41:23 +0000 Subject: Do not ask the user to pass either -DB_ENDIAN or -DL_ENDIAN to the compiler, but rather figure out the endianness from automagically; help from guenther@ ok jca@ guenther@ beck@ and the rest of the `Buena SSL rampage club' --- src/lib/libcrypto/sha/sha512.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/lib/libcrypto/sha/sha512.c') diff --git a/src/lib/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c index c92f18e418..49afaa05c2 100644 --- a/src/lib/libcrypto/sha/sha512.c +++ b/src/lib/libcrypto/sha/sha512.c @@ -43,6 +43,7 @@ */ #include #include +#include #include #include @@ -108,7 +109,7 @@ int SHA512_Final (unsigned char *md, SHA512_CTX *c) sha512_block_data_order (c,p,1); memset (p+n,0,sizeof(c->u)-16-n); -#ifdef B_ENDIAN +#if _BYTE_ORDER == _BIG_ENDIAN c->u.d[SHA_LBLOCK-2] = c->Nh; c->u.d[SHA_LBLOCK-1] = c->Nl; #else @@ -437,7 +438,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num for (i=0;i<16;i++) { -#ifdef B_ENDIAN +#if _BYTE_ORDER == _BIG_ENDIAN T1 = X[i] = W[i]; #else T1 = X[i] = PULL64(W[i]); @@ -492,7 +493,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; -#ifdef B_ENDIAN +#if _BYTE_ORDER == _BIG_ENDIAN T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); -- cgit v1.2.3-55-g6feb