summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/sha')
-rw-r--r--src/lib/libcrypto/sha/sha256.c5
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c
index 4eae074849..e767afde5a 100644
--- a/src/lib/libcrypto/sha/sha256.c
+++ b/src/lib/libcrypto/sha/sha256.c
@@ -9,6 +9,7 @@
9 9
10#include <stdlib.h> 10#include <stdlib.h>
11#include <string.h> 11#include <string.h>
12#include <machine/endian.h>
12 13
13#include <openssl/crypto.h> 14#include <openssl/crypto.h>
14#include <openssl/sha.h> 15#include <openssl/sha.h>
@@ -206,14 +207,14 @@ static void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num
206 SHA_LONG X[16]; 207 SHA_LONG X[16];
207 int i; 208 int i;
208 const unsigned char *data=in; 209 const unsigned char *data=in;
209 const union { long one; char little; } is_endian = {1};
210 210
211 while (num--) { 211 while (num--) {
212 212
213 a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; 213 a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3];
214 e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; 214 e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7];
215 215
216 if (!is_endian.little && sizeof(SHA_LONG)==4 && ((size_t)in%4)==0) 216 if (_BYTE_ORDER != _LITTLE_ENDIAN &&
217 sizeof(SHA_LONG)==4 && ((size_t)in%4)==0)
217 { 218 {
218 const SHA_LONG *W=(const SHA_LONG *)data; 219 const SHA_LONG *W=(const SHA_LONG *)data;
219 220
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index 6c6cd64282..1210176dda 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -202,6 +202,7 @@ fips_md_init_ctx(SHA1, SHA)
202#endif 202#endif
203 203
204#if !defined(SHA_1) || !defined(SHA1_ASM) 204#if !defined(SHA_1) || !defined(SHA1_ASM)
205#include <machine/endian.h>
205static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) 206static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
206 { 207 {
207 const unsigned char *data=p; 208 const unsigned char *data=p;
@@ -221,9 +222,9 @@ static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
221 222
222 for (;;) 223 for (;;)
223 { 224 {
224 const union { long one; char little; } is_endian = {1};
225 225
226 if (!is_endian.little && sizeof(SHA_LONG)==4 && ((size_t)p%4)==0) 226 if (_BYTE_ORDER != _LITTLE_ENDIAN &&
227 sizeof(SHA_LONG)==4 && ((size_t)p%4)==0)
227 { 228 {
228 const SHA_LONG *W=(const SHA_LONG *)data; 229 const SHA_LONG *W=(const SHA_LONG *)data;
229 230