summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-11-30 16:34:34 +0000
committertb <>2024-11-30 16:34:34 +0000
commit98f7a26186887ba45c08f5491bb6ef3a594837bd (patch)
treed2a32205fcc8d8414178308386d4dd44e01766b0 /src
parenta6c5e92ff8006052ab380ce91bd003b45d6eb794 (diff)
downloadopenbsd-98f7a26186887ba45c08f5491bb6ef3a594837bd.tar.gz
openbsd-98f7a26186887ba45c08f5491bb6ef3a594837bd.tar.bz2
openbsd-98f7a26186887ba45c08f5491bb6ef3a594837bd.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ecp_methods.c11
1 files changed, 3 insertions, 8 deletions
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 @@
1/* $OpenBSD: ecp_methods.c,v 1.10 2024/11/30 16:18:01 tb Exp $ */ 1/* $OpenBSD: ecp_methods.c,v 1.11 2024/11/30 16:34:34 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * 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[],
1141 if ((prod_Z = calloc(num, sizeof *prod_Z)) == NULL) 1141 if ((prod_Z = calloc(num, sizeof *prod_Z)) == NULL)
1142 goto err; 1142 goto err;
1143 for (i = 0; i < num; i++) { 1143 for (i = 0; i < num; i++) {
1144 if ((prod_Z[i] = BN_new()) == NULL) 1144 if ((prod_Z[i] = BN_CTX_get(ctx)) == NULL)
1145 goto err; 1145 goto err;
1146 } 1146 }
1147 1147
@@ -1253,12 +1253,7 @@ ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],
1253 1253
1254 err: 1254 err:
1255 BN_CTX_end(ctx); 1255 BN_CTX_end(ctx);
1256 1256 free(prod_Z);
1257 if (prod_Z != NULL) {
1258 for (i = 0; i < num; i++)
1259 BN_free(prod_Z[i]);
1260 free(prod_Z);
1261 }
1262 1257
1263 return ret; 1258 return ret;
1264} 1259}