From f47135756c85868134acb5d2b2308c4d31e448cb Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 24 Feb 2022 15:23:42 +0100 Subject: [PATCH] Map INVALID_PADDING from PSA to MbedTLS error in rsa_decrypt_wrap() Signed-off-by: Neil Armstrong --- library/pk_wrap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 9036e00bee..1735dd76e6 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -276,7 +276,14 @@ static int rsa_decrypt_wrap( void *ctx, NULL, 0, output, osize, olen ); if( status != PSA_SUCCESS ) { - ret = mbedtls_psa_err_translate_pk( status ); + if ( status == PSA_ERROR_INVALID_PADDING ) + { + ret = MBEDTLS_ERR_RSA_INVALID_PADDING; + } + else + { + ret = mbedtls_psa_err_translate_pk( status ); + } goto cleanup; }