Add USE_PSA version of PK test functions
While at it, also fix buffer size for functions that already depend on
USE_PSA: it should be PSA_HASH_MAX_SIZE for functions that always use
PSA, and the new macro MBEDTLS_USE_PSA_MD_MAX_SIZE for functions that
use it or not depending on USE_PSA.
The only case where MBEDTLS_MD_MAX_SIZE is OK is when the function
always uses MD - currently this is the case with
pk_sign_verify_restart() as it is incompatible with USE_PSA anyway.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/library/use_psa_helpers.h b/library/use_psa_helpers.h
index 6b63ce8..e9a1335 100644
--- a/library/use_psa_helpers.h
+++ b/library/use_psa_helpers.h
@@ -1,8 +1,10 @@
/**
* Internal macros for parts of the code governed by MBEDTLS_USE_PSA_CRYPTO.
- * These macros allow checking if an algorithm is available, either via the
- * legacy API or the PSA Crypto API, depending on MBEDTLS_USE_PSA_CRYPTO.
- * When possible, they're named after the corresponding PSA_WANT_ macro.
+ * Some macros allow checking if an algorithm is available, either via the
+ * legacy API or the PSA Crypto API, depending on MBEDTLS_USE_PSA_CRYPTO;
+ * when possible, they're named after the corresponding PSA_WANT_ macro.
+ * Other macros provide max sizes or similar information in a USE_PSA-aware
+ * way; they're name after a similar constant from the legacy API or PSA.
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
@@ -55,4 +57,11 @@
#define MBEDTLS_USE_PSA_WANT_ALG_SHA_512
#endif
+/* Hash information */
+#if defined(MBEDTLS_USE_PSA_CRYPTO)
+#define MBEDTLS_USE_PSA_MD_MAX_SIZE PSA_HASH_MAX_SIZE
+#else
+#define MBEDTLS_USE_PSA_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE
+#endif
+
#endif /* MBEDTLS_USE_PSA_HELPERS_H */