diff options
| author | tb <> | 2025-12-26 18:44:19 +0000 |
|---|---|---|
| committer | tb <> | 2025-12-26 18:44:19 +0000 |
| commit | e568a255270032a6a88715db4e3609b6129702ed (patch) | |
| tree | 0d03de25f717a3b4ea678bc059140fd9bbc00419 /src | |
| parent | 6aad598b27692cde1ada140f0cf7be0f102d2c84 (diff) | |
| download | openbsd-e568a255270032a6a88715db4e3609b6129702ed.tar.gz openbsd-e568a255270032a6a88715db4e3609b6129702ed.tar.bz2 openbsd-e568a255270032a6a88715db4e3609b6129702ed.zip | |
Replace group->meth != point->meth checks
The method will currently always be identical since all groups use the
EC_GFp_mont_method(). Use the ec_group_and_point_compatible() check to
ensure this and if both group and point have a nid set, check that they
are identical.
ok jsing kenjiro
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_convert.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 25 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 7 |
3 files changed, 21 insertions, 17 deletions
diff --git a/src/lib/libcrypto/ec/ec_convert.c b/src/lib/libcrypto/ec/ec_convert.c index 84641a4e72..3b88bd20ba 100644 --- a/src/lib/libcrypto/ec/ec_convert.c +++ b/src/lib/libcrypto/ec/ec_convert.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_convert.c,v 1.15 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: ec_convert.c,v 1.16 2025/12/26 18:44:19 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 | */ |
| @@ -452,7 +452,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
| 452 | if (ctx == NULL) | 452 | if (ctx == NULL) |
| 453 | goto err; | 453 | goto err; |
| 454 | 454 | ||
| 455 | if (group->meth != point->meth) { | 455 | if (!ec_group_and_point_compatible(group, point)) { |
| 456 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 456 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 457 | goto err; | 457 | goto err; |
| 458 | } | 458 | } |
| @@ -478,7 +478,7 @@ EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
| 478 | if (ctx == NULL) | 478 | if (ctx == NULL) |
| 479 | goto err; | 479 | goto err; |
| 480 | 480 | ||
| 481 | if (group->meth != point->meth) { | 481 | if (!ec_group_and_point_compatible(group, point)) { |
| 482 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 482 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 483 | goto err; | 483 | goto err; |
| 484 | } | 484 | } |
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index b3d3c4ca71..c140249f0e 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.128 2025/12/26 18:42:33 tb Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.129 2025/12/26 18:44:19 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 | */ |
| @@ -911,7 +911,7 @@ LCRYPTO_ALIAS(EC_POINT_dup); | |||
| 911 | int | 911 | int |
| 912 | EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) | 912 | EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) |
| 913 | { | 913 | { |
| 914 | if (group->meth != point->meth) { | 914 | if (!ec_group_and_point_compatible(group, point)) { |
| 915 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 915 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 916 | return 0; | 916 | return 0; |
| 917 | } | 917 | } |
| @@ -935,7 +935,7 @@ EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point, | |||
| 935 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 935 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 936 | goto err; | 936 | goto err; |
| 937 | } | 937 | } |
| 938 | if (group->meth != point->meth) { | 938 | if (!ec_group_and_point_compatible(group, point)) { |
| 939 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 939 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 940 | goto err; | 940 | goto err; |
| 941 | } | 941 | } |
| @@ -986,7 +986,7 @@ EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, | |||
| 986 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 986 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 987 | goto err; | 987 | goto err; |
| 988 | } | 988 | } |
| 989 | if (group->meth != point->meth) { | 989 | if (!ec_group_and_point_compatible(group, point)) { |
| 990 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 990 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 991 | goto err; | 991 | goto err; |
| 992 | } | 992 | } |
| @@ -1136,8 +1136,9 @@ EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | |||
| 1136 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1136 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1137 | goto err; | 1137 | goto err; |
| 1138 | } | 1138 | } |
| 1139 | if (group->meth != r->meth || group->meth != a->meth || | 1139 | if (!ec_group_and_point_compatible(group, r) || |
| 1140 | group->meth != b->meth) { | 1140 | !ec_group_and_point_compatible(group, a) || |
| 1141 | !ec_group_and_point_compatible(group, b)) { | ||
| 1141 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1142 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1142 | goto err; | 1143 | goto err; |
| 1143 | } | 1144 | } |
| @@ -1167,7 +1168,8 @@ EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | |||
| 1167 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1168 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1168 | goto err; | 1169 | goto err; |
| 1169 | } | 1170 | } |
| 1170 | if (group->meth != r->meth || r->meth != a->meth) { | 1171 | if (!ec_group_and_point_compatible(group, r) || |
| 1172 | !ec_group_and_point_compatible(group, a)) { | ||
| 1171 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1173 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1172 | goto err; | 1174 | goto err; |
| 1173 | } | 1175 | } |
| @@ -1196,7 +1198,7 @@ EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx_in) | |||
| 1196 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1198 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1197 | goto err; | 1199 | goto err; |
| 1198 | } | 1200 | } |
| 1199 | if (group->meth != a->meth) { | 1201 | if (!ec_group_and_point_compatible(group, a)) { |
| 1200 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1202 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1201 | goto err; | 1203 | goto err; |
| 1202 | } | 1204 | } |
| @@ -1213,7 +1215,7 @@ LCRYPTO_ALIAS(EC_POINT_invert); | |||
| 1213 | int | 1215 | int |
| 1214 | EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) | 1216 | EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) |
| 1215 | { | 1217 | { |
| 1216 | if (group->meth != point->meth) { | 1218 | if (!ec_group_and_point_compatible(group, point)) { |
| 1217 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1219 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1218 | return 0; | 1220 | return 0; |
| 1219 | } | 1221 | } |
| @@ -1237,7 +1239,7 @@ EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, | |||
| 1237 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1239 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1238 | goto err; | 1240 | goto err; |
| 1239 | } | 1241 | } |
| 1240 | if (group->meth != point->meth) { | 1242 | if (!ec_group_and_point_compatible(group, point)) { |
| 1241 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1243 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1242 | goto err; | 1244 | goto err; |
| 1243 | } | 1245 | } |
| @@ -1267,7 +1269,8 @@ EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, | |||
| 1267 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1269 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1268 | goto err; | 1270 | goto err; |
| 1269 | } | 1271 | } |
| 1270 | if (group->meth != a->meth || a->meth != b->meth) { | 1272 | if (!ec_group_and_point_compatible(group, a) || |
| 1273 | !ec_group_and_point_compatible(group, b)) { | ||
| 1271 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1274 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 1272 | goto err; | 1275 | goto err; |
| 1273 | } | 1276 | } |
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index 8816be7501..067df9a2a2 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_mult.c,v 1.60 2025/08/26 14:14:52 tb Exp $ */ | 1 | /* $OpenBSD: ec_mult.c,v 1.61 2025/12/26 18:44:19 tb Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> |
| @@ -287,8 +287,9 @@ ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar1, | |||
| 287 | ECerror(ERR_R_PASSED_NULL_PARAMETER); | 287 | ECerror(ERR_R_PASSED_NULL_PARAMETER); |
| 288 | goto err; | 288 | goto err; |
| 289 | } | 289 | } |
| 290 | if (group->meth != r->meth || group->meth != point1->meth || | 290 | if (!ec_group_and_point_compatible(group, r) || |
| 291 | group->meth != point2->meth) { | 291 | !ec_group_and_point_compatible(group, point1) || |
| 292 | !ec_group_and_point_compatible(group, point2)) { | ||
| 292 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 293 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
| 293 | goto err; | 294 | goto err; |
| 294 | } | 295 | } |
