Add function to translate PSA errors to PK module errors
This commit is contained in:
parent
afebf5a153
commit
000334f398
1 changed files with 26 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "ecp.h"
|
||||
#include "md.h"
|
||||
#include "pk.h"
|
||||
|
||||
/* Slot allocation */
|
||||
|
||||
|
@ -228,6 +229,31 @@ static inline psa_ecc_curve_t mbedtls_psa_translate_ecc_group( mbedtls_ecp_group
|
|||
}
|
||||
}
|
||||
|
||||
/* 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_COMMUNICATION_FAILURE:
|
||||
case PSA_ERROR_HARDWARE_FAILURE:
|
||||
case PSA_ERROR_TAMPERING_DETECTED:
|
||||
return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
|
||||
case PSA_ERROR_INSUFFICIENT_ENTROPY:
|
||||
return( MBEDTLS_ERR_ECP_RANDOM_FAILED );
|
||||
case PSA_ERROR_BAD_STATE:
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
default: /* should never happen */
|
||||
return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
#endif /* MBEDTLS_PSA_COMPAT_H */
|
||||
|
|
Loading…
Reference in a new issue