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 ) ); 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 */ #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 ); 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 */ #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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return ( mbedtls_psa_cipher_encrypt_setup( operation, return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
attributes, operation, attributes, key, key_length, alg ) );
key,
key_length,
alg ) );
} }
psa_status_t test_transparent_cipher_decrypt_setup( 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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return ( mbedtls_psa_cipher_decrypt_setup( operation, return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
attributes, operation, attributes, key, key_length, alg ) );
key,
key_length,
alg ) );
} }
psa_status_t test_transparent_cipher_abort( psa_status_t test_transparent_cipher_abort(
@ -255,7 +249,7 @@ psa_status_t test_transparent_cipher_abort(
if( operation->alg == 0 ) if( operation->alg == 0 )
return( PSA_SUCCESS ); 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 /* 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 * 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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_generate_iv( operation, return( mbedtls_transparent_test_driver_cipher_generate_iv(
iv, operation, iv, iv_size, iv_length ) );
iv_size,
iv_length ) );
} }
psa_status_t test_transparent_cipher_set_iv( 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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_set_iv( operation, return( mbedtls_transparent_test_driver_cipher_set_iv(
iv, operation, iv, iv_length ) );
iv_length ) );
} }
psa_status_t test_transparent_cipher_update( 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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_update( operation, return( mbedtls_transparent_test_driver_cipher_update(
input, input_length, operation, input, input_length,
output, output_size, output, output_size, output_length ) );
output_length ) );
} }
psa_status_t test_transparent_cipher_finish( 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 ) if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status ); return( test_driver_cipher_hooks.forced_status );
return( mbedtls_psa_cipher_finish( operation, return( mbedtls_transparent_test_driver_cipher_finish(
output, output_size, operation, output, output_size, output_length ) );
output_length ) );
} }
/* /*