Avoid dependency of PK on MD

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2022-07-05 11:55:20 +02:00
parent d8a298e1fc
commit a370e06e30

View File

@ -24,6 +24,8 @@
#include "pk_wrap.h"
#include "pkwrite.h"
#include "md_internal.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"
@ -358,15 +360,14 @@ int mbedtls_pk_can_do_ext( const mbedtls_pk_context *ctx, psa_algorithm_t alg,
*/
static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len )
{
const mbedtls_md_info_t *md_info;
if( *hash_len != 0 )
return( 0 );
if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL )
*hash_len = mbedtls_md_internal_get_size( md_alg );
if( *hash_len == 0 )
return( -1 );
*hash_len = mbedtls_md_get_size( md_info );
return( 0 );
}