X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fdsa%2Fdsa_key.c;h=bd5d0ce5673c1c514805798427e62d4ba58b0d2b;hp=d51ed9395f14a6e7f13226007666c5f21fb899e7;hb=12c2fe8d53fd43559ea862c9babfc2abf3c65299;hpb=7dfb0b774e6592dcbfe47015168a0ac8b44e2a17 diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index d51ed9395f..bd5d0ce567 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -56,19 +56,18 @@ * [including the GNU Public Licence.] */ +#ifndef OPENSSL_NO_SHA #include #include #include "cryptlib.h" -#include "sha.h" -#include "bn.h" -#include "dsa.h" -#include "rand.h" +#include +#include +#include +#include -int DSA_generate_key(dsa) -DSA *dsa; +int DSA_generate_key(DSA *dsa) { int ok=0; - unsigned int i; BN_CTX *ctx=NULL; BIGNUM *pub_key=NULL,*priv_key=NULL; @@ -81,14 +80,9 @@ DSA *dsa; else priv_key=dsa->priv_key; - i=BN_num_bits(dsa->q); - for (;;) - { - BN_rand(priv_key,i,1,0); - 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) { @@ -109,4 +103,4 @@ err: if (ctx != NULL) BN_CTX_free(ctx); return(ok); } - +#endif