diff options
author | miod <> | 2014-04-23 18:40:39 +0000 |
---|---|---|
committer | miod <> | 2014-04-23 18:40:39 +0000 |
commit | 7f5d17891e05458836147cd2b05889fde1e7be19 (patch) | |
tree | e1e4b99a334105ef85f59fe57d8b382b9d71b773 /src/lib/libcrypto/sha/sha_locl.h | |
parent | 909fa81274d3ab37a13fd6a376b38c3652c1ec4f (diff) | |
download | openbsd-7f5d17891e05458836147cd2b05889fde1e7be19.tar.gz openbsd-7f5d17891e05458836147cd2b05889fde1e7be19.tar.bz2 openbsd-7f5d17891e05458836147cd2b05889fde1e7be19.zip |
Figure out endianness at compile-time, using _BYTE_ORDER from
<machine/endian.h>, rather than writing 1 to a 32-bit variable and checking
whether the first byte is nonzero.
tweaks and ok matthew@; ok beck@ tedu@
Diffstat (limited to 'src/lib/libcrypto/sha/sha_locl.h')
-rw-r--r-- | src/lib/libcrypto/sha/sha_locl.h | 5 |
1 files changed, 3 insertions, 2 deletions
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> | ||
205 | static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) | 206 | static 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 | ||