From 05a50d0f2fa123333e4c07cc68de4816f3194f55 Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 25 Nov 2024 06:51:39 +0000 Subject: Unify checking for the asn1_flag There are only two flag values that libcrypto understands and the default value is 1 while, helpfully, the undesirable non-default is 0. The few existing callers set OPENSSL_EC_NAMED_CURVE or OPENSSL_EC_EXPLICIT_CURVE. Nevertheless, the flag should be checked properly as a flag. The recent upstream checks for EC_GROUP_get_asn1_flag(group) == OPENSSL_EC_NAMED_CURVE don't look right either... ok jsing --- src/lib/libcrypto/ec/ec_ameth.c | 4 ++-- src/lib/libcrypto/ec/eck_prn.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c index 754fabfb4d..903b18a8db 100644 --- a/src/lib/libcrypto/ec/ec_ameth.c +++ b/src/lib/libcrypto/ec/ec_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_ameth.c,v 1.72 2024/10/29 06:36:58 tb Exp $ */ +/* $OpenBSD: ec_ameth.c,v 1.73 2024/11/25 06:51:39 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -104,7 +104,7 @@ eckey_get_curve_name(const EC_KEY *eckey, int *nid) ECerror(EC_R_MISSING_PARAMETERS); return 0; } - if (EC_GROUP_get_asn1_flag(group) != 0) + if ((EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE) != 0) *nid = EC_GROUP_get_curve_name(group); return 1; diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c index 012391c803..98e1a7e7bd 100644 --- a/src/lib/libcrypto/ec/eck_prn.c +++ b/src/lib/libcrypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.39 2024/11/14 10:27:59 tb Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.40 2024/11/25 06:51:39 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -330,7 +330,7 @@ ECPKParameters_print(BIO *bio, const EC_GROUP *group, int off) return 0; } - if (EC_GROUP_get_asn1_flag(group)) + if ((EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE) != 0) return ecpk_print_asn1_parameters(bio, group, off); return ecpk_print_explicit_parameters(bio, group, off); -- cgit v1.2.3-55-g6feb