diff options
author | 2018-11-09 23:49:18 +0000 | |
---|---|---|
committer | 2018-11-09 23:49:18 +0000 | |
commit | 4435d402f0c8254b0708300bca81412b3f2747ec (patch) | |
tree | fcb6c059077650f252eedddbb5b8c1ff45a6feaa | |
parent | Initialize priv_key and pub_key on first use instead of at the top. (diff) | |
download | wireguard-openbsd-4435d402f0c8254b0708300bca81412b3f2747ec.tar.xz wireguard-openbsd-4435d402f0c8254b0708300bca81412b3f2747ec.zip |
Initialize priv_key and pub_key on first use instead of at the top.
While there, eliminate a flag that was only used once.
ok beck jsing mestre
-rw-r--r-- | lib/libcrypto/dh/dh_key.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/libcrypto/dh/dh_key.c b/lib/libcrypto/dh/dh_key.c index 790b7061348..694200a7c48 100644 --- a/lib/libcrypto/dh/dh_key.c +++ b/lib/libcrypto/dh/dh_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_key.c,v 1.34 2018/11/06 07:02:33 tb Exp $ */ +/* $OpenBSD: dh_key.c,v 1.35 2018/11/09 23:49:18 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,11 +102,10 @@ static int generate_key(DH *dh) { int ok = 0; - int generate_new_key = 0; unsigned l; BN_CTX *ctx; BN_MONT_CTX *mont = NULL; - BIGNUM *pub_key = dh->pub_key, *priv_key = dh->priv_key, *two = NULL; + BIGNUM *pub_key = NULL, *priv_key = NULL, *two = NULL; if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) { DHerror(DH_R_MODULUS_TOO_LARGE); @@ -117,10 +116,9 @@ generate_key(DH *dh) if (ctx == NULL) goto err; - if (priv_key == NULL) { + if ((priv_key = dh->priv_key) == NULL) { if ((priv_key = BN_new()) == NULL) goto err; - generate_new_key = 1; } if (pub_key == NULL) { @@ -135,7 +133,7 @@ generate_key(DH *dh) goto err; } - if (generate_new_key) { + if (dh->priv_key == NULL) { if (dh->q) { if ((two = BN_new()) == NULL) goto err; |