Simplify compilation guards around hash driver testing
The hash driver entry points (and consequentially the hash driver core)
are now always compiled on when PSA_CRYPTO_DRIVER_TEST is turned on.
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c
index 89452da..6c94472 100644
--- a/library/psa_crypto_driver_wrappers.c
+++ b/library/psa_crypto_driver_wrappers.c
@@ -1085,7 +1085,7 @@
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
/* Try accelerators first */
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
status = mbedtls_transparent_test_driver_hash_compute(
alg, input, input_length, hash, hash_size, hash_length );
if( status != PSA_ERROR_NOT_SUPPORTED )
@@ -1117,7 +1117,7 @@
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
/* Try setup on accelerators first */
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
status = mbedtls_transparent_test_driver_hash_setup(
&operation->ctx.test_driver_ctx, alg );
if( status == PSA_SUCCESS )
@@ -1155,7 +1155,7 @@
return( mbedtls_psa_hash_clone( &source_operation->ctx.mbedtls_ctx,
&target_operation->ctx.mbedtls_ctx ) );
#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
target_operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID;
return( mbedtls_transparent_test_driver_hash_clone(
@@ -1180,7 +1180,7 @@
return( mbedtls_psa_hash_update( &operation->ctx.mbedtls_ctx,
input, input_length ) );
#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( mbedtls_transparent_test_driver_hash_update(
&operation->ctx.test_driver_ctx,
@@ -1206,7 +1206,7 @@
return( mbedtls_psa_hash_finish( &operation->ctx.mbedtls_ctx,
hash, hash_size, hash_length ) );
#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( mbedtls_transparent_test_driver_hash_finish(
&operation->ctx.test_driver_ctx,
@@ -1229,7 +1229,7 @@
case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
return( mbedtls_psa_hash_abort( &operation->ctx.mbedtls_ctx ) );
#endif
-#if defined(PSA_CRYPTO_DRIVER_TEST) && defined(MBEDTLS_PSA_ACCEL_HASH)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( mbedtls_transparent_test_driver_hash_abort(
&operation->ctx.test_driver_ctx ) );
diff --git a/library/psa_crypto_hash.c b/library/psa_crypto_hash.c
index 432d8a0..7552100 100644
--- a/library/psa_crypto_hash.c
+++ b/library/psa_crypto_hash.c
@@ -68,21 +68,6 @@
#define BUILTIN_ALG_SHA_512 1
#endif
-/* If at least one of the hash algorithms is to be exercised through the
- * transparent test driver, then the mbedtls_transparent_test_driver_hash_*
- * entry points need to be implemented. */
-#if defined(PSA_CRYPTO_DRIVER_TEST) && \
- defined(MBEDTLS_PSA_ACCEL_HASH)
-#define INCLUDE_HASH_TEST_DRIVER
-#endif
-
-/* If either of the built-in or test driver entry points need to be implemented, then
- * the core implementation should be present. */
-#if defined(MBEDTLS_PSA_BUILTIN_HASH) || \
- defined(INCLUDE_HASH_TEST_DRIVER)
-#define INCLUDE_HASH_CORE 1
-#endif
-
#if defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) || \
@@ -138,7 +123,7 @@
/* Implement the PSA driver hash interface on top of mbed TLS if either the
* software driver or the test driver requires it. */
-#if defined(INCLUDE_HASH_CORE)
+#if defined(MBEDTLS_PSA_BUILTIN_HASH) || defined(PSA_CRYPTO_DRIVER_TEST)
static psa_status_t hash_abort(
mbedtls_psa_hash_operation_t *operation )
{
@@ -540,7 +525,7 @@
return( status );
}
-#endif /* INCLUDE_HASH_CORE */
+#endif /* MBEDTLS_PSA_BUILTIN_HASH || PSA_CRYPTO_DRIVER_TEST */
#if defined(MBEDTLS_PSA_BUILTIN_HASH)
psa_status_t mbedtls_psa_hash_compute(
@@ -596,7 +581,7 @@
/*
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
*/
-#if defined(INCLUDE_HASH_TEST_DRIVER)
+#if defined(PSA_CRYPTO_DRIVER_TEST)
psa_status_t is_hash_accelerated( psa_algorithm_t alg )
{
@@ -707,6 +692,6 @@
return( hash_abort( operation ) );
}
-#endif /* INCLUDE_HASH_TEST_DRIVER */
+#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* MBEDTLS_PSA_CRYPTO_C */