Make MD<->PSA translation static inline

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2023-06-07 12:06:06 +02:00
parent 44176b00ad
commit 001cbc98bc
2 changed files with 8 additions and 12 deletions

View File

@ -771,16 +771,6 @@ mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info)
} }
#if defined(MBEDTLS_PSA_CRYPTO_C) #if defined(MBEDTLS_PSA_CRYPTO_C)
psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type)
{
return PSA_ALG_CATEGORY_HASH | (psa_algorithm_t) md_type;
}
mbedtls_md_type_t mbedtls_md_type_from_psa_alg(psa_algorithm_t psa_alg)
{
return (mbedtls_md_type_t) (psa_alg & PSA_ALG_HASH_MASK);
}
int mbedtls_md_error_from_psa(psa_status_t status) int mbedtls_md_error_from_psa(psa_status_t status)
{ {
return PSA_TO_MBEDTLS_ERR_LIST(status, psa_to_md_errors, return PSA_TO_MBEDTLS_ERR_LIST(status, psa_to_md_errors,

View File

@ -42,7 +42,10 @@
* \return The PSA algorithm identifier associated with \p md_type, * \return The PSA algorithm identifier associated with \p md_type,
* regardless of whether it is supported or not. * regardless of whether it is supported or not.
*/ */
psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type); static inline psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type)
{
return PSA_ALG_CATEGORY_HASH | (psa_algorithm_t) md_type;
}
/** /**
* \brief This function returns the given digest type * \brief This function returns the given digest type
@ -56,7 +59,10 @@ psa_algorithm_t mbedtls_md_psa_alg_from_type(mbedtls_md_type_t md_type);
* \return The MD type associated with \p psa_alg, * \return The MD type associated with \p psa_alg,
* regardless of whether it is supported or not. * regardless of whether it is supported or not.
*/ */
mbedtls_md_type_t mbedtls_md_type_from_psa_alg(psa_algorithm_t psa_alg); static inline mbedtls_md_type_t mbedtls_md_type_from_psa_alg(psa_algorithm_t psa_alg)
{
return (mbedtls_md_type_t) (psa_alg & PSA_ALG_HASH_MASK);
}
/** Convert PSA status to MD error code. /** Convert PSA status to MD error code.
* *