diff options
author | tb <> | 2018-11-06 02:14:39 +0000 |
---|---|---|
committer | tb <> | 2018-11-06 02:14:39 +0000 |
commit | 011adf78027bced403e1190e496f00d941510468 (patch) | |
tree | 1393e16c882df0479eb41f25b6cca95143877b0b /src/lib/libcrypto/dsa | |
parent | 18a8420ea8e51c199239c2ef68a9188965089aad (diff) | |
download | openbsd-011adf78027bced403e1190e496f00d941510468.tar.gz openbsd-011adf78027bced403e1190e496f00d941510468.tar.bz2 openbsd-011adf78027bced403e1190e496f00d941510468.zip |
revert use of bn_rand_interval due to failures with ECDHE and TLS
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 17 |
2 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index 7ead1f30cc..4039fbf407 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_key.c,v 1.26 2018/11/05 23:54:27 tb Exp $ */ | 1 | /* $OpenBSD: dsa_key.c,v 1.27 2018/11/06 02:14:39 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 | * |
@@ -92,8 +92,10 @@ dsa_builtin_keygen(DSA *dsa) | |||
92 | goto err; | 92 | goto err; |
93 | } | 93 | } |
94 | 94 | ||
95 | if (!bn_rand_interval(priv_key, BN_value_one(), dsa->q)) | 95 | do { |
96 | goto err; | 96 | if (!BN_rand_range(priv_key, dsa->q)) |
97 | goto err; | ||
98 | } while (BN_is_zero(priv_key)); | ||
97 | 99 | ||
98 | if (pub_key == NULL) { | 100 | if (pub_key == NULL) { |
99 | if ((pub_key = BN_new()) == NULL) | 101 | if ((pub_key = BN_new()) == NULL) |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index cda750a0ed..6eb391ddeb 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.38 2018/11/05 23:54:27 tb Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.39 2018/11/06 02:14:39 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,9 +150,13 @@ 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). | 153 | * Where b is a random value in the range [1, q-1]. |
154 | */ | 154 | */ |
155 | if (!bn_rand_interval(&b, BN_value_one(), dsa->q)) | 155 | if (!BN_sub(&bm, dsa->q, BN_value_one())) |
156 | goto err; | ||
157 | if (!BN_rand_range(&b, &bm)) | ||
158 | goto err; | ||
159 | if (!BN_add(&b, &b, BN_value_one())) | ||
156 | goto err; | 160 | goto err; |
157 | if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) | 161 | if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) |
158 | goto err; | 162 | goto err; |
@@ -238,8 +242,11 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
238 | !BN_set_bit(&m, q_bits)) | 242 | !BN_set_bit(&m, q_bits)) |
239 | goto err; | 243 | goto err; |
240 | 244 | ||
241 | if (!bn_rand_interval(&k, BN_value_one(), dsa->q)) | 245 | /* Get random k */ |
242 | goto err; | 246 | do { |
247 | if (!BN_rand_range(&k, dsa->q)) | ||
248 | goto err; | ||
249 | } while (BN_is_zero(&k)); | ||
243 | 250 | ||
244 | BN_set_flags(&k, BN_FLG_CONSTTIME); | 251 | BN_set_flags(&k, BN_FLG_CONSTTIME); |
245 | 252 | ||