Simplify BN_rand_range
[openssl.git] / crypto / dsa / dsa_ossl.c
index 7304037947e5db01c0e80e66f7bf1efc75a44b5e..734681733703217a38fc1b14fbe3b195f708b345 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, dsa->q)) goto err;
+       while (BN_is_zero(&k));
 
        if ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))
                {