From 4224c3f647670fbf9a43ee732691b399a7640870 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sun, 12 Jul 2026 15:25:52 +0200 Subject: [PATCH] sha3: Make sure state and rate input buffers are 8-byte aligned Both buffers are accessed directly by casting to `uint64_t`. On platforms that don't allow unaligned accesses this could cause a SIGBUS. The reorder should avoid extra padding between the two buffers. Fixes: 5ff88c96228c ("xof: Implemented SHAKE128 and SHAKE256 Extended Output Functions") Fixes: 83c1883d0bb0 ("Use word-aligned XOR in sha3_absorb()") --- src/libstrongswan/plugins/sha3/sha3_keccak.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstrongswan/plugins/sha3/sha3_keccak.c b/src/libstrongswan/plugins/sha3/sha3_keccak.c index 69df057d3..480855692 100644 --- a/src/libstrongswan/plugins/sha3/sha3_keccak.c +++ b/src/libstrongswan/plugins/sha3/sha3_keccak.c @@ -59,18 +59,18 @@ struct private_sha3_keccak_t { /** * Internal state of 1600 bits as defined by FIPS-202 */ - uint8_t state[KECCAK_STATE_SIZE]; + uint8_t state[KECCAK_STATE_SIZE] __attribute__((aligned(8))); + + /** + * Rate input buffer + */ + uint8_t rate_buffer[KECCAK_MAX_RATE] __attribute__((aligned(8))); /** * Rate in bytes */ u_int rate; - /** - * Rate input buffer - */ - uint8_t rate_buffer[KECCAK_MAX_RATE]; - /** * Index pointing to the current position in the rate buffer */