From 98f7a26186887ba45c08f5491bb6ef3a594837bd Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 30 Nov 2024 16:34:34 +0000 Subject: Get BNs Z coordinates from the BN_CTX While there likely won't be enough BNs already available in the ctx, and thus it won't greatly reduce the amount of allocated BNs, it simplifies the exit path quite a bit. review feedback from jsing --- src/lib/libcrypto/ec/ecp_methods.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index a4713bdcdc..b394206aea 100644 --- a/src/lib/libcrypto/ec/ecp_methods.c +++ b/src/lib/libcrypto/ec/ecp_methods.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_methods.c,v 1.10 2024/11/30 16:18:01 tb Exp $ */ +/* $OpenBSD: ecp_methods.c,v 1.11 2024/11/30 16:34:34 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -1141,7 +1141,7 @@ ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], if ((prod_Z = calloc(num, sizeof *prod_Z)) == NULL) goto err; for (i = 0; i < num; i++) { - if ((prod_Z[i] = BN_new()) == NULL) + if ((prod_Z[i] = BN_CTX_get(ctx)) == NULL) goto err; } @@ -1253,12 +1253,7 @@ ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], err: BN_CTX_end(ctx); - - if (prod_Z != NULL) { - for (i = 0; i < num; i++) - BN_free(prod_Z[i]); - free(prod_Z); - } + free(prod_Z); return ret; } -- cgit v1.2.3-55-g6feb