From 6aad598b27692cde1ada140f0cf7be0f102d2c84 Mon Sep 17 00:00:00 2001 From: tb <> Date: Fri, 26 Dec 2025 18:42:33 +0000 Subject: 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 --- src/lib/libcrypto/ec/ec_lib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/ec/ec_lib.c') 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 @@ -/* $OpenBSD: ec_lib.c,v 1.127 2025/12/26 18:41:05 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.128 2025/12/26 18:42:33 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -792,6 +792,16 @@ EC_GROUP_cmp(const EC_GROUP *group1, const EC_GROUP *group2, BN_CTX *ctx_in) } LCRYPTO_ALIAS(EC_GROUP_cmp); +int +ec_group_and_point_compatible(const EC_GROUP *group, const EC_POINT *point) +{ + if (group->meth != point->meth) + return 0; + if (group->nid == NID_undef || point->nid == NID_undef) + return 1; + return group->nid == point->nid; +} + EC_POINT * EC_POINT_new(const EC_GROUP *group) { -- cgit v1.2.3-55-g6feb