From: tb Date: Fri, 29 Dec 2023 18:47:47 +0000 (+0000) Subject: Clean up eckey_param_decode() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=976ea5e2c408889bebccdb346415a750a3f86d83;p=openbsd Clean up eckey_param_decode() This aligns eckey's parameter decoding routine with the one of other cipher abstractions: better variable names, single exit and add missing check for EVP_PKEY_assign_EC_KEY(). ok jsing --- diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c index 2b3b3db63d1..e6fe8bd3702 100644 --- a/lib/libcrypto/ec/ec_ameth.c +++ b/lib/libcrypto/ec/ec_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_ameth.c,v 1.47 2023/12/29 18:46:24 tb Exp $ */ +/* $OpenBSD: ec_ameth.c,v 1.48 2023/12/29 18:47:47 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -551,16 +551,23 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) } static int -eckey_param_decode(EVP_PKEY *pkey, - const unsigned char **pder, int derlen) +eckey_param_decode(EVP_PKEY *pkey, const unsigned char **param, int param_len) { EC_KEY *eckey; - if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) { - ECerror(ERR_R_EC_LIB); - return 0; - } - EVP_PKEY_assign_EC_KEY(pkey, eckey); - return 1; + int ret = 0; + + if ((eckey = d2i_ECParameters(NULL, param, param_len)) == NULL) + goto err; + if (!EVP_PKEY_assign_EC_KEY(pkey, eckey)) + goto err; + eckey = NULL; + + ret = 1; + + err: + EC_KEY_free(eckey); + + return ret; } static int