psa: cipher: Add transparent driver test specific entry points

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2021-03-12 11:08:49 +01:00
parent 8287e6b078
commit 3522e32132
3 changed files with 114 additions and 25 deletions

View file

@ -418,4 +418,66 @@ psa_status_t mbedtls_psa_cipher_abort( mbedtls_psa_cipher_operation_t *operation
return( cipher_abort( operation ) );
}
/*
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
*/
#if defined(PSA_CRYPTO_DRIVER_TEST)
psa_status_t mbedtls_transparent_test_driver_cipher_encrypt_setup(
mbedtls_psa_cipher_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer, size_t key_buffer_size,
psa_algorithm_t alg )
{
return( cipher_encrypt_setup(
operation, attributes, key_buffer, key_buffer_size, alg ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_decrypt_setup(
mbedtls_psa_cipher_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer, size_t key_buffer_size,
psa_algorithm_t alg )
{
return( cipher_decrypt_setup(
operation, attributes, key_buffer, key_buffer_size, alg ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_generate_iv(
mbedtls_psa_cipher_operation_t *operation,
uint8_t *iv, size_t iv_size, size_t *iv_length )
{
return( cipher_generate_iv( operation, iv, iv_size, iv_length ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_set_iv(
mbedtls_psa_cipher_operation_t *operation,
const uint8_t *iv, size_t iv_length )
{
return( cipher_set_iv( operation, iv, iv_length ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_update(
mbedtls_psa_cipher_operation_t *operation,
const uint8_t *input, size_t input_length,
uint8_t *output, size_t output_size, size_t *output_length )
{
return( cipher_update( operation, input, input_length,
output, output_size, output_length ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_finish(
mbedtls_psa_cipher_operation_t *operation,
uint8_t *output, size_t output_size, size_t *output_length )
{
return( cipher_finish( operation, output, output_size, output_length ) );
}
psa_status_t mbedtls_transparent_test_driver_cipher_abort(
mbedtls_psa_cipher_operation_t *operation )
{
return( cipher_abort( operation ) );
}
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* MBEDTLS_PSA_CRYPTO_C */

View file

@ -206,4 +206,42 @@ psa_status_t mbedtls_psa_cipher_finish(
*/
psa_status_t mbedtls_psa_cipher_abort( mbedtls_psa_cipher_operation_t *operation );
/*
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
*/
#if defined(PSA_CRYPTO_DRIVER_TEST)
psa_status_t mbedtls_transparent_test_driver_cipher_encrypt_setup(
mbedtls_psa_cipher_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer, size_t key_buffer_size,
psa_algorithm_t alg );
psa_status_t mbedtls_transparent_test_driver_cipher_decrypt_setup(
mbedtls_psa_cipher_operation_t *operation,
const psa_key_attributes_t *attributes,
const uint8_t *key_buffer, size_t key_buffer_size,
psa_algorithm_t alg );
psa_status_t mbedtls_transparent_test_driver_cipher_generate_iv(
mbedtls_psa_cipher_operation_t *operation,
uint8_t *iv, size_t iv_size, size_t *iv_length );
psa_status_t mbedtls_transparent_test_driver_cipher_set_iv(
mbedtls_psa_cipher_operation_t *operation,
const uint8_t *iv, size_t iv_length );
psa_status_t mbedtls_transparent_test_driver_cipher_update(
mbedtls_psa_cipher_operation_t *operation,
const uint8_t *input, size_t input_length,
uint8_t *output, size_t output_size, size_t *output_length );
psa_status_t mbedtls_transparent_test_driver_cipher_finish(
mbedtls_psa_cipher_operation_t *operation,
uint8_t *output, size_t output_size, size_t *output_length );
psa_status_t mbedtls_transparent_test_driver_cipher_abort(
mbedtls_psa_cipher_operation_t *operation );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_CIPHER_H */

View file

@ -222,11 +222,8 @@ psa_status_t test_transparent_cipher_encrypt_setup(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return ( mbedtls_psa_cipher_encrypt_setup( operation,
attributes,
key,
key_length,
alg ) );
return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
operation, attributes, key, key_length, alg ) );
}
psa_status_t test_transparent_cipher_decrypt_setup(
@ -240,11 +237,8 @@ psa_status_t test_transparent_cipher_decrypt_setup(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return ( mbedtls_psa_cipher_decrypt_setup( operation,
attributes,
key,
key_length,
alg ) );
return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
operation, attributes, key, key_length, alg ) );
}
psa_status_t test_transparent_cipher_abort(
@ -255,7 +249,7 @@ psa_status_t test_transparent_cipher_abort(
if( operation->alg == 0 )
return( PSA_SUCCESS );
mbedtls_psa_cipher_abort( operation );
mbedtls_transparent_test_driver_cipher_abort( operation );
/* 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
@ -277,10 +271,8 @@ psa_status_t test_transparent_cipher_generate_iv(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_generate_iv( operation,
iv,
iv_size,
iv_length ) );
return( mbedtls_transparent_test_driver_cipher_generate_iv(
operation, iv, iv_size, iv_length ) );
}
psa_status_t test_transparent_cipher_set_iv(
@ -293,9 +285,8 @@ psa_status_t test_transparent_cipher_set_iv(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_set_iv( operation,
iv,
iv_length ) );
return( mbedtls_transparent_test_driver_cipher_set_iv(
operation, iv, iv_length ) );
}
psa_status_t test_transparent_cipher_update(
@ -324,10 +315,9 @@ psa_status_t test_transparent_cipher_update(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_update( operation,
input, input_length,
output, output_size,
output_length ) );
return( mbedtls_transparent_test_driver_cipher_update(
operation, input, input_length,
output, output_size, output_length ) );
}
psa_status_t test_transparent_cipher_finish(
@ -354,9 +344,8 @@ psa_status_t test_transparent_cipher_finish(
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_finish( operation,
output, output_size,
output_length ) );
return( mbedtls_transparent_test_driver_cipher_finish(
operation, output, output_size, output_length ) );
}
/*