Skip to content

Commit 9a22d11

Browse files
authored
Merge pull request #23 from mikatammi/fix_modinverse
Fix the modular inverse testcase
2 parents e09a376 + 7e00808 commit 9a22d11

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)