mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08:00
pkcs7: fail verification if MD alg or sig_alg are not secure
Add a check on mbedtls_pkcs7_data_or_hash_verify() so that the verification fails if the MD alg specified in PKCS7 structure or the signature algorithm specified in the X.509 certificate are not in the list of secure algorithms (i.e. mbedtls_x509_crt_profile_default). Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit is contained in:
parent
395bc86df8
commit
c25e7654ea
@ -665,6 +665,14 @@ static int mbedtls_pkcs7_data_or_hash_verify(mbedtls_pkcs7 *pkcs7,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 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)) {
|
||||
return MBEDTLS_ERR_PKCS7_VERIFY_FAIL;
|
||||
}
|
||||
|
||||
md_info = mbedtls_md_info_from_type(md_alg);
|
||||
if (md_info == NULL) {
|
||||
return MBEDTLS_ERR_PKCS7_VERIFY_FAIL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user