Skip to content

Commit 9b3a897

Browse files
committed
Map the reserved Mbed TLS error value in PSA
The natural choice would be to map it to PSA_ERROR_GENERIC_ERROR. However, PSA initialises return values to PSA_ERROR_CORRUPTION_DETECTED and it would be best to align this behaviour. Since Mbed Crypto is going to initialise return values to MBEDTLS_ERR_GENERIC_ERROR and therefore it is best to map these to each other.
1 parent 2bbcbbf commit 9b3a897

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/psa_crypto.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,14 @@ static psa_status_t mbedtls_to_psa_error( int ret )
351351
return( PSA_ERROR_INSUFFICIENT_MEMORY );
352352
case MBEDTLS_ERR_ECP_HW_ACCEL_FAILED:
353353
return( PSA_ERROR_HARDWARE_FAILURE );
354+
/*
355+
* Mbed Crypto return values are initialised to
356+
* MBEDTLS_ERR_GENERIC_ERROR. PSA return valuse are initialised to
357+
* PSA_ERROR_CORRUPTION_DETECTED. We are mapping these to each other
358+
* to align this behaviour.
359+
*/
360+
case MBEDTLS_ERR_GENERIC_ERROR:
361+
return( PSA_ERROR_CORRUPTION_DETECTED );
354362

355363
default:
356364
return( PSA_ERROR_GENERIC_ERROR );

0 commit comments

Comments
 (0)