Provide a PSA definition of mbedtls_ssl_ciphersuite_get_cipher_key_bitlen() when MBEDTLS_USE_PSA_CRYPTO is defined

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
Neil Armstrong 2022-05-04 17:38:10 +02:00
parent 6ab65e28cf
commit 801abb69a5

View File

@ -1876,7 +1876,21 @@ int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name )
size_t mbedtls_ssl_ciphersuite_get_cipher_key_bitlen( const mbedtls_ssl_ciphersuite_t *info )
{
#if defined(MBEDTLS_CIPHER_C)
#if defined(MBEDTLS_USE_PSA_CRYPTO)
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
psa_key_type_t key_type;
psa_algorithm_t alg;
size_t key_bits;
status = mbedtls_ssl_cipher_to_psa( info->cipher,
info->flags & MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16,
&alg, &key_type, &key_bits );
if( status != PSA_SUCCESS )
return 0;
return key_bits;
#elif defined(MBEDTLS_CIPHER_C)
const mbedtls_cipher_info_t * const cipher_info =
mbedtls_cipher_info_from_type( info->cipher );