2025-12-26 6:48 AM
Hello!
Quick question about ST patches for MbedTLS 3.6.5 (stm32-mw-mbedtls).
Why was the defined(MBEDTLS_MD_SOME_PSA) added here (in library/md.c)?
When MBEDTLS_PSA_CRYPTO_C is defined, the only way to define MBEDTLS_MD_SOME_PSA is to define one of MBEDTLS_PSA_ACCEL_ALG_XXX which, I think, is an internal macro of MbedTLS. Should I just remove the patch or does it serve a purpose? Would it be better to define MBEDTLS_PSA_ACCEL_ALG_XXX?
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && defined(MBEDTLS_MD_SOME_PSA)
int mbedtls_md_error_from_psa(psa_status_t status)
{
return PSA_TO_MBEDTLS_ERR_LIST(status, psa_to_md_errors,
psa_generic_status_to_mbedtls);
}
#endif /* MBEDTLS_PSA_CRYPTO_CLIENT and MBEDTLS_MD_SOME_PSA */Thank you in advance.
2025-12-30 2:28 AM
hello @Moemen
the macro defined(MBEDTLS_MD_SOME_PSA) is not originally part of MbedTLS 3.6.5.
It was introduced in later 3.6.x versions as part of the integration of the PSA Cryptography API.
When you enable a PSA accelerated algorithm by defining the corresponding MBEDTLS_PSA_ACCEL_ALG_XXX
macro, the MBEDTLS_MD_SOME_PSA macro is automatically activated.
For example, when using CubeMX to configure your STM32 project, you should enable the PSA Crypto acceleration options corresponding to your hardware capabilities. This will define the appropriate MBEDTLS_PSA_ACCEL_ALG_XXX macros automatically in the generated configuration, ensuring that MBEDTLS_MD_SOME_PSA is properly set and PSA Crypto support is enabled.
@Moemen wrote:
Should I just remove the patch or does it serve a purpose? Would it be better to define MBEDTLS_PSA_ACCEL_ALG_XXX?
you should not remove the patch if it provides useful PSA Crypto support for your platform.
However, it is better to define the MBEDTLS_PSA_ACCEL_ALG_XXX macros corresponding to the algorithms accelerated by your hardware.
Best regards,
2025-12-30 2:46 AM
Hey, Thank you for your response.
Where does CubeMX add the MBEDTLS_PSA_ACCEL_ALG_XXX macros exactly?
I'm doing all the configurations manually.
2026-01-02 12:20 AM
Hello @T_Hamdi,
I couldn't find the PSA Crypto acceleration options in CubeMX for STM32H757XI.
Is there an example STM32 project that uses PSA crypto for MbedTLS?