From b1f2fa8da88f8be2fe7d6d9d2b8308537fcfb408 Mon Sep 17 00:00:00 2001 From: tb <> Date: Tue, 6 Nov 2018 07:02:33 +0000 Subject: unrevert the use of bn_rand_interval(). ok beck jsing --- src/lib/libcrypto/ec/ec_key.c | 9 ++++----- src/lib/libcrypto/ec/ec_lib.c | 4 ++-- src/lib/libcrypto/ec/ecp_smpl.c | 8 +++----- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/lib/libcrypto/ec') diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index ca49c7676e..6ab4d3c9a4 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.20 2018/11/06 02:14:39 tb Exp $ */ +/* $OpenBSD: ec_key.c,v 1.21 2018/11/06 07:02:33 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -65,6 +65,7 @@ #include +#include "bn_lcl.h" #include "ec_lcl.h" #include @@ -231,10 +232,8 @@ EC_KEY_generate_key(EC_KEY *eckey) if (!EC_GROUP_get_order(eckey->group, order, ctx)) goto err; - do - if (!BN_rand_range(priv_key, order)) - goto err; - while (BN_is_zero(priv_key)); + if (!bn_rand_interval(priv_key, BN_value_one(), order)) + goto err; if (pub_key == NULL) { if ((pub_key = EC_POINT_new(eckey->group)) == NULL) diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index bf2f652fc7..e5d9620a00 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.30 2018/11/05 20:18:21 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.31 2018/11/06 07:02:33 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -547,7 +547,7 @@ ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx) { if (group->meth->blind_coordinates == NULL) return 1; - + return group->meth->blind_coordinates(group, p, ctx); } diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index e379a74fb1..c64c41130a 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.27 2018/11/06 06:59:25 tb Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.28 2018/11/06 07:02:33 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -1434,10 +1434,8 @@ ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx) goto err; /* Generate lambda in [1, group->field - 1] */ - do { - if (!BN_rand_range(lambda, &group->field)) - goto err; - } while (BN_is_zero(lambda)); + if (!bn_rand_interval(lambda, BN_value_one(), &group->field)) + goto err; if (group->meth->field_encode != NULL && !group->meth->field_encode(group, lambda, lambda, ctx)) -- cgit v1.2.3-55-g6feb