aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/ec/ec_key.c')
-rw-r--r--crypto/ec/ec_key.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index 96d489767b..a74ccf70f2 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -120,10 +120,8 @@ void EC_KEY_free(EC_KEY *r)
}
#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);
@@ -146,8 +144,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
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;
@@ -156,8 +153,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
}
/* 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;
@@ -274,7 +270,7 @@ int EC_KEY_generate_key(EC_KEY *eckey)
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);
@@ -347,8 +343,7 @@ int EC_KEY_check_key(const EC_KEY *eckey)
err:
if (ctx != NULL)
BN_CTX_free(ctx);
- if (point != NULL)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return (ok);
}
@@ -422,8 +417,7 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
err:
if (ctx)
BN_CTX_free(ctx);
- if (point)
- EC_POINT_free(point);
+ EC_POINT_free(point);
return ok;
}
@@ -435,8 +429,7 @@ const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
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;
}
@@ -461,8 +454,7 @@ const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key)
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;
}