From 05bd48b2c96375765c0c7dae9bb3aa4854670a3a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 25 Jan 2014 12:46:57 +0100 Subject: [PATCH 1/1] RSA keygen: when generating a key, don't fail so often. Previously, this code would fail if gcd(e, phi(n)) != 1 happens 3 times in a row. Upped to 16. As before, if this happens, another prime is tried. --- d0_blind_id.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/d0_blind_id.c b/d0_blind_id.c index f1cd22e..e62c724 100644 --- a/d0_blind_id.c +++ b/d0_blind_id.c @@ -229,7 +229,7 @@ static D0_BOOL d0_rsa_generate_key(size_t size, d0_blind_id_t *ctx) CHECK(d0_bignum_gcd(temp4, NULL, NULL, temp2, ctx->rsa_e)); if(!d0_bignum_cmp(temp4, one)) break; - if(++gcdfail == 3) + if(++gcdfail == 16) goto fail; ++gcdfail; } @@ -243,7 +243,7 @@ static D0_BOOL d0_rsa_generate_key(size_t size, d0_blind_id_t *ctx) if(!d0_bignum_cmp(temp1, ctx->rsa_d)) { UNLOCKTEMPS(); - if(++fail == 3) + if(++fail == 16) goto fail; continue; } @@ -261,7 +261,7 @@ static D0_BOOL d0_rsa_generate_key(size_t size, d0_blind_id_t *ctx) break; } UNLOCKTEMPS(); - if(++gcdfail == 3) + if(++gcdfail == 16) goto fail; ++gcdfail; } @@ -307,7 +307,7 @@ static D0_BOOL d0_rsa_generate_key_fastreject(size_t size, d0_fastreject_functio CHECK(d0_bignum_gcd(temp4, NULL, NULL, temp2, ctx->rsa_e)); if(!d0_bignum_cmp(temp4, one)) break; - if(++gcdfail == 3) + if(++gcdfail == 16) return 0; ++gcdfail; } @@ -321,7 +321,7 @@ static D0_BOOL d0_rsa_generate_key_fastreject(size_t size, d0_fastreject_functio if(!d0_bignum_cmp(temp1, ctx->rsa_d)) { UNLOCKTEMPS(); - if(++fail == 3) + if(++fail == 16) return 0; continue; } @@ -348,7 +348,7 @@ static D0_BOOL d0_rsa_generate_key_fastreject(size_t size, d0_fastreject_functio break; } UNLOCKTEMPS(); - if(++gcdfail == 3) + if(++gcdfail == 16) return 0; ++gcdfail; } -- 2.39.2