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>
This commit is contained in:
parent
b6bf4bbf95
commit
f8e45a4e98
@ -43,18 +43,6 @@
|
||||
#define MBEDTLS_PSA_BUILTIN_HASH
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_MD2) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_MD4) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_MD5) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_RIPEMD160) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_SHA_1) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_SHA_224) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_SHA_256) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_SHA_384) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_SHA_512)
|
||||
#define MBEDTLS_PSA_ACCEL_HASH
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
psa_algorithm_t alg;
|
||||
|
@ -1085,7 +1085,7 @@ psa_status_t psa_driver_wrapper_hash_compute(
|
||||
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 psa_driver_wrapper_hash_setup(
|
||||
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 @@ psa_status_t psa_driver_wrapper_hash_clone(
|
||||
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 @@ psa_status_t psa_driver_wrapper_hash_update(
|
||||
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 @@ psa_status_t psa_driver_wrapper_hash_finish(
|
||||
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 @@ psa_status_t psa_driver_wrapper_hash_abort(
|
||||
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 ) );
|
||||
|
@ -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 @@ const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg )
|
||||
|
||||
/* 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 @@ exit:
|
||||
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 @@ psa_status_t mbedtls_psa_hash_abort(
|
||||
/*
|
||||
* 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 @@ psa_status_t mbedtls_transparent_test_driver_hash_abort(
|
||||
return( hash_abort( operation ) );
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_HASH_TEST_DRIVER */
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
|
Loading…
Reference in New Issue
Block a user