From dc103866d4d9c51ca4e2b1fb4b2f659d7f687f4d Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 1 Mar 2023 10:37:39 +0000 Subject: [PATCH] ascon: use `chunks_exact_mut` for encoding permutation output (#48) --- ascon/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ascon/src/lib.rs b/ascon/src/lib.rs index b0415f5..708d34c 100644 --- a/ascon/src/lib.rs +++ b/ascon/src/lib.rs @@ -158,7 +158,9 @@ fn permutation(s: &mut [u8], start: usize, rounds: usize) { x[4] ^= x[4].rotate_right(7) ^ x[4].rotate_right(41); } - for (i, &b) in x.iter().enumerate() { - s[(i * 8)..((i + 1) * 8)].copy_from_slice(&b.to_be_bytes()) - } + x.into_iter() + .map(u64::to_be_bytes) + // TODO: replace with `array_chunks_mut` on stabilization + .zip(s.chunks_exact_mut(8)) + .for_each(|(inp, out)| out.copy_from_slice(&inp)) }