Fix incorrect alignment in ChaCha20

This commit is contained in:
Christoffer Lerno
2025-12-17 15:38:51 +01:00
parent bae0f0f579
commit b43dac24c4

View File

@@ -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);
}
}