summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2025-12-26 18:42:33 +0000
committertb <>2025-12-26 18:42:33 +0000
commit6aad598b27692cde1ada140f0cf7be0f102d2c84 (patch)
treef8dc97ebf07b22661de811efe823e1082e184e09 /src
parent9f98bd62b5811dc1239ca4a121b39c3d962c73c2 (diff)
downloadopenbsd-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.c12
-rw-r--r--src/lib/libcrypto/ec/ec_local.h3
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}
793LCRYPTO_ALIAS(EC_GROUP_cmp); 793LCRYPTO_ALIAS(EC_GROUP_cmp);
794 794
795int
796ec_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
795EC_POINT * 805EC_POINT *
796EC_POINT_new(const EC_GROUP *group) 806EC_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
198int ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid); 198int ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid);
199int 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}().