From 296148b4e63b0bf5419e82aeaa5eb273b80d3c42 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 7 Apr 2026 15:39:31 -0500 Subject: [PATCH] wolfcrypt/src/sha3.c: fix Load64Unaligned() implementation with unaligned integer access when WC_SHA3_FAULT_HARDEN && !BIG_ENDIAN_ORDER. --- wolfcrypt/src/sha3.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index 7c4558313f..7a6faffe56 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -615,19 +615,8 @@ static word64 Load64BitLittleEndian(const byte* a) return n; } #elif defined(WC_SHA3_FAULT_HARDEN) -static WC_INLINE word64 Load64Unaligned(const unsigned char *a) -{ -#ifdef WC_64BIT_CPU - return *(word64*)a; -#elif defined(WC_32BIT_CPU) - return (((word64)((word32*)a)[1]) << 32) | - ((word32*)a)[0]; -#else - return (((word64)((word16*)a)[3]) << 48) | - (((word64)((word16*)a)[2]) << 32) | - (((word64)((word16*)a)[1]) << 16) | - ((word16*)a)[0]; -#endif +static WC_INLINE word64 Load64Unaligned(const unsigned char *a) { + return readUnalignedWord64(a); } /* Convert the array of bytes, in little-endian order, to a 64-bit integer.