summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-12-28 22:12:37 +0000
committertb <>2023-12-28 22:12:37 +0000
commit8b997a41c9dd32b50a2349c56bffc17de6c5b753 (patch)
tree013a1bed22ac644e3b56d85fad3a818784f7fb78 /src/lib
parent93ff5806b4e95e427cc6b51725af8512138ee762 (diff)
downloadopenbsd-8b997a41c9dd32b50a2349c56bffc17de6c5b753.tar.gz
openbsd-8b997a41c9dd32b50a2349c56bffc17de6c5b753.tar.bz2
openbsd-8b997a41c9dd32b50a2349c56bffc17de6c5b753.zip
Clean up pkey_ec_paramgen()
This is basically the same as the dh and dsa version, except it's different because it's EC. Single exit, uniform error checking. "Plug" another leak. With this I earned another shining turd for my collection. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 0f4f00bc44..16fc07642a 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.20 2023/12/28 22:09:10 tb Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.21 2023/12/28 22:12:37 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -458,18 +458,25 @@ pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
458 EC_KEY *ec = NULL; 458 EC_KEY *ec = NULL;
459 EC_PKEY_CTX *dctx = ctx->data; 459 EC_PKEY_CTX *dctx = ctx->data;
460 int ret = 0; 460 int ret = 0;
461
461 if (dctx->gen_group == NULL) { 462 if (dctx->gen_group == NULL) {
462 ECerror(EC_R_NO_PARAMETERS_SET); 463 ECerror(EC_R_NO_PARAMETERS_SET);
463 return 0; 464 goto err;
464 } 465 }
465 ec = EC_KEY_new(); 466
466 if (!ec) 467 if ((ec = EC_KEY_new()) == NULL)
467 return 0; 468 goto err;
468 ret = EC_KEY_set_group(ec, dctx->gen_group); 469 if (!EC_KEY_set_group(ec, dctx->gen_group))
469 if (ret) 470 goto err;
470 EVP_PKEY_assign_EC_KEY(pkey, ec); 471 if (!EVP_PKEY_assign_EC_KEY(pkey, ec))
471 else 472 goto err;
472 EC_KEY_free(ec); 473 ec = NULL;
474
475 ret = 1;
476
477 err:
478 EC_KEY_free(ec);
479
473 return ret; 480 return ret;
474} 481}
475 482