diff options
author | Richard Levitte <levitte@openssl.org> | 2020-07-09 08:37:46 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-07-11 10:00:33 +0200 |
commit | e23d850ff3281220f33ed78d9ca4fcadfa279565 (patch) | |
tree | 4e7f73d978bb1a7986e0ac27ee61bdab23d66ed2 /crypto/chacha/chacha_enc.c | |
parent | d685fc7a59699aeb17120aebd17a9175ce5930cd (diff) |
Add and use internal header that implements endianness check
This moves test/ossl_test_endian.h to include/internal/endian.h and
thereby makes the macros in there our standard way to check endianness
in run-time.
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/12390)
Diffstat (limited to 'crypto/chacha/chacha_enc.c')
-rw-r--r-- | crypto/chacha/chacha_enc.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crypto/chacha/chacha_enc.c b/crypto/chacha/chacha_enc.c index 3cf5facd5e..86667cf9e2 100644 --- a/crypto/chacha/chacha_enc.c +++ b/crypto/chacha/chacha_enc.c @@ -11,6 +11,7 @@ #include <string.h> +#include "internal/endian.h" #include "crypto/chacha.h" #include "crypto/ctype.h" @@ -43,10 +44,7 @@ static void chacha20_core(chacha_buf *output, const u32 input[16]) { u32 x[16]; int i; - const union { - long one; - char little; - } is_endian = { 1 }; + DECLARE_IS_ENDIAN; memcpy(x, input, sizeof(x)); @@ -61,7 +59,7 @@ static void chacha20_core(chacha_buf *output, const u32 input[16]) QUARTERROUND(3, 4, 9, 14); } - if (is_endian.little) { + if (IS_LITTLE_ENDIAN) { for (i = 0; i < 16; ++i) output->u[i] = x[i] + input[i]; } else { |