diff options
author | 2001-04-23 07:46:00 +0000 | |
---|---|---|
committer | 2001-04-23 07:46:00 +0000 | |
commit | 0db957ea4b50977e63ac73c531368d2666d606d4 (patch) | |
tree | 507242862a2bbc9e1d7f4c7efd091a5097df07fd /lib/libssl/src/crypto/dsa/dsa_key.c | |
parent | when we take a pci interrupt, upgrade it to level. but always ignore (diff) | |
download | wireguard-openbsd-0db957ea4b50977e63ac73c531368d2666d606d4.tar.xz wireguard-openbsd-0db957ea4b50977e63ac73c531368d2666d606d4.zip |
import DSA changes from 0.9.6a (Bleichenbacher attack), ok provos@/deraadt@
Diffstat (limited to 'lib/libssl/src/crypto/dsa/dsa_key.c')
-rw-r--r-- | lib/libssl/src/crypto/dsa/dsa_key.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/libssl/src/crypto/dsa/dsa_key.c b/lib/libssl/src/crypto/dsa/dsa_key.c index af3c56d770e..a68d236e05d 100644 --- a/lib/libssl/src/crypto/dsa/dsa_key.c +++ b/lib/libssl/src/crypto/dsa/dsa_key.c @@ -65,10 +65,11 @@ #include <openssl/dsa.h> #include <openssl/rand.h> +extern int __BN_rand_range(BIGNUM *r, BIGNUM *range); + 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 +82,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) { |