summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ec
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-11-05 23:54:28 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-11-05 23:54:28 +0000
commit79fa2330665cf15454a202b9ca7458ffef077ad1 (patch)
treeebb38d6b6f3d5dc9e2b72fe847d6e06f1de49015 /lib/libcrypto/ec
parentdb0b200e51b789d8d80e7ff70f5ca8a9b29441d4 (diff)
Make use of bn_rand_interval() where appropriate.
ok beck jsing
Diffstat (limited to 'lib/libcrypto/ec')
-rw-r--r--lib/libcrypto/ec/ec_key.c9
-rw-r--r--lib/libcrypto/ec/ecp_smpl.c8
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c
index 966ebab4a55..8c6f3186ca9 100644
--- a/lib/libcrypto/ec/ec_key.c
+++ b/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_key.c,v 1.18 2018/11/05 23:50:05 tb Exp $ */
+/* $OpenBSD: ec_key.c,v 1.19 2018/11/05 23:54:27 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -65,6 +65,7 @@
#include <openssl/opensslconf.h>
+#include "bn_lcl.h"
#include "ec_lcl.h"
#include <openssl/err.h>
@@ -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/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c
index fe935251d9d..96c1e8a2781 100644
--- a/lib/libcrypto/ec/ecp_smpl.c
+++ b/lib/libcrypto/ec/ecp_smpl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecp_smpl.c,v 1.23 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ecp_smpl.c,v 1.24 2018/11/05 23:54:27 tb Exp $ */
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
* 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))