psa: driver wrapper: Change cipher_xyz signature

Change the operation context to the PSA one to be
able to call the software implementation from
the driver wrapper later on.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-12-15 13:58:07 +01:00
parent 6d05173359
commit 6056fe8a81
3 changed files with 48 additions and 45 deletions

View file

@ -3490,7 +3490,7 @@ psa_status_t psa_cipher_generate_iv( psa_cipher_operation_t *operation,
if( operation->mbedtls_in_use == 0 )
{
status = psa_driver_wrapper_cipher_generate_iv( &operation->ctx.driver,
status = psa_driver_wrapper_cipher_generate_iv( operation,
iv,
iv_size,
iv_length );
@ -3529,7 +3529,7 @@ psa_status_t psa_cipher_set_iv( psa_cipher_operation_t *operation,
if( operation->mbedtls_in_use == 0 )
{
status = psa_driver_wrapper_cipher_set_iv( &operation->ctx.driver,
status = psa_driver_wrapper_cipher_set_iv( operation,
iv,
iv_length );
}
@ -3565,7 +3565,7 @@ psa_status_t psa_cipher_update( psa_cipher_operation_t *operation,
if( operation->mbedtls_in_use == 0 )
{
status = psa_driver_wrapper_cipher_update( &operation->ctx.driver,
status = psa_driver_wrapper_cipher_update( operation,
input,
input_length,
output,
@ -3606,7 +3606,7 @@ psa_status_t psa_cipher_finish( psa_cipher_operation_t *operation,
if( operation->mbedtls_in_use == 0 )
{
status = psa_driver_wrapper_cipher_finish( &operation->ctx.driver,
status = psa_driver_wrapper_cipher_finish( operation,
output,
output_size,
output_length );
@ -3646,7 +3646,7 @@ psa_status_t psa_cipher_abort( psa_cipher_operation_t *operation )
return( PSA_ERROR_BAD_STATE );
if( operation->mbedtls_in_use == 0 )
psa_driver_wrapper_cipher_abort( &operation->ctx.driver );
psa_driver_wrapper_cipher_abort( operation );
else
mbedtls_psa_cipher_abort( operation );

View file

@ -890,24 +890,26 @@ psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
}
psa_status_t psa_driver_wrapper_cipher_generate_iv(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
uint8_t *iv,
size_t iv_size,
size_t *iv_length )
{
#if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
switch( operation->id )
switch( operation->ctx.driver.id )
{
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( test_transparent_cipher_generate_iv( operation->ctx,
return( test_transparent_cipher_generate_iv(
operation->ctx.driver.ctx,
iv,
iv_size,
iv_length ) );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID:
return( test_opaque_cipher_generate_iv( operation->ctx,
return( test_opaque_cipher_generate_iv(
operation->ctx.driver.ctx,
iv,
iv_size,
iv_length ) );
@ -927,22 +929,22 @@ psa_status_t psa_driver_wrapper_cipher_generate_iv(
}
psa_status_t psa_driver_wrapper_cipher_set_iv(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
const uint8_t *iv,
size_t iv_length )
{
#if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
switch( operation->id )
switch( operation->ctx.driver.id )
{
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( test_transparent_cipher_set_iv( operation->ctx,
return( test_transparent_cipher_set_iv( operation->ctx.driver.ctx,
iv,
iv_length ) );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID:
return( test_opaque_cipher_set_iv( operation->ctx,
return( test_opaque_cipher_set_iv( operation->ctx.driver.ctx,
iv,
iv_length ) );
#endif /* PSA_CRYPTO_DRIVER_TEST */
@ -960,7 +962,7 @@ psa_status_t psa_driver_wrapper_cipher_set_iv(
}
psa_status_t psa_driver_wrapper_cipher_update(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
const uint8_t *input,
size_t input_length,
uint8_t *output,
@ -968,11 +970,11 @@ psa_status_t psa_driver_wrapper_cipher_update(
size_t *output_length )
{
#if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
switch( operation->id )
switch( operation->ctx.driver.id )
{
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( test_transparent_cipher_update( operation->ctx,
return( test_transparent_cipher_update( operation->ctx.driver.ctx,
input,
input_length,
output,
@ -981,7 +983,7 @@ psa_status_t psa_driver_wrapper_cipher_update(
#endif /* PSA_CRYPTO_DRIVER_TEST */
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID:
return( test_opaque_cipher_update( operation->ctx,
return( test_opaque_cipher_update( operation->ctx.driver.ctx,
input,
input_length,
output,
@ -1005,24 +1007,24 @@ psa_status_t psa_driver_wrapper_cipher_update(
}
psa_status_t psa_driver_wrapper_cipher_finish(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
uint8_t *output,
size_t output_size,
size_t *output_length )
{
#if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
switch( operation->id )
switch( operation->ctx.driver.id )
{
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
return( test_transparent_cipher_finish( operation->ctx,
return( test_transparent_cipher_finish( operation->ctx.driver.ctx,
output,
output_size,
output_length ) );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID:
return( test_opaque_cipher_finish( operation->ctx,
return( test_opaque_cipher_finish( operation->ctx.driver.ctx,
output,
output_size,
output_length ) );
@ -1042,39 +1044,40 @@ psa_status_t psa_driver_wrapper_cipher_finish(
}
psa_status_t psa_driver_wrapper_cipher_abort(
psa_operation_driver_context_t *operation )
psa_cipher_operation_t *operation )
{
#if defined(PSA_CRYPTO_DRIVER_PRESENT) && defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
psa_operation_driver_context_t *driver_context = &operation->ctx.driver;
/* The object has (apparently) been initialized but it is not in use. It's
* ok to call abort on such an object, and there's nothing to do. */
if( operation->ctx == NULL && operation->id == 0 )
if( driver_context->ctx == NULL && driver_context->id == 0 )
return( PSA_SUCCESS );
switch( operation->id )
switch( driver_context->id )
{
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID:
status = test_transparent_cipher_abort( operation->ctx );
status = test_transparent_cipher_abort( driver_context->ctx );
mbedtls_platform_zeroize(
operation->ctx,
driver_context->ctx,
sizeof( test_transparent_cipher_operation_t ) );
mbedtls_free( operation->ctx );
operation->ctx = NULL;
operation->id = 0;
mbedtls_free( driver_context->ctx );
driver_context->ctx = NULL;
driver_context->id = 0;
return( status );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_OPAQUE_TEST_DRIVER_ID:
status = test_opaque_cipher_abort( operation->ctx );
status = test_opaque_cipher_abort( driver_context->ctx );
mbedtls_platform_zeroize(
operation->ctx,
driver_context->ctx,
sizeof( test_opaque_cipher_operation_t ) );
mbedtls_free( operation->ctx );
operation->ctx = NULL;
operation->id = 0;
mbedtls_free( driver_context->ctx );
driver_context->ctx = NULL;
driver_context->id = 0;
return( status );
#endif /* PSA_CRYPTO_DRIVER_TEST */

View file

@ -102,18 +102,18 @@ psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
psa_algorithm_t alg );
psa_status_t psa_driver_wrapper_cipher_generate_iv(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
uint8_t *iv,
size_t iv_size,
size_t *iv_length );
psa_status_t psa_driver_wrapper_cipher_set_iv(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
const uint8_t *iv,
size_t iv_length );
psa_status_t psa_driver_wrapper_cipher_update(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
const uint8_t *input,
size_t input_length,
uint8_t *output,
@ -121,13 +121,13 @@ psa_status_t psa_driver_wrapper_cipher_update(
size_t *output_length );
psa_status_t psa_driver_wrapper_cipher_finish(
psa_operation_driver_context_t *operation,
psa_cipher_operation_t *operation,
uint8_t *output,
size_t output_size,
size_t *output_length );
psa_status_t psa_driver_wrapper_cipher_abort(
psa_operation_driver_context_t *operation );
psa_cipher_operation_t *operation );
/*
* Hashing functions