diff options
| author | markus <> | 2001-04-23 07:46:00 +0000 |
|---|---|---|
| committer | markus <> | 2001-04-23 07:46:00 +0000 |
| commit | b32892991f70744ca178482fe884c025b4782b1e (patch) | |
| tree | 85bc1ff1cac03d5ce1f6f03f4eea6c3886398df1 /src/lib/libcrypto/dsa/dsa_key.c | |
| parent | 7bdbb2116dd933f7b4639bd9028ed79bfc1c12f9 (diff) | |
| download | openbsd-b32892991f70744ca178482fe884c025b4782b1e.tar.gz openbsd-b32892991f70744ca178482fe884c025b4782b1e.tar.bz2 openbsd-b32892991f70744ca178482fe884c025b4782b1e.zip | |
import DSA changes from 0.9.6a (Bleichenbacher attack), ok provos@/deraadt@
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_key.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index af3c56d770..a68d236e05 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
| @@ -65,10 +65,11 @@ | |||
| 65 | #include <openssl/dsa.h> | 65 | #include <openssl/dsa.h> |
| 66 | #include <openssl/rand.h> | 66 | #include <openssl/rand.h> |
| 67 | 67 | ||
| 68 | extern int __BN_rand_range(BIGNUM *r, BIGNUM *range); | ||
| 69 | |||
| 68 | int DSA_generate_key(DSA *dsa) | 70 | int DSA_generate_key(DSA *dsa) |
| 69 | { | 71 | { |
| 70 | int ok=0; | 72 | int ok=0; |
| 71 | unsigned int i; | ||
| 72 | BN_CTX *ctx=NULL; | 73 | BN_CTX *ctx=NULL; |
| 73 | BIGNUM *pub_key=NULL,*priv_key=NULL; | 74 | BIGNUM *pub_key=NULL,*priv_key=NULL; |
| 74 | 75 | ||
| @@ -81,15 +82,9 @@ int DSA_generate_key(DSA *dsa) | |||
| 81 | else | 82 | else |
| 82 | priv_key=dsa->priv_key; | 83 | priv_key=dsa->priv_key; |
| 83 | 84 | ||
| 84 | i=BN_num_bits(dsa->q); | 85 | do |
| 85 | for (;;) | 86 | if (!__BN_rand_range(priv_key,dsa->q)) goto err; |
| 86 | { | 87 | while (BN_is_zero(priv_key)); |
| 87 | if (!BN_rand(priv_key,i,0,0)) | ||
| 88 | goto err; | ||
| 89 | if (BN_cmp(priv_key,dsa->q) >= 0) | ||
| 90 | BN_sub(priv_key,priv_key,dsa->q); | ||
| 91 | if (!BN_is_zero(priv_key)) break; | ||
| 92 | } | ||
| 93 | 88 | ||
| 94 | if (dsa->pub_key == NULL) | 89 | if (dsa->pub_key == NULL) |
| 95 | { | 90 | { |
