summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_lib.c
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/lib/libcrypto/ec/ec_lib.c
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/lib/libcrypto/ec/ec_lib.c')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c12
1 files changed, 11 insertions, 1 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{