From 636cc057bc8866213997eef23a190f9ff9ab1fad Mon Sep 17 00:00:00 2001 From: SethArchambault Date: Sat, 21 Oct 2023 19:59:11 -0400 Subject: [PATCH] Just changing the types on those two resolved everything, and tests pass! --- a/src/monocypher.c +++ b/src/monocypher.c -u64 lane = +u32 lane = ... -u64 ref = (window_start + z) % lane_size; +u32 ref = (window_start + z) % lane_size; -u32 index = (u32)(lane * lane_size) + (u32)ref; +u32 index = lane * lane_size + ref; --- src/monocypher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monocypher.c b/src/monocypher.c index 1f4b2e6..0accae7 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -863,7 +863,7 @@ void crypto_argon2(u8 *hash, u32 hash_size, void *work_area, u32 next_slice = ((slice + 1) % 4) * segment_size; u32 window_start = pass == 0 ? 0 : next_slice; u32 nb_segments = pass == 0 ? slice : 3; - u64 lane = + u32 lane = pass == 0 && slice == 0 ? segment : (index_seed >> 32) % config.nb_lanes; @@ -877,8 +877,8 @@ void crypto_argon2(u8 *hash, u32 hash_size, void *work_area, u64 x = (j1 * j1) >> 32; u64 y = (window_size * x) >> 32; u64 z = (window_size - 1) - y; - u64 ref = (window_start + z) % lane_size; - u32 index = (u32)(lane * lane_size) + (u32)ref; + u32 ref = (window_start + z) % lane_size; + u32 index = lane * lane_size + ref; blk *reference = blocks + index; // Shuffle the previous & reference block