diff options
Diffstat (limited to 'libtommath/bn_mp_invmod.c')
-rw-r--r-- | libtommath/bn_mp_invmod.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libtommath/bn_mp_invmod.c b/libtommath/bn_mp_invmod.c index 525493a..96717ea 100644 --- a/libtommath/bn_mp_invmod.c +++ b/libtommath/bn_mp_invmod.c @@ -18,14 +18,14 @@ /* hac 14.61, pp608 */ int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) { - /* b cannot be negative */ - if ((b->sign == MP_NEG) || (mp_iszero(b) == MP_YES)) { + /* b cannot be negative and has to be >1 */ + if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) { return MP_VAL; } #ifdef BN_FAST_MP_INVMOD_C /* if the modulus is odd we can use a faster routine instead */ - if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) { + if ((mp_isodd(b) == MP_YES)) { return fast_mp_invmod(a, b, c); } #endif |