mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-10-31 21:50:31 +03:00
tests: psa: Add mbedtls/MBEDTLS prefix to test driver symbols
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@@ -36,9 +36,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
test_driver_cipher_hooks_t test_driver_cipher_hooks = TEST_DRIVER_CIPHER_INIT;
|
||||
mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks =
|
||||
MBEDTLS_TEST_DRIVER_CIPHER_INIT;
|
||||
|
||||
static psa_status_t test_transparent_cipher_oneshot(
|
||||
static psa_status_t mbedtls_test_transparent_cipher_oneshot(
|
||||
mbedtls_operation_t direction,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
@@ -46,7 +47,7 @@ static psa_status_t test_transparent_cipher_oneshot(
|
||||
const uint8_t *input, size_t input_length,
|
||||
uint8_t *output, size_t output_size, size_t *output_length)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
/* Test driver supports AES-CTR only, to verify operation calls. */
|
||||
if( alg != PSA_ALG_CTR ||
|
||||
@@ -54,21 +55,21 @@ static psa_status_t test_transparent_cipher_oneshot(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
|
||||
/* If test driver response code is not SUCCESS, we can return early */
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
/* If test driver output is overridden, we don't need to do actual crypto */
|
||||
if( test_driver_cipher_hooks.forced_output != NULL )
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
|
||||
{
|
||||
if( output_size < test_driver_cipher_hooks.forced_output_length )
|
||||
if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
|
||||
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
||||
|
||||
memcpy( output,
|
||||
test_driver_cipher_hooks.forced_output,
|
||||
test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = test_driver_cipher_hooks.forced_output_length;
|
||||
mbedtls_test_driver_cipher_hooks.forced_output,
|
||||
mbedtls_test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
|
||||
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
}
|
||||
|
||||
/* Run AES-CTR using the cipher module */
|
||||
@@ -166,7 +167,7 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_encrypt(
|
||||
psa_status_t mbedtls_test_transparent_cipher_encrypt(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg,
|
||||
@@ -174,7 +175,7 @@ psa_status_t test_transparent_cipher_encrypt(
|
||||
uint8_t *output, size_t output_size, size_t *output_length)
|
||||
{
|
||||
return (
|
||||
test_transparent_cipher_oneshot(
|
||||
mbedtls_test_transparent_cipher_oneshot(
|
||||
MBEDTLS_ENCRYPT,
|
||||
attributes,
|
||||
key, key_length,
|
||||
@@ -183,7 +184,7 @@ psa_status_t test_transparent_cipher_encrypt(
|
||||
output, output_size, output_length) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_decrypt(
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg,
|
||||
@@ -191,7 +192,7 @@ psa_status_t test_transparent_cipher_decrypt(
|
||||
uint8_t *output, size_t output_size, size_t *output_length)
|
||||
{
|
||||
return (
|
||||
test_transparent_cipher_oneshot(
|
||||
mbedtls_test_transparent_cipher_oneshot(
|
||||
MBEDTLS_DECRYPT,
|
||||
attributes,
|
||||
key, key_length,
|
||||
@@ -200,13 +201,13 @@ psa_status_t test_transparent_cipher_decrypt(
|
||||
output, output_size, output_length) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_encrypt_setup(
|
||||
psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
/* 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
|
||||
@@ -214,32 +215,32 @@ psa_status_t test_transparent_cipher_encrypt_setup(
|
||||
* our context struct. */
|
||||
memset( operation, 0, sizeof( *operation ) );
|
||||
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
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 ) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_decrypt_setup(
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
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 ) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_abort(
|
||||
psa_status_t mbedtls_test_transparent_cipher_abort(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
if( operation->alg == 0 )
|
||||
return( PSA_SUCCESS );
|
||||
@@ -252,24 +253,24 @@ psa_status_t test_transparent_cipher_abort(
|
||||
* our context struct. */
|
||||
memset( operation, 0, sizeof( *operation ) );
|
||||
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_set_iv(
|
||||
psa_status_t mbedtls_test_transparent_cipher_set_iv(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation,
|
||||
const uint8_t *iv,
|
||||
size_t iv_length)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return( mbedtls_transparent_test_driver_cipher_set_iv(
|
||||
operation, iv, iv_length ) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_update(
|
||||
psa_status_t mbedtls_test_transparent_cipher_update(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length,
|
||||
@@ -277,52 +278,52 @@ psa_status_t test_transparent_cipher_update(
|
||||
size_t output_size,
|
||||
size_t *output_length)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
if( test_driver_cipher_hooks.forced_output != NULL )
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
|
||||
{
|
||||
if( output_size < test_driver_cipher_hooks.forced_output_length )
|
||||
if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
|
||||
return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy( output,
|
||||
test_driver_cipher_hooks.forced_output,
|
||||
test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = test_driver_cipher_hooks.forced_output_length;
|
||||
mbedtls_test_driver_cipher_hooks.forced_output,
|
||||
mbedtls_test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
|
||||
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
}
|
||||
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return( mbedtls_transparent_test_driver_cipher_update(
|
||||
operation, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
}
|
||||
|
||||
psa_status_t test_transparent_cipher_finish(
|
||||
psa_status_t mbedtls_test_transparent_cipher_finish(
|
||||
mbedtls_transparent_test_driver_cipher_operation_t *operation,
|
||||
uint8_t *output,
|
||||
size_t output_size,
|
||||
size_t *output_length)
|
||||
{
|
||||
test_driver_cipher_hooks.hits++;
|
||||
mbedtls_test_driver_cipher_hooks.hits++;
|
||||
|
||||
if( test_driver_cipher_hooks.forced_output != NULL )
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
|
||||
{
|
||||
if( output_size < test_driver_cipher_hooks.forced_output_length )
|
||||
if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
|
||||
return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy( output,
|
||||
test_driver_cipher_hooks.forced_output,
|
||||
test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = test_driver_cipher_hooks.forced_output_length;
|
||||
mbedtls_test_driver_cipher_hooks.forced_output,
|
||||
mbedtls_test_driver_cipher_hooks.forced_output_length );
|
||||
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
|
||||
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
}
|
||||
|
||||
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( test_driver_cipher_hooks.forced_status );
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return( mbedtls_transparent_test_driver_cipher_finish(
|
||||
operation, output, output_size, output_length ) );
|
||||
@@ -331,7 +332,7 @@ psa_status_t test_transparent_cipher_finish(
|
||||
/*
|
||||
* opaque versions, to do
|
||||
*/
|
||||
psa_status_t test_opaque_cipher_encrypt(
|
||||
psa_status_t mbedtls_test_opaque_cipher_encrypt(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg,
|
||||
@@ -350,7 +351,7 @@ psa_status_t test_opaque_cipher_encrypt(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_decrypt(
|
||||
psa_status_t mbedtls_test_opaque_cipher_decrypt(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
psa_algorithm_t alg,
|
||||
@@ -369,7 +370,7 @@ psa_status_t test_opaque_cipher_decrypt(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_encrypt_setup(
|
||||
psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
@@ -383,7 +384,7 @@ psa_status_t test_opaque_cipher_encrypt_setup(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_decrypt_setup(
|
||||
psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation,
|
||||
const psa_key_attributes_t *attributes,
|
||||
const uint8_t *key, size_t key_length,
|
||||
@@ -397,14 +398,14 @@ psa_status_t test_opaque_cipher_decrypt_setup(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_abort(
|
||||
psa_status_t mbedtls_test_opaque_cipher_abort(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation )
|
||||
{
|
||||
(void) operation;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_set_iv(
|
||||
psa_status_t mbedtls_test_opaque_cipher_set_iv(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation,
|
||||
const uint8_t *iv,
|
||||
size_t iv_length)
|
||||
@@ -415,7 +416,7 @@ psa_status_t test_opaque_cipher_set_iv(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_update(
|
||||
psa_status_t mbedtls_test_opaque_cipher_update(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation,
|
||||
const uint8_t *input,
|
||||
size_t input_length,
|
||||
@@ -432,7 +433,7 @@ psa_status_t test_opaque_cipher_update(
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_cipher_finish(
|
||||
psa_status_t mbedtls_test_opaque_cipher_finish(
|
||||
mbedtls_opaque_test_driver_cipher_operation_t *operation,
|
||||
uint8_t *output,
|
||||
size_t output_size,
|
||||
|
||||
Reference in New Issue
Block a user