From 1a5acb1b1fd2ab9eae1e453383537b4a9ac34758 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 19 Oct 2024 14:41:03 +0000 Subject: Make ec EVP_PKEY_CTRL_MD handler match dsa/rsa more closely This makes the thing a bit easier on the eyes and improves greppability. ok joshua jsing --- src/lib/libcrypto/ec/ec_pmeth.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c index d422765b00..424d1896b2 100644 --- a/src/lib/libcrypto/ec/ec_pmeth.c +++ b/src/lib/libcrypto/ec/ec_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_pmeth.c,v 1.22 2024/08/26 22:01:28 op Exp $ */ +/* $OpenBSD: ec_pmeth.c,v 1.23 2024/10/19 14:41:03 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -381,16 +381,19 @@ pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) case EVP_PKEY_CTRL_MD: /* RFC 3279, RFC 5758 and NIST CSOR. */ - if (EVP_MD_type((const EVP_MD *) p2) != NID_sha1 && - EVP_MD_type((const EVP_MD *) p2) != NID_ecdsa_with_SHA1 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha224 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha256 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha384 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha512 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha3_224 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha3_256 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha3_384 && - EVP_MD_type((const EVP_MD *) p2) != NID_sha3_512) { + switch (EVP_MD_type(p2)) { + case NID_sha1: + case NID_ecdsa_with_SHA1: + case NID_sha224: + case NID_sha256: + case NID_sha384: + case NID_sha512: + case NID_sha3_224: + case NID_sha3_256: + case NID_sha3_384: + case NID_sha3_512: + break; + default: ECerror(EC_R_INVALID_DIGEST_TYPE); return 0; } -- cgit v1.2.3-55-g6feb