mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-11-02 09:33:20 +03:00
psa: driver: Reduce the scope of test driver entry points
Define test driver entry points that provide an alternative to Mbed TLS driver entry points only when the PSA configuration is used. Their purpose is only to test the PSA configuration thus there is no good reason to use them out of this scope. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@@ -66,10 +66,19 @@ psa_status_t mbedtls_test_transparent_cipher_encrypt(
|
||||
|
||||
psa_generate_random( output, PSA_CIPHER_IV_LENGTH( attributes->core.type, alg ) );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_encrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_encrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt(
|
||||
@@ -101,10 +110,19 @@ psa_status_t mbedtls_test_transparent_cipher_decrypt(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_decrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_decrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
|
||||
@@ -124,8 +142,15 @@ psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
|
||||
@@ -139,8 +164,15 @@ psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_abort(
|
||||
@@ -148,7 +180,11 @@ psa_status_t mbedtls_test_transparent_cipher_abort(
|
||||
{
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_transparent_test_driver_cipher_abort( operation );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
mbedtls_psa_cipher_abort( operation );
|
||||
#endif
|
||||
|
||||
/* Wiping the entire struct here, instead of member-by-member. This is
|
||||
* useful for the test suite, since it gives a chance of catching memory
|
||||
@@ -169,8 +205,14 @@ psa_status_t mbedtls_test_transparent_cipher_set_iv(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_set_iv(
|
||||
operation, iv, iv_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_set_iv( operation, iv, iv_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_update(
|
||||
@@ -199,9 +241,17 @@ psa_status_t mbedtls_test_transparent_cipher_update(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_update(
|
||||
operation, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_update(
|
||||
operation, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_finish(
|
||||
@@ -228,8 +278,15 @@ psa_status_t mbedtls_test_transparent_cipher_finish(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_finish(
|
||||
operation, output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_finish(
|
||||
operation, output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user