From 7acba5f3a6ff10f1424c309d0d34d2b713233019 Mon Sep 17 00:00:00 2001 From: Wouter Bolsterlee Date: Fri, 20 Jun 2014 22:07:46 +0200 Subject: Increase attempts for recovering RSA (p,q) from (n,e,d) Bump the maximum number of iterations to recover (p,q) given (n,e,d) to increase the chance that the algorithm succeeds. The algorithm used is a probabilistic one with a 1/2 chance of finding the right value in each iteration, so it's likely that only a few iterations are needed. However, in some extreme cases this may still fail. Bumping the maximum number allow the algorithm to correctly find the right values for these cases. This changes bumps the number of iterations from 50 to 500 (the value 'a' is increased by 2 in each step), and hence reduces the chance of failure from 2**-50 to 2**-500. Note that this change does *not* result in a performance degradation. --- lib/Crypto/PublicKey/_slowmath.py | 2 +- src/_fastmath.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Crypto/PublicKey/_slowmath.py b/lib/Crypto/PublicKey/_slowmath.py index e9f48f9..1350773 100644 --- a/lib/Crypto/PublicKey/_slowmath.py +++ b/lib/Crypto/PublicKey/_slowmath.py @@ -113,7 +113,7 @@ def rsa_construct(n, e, d=None, p=None, q=None, u=None): # as Factorization", M. Rabin, 1979 spotted = 0 a = 2 - while not spotted and a<100: + while not spotted and a<1000: k = t # Cycle through all values a^{t*2^i}=a^k while kn); -- cgit v1.2.1