summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWouter Bolsterlee <uws@xs4all.nl>2014-06-20 22:07:46 +0200
committerDwayne Litzenberger <dlitz@dlitz.net>2014-06-23 00:12:24 -0700
commit7acba5f3a6ff10f1424c309d0d34d2b713233019 (patch)
tree268d6fc5498f71f907466b66b6fe8312e954f5e3 /src
parent13fcb9e63892f18de043e8308bc645ae5baf4aa4 (diff)
downloadpycrypto-7acba5f3a6ff10f1424c309d0d34d2b713233019.tar.gz
Increase attempts for recovering RSA (p,q) from (n,e,d)stage
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.
Diffstat (limited to 'src')
-rw-r--r--src/_fastmath.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/_fastmath.c b/src/_fastmath.c
index c331557..e369f5a 100644
--- a/src/_fastmath.c
+++ b/src/_fastmath.c
@@ -616,7 +616,7 @@ static int factorize_N_from_D(rsaKey *key)
cnt = mpz_scan1(t, 0);
mpz_fdiv_q_2exp(t,t,cnt);
mpz_set_ui(a, 2);
- for (spotted=0; (!spotted) && (mpz_cmp_ui(a,100)<0); mpz_add_ui(a,a,2)) {
+ for (spotted=0; (!spotted) && (mpz_cmp_ui(a,1000)<0); mpz_add_ui(a,a,2)) {
mpz_set(k, t);
for (; (mpz_cmp(k,ktot)<0); mpz_mul_ui(k,k,2)) {
mpz_powm(cand,a,k,key->n);