summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_lib.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index d7f0bc6358..c2a5545c30 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.105 2025/01/09 11:35:46 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.106 2025/01/11 13:38:42 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -1229,6 +1229,7 @@ int
1229EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in) 1229EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in)
1230{ 1230{
1231 BN_CTX *ctx; 1231 BN_CTX *ctx;
1232 BIGNUM *x, *y;
1232 int ret = 0; 1233 int ret = 0;
1233 1234
1234 if ((ctx = ctx_in) == NULL) 1235 if ((ctx = ctx_in) == NULL)
@@ -1236,17 +1237,29 @@ EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in)
1236 if (ctx == NULL) 1237 if (ctx == NULL)
1237 goto err; 1238 goto err;
1238 1239
1239 if (group->meth->make_affine == NULL) { 1240 BN_CTX_start(ctx);
1240 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 1241
1242 if ((x = BN_CTX_get(ctx)) == NULL)
1241 goto err; 1243 goto err;
1242 } 1244 if ((y = BN_CTX_get(ctx)) == NULL)
1243 if (group->meth != point->meth) { 1245 goto err;
1244 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 1246
1247 if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
1248 goto err;
1249 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
1250 goto err;
1251
1252 /* XXX - is this the right spot for this check? */
1253 if (!point->Z_is_one) {
1254 ECerror(ERR_R_INTERNAL_ERROR);
1245 goto err; 1255 goto err;
1246 } 1256 }
1247 ret = group->meth->make_affine(group, point, ctx); 1257
1258 ret = 1;
1248 1259
1249 err: 1260 err:
1261 BN_CTX_end(ctx);
1262
1250 if (ctx != ctx_in) 1263 if (ctx != ctx_in)
1251 BN_CTX_free(ctx); 1264 BN_CTX_free(ctx);
1252 1265