Skip to content

Commit 9425e16

Browse files
committed
Fix for CVE-2015-2141. Thanks to Evgeny Sidorov for reporting. Squaring to satisfy Jacobi requirements suggested by JPM.
1 parent cf08f3e commit 9425e16

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: rw.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,16 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
126126
DoQuickSanityCheck();
127127
ModularArithmetic modn(m_n);
128128
Integer r, rInv;
129-
do { // do this in a loop for people using small numbers for testing
129+
130+
// do this in a loop for people using small numbers for testing
131+
do {
130132
r.Randomize(rng, Integer::One(), m_n - Integer::One());
133+
// Fix for CVE-2015-2141. Thanks to Evgeny Sidorov for reporting.
134+
// Squaring to satisfy Jacobi requirements suggested by JPM.
135+
r = modn.Square(r);
131136
rInv = modn.MultiplicativeInverse(r);
132137
} while (rInv.IsZero());
138+
133139
Integer re = modn.Square(r);
134140
re = modn.Multiply(re, x); // blind
135141

0 commit comments

Comments
 (0)