[PATCH] Fix ChaCha SIMD feed-forward carry (GH #1362, PR #1363)
authorCoraleSoft <82213665+Coralesoft@users.noreply.github.com>
Mon, 13 Jul 2026 13:28:33 +0000 (21:28 +0800)
committerLaszlo Boszormenyi (GCS) <gcs@debian.org>
Tue, 14 Jul 2026 16:40:33 +0000 (18:40 +0200)
commit0faabb691a8eda067a066ecb9c8faf0986ccd8b9
tree5be274c5bd6f9c8f64bb1ee2dd44e37851cfeae7
parent7638ac4cba8e39008cf82aa483ca9e9e7ce6e620
[PATCH] Fix ChaCha SIMD feed-forward carry (GH #1362, PR #1363)

The NEON, SSE2 and Altivec backends applied the per-block counter offset with a 64-bit add after the rounds. A carry from word 12 could therefore alter word 13 of the keystream.

Precompute each block's initial state, then use 32-bit feed-forward adds. Add regression vectors covering ChaCha8/12/20 and counter offsets 1, 2 and 3.

This matches the earlier AVX2 fix in GH #1069.

Gbp-Pq: Name fix_ChaCha_SIMD_feed-forward_carry.patch
TestVectors/chacha.txt
chacha_simd.cpp