From b7f5b97650e29d8df172fed10d2ccb9630d82002 Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Tue, 15 Mar 2022 11:26:55 +0000 Subject: [PATCH] Minor changes to sha256.c to bring it in line with sha512.c Signed-off-by: Tom Cosgrove --- library/sha256.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library/sha256.c b/library/sha256.c index ff62802704..bdc396a188 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -49,8 +49,15 @@ defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY) # include # endif -# if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) && defined(__linux__) -# include +# if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) +# if defined(__unix__) +# if defined(__linux__) + /* Our preferred method of detection is getauxval() */ +# include +# endif + /* Use SIGILL on Unix, and fall back to it on Linux */ +# include +# endif # endif #elif defined(_M_ARM64) # if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) || \ @@ -272,10 +279,10 @@ static size_t mbedtls_internal_sha256_process_many_a64_crypto( uint32x4_t abcd_orig = abcd; uint32x4_t efgh_orig = efgh; - uint32x4_t sched0 = vld1q_u32( (const uint32_t *)( msg + 16 * 0 ) ); - uint32x4_t sched1 = vld1q_u32( (const uint32_t *)( msg + 16 * 1 ) ); - uint32x4_t sched2 = vld1q_u32( (const uint32_t *)( msg + 16 * 2 ) ); - uint32x4_t sched3 = vld1q_u32( (const uint32_t *)( msg + 16 * 3 ) ); + uint32x4_t sched0 = (uint32x4_t) vld1q_u8( msg + 16 * 0 ); + uint32x4_t sched1 = (uint32x4_t) vld1q_u8( msg + 16 * 1 ); + uint32x4_t sched2 = (uint32x4_t) vld1q_u8( msg + 16 * 2 ); + uint32x4_t sched3 = (uint32x4_t) vld1q_u8( msg + 16 * 3 ); #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ /* Will be true if not defined */ /* Untested on BE */