summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ec
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-12-29 18:48:26 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-12-29 18:48:26 +0000
commit937d6f96c7aa70c9b5d07aa0d93dd9b232364740 (patch)
treed288a839ba4140792f26659b52c89781d778ab40 /lib/libcrypto/ec
parenteed9fb25170f81e8f1b8e18f9611b4ff38c96b85 (diff)
Clean up old_ec_priv_decode()
As per usual. Stylistic adjustments and missing error check. ok jsing
Diffstat (limited to 'lib/libcrypto/ec')
-rw-r--r--lib/libcrypto/ec/ec_ameth.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c
index e6fe8bd3702..660e5bffd1b 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.48 2023/12/29 18:47:47 tb Exp $ */
+/* $OpenBSD: ec_ameth.c,v 1.49 2023/12/29 18:48:25 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@@ -599,16 +599,23 @@ eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent,
}
static int
-old_ec_priv_decode(EVP_PKEY *pkey,
- const unsigned char **pder, int derlen)
+old_ec_priv_decode(EVP_PKEY *pkey, const unsigned char **priv, int priv_len)
{
- EC_KEY *ec;
- if (!(ec = d2i_ECPrivateKey(NULL, pder, derlen))) {
- ECerror(EC_R_DECODE_ERROR);
- return 0;
- }
- EVP_PKEY_assign_EC_KEY(pkey, ec);
- return 1;
+ EC_KEY *eckey;
+ int ret = 0;
+
+ if ((eckey = d2i_ECPrivateKey(NULL, priv, priv_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