Merge pull request #2621 from JacobBarthelmeh/SanityChecks

sanity check on "a" input to invmod
This commit is contained in:
David Garske
2019-12-02 10:57:01 -08:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -966,8 +966,8 @@ int wolfcrypt_mp_invmod(mp_int * a, mp_int * b, mp_int * c)
int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
#endif
{
/* b cannot be negative */
if (b->sign == MP_NEG || mp_iszero(b) == MP_YES) {
/* b cannot be negative or zero, and can not divide by 0 (1/a mod b) */
if (b->sign == MP_NEG || mp_iszero(b) == MP_YES || mp_iszero(a) == MP_YES) {
return MP_VAL;
}