From 0116416e61329a6d01493430c77e8a5ee70cf046 Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Mon, 20 Jul 2020 15:31:37 +0200 Subject: [PATCH] Expose mbedtls_error_to_psa_status for use in test drivers Signed-off-by: Steven Cooreman --- include/psa/crypto_extra.h | 11 +++++++++++ library/psa_crypto.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h index f0c7979a8..2ac2c5bf1 100644 --- a/include/psa/crypto_extra.h +++ b/include/psa/crypto_extra.h @@ -645,6 +645,17 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve, size_t byte_length ); #endif /* MBEDTLS_ECP_C */ +/** Convert an mbed TLS error code to a PSA error code + * + * \note This function is provided solely for the convenience of + * Mbed TLS and may be removed at any time without notice. + * + * \param ret An mbed TLS-thrown error code + * + * \return The corresponding PSA error code + */ +psa_status_t mbedtls_to_psa_error( int ret ); + /**@}*/ #ifdef __cplusplus diff --git a/library/psa_crypto.c b/library/psa_crypto.c index edef287c1..7da2ff678 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -125,7 +125,7 @@ static psa_global_data_t global_data; if( global_data.initialized == 0 ) \ return( PSA_ERROR_BAD_STATE ); -static psa_status_t mbedtls_to_psa_error( int ret ) +psa_status_t mbedtls_to_psa_error( int ret ) { /* If there's both a high-level code and low-level code, dispatch on * the high-level code. */