From 001cbc98bcbc26c4bb95409d62e848a8fc572f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 7 Jun 2023 12:06:06 +0200 Subject: [PATCH] Make MD<->PSA translation static inline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- library/md.c | 10 ---------- library/md_psa.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/library/md.c b/library/md.c index d8066e2a3c..93fe8c5276 100644 --- a/library/md.c +++ b/library/md.c @@ -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) -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) { return PSA_TO_MBEDTLS_ERR_LIST(status, psa_to_md_errors, diff --git a/library/md_psa.h b/library/md_psa.h index 20da5c22be..8e00bb1492 100644 --- a/library/md_psa.h +++ b/library/md_psa.h @@ -42,7 +42,10 @@ * \return The PSA algorithm identifier associated with \p md_type, * 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 @@ -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, * 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. *