From 130fa4d3769cc75c3f317efaf828ac6ae55579b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 18 Jul 2022 15:12:48 +0200 Subject: [PATCH] Rm local helper now that a global one is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a small difference: the global function only works for hashes that are included in the build, while the old one worked for all hashes regardless of whether they were enabled or not. We'll see in the CI is this causes any issues. Signed-off-by: Manuel Pégourié-Gonnard --- library/psa_crypto_rsa.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index 4a3944e18..19011a4e6 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -320,30 +320,6 @@ psa_status_t mbedtls_psa_rsa_generate_key( #if defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) -/* Convert a hash algorithm from PSA to MD identifier */ -static inline mbedtls_md_type_t get_md_alg_from_psa( psa_algorithm_t psa_alg ) -{ - switch( psa_alg ) - { - case PSA_ALG_MD5: - return( MBEDTLS_MD_MD5 ); - case PSA_ALG_RIPEMD160: - return( MBEDTLS_MD_RIPEMD160 ); - case PSA_ALG_SHA_1: - return( MBEDTLS_MD_SHA1 ); - case PSA_ALG_SHA_224: - return( MBEDTLS_MD_SHA224 ); - case PSA_ALG_SHA_256: - return( MBEDTLS_MD_SHA256 ); - case PSA_ALG_SHA_384: - return( MBEDTLS_MD_SHA384 ); - case PSA_ALG_SHA_512: - return( MBEDTLS_MD_SHA512 ); - default: - return( MBEDTLS_MD_NONE ); - } -} - /* Decode the hash algorithm from alg and store the mbedtls encoding in * md_alg. Verify that the hash length is acceptable. */ static psa_status_t psa_rsa_decode_md_type( psa_algorithm_t alg, @@ -351,7 +327,7 @@ static psa_status_t psa_rsa_decode_md_type( psa_algorithm_t alg, mbedtls_md_type_t *md_alg ) { psa_algorithm_t hash_alg = PSA_ALG_SIGN_GET_HASH( alg ); - *md_alg = get_md_alg_from_psa( hash_alg ); + *md_alg = mbedtls_hash_info_md_from_psa( hash_alg ); /* The Mbed TLS RSA module uses an unsigned int for hash length * parameters. Validate that it fits so that we don't risk an