sanity check on "a" input to invmod

This commit is contained in:
Jacob Barthelmeh
2019-11-22 15:47:05 -07:00
parent edb07cf68e
commit 9a0a48e093

View File

@ -1023,6 +1023,11 @@ int fp_invmod(fp_int *a, fp_int *b, fp_int *c)
#endif
int neg;
/* [modified] sanity check on "a" */
if (fp_iszero(a) == FP_YES) {
return FP_VAL; /* can not divide by 0 here */
}
/* 2. [modified] b must be odd */
if (fp_iseven (b) == FP_YES) {
return fp_invmod_slow(a,b,c);