Integrate my implementation of a countermeasure against
[openssl.git] / crypto / dsa / dsa_ossl.c
index 7304037947e5db01c0e80e66f7bf1efc75a44b5e..1967290bafb01774f29ac400e346f9f830077922 100644 (file)
@@ -180,7 +180,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
        kinv=NULL;
 
        /* Get random k */
-       if (!BN_rand_range(&k, BN_value_one(), dsa->q)) goto err;
+       do
+               if (!BN_rand_range(&k, NULL, dsa->q)) goto err;
+       while (BN_is_zero(&k));
 
        if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
                {