>From 5220048b2d77a411256ffa41ad54f7ddca6e464c Mon Sep 17 00:00:00 2001 From: szdowk Date: Wed, 4 Nov 2026 09:54:58 +0100 Subject: [PATCH] Update certcheck.c: Allow P-384 and P-521 certificates using ECDSA with SHA-256. sm/certcheck.c (do_encode_md): Extend the existing P-521/SHA-384 exception to also allow P-384/SHA-256 and P-521/SHA-256. Restrict these exceptions to ECC keys, preserving DSA checks. --- sm/certcheck.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sm/certcheck.c b/sm/certcheck.c index 41542948f..f42a712cb 100644 --- a/sm/certcheck.c +++ b/sm/certcheck.c @@ -108,7 +108,12 @@ do_encode_md (gcry_md_hd_t md, int algo, int pkalgo, unsigned int nbits, /* Check if we're too short. Too long is safe as we'll automatically left-truncate. */ nframe = gcry_md_get_algo_dlen (algo); - if (nframe < qbits/8 && !(qbits0 == 521 && algo == GCRY_MD_SHA384)) + if (nframe < qbits/8 + && !(pkalgo == GCRY_PK_ECC /*Let's limit exceptions only for ECDSA*/ + && ((qbits0 == 384 && algo == GCRY_MD_SHA256) + || (qbits0 == 521 + && (algo == GCRY_MD_SHA384 + || algo == GCRY_MD_SHA256))))) { log_error (_("a %u bit hash is not valid for a %u bit %s key\n"), (unsigned int)nframe*8,