summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/dh/dh_key.c
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2001-06-22 00:02:45 +0000
committerbeck <beck@openbsd.org>2001-06-22 00:02:45 +0000
commitce6fc0900b2b4e5edea1b1b8e032cab822e464e9 (patch)
treeb11b933beb98ff4d5fb927f3ad0fdef1f485128d /lib/libcrypto/dh/dh_key.c
parentBuild and install Heimdal infofile. (diff)
downloadwireguard-openbsd-ce6fc0900b2b4e5edea1b1b8e032cab822e464e9.tar.xz
wireguard-openbsd-ce6fc0900b2b4e5edea1b1b8e032cab822e464e9.zip
openssl-engine-0.9.6a merge
Diffstat (limited to 'lib/libcrypto/dh/dh_key.c')
-rw-r--r--lib/libcrypto/dh/dh_key.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/libcrypto/dh/dh_key.c b/lib/libcrypto/dh/dh_key.c
index 6915d79dcc2..22b087b778f 100644
--- a/lib/libcrypto/dh/dh_key.c
+++ b/lib/libcrypto/dh/dh_key.c
@@ -100,7 +100,6 @@ DH_METHOD *DH_OpenSSL(void)
static int generate_key(DH *dh)
{
int ok=0;
- unsigned int i;
BN_CTX ctx;
BN_MONT_CTX *mont;
BIGNUM *pub_key=NULL,*priv_key=NULL;
@@ -109,15 +108,11 @@ static int generate_key(DH *dh)
if (dh->priv_key == NULL)
{
- i=dh->length;
- if (i == 0)
- {
- /* Make the number p-1 bits long */
- i=BN_num_bits(dh->p)-1;
- }
priv_key=BN_new();
if (priv_key == NULL) goto err;
- if (!BN_rand(priv_key,i,0,0)) goto err;
+ do
+ if (!BN_rand_range(priv_key, dh->p)) goto err;
+ while (BN_is_zero(priv_key));
}
else
priv_key=dh->priv_key;