aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/dh
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-04-30 21:37:06 -0400
committerRich Salz <rsalz@openssl.org>2015-04-30 21:37:06 -0400
commit23a1d5e97cd543d2b8e1b01dbf0f619b2e5ce540 (patch)
tree2d9372864fc2b34939d21b3706768ec225c9548f /crypto/dh
parent34166d41892643a36ad2d1f53cc0025e2edc2a39 (diff)
downloadopenssl-23a1d5e97cd543d2b8e1b01dbf0f619b2e5ce540.tar.gz
free NULL cleanup 7
This gets BN_.*free: BN_BLINDING_free BN_CTX_free BN_FLG_FREE BN_GENCB_free BN_MONT_CTX_free BN_RECP_CTX_free BN_clear_free BN_free BUF_MEM_free Also fix a call to DSA_SIG_free to ccgost engine and remove some #ifdef'd dead code in engines/e_ubsec. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh_ameth.c3
-rw-r--r--crypto/dh/dh_check.c3
-rw-r--r--crypto/dh/dh_key.c13
-rw-r--r--crypto/dh/dh_lib.c21
-rw-r--r--crypto/dh/dh_pmeth.c9
5 files changed, 17 insertions, 32 deletions
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c
index f3abe0774f..6a4223c167 100644
--- a/crypto/dh/dh_ameth.c
+++ b/crypto/dh/dh_ameth.c
@@ -463,8 +463,7 @@ static int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src)
return 0;
} else
a = NULL;
- if (*dst)
- BN_free(*dst);
+ BN_free(*dst);
*dst = a;
return 1;
}
diff --git a/crypto/dh/dh_check.c b/crypto/dh/dh_check.c
index 7a8e063fc8..b8b3890d9e 100644
--- a/crypto/dh/dh_check.c
+++ b/crypto/dh/dh_check.c
@@ -159,7 +159,6 @@ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
ok = 1;
err:
- if (q != NULL)
- BN_free(q);
+ BN_free(q);
return (ok);
}
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index 9e2c8b26e6..e2f48b142d 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -172,12 +172,10 @@ static int generate_key(DH *dh)
prk = priv_key;
if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont)) {
- if (local_prk)
- BN_free(local_prk);
+ BN_free(local_prk);
goto err;
}
- if (local_prk)
- BN_free(local_prk);
+ BN_free(local_prk);
}
dh->pub_key = pub_key;
@@ -187,9 +185,9 @@ static int generate_key(DH *dh)
if (ok != 1)
DHerr(DH_F_GENERATE_KEY, ERR_R_BN_LIB);
- if ((pub_key != NULL) && (dh->pub_key == NULL))
+ if (pub_key != dh->pub_key)
BN_free(pub_key);
- if ((priv_key != NULL) && (dh->priv_key == NULL))
+ if (priv_key != dh->priv_key)
BN_free(priv_key);
BN_CTX_free(ctx);
return (ok);
@@ -273,7 +271,6 @@ static int dh_init(DH *dh)
static int dh_finish(DH *dh)
{
- if (dh->method_mont_p)
- BN_MONT_CTX_free(dh->method_mont_p);
+ BN_MONT_CTX_free(dh->method_mont_p);
return (1);
}
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 68a54a6fd2..74bad4dfcf 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -194,22 +194,15 @@ void DH_free(DH *r)
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
- if (r->p != NULL)
- BN_clear_free(r->p);
- if (r->g != NULL)
- BN_clear_free(r->g);
- if (r->q != NULL)
- BN_clear_free(r->q);
- if (r->j != NULL)
- BN_clear_free(r->j);
+ BN_clear_free(r->p);
+ BN_clear_free(r->g);
+ BN_clear_free(r->q);
+ BN_clear_free(r->j);
if (r->seed)
OPENSSL_free(r->seed);
- if (r->counter != NULL)
- BN_clear_free(r->counter);
- if (r->pub_key != NULL)
- BN_clear_free(r->pub_key);
- if (r->priv_key != NULL)
- BN_clear_free(r->priv_key);
+ BN_clear_free(r->counter);
+ BN_clear_free(r->pub_key);
+ BN_clear_free(r->priv_key);
OPENSSL_free(r);
}
diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
index e3ebc0201d..069b855aa0 100644
--- a/crypto/dh/dh_pmeth.c
+++ b/crypto/dh/dh_pmeth.c
@@ -383,8 +383,7 @@ static int pkey_dh_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
if (dctx->use_dsa) {
DSA *dsa_dh;
dsa_dh = dsa_dh_generate(dctx, pcb);
- if (pcb)
- BN_GENCB_free(pcb);
+ BN_GENCB_free(pcb);
if (!dsa_dh)
return 0;
dh = DSA_dup_DH(dsa_dh);
@@ -397,14 +396,12 @@ static int pkey_dh_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
#endif
dh = DH_new();
if (!dh) {
- if (pcb)
- BN_GENCB_free(pcb);
+ BN_GENCB_free(pcb);
return 0;
}
ret = DH_generate_parameters_ex(dh,
dctx->prime_len, dctx->generator, pcb);
- if (pcb)
- BN_GENCB_free(pcb);
+ BN_GENCB_free(pcb);
if (ret)
EVP_PKEY_assign_DH(pkey, dh);
else