Remove actual and use new PSA to mbedtls PK errors mapping functions
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h
index e38e2e3..a70ee96 100644
--- a/include/mbedtls/psa_util.h
+++ b/include/mbedtls/psa_util.h
@@ -277,34 +277,6 @@
}
#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
diff --git a/library/pk.c b/library/pk.c
index 7c5c40b..e9eff0a 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -440,7 +440,7 @@
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 @@
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
diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index 0bb87a4..9e14fbc 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -596,7 +596,7 @@
&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 @@
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 @@
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 ) );