Fix for CVE-2015-2141. Thanks to Evgeny Sidorov for reporting. Squaring to satisfy Jacobi requirements suggested by JPM.
parent
cf08f3e98d
commit
9425e16437
8
rw.cpp
8
rw.cpp
|
|
@ -126,10 +126,16 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
|
||||||
DoQuickSanityCheck();
|
DoQuickSanityCheck();
|
||||||
ModularArithmetic modn(m_n);
|
ModularArithmetic modn(m_n);
|
||||||
Integer r, rInv;
|
Integer r, rInv;
|
||||||
do { // do this in a loop for people using small numbers for testing
|
|
||||||
|
// do this in a loop for people using small numbers for testing
|
||||||
|
do {
|
||||||
r.Randomize(rng, Integer::One(), m_n - Integer::One());
|
r.Randomize(rng, Integer::One(), m_n - Integer::One());
|
||||||
|
// Fix for CVE-2015-2141. Thanks to Evgeny Sidorov for reporting.
|
||||||
|
// Squaring to satisfy Jacobi requirements suggested by JPM.
|
||||||
|
r = modn.Square(r);
|
||||||
rInv = modn.MultiplicativeInverse(r);
|
rInv = modn.MultiplicativeInverse(r);
|
||||||
} while (rInv.IsZero());
|
} while (rInv.IsZero());
|
||||||
|
|
||||||
Integer re = modn.Square(r);
|
Integer re = modn.Square(r);
|
||||||
re = modn.Multiply(re, x); // blind
|
re = modn.Multiply(re, x); // blind
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue