diff options
author | jsing <> | 2025-05-24 08:25:58 +0000 |
---|---|---|
committer | jsing <> | 2025-05-24 08:25:58 +0000 |
commit | 1ede5cd4176ce288d6f0a00c790e1d04aa0d108b (patch) | |
tree | 05720c53df661e16f6cc31648d8dc9cffe10aa8e /src | |
parent | 3619e99136e45a9b10d78b643bae51a9a1b8e1c9 (diff) | |
download | openbsd-1ede5cd4176ce288d6f0a00c790e1d04aa0d108b.tar.gz openbsd-1ede5cd4176ce288d6f0a00c790e1d04aa0d108b.tar.bz2 openbsd-1ede5cd4176ce288d6f0a00c790e1d04aa0d108b.zip |
Provide method specific functions for EC POINT infinity.
Provide method specific functions for EC_POINT_set_to_infinity() and
EC_POINT_is_at_infinity(). These are not always the same thing and
will depend on the coordinate system in use.
ok beck@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_methods.c | 21 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index d760ecfb95..7cc7efe73f 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.124 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.125 2025/05/24 08:25:58 jsing 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 | */ |
@@ -894,11 +894,7 @@ EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) | |||
894 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 894 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
895 | return 0; | 895 | return 0; |
896 | } | 896 | } |
897 | 897 | return point->meth->point_set_to_infinity(group, point); | |
898 | BN_zero(point->Z); | ||
899 | point->Z_is_one = 0; | ||
900 | |||
901 | return 1; | ||
902 | } | 898 | } |
903 | LCRYPTO_ALIAS(EC_POINT_set_to_infinity); | 899 | LCRYPTO_ALIAS(EC_POINT_set_to_infinity); |
904 | 900 | ||
@@ -1200,8 +1196,7 @@ EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) | |||
1200 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1196 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
1201 | return 0; | 1197 | return 0; |
1202 | } | 1198 | } |
1203 | 1199 | return point->meth->point_is_at_infinity(group, point); | |
1204 | return BN_is_zero(point->Z); | ||
1205 | } | 1200 | } |
1206 | LCRYPTO_ALIAS(EC_POINT_is_at_infinity); | 1201 | LCRYPTO_ALIAS(EC_POINT_is_at_infinity); |
1207 | 1202 | ||
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index c7a54d3a2b..c0ff026fb2 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.67 2025/03/24 13:07:04 jsing Exp $ */ | 1 | /* $OpenBSD: ec_local.h,v 1.68 2025/05/24 08:25:58 jsing 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 | */ |
@@ -85,6 +85,9 @@ typedef struct ec_method_st { | |||
85 | int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, | 85 | int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, |
86 | BIGNUM *b, BN_CTX *); | 86 | BIGNUM *b, BN_CTX *); |
87 | 87 | ||
88 | int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *); | ||
89 | int (*point_is_at_infinity)(const EC_GROUP *, const EC_POINT *); | ||
90 | |||
88 | int (*point_is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); | 91 | int (*point_is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); |
89 | int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, | 92 | int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, |
90 | BN_CTX *); | 93 | BN_CTX *); |
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 5adc049ab7..fcb48d9e33 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.46 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: ecp_methods.c,v 1.47 2025/05/24 08:25:58 jsing 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. |
@@ -180,6 +180,21 @@ ec_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, | |||
180 | } | 180 | } |
181 | 181 | ||
182 | static int | 182 | static int |
183 | ec_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point) | ||
184 | { | ||
185 | BN_zero(point->Z); | ||
186 | point->Z_is_one = 0; | ||
187 | |||
188 | return 1; | ||
189 | } | ||
190 | |||
191 | static int | ||
192 | ec_point_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) | ||
193 | { | ||
194 | return BN_is_zero(point->Z); | ||
195 | } | ||
196 | |||
197 | static int | ||
183 | ec_point_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) | 198 | ec_point_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) |
184 | { | 199 | { |
185 | BIGNUM *rh, *tmp, *Z4, *Z6; | 200 | BIGNUM *rh, *tmp, *Z4, *Z6; |
@@ -1281,6 +1296,8 @@ ec_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | |||
1281 | static const EC_METHOD ec_GFp_simple_method = { | 1296 | static const EC_METHOD ec_GFp_simple_method = { |
1282 | .group_set_curve = ec_group_set_curve, | 1297 | .group_set_curve = ec_group_set_curve, |
1283 | .group_get_curve = ec_group_get_curve, | 1298 | .group_get_curve = ec_group_get_curve, |
1299 | .point_set_to_infinity = ec_point_set_to_infinity, | ||
1300 | .point_is_at_infinity = ec_point_is_at_infinity, | ||
1284 | .point_is_on_curve = ec_point_is_on_curve, | 1301 | .point_is_on_curve = ec_point_is_on_curve, |
1285 | .point_cmp = ec_point_cmp, | 1302 | .point_cmp = ec_point_cmp, |
1286 | .point_set_affine_coordinates = ec_point_set_affine_coordinates, | 1303 | .point_set_affine_coordinates = ec_point_set_affine_coordinates, |
@@ -1304,6 +1321,8 @@ EC_GFp_simple_method(void) | |||
1304 | static const EC_METHOD ec_GFp_mont_method = { | 1321 | static const EC_METHOD ec_GFp_mont_method = { |
1305 | .group_set_curve = ec_mont_group_set_curve, | 1322 | .group_set_curve = ec_mont_group_set_curve, |
1306 | .group_get_curve = ec_group_get_curve, | 1323 | .group_get_curve = ec_group_get_curve, |
1324 | .point_set_to_infinity = ec_point_set_to_infinity, | ||
1325 | .point_is_at_infinity = ec_point_is_at_infinity, | ||
1307 | .point_is_on_curve = ec_point_is_on_curve, | 1326 | .point_is_on_curve = ec_point_is_on_curve, |
1308 | .point_cmp = ec_point_cmp, | 1327 | .point_cmp = ec_point_cmp, |
1309 | .point_set_affine_coordinates = ec_point_set_affine_coordinates, | 1328 | .point_set_affine_coordinates = ec_point_set_affine_coordinates, |