From 82df83719a0c790f8c71167e22708a46bc8267ab Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 18 Feb 2020 18:55:56 +0000 Subject: [PATCH] Test passing null pointers to mp_divmod_into. I've got opt_val_mpint already in the test system, so it makes sense to use it. --- test/cryptsuite.py | 12 ++++++++++++ testcrypt.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/cryptsuite.py b/test/cryptsuite.py index 7638d346..55269189 100755 --- a/test/cryptsuite.py +++ b/test/cryptsuite.py @@ -370,6 +370,18 @@ class mpint(MyTestBase): self.assertEqual(int(mp_div(n, d)), q) self.assertEqual(int(mp_mod(n, d)), r) + # Make sure divmod_into can handle not getting one + # of its output pointers (or even both). + mp_clear(mq) + mp_divmod_into(n, d, mq, None) + self.assertEqual(int(mq), q) + mp_clear(mr) + mp_divmod_into(n, d, None, mr) + self.assertEqual(int(mr), r) + mp_divmod_into(n, d, None, None) + # No tests we can do after that last one - we just + # insist that it isn't allowed to have crashed! + def testBitwise(self): p = 0x3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e e = 0x2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190 diff --git a/testcrypt.h b/testcrypt.h index 41bee353..13f7011b 100644 --- a/testcrypt.h +++ b/testcrypt.h @@ -48,7 +48,7 @@ FUNC4(void, mp_cond_add_into, val_mpint, val_mpint, val_mpint, uint) FUNC4(void, mp_cond_sub_into, val_mpint, val_mpint, val_mpint, uint) FUNC3(void, mp_cond_swap, val_mpint, val_mpint, uint) FUNC2(void, mp_cond_clear, val_mpint, uint) -FUNC4(void, mp_divmod_into, val_mpint, val_mpint, val_mpint, val_mpint) +FUNC4(void, mp_divmod_into, val_mpint, val_mpint, opt_val_mpint, opt_val_mpint) FUNC2(val_mpint, mp_div, val_mpint, val_mpint) FUNC2(val_mpint, mp_mod, val_mpint, val_mpint) FUNC2(void, mp_reduce_mod_2to, val_mpint, uint)