summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_curve.c
diff options
context:
space:
mode:
authortb <>2024-12-06 04:35:03 +0000
committertb <>2024-12-06 04:35:03 +0000
commitec6a80c2122918d0d43aa05322cc30a8d45c7d81 (patch)
treeed4fda406898fc81a1d4c617faf07972aad0d8ea /src/lib/libcrypto/ec/ec_curve.c
parentb32147fff9dbbaff86a38b82df29174c55cca816 (diff)
downloadopenbsd-ec6a80c2122918d0d43aa05322cc30a8d45c7d81.tar.gz
openbsd-ec6a80c2122918d0d43aa05322cc30a8d45c7d81.tar.bz2
openbsd-ec6a80c2122918d0d43aa05322cc30a8d45c7d81.zip
Set nid on group decoded from EC parameters
We match curve parameters against the builtin curves and only accept them if they're encoding a curve known to us. After getting rid of the wtls curves, some of which used to coincide with secp curves (sometimes the wrong ones), the nid is unambiguous. Setting the nid has no direct implications on the encoding. This helps ssh avoid doing ugly computations during the key exchange for PEM keys using this encoding. ok djm joshua jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_curve.c')
-rw-r--r--src/lib/libcrypto/ec/ec_curve.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c
index a37f324a24..cc5ad4d4e6 100644
--- a/src/lib/libcrypto/ec/ec_curve.c
+++ b/src/lib/libcrypto/ec/ec_curve.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_curve.c,v 1.51 2024/12/04 09:50:52 tb Exp $ */ 1/* $OpenBSD: ec_curve.c,v 1.52 2024/12/06 04:35:03 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -2685,16 +2685,21 @@ ec_group_nid_from_curve(const struct ec_curve *curve)
2685} 2685}
2686 2686
2687int 2687int
2688ec_group_is_builtin_curve(const EC_GROUP *group) 2688ec_group_is_builtin_curve(const EC_GROUP *group, int *out_nid)
2689{ 2689{
2690 struct ec_curve *curve; 2690 struct ec_curve *curve;
2691 int ret = 0; 2691 int ret = 0;
2692 int nid;
2693
2694 *out_nid = NID_undef;
2692 2695
2693 if ((curve = ec_curve_from_group(group)) == NULL) 2696 if ((curve = ec_curve_from_group(group)) == NULL)
2694 goto err; 2697 goto err;
2695 if (ec_group_nid_from_curve(curve) == NID_undef) 2698 if ((nid = ec_group_nid_from_curve(curve)) == NID_undef)
2696 goto err; 2699 goto err;
2697 2700
2701 *out_nid = nid;
2702
2698 ret = 1; 2703 ret = 1;
2699 2704
2700 err: 2705 err: