diff options
| author | tb <> | 2018-11-05 23:54:27 +0000 |
|---|---|---|
| committer | tb <> | 2018-11-05 23:54:27 +0000 |
| commit | eaddac22ab3166ef515cb4c286c0c3ed322fbe40 (patch) | |
| tree | 78a9bc333df72424887ef3936cbdf13c338b303d /src/lib/libcrypto/dsa/dsa_ossl.c | |
| parent | 180c3e4250e4e8ea8cdade42002a7fd6564d66c2 (diff) | |
| download | openbsd-eaddac22ab3166ef515cb4c286c0c3ed322fbe40.tar.gz openbsd-eaddac22ab3166ef515cb4c286c0c3ed322fbe40.tar.bz2 openbsd-eaddac22ab3166ef515cb4c286c0c3ed322fbe40.zip | |
Make use of bn_rand_interval() where appropriate.
ok beck jsing
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_ossl.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index c9399573ab..cda750a0ed 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_ossl.c,v 1.37 2018/06/14 18:34:50 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.38 2018/11/05 23:54:27 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -150,13 +150,9 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
| 150 | * | 150 | * |
| 151 | * s = inv(k)inv(b)(bm + bxr) mod q | 151 | * s = inv(k)inv(b)(bm + bxr) mod q |
| 152 | * | 152 | * |
| 153 | * Where b is a random value in the range [1, q-1]. | 153 | * Where b is a random value in the range [1, q). |
| 154 | */ | 154 | */ |
| 155 | if (!BN_sub(&bm, dsa->q, BN_value_one())) | 155 | if (!bn_rand_interval(&b, BN_value_one(), dsa->q)) |
| 156 | goto err; | ||
| 157 | if (!BN_rand_range(&b, &bm)) | ||
| 158 | goto err; | ||
| 159 | if (!BN_add(&b, &b, BN_value_one())) | ||
| 160 | goto err; | 156 | goto err; |
| 161 | if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) | 157 | if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) |
| 162 | goto err; | 158 | goto err; |
| @@ -242,11 +238,8 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
| 242 | !BN_set_bit(&m, q_bits)) | 238 | !BN_set_bit(&m, q_bits)) |
| 243 | goto err; | 239 | goto err; |
| 244 | 240 | ||
| 245 | /* Get random k */ | 241 | if (!bn_rand_interval(&k, BN_value_one(), dsa->q)) |
| 246 | do { | 242 | goto err; |
| 247 | if (!BN_rand_range(&k, dsa->q)) | ||
| 248 | goto err; | ||
| 249 | } while (BN_is_zero(&k)); | ||
| 250 | 243 | ||
| 251 | BN_set_flags(&k, BN_FLG_CONSTTIME); | 244 | BN_set_flags(&k, BN_FLG_CONSTTIME); |
| 252 | 245 | ||
