Unify PSA to Mbed TLS error translation

Move all error translation utilities to psa_util.c.
Introduce macros and functions to avoid having
a local copy of the error translating function in
each place.
Identify overlapping errors and introduce a
generic function.
Provide a single macro for all error translations
(unless one file needs a couple of different ones).
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/library/rsa.c b/library/rsa.c
index df7d797..7159588 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -60,7 +60,10 @@
 #if !defined(MBEDTLS_MD_C)
 #include "psa/crypto.h"
 #include "mbedtls/psa_util.h"
-#endif /* MBEDTLS_MD_C */
+#define PSA_TO_MBEDTLS_ERR(status) PSA_TO_MBEDTLS_ERR_LIST(status,   \
+                                                           psa_to_md_errors,              \
+                                                           psa_generic_status_to_mbedtls)
+#endif /* !MBEDTLS_MD_C */
 #endif /* MBEDTLS_PKCS1_V21 */
 
 #include "mbedtls/platform.h"
@@ -1156,7 +1159,7 @@
 #else
     psa_hash_abort(&op);
 
-    return mbedtls_md_error_from_psa(status);
+    return PSA_TO_MBEDTLS_ERR(status);
 #endif
 }
 
@@ -1236,7 +1239,7 @@
 exit:
     psa_hash_abort(&op);
 
-    return mbedtls_md_error_from_psa(status);
+    return PSA_TO_MBEDTLS_ERR(status);
 #endif /* !MBEDTLS_MD_C */
 }
 
@@ -1269,7 +1272,7 @@
 
     status = psa_hash_compute(alg, input, ilen, output, out_size, &out_len);
 
-    return mbedtls_md_error_from_psa(status);
+    return PSA_TO_MBEDTLS_ERR(status);
 #endif /* !MBEDTLS_MD_C */
 }
 #endif /* MBEDTLS_PKCS1_V21 */