diff options
| author | tb <> | 2025-12-26 18:42:33 +0000 |
|---|---|---|
| committer | tb <> | 2025-12-26 18:42:33 +0000 |
| commit | 6aad598b27692cde1ada140f0cf7be0f102d2c84 (patch) | |
| tree | f8dc97ebf07b22661de811efe823e1082e184e09 /src | |
| parent | 9f98bd62b5811dc1239ca4a121b39c3d962c73c2 (diff) | |
| download | openbsd-6aad598b27692cde1ada140f0cf7be0f102d2c84.tar.gz openbsd-6aad598b27692cde1ada140f0cf7be0f102d2c84.tar.bz2 openbsd-6aad598b27692cde1ada140f0cf7be0f102d2c84.zip | |
Add ec_group_and_point_compatible() helper
Check that a given group and point are reasonably compatible. First see
if they use the same method. Compare nids if both have nid != NID_undef.
ok jsing kenjiro
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index b31c132a77..b3d3c4ca71 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.127 2025/12/26 18:41:05 tb Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.128 2025/12/26 18:42:33 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 | */ |
| @@ -792,6 +792,16 @@ EC_GROUP_cmp(const EC_GROUP *group1, const EC_GROUP *group2, BN_CTX *ctx_in) | |||
| 792 | } | 792 | } |
| 793 | LCRYPTO_ALIAS(EC_GROUP_cmp); | 793 | LCRYPTO_ALIAS(EC_GROUP_cmp); |
| 794 | 794 | ||
| 795 | int | ||
| 796 | ec_group_and_point_compatible(const EC_GROUP *group, const EC_POINT *point) | ||
| 797 | { | ||
| 798 | if (group->meth != point->meth) | ||
| 799 | return 0; | ||
| 800 | if (group->nid == NID_undef || point->nid == NID_undef) | ||
| 801 | return 1; | ||
| 802 | return group->nid == point->nid; | ||
| 803 | } | ||
| 804 | |||
| 795 | EC_POINT * | 805 | EC_POINT * |
| 796 | EC_POINT_new(const EC_GROUP *group) | 806 | EC_POINT_new(const EC_GROUP *group) |
| 797 | { | 807 | { |
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index 933fd98f14..d84e92767c 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.72 2025/12/26 18:41:05 tb Exp $ */ | 1 | /* $OpenBSD: ec_local.h,v 1.73 2025/12/26 18:42:33 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 | */ |
| @@ -196,6 +196,7 @@ int ec_wnaf_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar1, | |||
| 196 | BN_CTX *ctx); | 196 | BN_CTX *ctx); |
| 197 | 197 | ||
| 198 | int ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid); | 198 | int ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid); |
| 199 | int ec_group_and_point_compatible(const EC_GROUP *group, const EC_POINT *point); | ||
| 199 | 200 | ||
| 200 | /* | 201 | /* |
| 201 | * Wrappers around the unergonomic EC_POINT_{oct2point,point2oct}(). | 202 | * Wrappers around the unergonomic EC_POINT_{oct2point,point2oct}(). |
