]> de.git.xonotic.org Git - xonotic/d0_blind_id.git/blobdiff - d0_blind_id.c
Fixed version-info.
[xonotic/d0_blind_id.git] / d0_blind_id.c
index 57ca8fd0594242d11c3f8507571321f16edb3e02..b9989cec5aff1e94866e2a7cf5d4504bc28131ce 100644 (file)
@@ -229,9 +229,8 @@ 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;
        }
        UNLOCKTEMPS();
 
@@ -243,7 +242,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,9 +260,8 @@ 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;
        }
 
        // ctx->rsa_n = ctx->rsa_d*temp1
@@ -271,8 +269,8 @@ static D0_BOOL d0_rsa_generate_key(size_t size, d0_blind_id_t *ctx)
 
        // ctx->rsa_d = ctx->rsa_e^-1 mod (ctx->rsa_d-1)(temp1-1)
        CHECK(d0_bignum_sub(temp2, ctx->rsa_d, one)); // we can't reuse the value from above because temps were unlocked
-       CHECK(d0_bignum_mul(temp0, temp2, temp3));
-       CHECK(d0_bignum_mod_inv(ctx->rsa_d, ctx->rsa_e, temp0));
+       CHECK(d0_bignum_mul(temp1, temp2, temp3));
+       CHECK(d0_bignum_mod_inv(ctx->rsa_d, ctx->rsa_e, temp1));
        UNLOCKTEMPS();
        return 1;
 fail:
@@ -307,9 +305,8 @@ 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;
        }
        UNLOCKTEMPS();
 
@@ -321,7 +318,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,15 +345,14 @@ 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;
        }
 
        // ctx->rsa_d = ctx->rsa_e^-1 mod (ctx->rsa_d-1)(temp1-1)
        CHECK(d0_bignum_sub(temp2, ctx->rsa_d, one)); // we can't reuse the value from above because temps were unlocked
-       CHECK(d0_bignum_mul(ctx->rsa_d, temp2, temp3));
-       CHECK(d0_bignum_mod_inv(ctx->rsa_d, ctx->rsa_e, temp0));
+       CHECK(d0_bignum_mul(temp1, temp2, temp3));
+       CHECK(d0_bignum_mod_inv(ctx->rsa_d, ctx->rsa_e, temp1));
        UNLOCKTEMPS();
        return 1;
 fail:
@@ -1442,13 +1438,12 @@ fail:
 
 D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_verify_private_id(const d0_blind_id_t *ctx)
 {
-       USINGTEMPS(); // temps: temp0 = order, temp1 = g^s
+       USINGTEMPS(); // temps: temp0 = g^s
        USING(schnorr_G); USING(schnorr_s); USING(schnorr_g_to_s);
 
        LOCKTEMPS();
-       CHECK(d0_dl_get_order(temp0, ctx->schnorr_G));
-       CHECK(d0_bignum_mod_pow(temp1, four, ctx->schnorr_s, ctx->schnorr_G));
-       CHECK(!d0_bignum_cmp(temp1, ctx->schnorr_g_to_s));
+       CHECK(d0_bignum_mod_pow(temp0, four, ctx->schnorr_s, ctx->schnorr_G));
+       CHECK(!d0_bignum_cmp(temp0, ctx->schnorr_g_to_s));
        UNLOCKTEMPS();
        return 1;