diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2002-09-05 22:12:13 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2002-09-05 22:12:13 +0000 |
commit | bf89ad4321ebfd31b01ca2f89e6b00d8eeb96797 (patch) | |
tree | 37d7f1deb8b923090b68ce0ea7166342f59740f3 /lib/libcrypto/dsa | |
parent | ddcc35286c73ea48fe80f700c807c45342aca191 (diff) |
merge with 0.9.7-beta1
Diffstat (limited to 'lib/libcrypto/dsa')
-rw-r--r-- | lib/libcrypto/dsa/dsa_key.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_ossl.c | 56 |
2 files changed, 2 insertions, 58 deletions
diff --git a/lib/libcrypto/dsa/dsa_key.c b/lib/libcrypto/dsa/dsa_key.c index bf718c1c6d2..ef87c3e6372 100644 --- a/lib/libcrypto/dsa/dsa_key.c +++ b/lib/libcrypto/dsa/dsa_key.c @@ -64,8 +64,6 @@ #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; @@ -82,7 +80,7 @@ int DSA_generate_key(DSA *dsa) priv_key=dsa->priv_key; do - if (!__BN_rand_range(priv_key,dsa->q)) goto err; + if (!BN_rand_range(priv_key,dsa->q)) goto err; while (BN_is_zero(priv_key)); if (dsa->pub_key == NULL) diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index 07addc94d9e..37dd5fc9940 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -66,8 +66,6 @@ #include <openssl/asn1.h> #include <openssl/engine.h> -int __BN_rand_range(BIGNUM *r, BIGNUM *range); - static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, @@ -193,7 +191,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) /* Get random k */ do - if (!__BN_rand_range(&k, dsa->q)) goto err; + 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)) @@ -344,55 +342,3 @@ static int dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, { return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); } - - -/* random number r: 0 <= r < range */ -int __BN_rand_range(BIGNUM *r, BIGNUM *range) - { - int n; - - if (range->neg || BN_is_zero(range)) - { - /* BNerr(BN_F_BN_RAND_RANGE, BN_R_INVALID_RANGE); */ - return 0; - } - - n = BN_num_bits(range); /* n > 0 */ - - if (n == 1) - { - if (!BN_zero(r)) return 0; - } - else if (BN_is_bit_set(range, n - 2)) - { - do - { - /* range = 11..._2, so each iteration succeeds with probability >= .75 */ - if (!BN_rand(r, n, -1, 0)) return 0; - } - while (BN_cmp(r, range) >= 0); - } - else - { - /* range = 10..._2, - * so 3*range (= 11..._2) is exactly one bit longer than range */ - do - { - if (!BN_rand(r, n + 1, -1, 0)) return 0; - /* If r < 3*range, use r := r MOD range - * (which is either r, r - range, or r - 2*range). - * Otherwise, iterate once more. - * Since 3*range = 11..._2, each iteration succeeds with - * probability >= .75. */ - if (BN_cmp(r ,range) >= 0) - { - if (!BN_sub(r, r, range)) return 0; - if (BN_cmp(r, range) >= 0) - if (!BN_sub(r, r, range)) return 0; - } - } - while (BN_cmp(r, range) >= 0); - } - - return 1; - } |