summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_asn1.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_asn1.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_asn1.c')
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index b5be7b496d..7d2243db0c 100644
--- a/src/lib/libcrypto/ec/ec_asn1.c
+++ b/src/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_asn1.c,v 1.107 2024/11/22 12:01:14 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.108 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 */
@@ -1069,6 +1069,7 @@ static EC_GROUP *
1069ec_asn1_parameters2group(const ECPARAMETERS *params) 1069ec_asn1_parameters2group(const ECPARAMETERS *params)
1070{ 1070{
1071 EC_GROUP *group = NULL; 1071 EC_GROUP *group = NULL;
1072 int nid = NID_undef;
1072 1073
1073 if (params == NULL) { 1074 if (params == NULL) {
1074 ECerror(EC_R_ASN1_ERROR); 1075 ECerror(EC_R_ASN1_ERROR);
@@ -1077,8 +1078,9 @@ ec_asn1_parameters2group(const ECPARAMETERS *params)
1077 1078
1078 if (!ec_asn1_parameters_extract_prime_group(params, &group)) 1079 if (!ec_asn1_parameters_extract_prime_group(params, &group))
1079 goto err; 1080 goto err;
1080 if (!ec_group_is_builtin_curve(group)) 1081 if (!ec_group_is_builtin_curve(group, &nid))
1081 goto err; 1082 goto err;
1083 EC_GROUP_set_curve_name(group, nid);
1082 1084
1083 return group; 1085 return group;
1084 1086