From 45654b0246251afd681430c617391521fe93382b Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Mon, 15 Jun 2026 10:14:24 +0200 Subject: [PATCH] pkcs7: split MD/PK check in mbedtls_pkcs7_data_or_hash_verify Follow the default Mbed TLS coding style and ease debugging (i.e. placing of breakpoints). Signed-off-by: Valerio Setti --- library/pkcs7.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/pkcs7.c b/library/pkcs7.c index 1e952998cc..885ead6cb1 100644 --- a/library/pkcs7.c +++ b/library/pkcs7.c @@ -668,8 +668,12 @@ static int mbedtls_pkcs7_data_or_hash_verify(mbedtls_pkcs7 *pkcs7, /* Ensure the MD alg from the PKCS#7 context and signature algorithm from * the certificate belong to the list of secure algorithms * (i.e. mbedtls_x509_crt_profile_default). */ - if (mbedtls_x509_profile_check_md_alg(&mbedtls_x509_crt_profile_default, md_alg) || - mbedtls_x509_profile_check_pk_alg(&mbedtls_x509_crt_profile_default, cert->sig_pk)) { + ret = mbedtls_x509_profile_check_md_alg(&mbedtls_x509_crt_profile_default, md_alg); + if (ret != 0) { + return MBEDTLS_ERR_PKCS7_VERIFY_FAIL; + } + ret = mbedtls_x509_profile_check_pk_alg(&mbedtls_x509_crt_profile_default, cert->sig_pk); + if (ret != 0) { return MBEDTLS_ERR_PKCS7_VERIFY_FAIL; }