mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Rename error translation functions and move them to library/pk_wrap.*
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
38
library/pk.c
38
library/pk.c
@ -147,40 +147,6 @@ int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info )
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
int mbedtls_pk_psa_err_translate( psa_status_t status )
|
||||
{
|
||||
switch( status )
|
||||
{
|
||||
case PSA_SUCCESS:
|
||||
return( 0 );
|
||||
case PSA_ERROR_INVALID_HANDLE:
|
||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT );
|
||||
case PSA_ERROR_NOT_PERMITTED:
|
||||
return( MBEDTLS_ERR_ERROR_GENERIC_ERROR );
|
||||
case PSA_ERROR_BUFFER_TOO_SMALL:
|
||||
return( MBEDTLS_ERR_PK_BUFFER_TOO_SMALL );
|
||||
case PSA_ERROR_NOT_SUPPORTED:
|
||||
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
|
||||
case PSA_ERROR_INVALID_ARGUMENT:
|
||||
return( MBEDTLS_ERR_PK_INVALID_ALG );
|
||||
case PSA_ERROR_INSUFFICIENT_MEMORY:
|
||||
return( MBEDTLS_ERR_PK_ALLOC_FAILED );
|
||||
case PSA_ERROR_BAD_STATE:
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
case PSA_ERROR_COMMUNICATION_FAILURE:
|
||||
case PSA_ERROR_HARDWARE_FAILURE:
|
||||
return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
|
||||
case PSA_ERROR_DATA_CORRUPT:
|
||||
case PSA_ERROR_DATA_INVALID:
|
||||
case PSA_ERROR_STORAGE_FAILURE:
|
||||
return( MBEDTLS_ERR_PK_FILE_IO_ERROR );
|
||||
case PSA_ERROR_CORRUPTION_DETECTED:
|
||||
return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED );
|
||||
default:
|
||||
return( MBEDTLS_ERR_ERROR_GENERIC_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise a PSA-wrapping context
|
||||
*/
|
||||
@ -440,7 +406,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_pk_psa_err_translate( status ) );
|
||||
return( mbedtls_pk_error_from_psa( status ) );
|
||||
}
|
||||
|
||||
/* This function requires returning MBEDTLS_ERR_PK_SIG_LEN_MISMATCH
|
||||
@ -460,7 +426,7 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
|
||||
if( status == PSA_SUCCESS )
|
||||
status = destruction_status;
|
||||
|
||||
return( mbedtls_pk_rsa_psa_err_translate( status ) );
|
||||
return( mbedtls_pk_error_from_psa_rsa( status ) );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user