Add specialized PSA to mbedtls PK/RSA error mapping function
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
cd501f406e
commit
ea761963c5
2 changed files with 31 additions and 0 deletions
|
@ -90,6 +90,10 @@ int mbedtls_pk_psa_err_translate( psa_status_t status );
|
|||
#if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
int mbedtls_pk_ecp_psa_err_translate( psa_status_t status );
|
||||
#endif
|
||||
|
||||
#if defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
int mbedtls_pk_rsa_psa_err_translate( psa_status_t status );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,6 +66,33 @@
|
|||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#include "mbedtls/pk.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
int mbedtls_pk_rsa_psa_err_translate( psa_status_t status )
|
||||
{
|
||||
switch( status )
|
||||
{
|
||||
case PSA_ERROR_NOT_PERMITTED:
|
||||
case PSA_ERROR_INVALID_ARGUMENT:
|
||||
case PSA_ERROR_INVALID_HANDLE:
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
case PSA_ERROR_BUFFER_TOO_SMALL:
|
||||
return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
|
||||
case PSA_ERROR_INSUFFICIENT_ENTROPY:
|
||||
return( MBEDTLS_ERR_RSA_RNG_FAILED );
|
||||
case PSA_ERROR_INVALID_SIGNATURE:
|
||||
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
|
||||
case PSA_ERROR_INVALID_PADDING:
|
||||
return( MBEDTLS_ERR_RSA_INVALID_PADDING );
|
||||
default:
|
||||
return( mbedtls_pk_psa_err_translate( status ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_RSA_ALT)
|
||||
|
||||
/* Parameter validation macros */
|
||||
|
|
Loading…
Reference in a new issue