We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cf08f3e commit 9425e16Copy full SHA for 9425e16
rw.cpp
@@ -126,10 +126,16 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
126
DoQuickSanityCheck();
127
ModularArithmetic modn(m_n);
128
Integer r, rInv;
129
- do { // do this in a loop for people using small numbers for testing
+
130
+ // do this in a loop for people using small numbers for testing
131
+ do {
132
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);
136
rInv = modn.MultiplicativeInverse(r);
137
} while (rInv.IsZero());
138
139
Integer re = modn.Square(r);
140
re = modn.Multiply(re, x); // blind
141
0 commit comments