From 1763f125d458b0383eb380b8132b8261bd3abb92 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 24 Feb 2023 13:26:58 -0500
Subject: [PATCH] Fix the decryptSegment' test by not extraneously dividing by
 16 in the caller

Also remove some duplication to make it more clear that the two decryptions
are the same *except* for the segmentSize
---
 test/SpecCHK.hs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/SpecCHK.hs b/test/SpecCHK.hs
index efd8790..5b62948 100644
--- a/test/SpecCHK.hs
+++ b/test/SpecCHK.hs
@@ -355,8 +355,11 @@ prop_decrypt_segmentSize_invariant = property $ do
 
     ciphertext <- liftIO $ getCiphertext key plaintext 16
 
-    let plaintextA = B.concat $ zipWith (curry $ decryptSegment' key) [0, fromIntegral segmentSizeA `div` 16 ..] (chunkedBy segmentSizeA ciphertext)
-        plaintextB = B.concat $ zipWith (curry $ decryptSegment' key) [0, fromIntegral segmentSizeB `div` 16 ..] (chunkedBy segmentSizeB ciphertext)
+    let decrypt segmentSize =
+            B.concat $ zipWith (curry $ decryptSegment' key) [0, fromIntegral segmentSize ..] (chunkedBy segmentSize ciphertext)
+        plaintextA = decrypt segmentSizeA
+        plaintextB = decrypt segmentSizeB
+
     diff plaintextA (==) plaintextB
 
 prop_encrypt_decrypt_roundtrip :: Property
-- 
GitLab