Fix a_exp_b_mod_c and divide by 0 (GH #604)

This commit is contained in:
Jeffrey Walton 2018-03-25 19:22:42 -04:00
parent 1efa1a9fc7
commit 874c48a329
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

View File

@ -4362,12 +4362,18 @@ Integer Integer::MultiplicativeInverse() const
Integer a_times_b_mod_c(const Integer &x, const Integer& y, const Integer& m)
{
CRYPTOPP_ASSERT(m != 0);
if (m == 0)
throw Integer::DivideByZero();
return x*y%m;
}
Integer a_exp_b_mod_c(const Integer &x, const Integer& e, const Integer& m)
{
CRYPTOPP_ASSERT(m != 0);
if (m == 0)
throw Integer::DivideByZero();
ModularArithmetic mr(m);
return mr.Exponentiate(x, e);
}