From 393a527364e2f0e3e28936cc2ee28c906ea55856 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Sun, 9 Apr 2017 00:36:50 +0200 Subject: [PATCH] fix fast_mp_invmod() not being able to handle case where b=1 This closes #67 --- bn_mp_invmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bn_mp_invmod.c b/bn_mp_invmod.c index 44951e5..820635d 100644 --- a/bn_mp_invmod.c +++ b/bn_mp_invmod.c @@ -25,7 +25,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c) #ifdef BN_FAST_MP_INVMOD_C /* if the modulus is odd we can use a faster routine instead */ - if (mp_isodd (b) == MP_YES) { + if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) { return fast_mp_invmod (a, b, c); } #endif