diff options
author | miod <> | 2014-04-18 19:41:23 +0000 |
---|---|---|
committer | miod <> | 2014-04-18 19:41:23 +0000 |
commit | 930c56fd76017b058cc6c163a58bb711f073c608 (patch) | |
tree | e49172ab57b9f2168c16ae25c50bfce96e44abe6 | |
parent | 698143c53d1a1e4fe680b08c6a68ab327f4b6c5d (diff) | |
download | openbsd-930c56fd76017b058cc6c163a58bb711f073c608.tar.gz openbsd-930c56fd76017b058cc6c163a58bb711f073c608.tar.bz2 openbsd-930c56fd76017b058cc6c163a58bb711f073c608.zip |
Do not ask the user to pass either -DB_ENDIAN or -DL_ENDIAN to the compiler,
but rather figure out the endianness from <machine/endian.h> automagically;
help from guenther@
ok jca@ guenther@ beck@ and the rest of the `Buena SSL rampage club'
-rw-r--r-- | src/lib/libcrypto/bn/bn_nist.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto/Makefile | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/des/cfb_enc.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/sha/sha512.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/whrlpool/wp_block.c | 9 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn_nist.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/des/cfb_enc.c | 11 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/sha/sha512.c | 7 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/whrlpool/wp_block.c | 9 |
9 files changed, 37 insertions, 37 deletions
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c index 1e4cf833dc..4d4a7b86df 100644 --- a/src/lib/libcrypto/bn/bn_nist.c +++ b/src/lib/libcrypto/bn/bn_nist.c | |||
@@ -59,6 +59,8 @@ | |||
59 | #include "bn_lcl.h" | 59 | #include "bn_lcl.h" |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | 61 | ||
62 | #include <machine/endian.h> | ||
63 | |||
62 | 64 | ||
63 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 | 65 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 |
64 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 | 66 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 |
@@ -318,7 +320,7 @@ static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top) | |||
318 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) | 320 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) |
319 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); | 321 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); |
320 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) | 322 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) |
321 | # if defined(L_ENDIAN) | 323 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
322 | # if defined(__arch64__) | 324 | # if defined(__arch64__) |
323 | # define NIST_INT64 long | 325 | # define NIST_INT64 long |
324 | # else | 326 | # else |
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile index 31cab709d9..f46702b7eb 100644 --- a/src/lib/libcrypto/crypto/Makefile +++ b/src/lib/libcrypto/crypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.25 2014/04/18 17:32:31 miod Exp $ | 1 | # $OpenBSD: Makefile,v 1.26 2014/04/18 19:41:21 miod Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | 4 | ||
@@ -7,16 +7,6 @@ LCRYPTO_SRC= ${SSL_SRC}/crypto | |||
7 | 7 | ||
8 | CFLAGS+= -Wall | 8 | CFLAGS+= -Wall |
9 | 9 | ||
10 | # arm and sh default to little endian, mips defaults to big endian | ||
11 | .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "amd64" || \ | ||
12 | ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "i386" || \ | ||
13 | ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "sh" || \ | ||
14 | ${MACHINE_ARCH} == "vax" | ||
15 | CFLAGS+= -DL_ENDIAN | ||
16 | .else | ||
17 | CFLAGS+= -DB_ENDIAN | ||
18 | .endif | ||
19 | |||
20 | .include <bsd.own.mk> # for 'NOPIC' definition | 10 | .include <bsd.own.mk> # for 'NOPIC' definition |
21 | .if !defined(NOPIC) | 11 | .if !defined(NOPIC) |
22 | CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H | 12 | CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H |
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c index dd5237a86d..9bf6466bd2 100644 --- a/src/lib/libcrypto/des/cfb_enc.c +++ b/src/lib/libcrypto/des/cfb_enc.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | #include <assert.h> | 60 | #include <assert.h> |
61 | #include <machine/endian.h> | ||
61 | 62 | ||
62 | /* The input and output are loaded in multiples of 8 bits. | 63 | /* The input and output are loaded in multiples of 8 bits. |
63 | * What this means is that if you hame numbits=12 and length=2 | 64 | * What this means is that if you hame numbits=12 and length=2 |
@@ -76,7 +77,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
76 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; | 77 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; |
77 | DES_LONG ti[2]; | 78 | DES_LONG ti[2]; |
78 | unsigned char *iv; | 79 | unsigned char *iv; |
79 | #ifndef L_ENDIAN | 80 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
80 | unsigned char ovec[16]; | 81 | unsigned char ovec[16]; |
81 | #else | 82 | #else |
82 | unsigned int sh[4]; | 83 | unsigned int sh[4]; |
@@ -114,7 +115,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
114 | { v0=d0; v1=d1; } | 115 | { v0=d0; v1=d1; } |
115 | else | 116 | else |
116 | { | 117 | { |
117 | #ifndef L_ENDIAN | 118 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
118 | iv=&ovec[0]; | 119 | iv=&ovec[0]; |
119 | l2c(v0,iv); | 120 | l2c(v0,iv); |
120 | l2c(v1,iv); | 121 | l2c(v1,iv); |
@@ -129,7 +130,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
129 | for(i=0 ; i < 8 ; ++i) | 130 | for(i=0 ; i < 8 ; ++i) |
130 | ovec[i]=ovec[i+num]<<rem | | 131 | ovec[i]=ovec[i+num]<<rem | |
131 | ovec[i+num+1]>>(8-rem); | 132 | ovec[i+num+1]>>(8-rem); |
132 | #ifdef L_ENDIAN | 133 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
133 | v0=sh[0], v1=sh[1]; | 134 | v0=sh[0], v1=sh[1]; |
134 | #else | 135 | #else |
135 | iv=&ovec[0]; | 136 | iv=&ovec[0]; |
@@ -157,7 +158,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
157 | { v0=d0; v1=d1; } | 158 | { v0=d0; v1=d1; } |
158 | else | 159 | else |
159 | { | 160 | { |
160 | #ifndef L_ENDIAN | 161 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
161 | iv=&ovec[0]; | 162 | iv=&ovec[0]; |
162 | l2c(v0,iv); | 163 | l2c(v0,iv); |
163 | l2c(v1,iv); | 164 | l2c(v1,iv); |
@@ -172,7 +173,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
172 | for(i=0 ; i < 8 ; ++i) | 173 | for(i=0 ; i < 8 ; ++i) |
173 | ovec[i]=ovec[i+num]<<rem | | 174 | ovec[i]=ovec[i+num]<<rem | |
174 | ovec[i+num+1]>>(8-rem); | 175 | ovec[i+num+1]>>(8-rem); |
175 | #ifdef L_ENDIAN | 176 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
176 | v0=sh[0], v1=sh[1]; | 177 | v0=sh[0], v1=sh[1]; |
177 | #else | 178 | #else |
178 | iv=&ovec[0]; | 179 | iv=&ovec[0]; |
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 @@ | |||
43 | */ | 43 | */ |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <string.h> | 45 | #include <string.h> |
46 | #include <machine/endian.h> | ||
46 | 47 | ||
47 | #include <openssl/crypto.h> | 48 | #include <openssl/crypto.h> |
48 | #include <openssl/sha.h> | 49 | #include <openssl/sha.h> |
@@ -108,7 +109,7 @@ int SHA512_Final (unsigned char *md, SHA512_CTX *c) | |||
108 | sha512_block_data_order (c,p,1); | 109 | sha512_block_data_order (c,p,1); |
109 | 110 | ||
110 | memset (p+n,0,sizeof(c->u)-16-n); | 111 | memset (p+n,0,sizeof(c->u)-16-n); |
111 | #ifdef B_ENDIAN | 112 | #if _BYTE_ORDER == _BIG_ENDIAN |
112 | c->u.d[SHA_LBLOCK-2] = c->Nh; | 113 | c->u.d[SHA_LBLOCK-2] = c->Nh; |
113 | c->u.d[SHA_LBLOCK-1] = c->Nl; | 114 | c->u.d[SHA_LBLOCK-1] = c->Nl; |
114 | #else | 115 | #else |
@@ -437,7 +438,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num | |||
437 | 438 | ||
438 | for (i=0;i<16;i++) | 439 | for (i=0;i<16;i++) |
439 | { | 440 | { |
440 | #ifdef B_ENDIAN | 441 | #if _BYTE_ORDER == _BIG_ENDIAN |
441 | T1 = X[i] = W[i]; | 442 | T1 = X[i] = W[i]; |
442 | #else | 443 | #else |
443 | T1 = X[i] = PULL64(W[i]); | 444 | 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 | |||
492 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; | 493 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; |
493 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; | 494 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; |
494 | 495 | ||
495 | #ifdef B_ENDIAN | 496 | #if _BYTE_ORDER == _BIG_ENDIAN |
496 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); | 497 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); |
497 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); | 498 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); |
498 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); | 499 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); |
diff --git a/src/lib/libcrypto/whrlpool/wp_block.c b/src/lib/libcrypto/whrlpool/wp_block.c index fadad01401..11164e50f5 100644 --- a/src/lib/libcrypto/whrlpool/wp_block.c +++ b/src/lib/libcrypto/whrlpool/wp_block.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include "wp_locl.h" | 38 | #include "wp_locl.h" |
39 | #include <string.h> | 39 | #include <string.h> |
40 | #include <machine/endian.h> | ||
40 | 41 | ||
41 | typedef unsigned char u8; | 42 | typedef unsigned char u8; |
42 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) | 43 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) |
@@ -82,10 +83,10 @@ typedef unsigned long long u64; | |||
82 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ | 83 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ |
83 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) | 84 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) |
84 | # elif defined(__ia64) || defined(__ia64__) | 85 | # elif defined(__ia64) || defined(__ia64__) |
85 | # if defined(L_ENDIAN) | 86 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
86 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 87 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
87 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) | 88 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) |
88 | # elif defined(B_ENDIAN) | 89 | # else |
89 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 90 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
90 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) | 91 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) |
91 | # endif | 92 | # endif |
@@ -94,9 +95,9 @@ typedef unsigned long long u64; | |||
94 | 95 | ||
95 | #if defined(OPENSSL_SMALL_FOOTPRINT) | 96 | #if defined(OPENSSL_SMALL_FOOTPRINT) |
96 | # if !defined(ROTATE) | 97 | # if !defined(ROTATE) |
97 | # if defined(L_ENDIAN) /* little-endians have to rotate left */ | 98 | # if _BYTE_ORDER == _LITTLE_ENDIAN /* little-endians have to rotate left */ |
98 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) | 99 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) |
99 | # elif defined(B_ENDIAN) /* big-endians have to rotate right */ | 100 | # else /* big-endians have to rotate right */ |
100 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) | 101 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) |
101 | # endif | 102 | # endif |
102 | # endif | 103 | # endif |
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c index 1e4cf833dc..4d4a7b86df 100644 --- a/src/lib/libssl/src/crypto/bn/bn_nist.c +++ b/src/lib/libssl/src/crypto/bn/bn_nist.c | |||
@@ -59,6 +59,8 @@ | |||
59 | #include "bn_lcl.h" | 59 | #include "bn_lcl.h" |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | 61 | ||
62 | #include <machine/endian.h> | ||
63 | |||
62 | 64 | ||
63 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 | 65 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 |
64 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 | 66 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 |
@@ -318,7 +320,7 @@ static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top) | |||
318 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) | 320 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) |
319 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); | 321 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); |
320 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) | 322 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) |
321 | # if defined(L_ENDIAN) | 323 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
322 | # if defined(__arch64__) | 324 | # if defined(__arch64__) |
323 | # define NIST_INT64 long | 325 | # define NIST_INT64 long |
324 | # else | 326 | # else |
diff --git a/src/lib/libssl/src/crypto/des/cfb_enc.c b/src/lib/libssl/src/crypto/des/cfb_enc.c index dd5237a86d..9bf6466bd2 100644 --- a/src/lib/libssl/src/crypto/des/cfb_enc.c +++ b/src/lib/libssl/src/crypto/des/cfb_enc.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | #include <assert.h> | 60 | #include <assert.h> |
61 | #include <machine/endian.h> | ||
61 | 62 | ||
62 | /* The input and output are loaded in multiples of 8 bits. | 63 | /* The input and output are loaded in multiples of 8 bits. |
63 | * What this means is that if you hame numbits=12 and length=2 | 64 | * What this means is that if you hame numbits=12 and length=2 |
@@ -76,7 +77,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
76 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; | 77 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; |
77 | DES_LONG ti[2]; | 78 | DES_LONG ti[2]; |
78 | unsigned char *iv; | 79 | unsigned char *iv; |
79 | #ifndef L_ENDIAN | 80 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
80 | unsigned char ovec[16]; | 81 | unsigned char ovec[16]; |
81 | #else | 82 | #else |
82 | unsigned int sh[4]; | 83 | unsigned int sh[4]; |
@@ -114,7 +115,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
114 | { v0=d0; v1=d1; } | 115 | { v0=d0; v1=d1; } |
115 | else | 116 | else |
116 | { | 117 | { |
117 | #ifndef L_ENDIAN | 118 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
118 | iv=&ovec[0]; | 119 | iv=&ovec[0]; |
119 | l2c(v0,iv); | 120 | l2c(v0,iv); |
120 | l2c(v1,iv); | 121 | l2c(v1,iv); |
@@ -129,7 +130,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
129 | for(i=0 ; i < 8 ; ++i) | 130 | for(i=0 ; i < 8 ; ++i) |
130 | ovec[i]=ovec[i+num]<<rem | | 131 | ovec[i]=ovec[i+num]<<rem | |
131 | ovec[i+num+1]>>(8-rem); | 132 | ovec[i+num+1]>>(8-rem); |
132 | #ifdef L_ENDIAN | 133 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
133 | v0=sh[0], v1=sh[1]; | 134 | v0=sh[0], v1=sh[1]; |
134 | #else | 135 | #else |
135 | iv=&ovec[0]; | 136 | iv=&ovec[0]; |
@@ -157,7 +158,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
157 | { v0=d0; v1=d1; } | 158 | { v0=d0; v1=d1; } |
158 | else | 159 | else |
159 | { | 160 | { |
160 | #ifndef L_ENDIAN | 161 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
161 | iv=&ovec[0]; | 162 | iv=&ovec[0]; |
162 | l2c(v0,iv); | 163 | l2c(v0,iv); |
163 | l2c(v1,iv); | 164 | l2c(v1,iv); |
@@ -172,7 +173,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
172 | for(i=0 ; i < 8 ; ++i) | 173 | for(i=0 ; i < 8 ; ++i) |
173 | ovec[i]=ovec[i+num]<<rem | | 174 | ovec[i]=ovec[i+num]<<rem | |
174 | ovec[i+num+1]>>(8-rem); | 175 | ovec[i+num+1]>>(8-rem); |
175 | #ifdef L_ENDIAN | 176 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
176 | v0=sh[0], v1=sh[1]; | 177 | v0=sh[0], v1=sh[1]; |
177 | #else | 178 | #else |
178 | iv=&ovec[0]; | 179 | iv=&ovec[0]; |
diff --git a/src/lib/libssl/src/crypto/sha/sha512.c b/src/lib/libssl/src/crypto/sha/sha512.c index c92f18e418..49afaa05c2 100644 --- a/src/lib/libssl/src/crypto/sha/sha512.c +++ b/src/lib/libssl/src/crypto/sha/sha512.c | |||
@@ -43,6 +43,7 @@ | |||
43 | */ | 43 | */ |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <string.h> | 45 | #include <string.h> |
46 | #include <machine/endian.h> | ||
46 | 47 | ||
47 | #include <openssl/crypto.h> | 48 | #include <openssl/crypto.h> |
48 | #include <openssl/sha.h> | 49 | #include <openssl/sha.h> |
@@ -108,7 +109,7 @@ int SHA512_Final (unsigned char *md, SHA512_CTX *c) | |||
108 | sha512_block_data_order (c,p,1); | 109 | sha512_block_data_order (c,p,1); |
109 | 110 | ||
110 | memset (p+n,0,sizeof(c->u)-16-n); | 111 | memset (p+n,0,sizeof(c->u)-16-n); |
111 | #ifdef B_ENDIAN | 112 | #if _BYTE_ORDER == _BIG_ENDIAN |
112 | c->u.d[SHA_LBLOCK-2] = c->Nh; | 113 | c->u.d[SHA_LBLOCK-2] = c->Nh; |
113 | c->u.d[SHA_LBLOCK-1] = c->Nl; | 114 | c->u.d[SHA_LBLOCK-1] = c->Nl; |
114 | #else | 115 | #else |
@@ -437,7 +438,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num | |||
437 | 438 | ||
438 | for (i=0;i<16;i++) | 439 | for (i=0;i<16;i++) |
439 | { | 440 | { |
440 | #ifdef B_ENDIAN | 441 | #if _BYTE_ORDER == _BIG_ENDIAN |
441 | T1 = X[i] = W[i]; | 442 | T1 = X[i] = W[i]; |
442 | #else | 443 | #else |
443 | T1 = X[i] = PULL64(W[i]); | 444 | 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 | |||
492 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; | 493 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; |
493 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; | 494 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; |
494 | 495 | ||
495 | #ifdef B_ENDIAN | 496 | #if _BYTE_ORDER == _BIG_ENDIAN |
496 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); | 497 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); |
497 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); | 498 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); |
498 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); | 499 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); |
diff --git a/src/lib/libssl/src/crypto/whrlpool/wp_block.c b/src/lib/libssl/src/crypto/whrlpool/wp_block.c index fadad01401..11164e50f5 100644 --- a/src/lib/libssl/src/crypto/whrlpool/wp_block.c +++ b/src/lib/libssl/src/crypto/whrlpool/wp_block.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include "wp_locl.h" | 38 | #include "wp_locl.h" |
39 | #include <string.h> | 39 | #include <string.h> |
40 | #include <machine/endian.h> | ||
40 | 41 | ||
41 | typedef unsigned char u8; | 42 | typedef unsigned char u8; |
42 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) | 43 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) |
@@ -82,10 +83,10 @@ typedef unsigned long long u64; | |||
82 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ | 83 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ |
83 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) | 84 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) |
84 | # elif defined(__ia64) || defined(__ia64__) | 85 | # elif defined(__ia64) || defined(__ia64__) |
85 | # if defined(L_ENDIAN) | 86 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
86 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 87 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
87 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) | 88 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) |
88 | # elif defined(B_ENDIAN) | 89 | # else |
89 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 90 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
90 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) | 91 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) |
91 | # endif | 92 | # endif |
@@ -94,9 +95,9 @@ typedef unsigned long long u64; | |||
94 | 95 | ||
95 | #if defined(OPENSSL_SMALL_FOOTPRINT) | 96 | #if defined(OPENSSL_SMALL_FOOTPRINT) |
96 | # if !defined(ROTATE) | 97 | # if !defined(ROTATE) |
97 | # if defined(L_ENDIAN) /* little-endians have to rotate left */ | 98 | # if _BYTE_ORDER == _LITTLE_ENDIAN /* little-endians have to rotate left */ |
98 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) | 99 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) |
99 | # elif defined(B_ENDIAN) /* big-endians have to rotate right */ | 100 | # else /* big-endians have to rotate right */ |
100 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) | 101 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) |
101 | # endif | 102 | # endif |
102 | # endif | 103 | # endif |