wolfSSL / wolfssl

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!
https://www.wolfssl.com
GNU General Public License v2.0
2.23k stars 799 forks source link

20240617-fix-wc_Sha256-overalignment #7652

Closed douzzer closed 3 weeks ago

douzzer commented 3 weeks ago

wolfssl/wolfcrypt/sha256.h: in definition of struct wc_Sha256, conditionalize alignment optimization of digest and buffer slots on defined(WC_64BIT_CPU), to avoid overalignment warnings on 32 bit targets. this also fixes overalignment of struct Hmac.

see https://www.wolfssl.com/forums/topic2125-armcc-byte-alignment-cannot-be-greater-than-8-bytes-warning.html

ARMCC reports

wolfcrypt\src\kdf.c(87): warning:  #1041-D: alignment for an auto object may not be larger than 8

With this patch, the alignment of struct Hmac drops from 16 to 8 on 32 bit targets.

tested with wolfssl-multi-test.sh ... sanitizer-all-intelasm-c-fallback-fuzzer cross-aarch64-all-armasm-unittest-sanitizer cross-aarch64-all-noasm-unittest-sanitizer cross-armv7a-all-armasm-testsuite-sanitizer super-quick-check