end:
BIO_free(in);
BIO_free_all(out);
- if (eckey)
- EC_KEY_free(eckey);
+ EC_KEY_free(eckey);
if (passin)
OPENSSL_free(passin);
if (passout)
OPENSSL_free(buffer);
BIO_free(in);
BIO_free_all(out);
- if (group != NULL)
- EC_GROUP_free(group);
+ EC_GROUP_free(group);
apps_shutdown();
OPENSSL_EXIT(ret);
}
#ifndef OPENSSL_NO_EC
for (i = 0; i < EC_NUM; i++)
- if (ecdsa[i] != NULL)
- EC_KEY_free(ecdsa[i]);
+ EC_KEY_free(ecdsa[i]);
for (i = 0; i < EC_NUM; i++) {
- if (ecdh_a[i] != NULL)
- EC_KEY_free(ecdh_a[i]);
- if (ecdh_b[i] != NULL)
- EC_KEY_free(ecdh_b[i]);
+ EC_KEY_free(ecdh_a[i]);
+ EC_KEY_free(ecdh_b[i]);
}
#endif
ret = 1;
err:
- if (p)
- EC_POINT_free(p);
- if (acc)
- EC_POINT_free(acc);
+ EC_POINT_free(p);
+ EC_POINT_free(acc);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
return ret;
return eckey;
ecerr:
- if (eckey)
- EC_KEY_free(eckey);
+ EC_KEY_free(eckey);
return NULL;
}
return 1;
ecerr:
- if (eckey)
- EC_KEY_free(eckey);
+ EC_KEY_free(eckey);
return 0;
}
ecliberr:
ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB);
ecerr:
- if (eckey)
- EC_KEY_free(eckey);
+ EC_KEY_free(eckey);
return 0;
}
if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)
rv = 1;
err:
- if (ecpeer)
- EC_KEY_free(ecpeer);
+ EC_KEY_free(ecpeer);
if (pkpeer)
EVP_PKEY_free(pkpeer);
return rv;
ok = 1;
- err:if (!ok) {
- if (ret)
- EC_GROUP_clear_free(ret);
+ err:
+ if (!ok) {
+ EC_GROUP_clear_free(ret);
ret = NULL;
}
BN_free(a);
if (b)
BN_free(b);
- if (point)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return (ret);
}
return NULL;
}
- if (a && *a)
+ if (a) {
EC_GROUP_clear_free(*a);
- if (a)
*a = group;
+ }
ECPKPARAMETERS_free(params);
return (group);
ret = *a;
if (priv_key->parameters) {
- if (ret->group)
- EC_GROUP_clear_free(ret->group);
+ EC_GROUP_clear_free(ret->group);
ret->group = ec_asn1_pkparameters2group(priv_key->parameters);
}
goto err;
}
- if (ret->pub_key)
- EC_POINT_clear_free(ret->pub_key);
+ EC_POINT_clear_free(ret->pub_key);
ret->pub_key = EC_POINT_new(ret->group);
if (ret->pub_key == NULL) {
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
ok = 1;
err:
if (!ok) {
- if (ret && (a == NULL || *a != ret))
+ if (a == NULL || *a != ret)
EC_KEY_free(ret);
ret = NULL;
}
BN_CTX_end(ctx);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
- if (point)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return ret;
}
EC_GROUP_free(group);
group = NULL;
}
- if (P)
- EC_POINT_free(P);
+ EC_POINT_free(P);
if (ctx)
BN_CTX_free(ctx);
if (p)
}
#endif
- if (r->group != NULL)
- EC_GROUP_free(r->group);
- if (r->pub_key != NULL)
- EC_POINT_free(r->pub_key);
+ EC_GROUP_free(r->group);
+ EC_POINT_free(r->pub_key);
if (r->priv_key != NULL)
BN_clear_free(r->priv_key);
if (src->group) {
const EC_METHOD *meth = EC_GROUP_method_of(src->group);
/* clear the old group */
- if (dest->group)
- EC_GROUP_free(dest->group);
+ EC_GROUP_free(dest->group);
dest->group = EC_GROUP_new(meth);
if (dest->group == NULL)
return NULL;
}
/* copy the public key */
if (src->pub_key && src->group) {
- if (dest->pub_key)
- EC_POINT_free(dest->pub_key);
+ EC_POINT_free(dest->pub_key);
dest->pub_key = EC_POINT_new(src->group);
if (dest->pub_key == NULL)
return NULL;
err:
if (order)
BN_free(order);
- if (pub_key != NULL && eckey->pub_key == NULL)
+ if (eckey->pub_key == NULL)
EC_POINT_free(pub_key);
if (priv_key != NULL && eckey->priv_key == NULL)
BN_free(priv_key);
err:
if (ctx != NULL)
BN_CTX_free(ctx);
- if (point != NULL)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return (ok);
}
err:
if (ctx)
BN_CTX_free(ctx);
- if (point)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return ok;
}
int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)
{
- if (key->group != NULL)
- EC_GROUP_free(key->group);
+ EC_GROUP_free(key->group);
key->group = EC_GROUP_dup(group);
return (key->group == NULL) ? 0 : 1;
}
int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key)
{
- if (key->pub_key != NULL)
- EC_POINT_free(key->pub_key);
+ EC_POINT_free(key->pub_key);
key->pub_key = EC_POINT_dup(pub_key, key->group);
return (key->pub_key == NULL) ? 0 : 1;
}
if (group->mont_data)
BN_MONT_CTX_free(group->mont_data);
- if (group->generator != NULL)
- EC_POINT_free(group->generator);
+ EC_POINT_free(group->generator);
BN_free(group->order);
BN_free(group->cofactor);
if (group->mont_data)
BN_MONT_CTX_free(group->mont_data);
- if (group->generator != NULL)
- EC_POINT_clear_free(group->generator);
+ EC_POINT_clear_free(group->generator);
BN_clear_free(group->order);
BN_clear_free(group->cofactor);
return 0;
} else {
/* src->generator == NULL */
- if (dest->generator != NULL) {
- EC_POINT_clear_free(dest->generator);
- dest->generator = NULL;
- }
+ EC_POINT_clear_free(dest->generator);
+ dest->generator = NULL;
}
if (!BN_copy(dest->order, src->order))
err:
if (!ok) {
- if (t)
- EC_GROUP_free(t);
+ EC_GROUP_free(t);
return NULL;
- } else
+ }
return t;
}
if (!r) {
EC_POINT_free(t);
return NULL;
- } else
- return t;
+ }
+ return t;
}
const EC_METHOD *EC_POINT_method_of(const EC_POINT *point)
err:
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
- if (tmp != NULL)
- EC_POINT_free(tmp);
+ EC_POINT_free(tmp);
if (wsize != NULL)
OPENSSL_free(wsize);
if (wNAF_len != NULL)
EC_POINT_free(*p);
OPENSSL_free(points);
}
- if (tmp_point)
- EC_POINT_free(tmp_point);
- if (base)
- EC_POINT_free(base);
+ EC_POINT_free(tmp_point);
+ EC_POINT_free(base);
return ret;
}
{
EC_PKEY_CTX *dctx = ctx->data;
if (dctx) {
- if (dctx->gen_group)
- EC_GROUP_free(dctx->gen_group);
- if (dctx->co_key)
- EC_KEY_free(dctx->co_key);
+ EC_GROUP_free(dctx->gen_group);
+ EC_KEY_free(dctx->co_key);
if (dctx->kdf_ukm)
OPENSSL_free(dctx->kdf_ukm);
OPENSSL_free(dctx);
ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_CURVE);
return 0;
}
- if (dctx->gen_group)
- EC_GROUP_free(dctx->gen_group);
+ EC_GROUP_free(dctx->gen_group);
dctx->gen_group = group;
return 1;
EC_KEY_set_flags(dctx->co_key, EC_FLAG_COFACTOR_ECDH);
else
EC_KEY_clear_flags(dctx->co_key, EC_FLAG_COFACTOR_ECDH);
- } else if (dctx->co_key) {
+ } else {
EC_KEY_free(dctx->co_key);
dctx->co_key = NULL;
}
ret = point;
if (!EC_POINT_oct2point(group, ret, buf, buf_len, ctx)) {
- if (point == NULL)
+ if (ret != point)
EC_POINT_clear_free(ret);
OPENSSL_free(buf);
return NULL;
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (secrets != NULL)
pre = NULL;
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (pre)
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (secrets != NULL)
pre = NULL;
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (pre)
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (secrets != NULL)
pre = NULL;
err:
BN_CTX_end(ctx);
- if (generator != NULL)
- EC_POINT_free(generator);
+ EC_POINT_free(generator);
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (pre)
ecp_nistz256_pre_comp_free(pre_comp);
if (precomp_storage)
OPENSSL_free(precomp_storage);
- if (P)
- EC_POINT_free(P);
- if (T)
- EC_POINT_free(T);
+ EC_POINT_free(P);
+ EC_POINT_free(T);
return ret;
}
BN_free(y);
BN_free(z);
- if (P_160)
- EC_GROUP_free(P_160);
- if (P_192)
- EC_GROUP_free(P_192);
- if (P_224)
- EC_GROUP_free(P_224);
- if (P_256)
- EC_GROUP_free(P_256);
- if (P_384)
- EC_GROUP_free(P_384);
- if (P_521)
- EC_GROUP_free(P_521);
+ EC_GROUP_free(P_160);
+ EC_GROUP_free(P_192);
+ EC_GROUP_free(P_224);
+ EC_GROUP_free(P_256);
+ EC_GROUP_free(P_384);
+ EC_GROUP_free(P_521);
}
BN_free(z);
BN_free(cof);
- if (C2_K163)
- EC_GROUP_free(C2_K163);
- if (C2_B163)
- EC_GROUP_free(C2_B163);
- if (C2_K233)
- EC_GROUP_free(C2_K233);
- if (C2_B233)
- EC_GROUP_free(C2_B233);
- if (C2_K283)
- EC_GROUP_free(C2_K283);
- if (C2_B283)
- EC_GROUP_free(C2_B283);
- if (C2_K409)
- EC_GROUP_free(C2_K409);
- if (C2_B409)
- EC_GROUP_free(C2_B409);
- if (C2_K571)
- EC_GROUP_free(C2_K571);
- if (C2_B571)
- EC_GROUP_free(C2_B571);
+ EC_GROUP_free(C2_K163);
+ EC_GROUP_free(C2_B163);
+ EC_GROUP_free(C2_K233);
+ EC_GROUP_free(C2_B233);
+ EC_GROUP_free(C2_K283);
+ EC_GROUP_free(C2_B283);
+ EC_GROUP_free(C2_K409);
+ EC_GROUP_free(C2_B409);
+ EC_GROUP_free(C2_K571);
+ EC_GROUP_free(C2_B571);
}
# endif
BN_free(x_b);
if (y_b)
BN_free(y_b);
- if (b)
- EC_KEY_free(b);
- if (a)
- EC_KEY_free(a);
+ EC_KEY_free(b);
+ EC_KEY_free(a);
return (ret);
}
err:
if (priv)
BN_clear_free(priv);
- if (pub)
- EC_POINT_free(pub);
+ EC_POINT_free(pub);
if (ok)
return k;
- else if (k)
- EC_KEY_free(k);
+ EC_KEY_free(k);
return NULL;
}
goto err;
rv = 1;
err:
- if (key1)
- EC_KEY_free(key1);
- if (key2)
- EC_KEY_free(key2);
+ EC_KEY_free(key1);
+ EC_KEY_free(key2);
if (Ztmp)
OPENSSL_free(Ztmp);
if (rv)
}
err:
- if (tmp)
- EC_POINT_free(tmp);
+ EC_POINT_free(tmp);
if (ctx)
BN_CTX_end(ctx);
if (ctx)
x962_int_err:
if (!ret)
BIO_printf(out, " failed\n");
- if (key)
- EC_KEY_free(key);
+ EC_KEY_free(key);
if (signature)
ECDSA_SIG_free(signature);
if (r)
goto builtin_err;
EC_GROUP_free(group);
degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
- if (degree < 160)
+ if (degree < 160) {
/* drop the curve */
- {
EC_KEY_free(eckey);
eckey = NULL;
continue;
ret = 1;
builtin_err:
- if (eckey)
- EC_KEY_free(eckey);
- if (wrong_eckey)
- EC_KEY_free(wrong_eckey);
+ EC_KEY_free(eckey);
+ EC_KEY_free(wrong_eckey);
if (ecdsa_sig)
ECDSA_SIG_free(ecdsa_sig);
if (signature)
BN_CTX_free(ctx);
if (order != NULL)
BN_free(order);
- if (tmp_point != NULL)
- EC_POINT_free(tmp_point);
+ EC_POINT_free(tmp_point);
if (X)
BN_clear_free(X);
return (ret);
err:
BN_CTX_end(ctx);
BN_CTX_free(ctx);
- if (point)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return ret;
}
be constructed.
EC_GROUP_free frees the memory associated with the EC_GROUP.
+If B<group> is NULL nothing is done.
EC_GROUP_clear_free destroys any sensitive data held within the EC_GROUP and then frees its memory.
+If B<group> is NULL nothing is done.
=head1 RETURN VALUES
Calling EC_KEY_free decrements the reference count for the EC_KEY object, and if it has dropped to zero then frees the memory associated
with it.
+If B<key> is NULL nothing is done.
EC_KEY_copy copies the contents of the EC_KEY in B<src> into B<dest>.
object that the point relates to.
EC_POINT_free frees the memory associated with the EC_POINT.
+if B<point> is NULL nothing is done.
EC_POINT_clear_free destroys any sensitive data held within the EC_POINT and then frees its memory.
+if B<point> is NULL nothing is done.
EC_POINT_copy copies the point B<src> into B<dst>. Both B<src> and B<dst> must use the same EC_METHOD.
static void pkey_free_gost01(EVP_PKEY *key)
{
- if (key->pkey.ec) {
- EC_KEY_free(key->pkey.ec);
- }
+ EC_KEY_free(key->pkey.ec);
}
/* ------------------ private key functions -----------------------------*/
s->session->sess_cert->peer_dh_tmp = NULL;
#endif
#ifndef OPENSSL_NO_EC
- if (s->session->sess_cert->peer_ecdh_tmp) {
- EC_KEY_free(s->session->sess_cert->peer_ecdh_tmp);
- s->session->sess_cert->peer_ecdh_tmp = NULL;
- }
+ EC_KEY_free(s->session->sess_cert->peer_ecdh_tmp);
+ s->session->sess_cert->peer_ecdh_tmp = NULL;
#endif
} else {
s->session->sess_cert = ssl_sess_cert_new();
#ifndef OPENSSL_NO_EC
BN_CTX_free(bn_ctx);
EC_POINT_free(srvr_ecpoint);
- if (ecdh != NULL)
- EC_KEY_free(ecdh);
+ EC_KEY_free(ecdh);
#endif
EVP_MD_CTX_cleanup(&md_ctx);
return (-1);
BN_CTX_free(bn_ctx);
if (encodedPoint != NULL)
OPENSSL_free(encodedPoint);
- if (clnt_ecdh != NULL)
- EC_KEY_free(clnt_ecdh);
+ EC_KEY_free(clnt_ecdh);
EVP_PKEY_free(srvr_pub_pkey);
}
#endif /* !OPENSSL_NO_EC */
BN_CTX_free(bn_ctx);
if (encodedPoint != NULL)
OPENSSL_free(encodedPoint);
- if (clnt_ecdh != NULL)
- EC_KEY_free(clnt_ecdh);
+ EC_KEY_free(clnt_ecdh);
EVP_PKEY_free(srvr_pub_pkey);
#endif
return (-1);
DH_free(s->s3->tmp.dh);
#endif
#ifndef OPENSSL_NO_EC
- if (s->s3->tmp.ecdh != NULL)
- EC_KEY_free(s->s3->tmp.ecdh);
+ EC_KEY_free(s->s3->tmp.ecdh);
#endif
if (s->s3->tmp.ca_names != NULL)
s->s3->tmp.dh = NULL;
#endif
#ifndef OPENSSL_NO_EC
- if (s->s3->tmp.ecdh != NULL) {
- EC_KEY_free(s->s3->tmp.ecdh);
- s->s3->tmp.ecdh = NULL;
- }
+ EC_KEY_free(s->s3->tmp.ecdh);
+ s->s3->tmp.ecdh = NULL;
#endif
#ifndef OPENSSL_NO_TLSEXT
# ifndef OPENSSL_NO_EC
return (ret);
}
}
- if (s->cert->ecdh_tmp != NULL)
- EC_KEY_free(s->cert->ecdh_tmp);
+ EC_KEY_free(s->cert->ecdh_tmp);
s->cert->ecdh_tmp = ecdh;
ret = 1;
}
}
}
- if (cert->ecdh_tmp != NULL) {
- EC_KEY_free(cert->ecdh_tmp);
- }
+ EC_KEY_free(cert->ecdh_tmp);
cert->ecdh_tmp = ecdh;
return 1;
}
#ifndef OPENSSL_NO_EC
EVP_PKEY_free(clnt_pub_pkey);
EC_POINT_free(clnt_ecpoint);
- if (srvr_ecdh != NULL)
- EC_KEY_free(srvr_ecdh);
+ EC_KEY_free(srvr_ecdh);
BN_CTX_free(bn_ctx);
#endif
return (-1);
DH_free(c->dh_tmp);
#endif
#ifndef OPENSSL_NO_EC
- if (c->ecdh_tmp)
- EC_KEY_free(c->ecdh_tmp);
+ EC_KEY_free(c->ecdh_tmp);
#endif
ssl_cert_clear_certs(c);
DH_free(sc->peer_dh_tmp);
#endif
#ifndef OPENSSL_NO_EC
- if (sc->peer_ecdh_tmp != NULL)
- EC_KEY_free(sc->peer_ecdh_tmp);
+ EC_KEY_free(sc->peer_ecdh_tmp);
#endif
OPENSSL_free(sc);