From b43dac24c4fb3732d46b30c0139187b93258c55a Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 17 Dec 2025 15:38:51 +0100 Subject: [PATCH] Fix incorrect alignment in ChaCha20 --- lib/std/crypto/chacha20.c3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/crypto/chacha20.c3 b/lib/std/crypto/chacha20.c3 index ab2a75cc9..b112ec1b0 100644 --- a/lib/std/crypto/chacha20.c3 +++ b/lib/std/crypto/chacha20.c3 @@ -150,7 +150,8 @@ fn void ChaCha20.transform(&self, char[] data) self.mutate_keystream(); for (usz i = 0; i < BLOCK_SIZE / usz.sizeof; i++) { - ((usz*)data.ptr)[i] ^= ((usz*)&self.key_stream)[i]; + usz* data_ref = (usz*)data.ptr + i; + @unaligned_store(*data_ref, @unaligned_load(*data_ref, 1) ^ ((usz*)&self.key_stream)[i], 1); } }