Skip to content

Commit 7e00808

Browse files
committed
Fix the modular inverse testcase
Fix "can computer the modular inverse" testcase, x needs to be smaller than mod. Also check result. Signed-off-by: Mika Tammi <[email protected]>
1 parent 434ac71 commit 7e00808

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

botan-low/test/Botan/Low/MPISpec.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,15 @@ main = hspec $ do
308308
r `shouldBe` 64
309309
pass
310310
it "can compute the modular inverse" $ do
311-
r <- mpInit
311+
result <- mpInit
312312
x <- mpInit
313-
mpSetFromInt x 512
313+
mpSetFromInt x 29
314314
mod <- mpInit
315-
mpSetFromInt mod 29
316-
mpModInverse r x mod
317-
-- TODO: Actually check more than just being bound
315+
mpSetFromInt mod 65535
316+
-- x needs to be smaller than mod
317+
mpModInverse result x mod
318+
r <- mpToWord32 result
319+
r `shouldBe` 13559
318320
pass
319321
it "can generate a number of random bits" $ do
320322
mp <- mpInit

0 commit comments

Comments
 (0)