Use '*this >= m' for InverseMod reduction
The previous test used '*this > m', which did not capture 'm'pull/611/head
parent
302d210ceb
commit
a665e0825f
|
|
@ -4386,13 +4386,13 @@ Integer Integer::Gcd(const Integer &a, const Integer &b)
|
|||
Integer Integer::InverseMod(const Integer &m) const
|
||||
{
|
||||
CRYPTOPP_ASSERT(m.NotNegative());
|
||||
CRYPTOPP_ASSERT(m != 0);
|
||||
CRYPTOPP_ASSERT(m.NotZero());
|
||||
|
||||
if (IsNegative())
|
||||
return Modulo(m).InverseModNext(m);
|
||||
|
||||
// http://github.com/weidai11/cryptopp/issues/602
|
||||
if (*this > m)
|
||||
if (*this >= m)
|
||||
return Modulo(m).InverseModNext(m);
|
||||
|
||||
return InverseModNext(m);
|
||||
|
|
@ -4401,7 +4401,7 @@ Integer Integer::InverseMod(const Integer &m) const
|
|||
Integer Integer::InverseModNext(const Integer &m) const
|
||||
{
|
||||
CRYPTOPP_ASSERT(m.NotNegative());
|
||||
CRYPTOPP_ASSERT(m != 0);
|
||||
CRYPTOPP_ASSERT(m.NotZero());
|
||||
|
||||
if (m.IsEven())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3374,7 +3374,7 @@ bool TestIntegerOps()
|
|||
// ******************** Integer Modulo and InverseMod ********************
|
||||
|
||||
// http://github.com/weidai11/cryptopp/issues/602
|
||||
// The bug report that uncovered the InverseMod problems
|
||||
// The bug report that uncovered the InverseMod problems
|
||||
{
|
||||
Integer a("0x2F0500010000018000000000001C1C000000000000000A000B0000000000000000000000000000FDFFFFFF00000000");
|
||||
Integer b("0x3D2F050001");
|
||||
|
|
|
|||
Loading…
Reference in New Issue