diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 27 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_methods.c | 36 |
3 files changed, 22 insertions, 44 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 | |||
| 1229 | EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in) | 1229 | EC_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 | ||
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index 5949908991..7cb5c55f6d 100644 --- a/src/lib/libcrypto/ec/ec_local.h +++ b/src/lib/libcrypto/ec/ec_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_local.h,v 1.54 2025/01/07 08:52:17 tb Exp $ */ | 1 | /* $OpenBSD: ec_local.h,v 1.55 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 | */ |
| @@ -109,7 +109,6 @@ struct ec_method_st { | |||
| 109 | int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, | 109 | int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, |
| 110 | BN_CTX *); | 110 | BN_CTX *); |
| 111 | 111 | ||
| 112 | int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *); | ||
| 113 | int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], | 112 | int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], |
| 114 | BN_CTX *); | 113 | BN_CTX *); |
| 115 | 114 | ||
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 9593428870..a2a74334f4 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.26 2025/01/07 08:30:52 tb Exp $ */ | 1 | /* $OpenBSD: ecp_methods.c,v 1.27 2025/01/11 13:38:42 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. |
| @@ -892,38 +892,6 @@ ec_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) | |||
| 892 | } | 892 | } |
| 893 | 893 | ||
| 894 | static int | 894 | static int |
| 895 | ec_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) | ||
| 896 | { | ||
| 897 | BIGNUM *x, *y; | ||
| 898 | int ret = 0; | ||
| 899 | |||
| 900 | if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) | ||
| 901 | return 1; | ||
| 902 | |||
| 903 | BN_CTX_start(ctx); | ||
| 904 | |||
| 905 | if ((x = BN_CTX_get(ctx)) == NULL) | ||
| 906 | goto err; | ||
| 907 | if ((y = BN_CTX_get(ctx)) == NULL) | ||
| 908 | goto err; | ||
| 909 | |||
| 910 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) | ||
| 911 | goto err; | ||
| 912 | if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) | ||
| 913 | goto err; | ||
| 914 | if (!point->Z_is_one) { | ||
| 915 | ECerror(ERR_R_INTERNAL_ERROR); | ||
| 916 | goto err; | ||
| 917 | } | ||
| 918 | ret = 1; | ||
| 919 | |||
| 920 | err: | ||
| 921 | BN_CTX_end(ctx); | ||
| 922 | |||
| 923 | return ret; | ||
| 924 | } | ||
| 925 | |||
| 926 | static int | ||
| 927 | ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], | 895 | ec_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], |
| 928 | BN_CTX *ctx) | 896 | BN_CTX *ctx) |
| 929 | { | 897 | { |
| @@ -1462,7 +1430,6 @@ static const EC_METHOD ec_GFp_simple_method = { | |||
| 1462 | .invert = ec_invert, | 1430 | .invert = ec_invert, |
| 1463 | .is_on_curve = ec_is_on_curve, | 1431 | .is_on_curve = ec_is_on_curve, |
| 1464 | .point_cmp = ec_cmp, | 1432 | .point_cmp = ec_cmp, |
| 1465 | .make_affine = ec_make_affine, | ||
| 1466 | .points_make_affine = ec_points_make_affine, | 1433 | .points_make_affine = ec_points_make_affine, |
| 1467 | .mul_generator_ct = ec_mul_generator_ct, | 1434 | .mul_generator_ct = ec_mul_generator_ct, |
| 1468 | .mul_single_ct = ec_mul_single_ct, | 1435 | .mul_single_ct = ec_mul_single_ct, |
| @@ -1490,7 +1457,6 @@ static const EC_METHOD ec_GFp_mont_method = { | |||
| 1490 | .invert = ec_invert, | 1457 | .invert = ec_invert, |
| 1491 | .is_on_curve = ec_is_on_curve, | 1458 | .is_on_curve = ec_is_on_curve, |
| 1492 | .point_cmp = ec_cmp, | 1459 | .point_cmp = ec_cmp, |
| 1493 | .make_affine = ec_make_affine, | ||
| 1494 | .points_make_affine = ec_points_make_affine, | 1460 | .points_make_affine = ec_points_make_affine, |
| 1495 | .mul_generator_ct = ec_mul_generator_ct, | 1461 | .mul_generator_ct = ec_mul_generator_ct, |
| 1496 | .mul_single_ct = ec_mul_single_ct, | 1462 | .mul_single_ct = ec_mul_single_ct, |
