mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-03 20:54:00 +00:00
Remove actual and use new PSA to mbedtls PK errors mapping functions
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
ea761963c5
commit
3f9cef4547
@ -277,34 +277,6 @@ static inline psa_key_type_t mbedtls_psa_parse_tls_ecc_group(
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
/* Translations for PK layer */
|
||||
|
||||
static inline int mbedtls_psa_err_translate_pk( psa_status_t status )
|
||||
{
|
||||
switch( status )
|
||||
{
|
||||
case PSA_SUCCESS:
|
||||
return( 0 );
|
||||
case PSA_ERROR_NOT_SUPPORTED:
|
||||
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
|
||||
case PSA_ERROR_INSUFFICIENT_MEMORY:
|
||||
return( MBEDTLS_ERR_PK_ALLOC_FAILED );
|
||||
case PSA_ERROR_INSUFFICIENT_ENTROPY:
|
||||
return( MBEDTLS_ERR_ECP_RANDOM_FAILED );
|
||||
case PSA_ERROR_BAD_STATE:
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
/* All other failures */
|
||||
case PSA_ERROR_COMMUNICATION_FAILURE:
|
||||
case PSA_ERROR_HARDWARE_FAILURE:
|
||||
case PSA_ERROR_CORRUPTION_DETECTED:
|
||||
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||
default: /* We return the same as for the 'other failures',
|
||||
* but list them separately nonetheless to indicate
|
||||
* which failure conditions we have considered. */
|
||||
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
/* Expose whatever RNG the PSA subsystem uses to applications using the
|
||||
|
@ -440,7 +440,7 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
|
||||
if( status != PSA_SUCCESS )
|
||||
{
|
||||
psa_destroy_key( key_id );
|
||||
return( mbedtls_psa_err_translate_pk( status ) );
|
||||
return( mbedtls_pk_psa_err_translate( status ) );
|
||||
}
|
||||
|
||||
/* This function requires returning MBEDTLS_ERR_PK_SIG_LEN_MISMATCH
|
||||
@ -457,13 +457,10 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
|
||||
if( status == PSA_SUCCESS && sig_len > mbedtls_pk_get_len( ctx ) )
|
||||
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
|
||||
|
||||
if( status == PSA_ERROR_INVALID_SIGNATURE )
|
||||
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
|
||||
|
||||
if( status == PSA_SUCCESS )
|
||||
status = destruction_status;
|
||||
|
||||
return( mbedtls_psa_err_translate_pk( status ) );
|
||||
return( mbedtls_pk_rsa_psa_err_translate( status ) );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -596,7 +596,7 @@ static int ecdsa_verify_wrap( void *ctx_arg, mbedtls_md_type_t md_alg,
|
||||
&key_id );
|
||||
if( status != PSA_SUCCESS )
|
||||
{
|
||||
ret = mbedtls_psa_err_translate_pk( status );
|
||||
ret = mbedtls_pk_psa_err_translate( status );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -615,12 +615,12 @@ static int ecdsa_verify_wrap( void *ctx_arg, mbedtls_md_type_t md_alg,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( psa_verify_hash( key_id, psa_sig_md,
|
||||
hash, hash_len,
|
||||
buf, 2 * signature_part_size )
|
||||
!= PSA_SUCCESS )
|
||||
status = psa_verify_hash( key_id, psa_sig_md,
|
||||
hash, hash_len,
|
||||
buf, 2 * signature_part_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
{
|
||||
ret = MBEDTLS_ERR_ECP_VERIFY_FAILED;
|
||||
ret = mbedtls_pk_ecp_psa_err_translate( status );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1045,7 +1045,7 @@ static int pk_opaque_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
|
||||
status = psa_sign_hash( *key, alg, hash, hash_len,
|
||||
sig, sig_size, sig_len );
|
||||
if( status != PSA_SUCCESS )
|
||||
return( mbedtls_psa_err_translate_pk( status ) );
|
||||
return( mbedtls_pk_ecp_psa_err_translate( status ) );
|
||||
|
||||
/* transcode it to ASN.1 sequence */
|
||||
return( pk_ecdsa_sig_asn1_from_psa( sig, sig_len, sig_size ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user