]> de.git.xonotic.org Git - xonotic/d0_blind_id.git/commitdiff
RSA keygen: when generating a key, don't fail so often.
authorRudolf Polzer <divverent@xonotic.org>
Sat, 25 Jan 2014 11:46:57 +0000 (12:46 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 25 Jan 2014 11:51:31 +0000 (12:51 +0100)
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

index f1cd22e4e14172707b6c6e07826d1d4a9b2ec581..e62c72412d5069ddde2d0b4d474bd70a07a2573a 100644 (file)
@@ -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;
                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;
        }
                        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(!d0_bignum_cmp(temp1, ctx->rsa_d))
                {
                        UNLOCKTEMPS();
-                       if(++fail == 3)
+                       if(++fail == 16)
                                goto fail;
                        continue;
                }
                                goto fail;
                        continue;
                }
@@ -261,7 +261,7 @@ static D0_BOOL d0_rsa_generate_key(size_t size, d0_blind_id_t *ctx)
                        break;
                }
                UNLOCKTEMPS();
                        break;
                }
                UNLOCKTEMPS();
-               if(++gcdfail == 3)
+               if(++gcdfail == 16)
                        goto fail;
                ++gcdfail;
        }
                        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;
                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;
        }
                        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(!d0_bignum_cmp(temp1, ctx->rsa_d))
                {
                        UNLOCKTEMPS();
-                       if(++fail == 3)
+                       if(++fail == 16)
                                return 0;
                        continue;
                }
                                return 0;
                        continue;
                }
@@ -348,7 +348,7 @@ static D0_BOOL d0_rsa_generate_key_fastreject(size_t size, d0_fastreject_functio
                        break;
                }
                UNLOCKTEMPS();
                        break;
                }
                UNLOCKTEMPS();
-               if(++gcdfail == 3)
+               if(++gcdfail == 16)
                        return 0;
                ++gcdfail;
        }
                        return 0;
                ++gcdfail;
        }