From: tb Date: Fri, 11 Oct 2024 06:19:52 +0000 (+0000) Subject: Simplify ec_asn1_group2pkparameters() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=87a99c53869f6743a9de19acd2d91e326e3105b0;p=openbsd Simplify ec_asn1_group2pkparameters() The parameters argument is always NULL, so we can simplify this helper accordingly. ok jsing --- diff --git a/lib/libcrypto/ec/ec_asn1.c b/lib/libcrypto/ec/ec_asn1.c index d471d2dff4b..61216df26f9 100644 --- a/lib/libcrypto/ec/ec_asn1.c +++ b/lib/libcrypto/ec/ec_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1.c,v 1.59 2024/10/11 06:18:40 tb Exp $ */ +/* $OpenBSD: ec_asn1.c,v 1.60 2024/10/11 06:19:52 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -791,21 +791,14 @@ ec_asn1_group2parameters(const EC_GROUP *group, ECPARAMETERS *param) } ECPKPARAMETERS * -ec_asn1_group2pkparameters(const EC_GROUP *group, ECPKPARAMETERS *params) +ec_asn1_group2pkparameters(const EC_GROUP *group) { int ok = 1, tmp; - ECPKPARAMETERS *ret = params; + ECPKPARAMETERS *ret; - if (ret == NULL) { - if ((ret = ECPKPARAMETERS_new()) == NULL) { - ECerror(ERR_R_MALLOC_FAILURE); - return NULL; - } - } else { - if (ret->type == 0 && ret->value.named_curve) - ASN1_OBJECT_free(ret->value.named_curve); - else if (ret->type == 1 && ret->value.parameters) - ECPARAMETERS_free(ret->value.parameters); + if ((ret = ECPKPARAMETERS_new()) == NULL) { + ECerror(ERR_R_MALLOC_FAILURE); + return NULL; } if (EC_GROUP_get_asn1_flag(group)) { @@ -1039,7 +1032,7 @@ i2d_ECPKParameters(const EC_GROUP *group, unsigned char **out_der) ECPKPARAMETERS *parameters; int ret = 0; - if ((parameters = ec_asn1_group2pkparameters(group, NULL)) == NULL) { + if ((parameters = ec_asn1_group2pkparameters(group)) == NULL) { ECerror(EC_R_GROUP2PKPARAMETERS_FAILURE); goto err; } @@ -1184,7 +1177,7 @@ i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) if (!(a->enc_flag & EC_PKEY_NO_PARAMETERS)) { ECPKPARAMETERS *parameters; - if ((parameters = ec_asn1_group2pkparameters(a->group, NULL)) == NULL) { + if ((parameters = ec_asn1_group2pkparameters(a->group)) == NULL) { ECerror(ERR_R_EC_LIB); goto err; }