From e23d850ff3281220f33ed78d9ca4fcadfa279565 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 9 Jul 2020 08:37:46 +0200 Subject: 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 (Merged from https://github.com/openssl/openssl/pull/12390) --- crypto/chacha/chacha_enc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crypto/chacha') 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 +#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 { -- cgit v1.2.3