diff options
Diffstat (limited to 'crypto/dsa')
-rw-r--r-- | crypto/dsa/dsa_key.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index 5f4a8fca92..bd5d0ce567 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -68,7 +68,6 @@ int DSA_generate_key(DSA *dsa) { int ok=0; - unsigned int i; BN_CTX *ctx=NULL; BIGNUM *pub_key=NULL,*priv_key=NULL; @@ -81,15 +80,9 @@ int DSA_generate_key(DSA *dsa) else priv_key=dsa->priv_key; - i=BN_num_bits(dsa->q); - for (;;) - { - if (!BN_rand(priv_key,i,0,0)) - goto err; - if (BN_cmp(priv_key,dsa->q) >= 0) - BN_sub(priv_key,priv_key,dsa->q); - if (!BN_is_zero(priv_key)) break; - } + do + if (!BN_rand_range(priv_key,dsa->q)) goto err; + while (BN_is_zero(priv_key)); if (dsa->pub_key == NULL) { |