Apply mbedtls namespacing to MAC driver test hooks
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
d1a68f10c0
commit
ae3ec52d8d
3 changed files with 111 additions and 109 deletions
|
@ -37,16 +37,17 @@ typedef struct {
|
||||||
unsigned long hits;
|
unsigned long hits;
|
||||||
/* Status returned by the last MAC driver function call. */
|
/* Status returned by the last MAC driver function call. */
|
||||||
psa_status_t driver_status;
|
psa_status_t driver_status;
|
||||||
} test_driver_mac_hooks_t;
|
} mbedtls_test_driver_mac_hooks_t;
|
||||||
|
|
||||||
#define MBEDTLS_TEST_DRIVER_MAC_INIT { 0, 0, 0 }
|
#define MBEDTLS_TEST_DRIVER_MAC_INIT { 0, 0, 0 }
|
||||||
static inline test_driver_mac_hooks_t test_driver_mac_hooks_init( void )
|
static inline mbedtls_test_driver_mac_hooks_t
|
||||||
|
mbedtls_test_driver_mac_hooks_init( void )
|
||||||
{
|
{
|
||||||
const test_driver_mac_hooks_t v = MBEDTLS_TEST_DRIVER_MAC_INIT;
|
const mbedtls_test_driver_mac_hooks_t v = MBEDTLS_TEST_DRIVER_MAC_INIT;
|
||||||
return( v );
|
return( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
extern test_driver_mac_hooks_t test_driver_mac_hooks;
|
extern mbedtls_test_driver_mac_hooks_t mbedtls_test_driver_mac_hooks;
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_compute(
|
psa_status_t mbedtls_test_transparent_mac_compute(
|
||||||
const psa_key_attributes_t *attributes,
|
const psa_key_attributes_t *attributes,
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
#include "test/drivers/mac.h"
|
#include "test/drivers/mac.h"
|
||||||
|
|
||||||
test_driver_mac_hooks_t test_driver_mac_hooks = MBEDTLS_TEST_DRIVER_MAC_INIT;
|
mbedtls_test_driver_mac_hooks_t mbedtls_test_driver_mac_hooks =
|
||||||
|
MBEDTLS_TEST_DRIVER_MAC_INIT;
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_compute(
|
psa_status_t mbedtls_test_transparent_mac_compute(
|
||||||
const psa_key_attributes_t *attributes,
|
const psa_key_attributes_t *attributes,
|
||||||
|
@ -41,23 +42,23 @@ psa_status_t mbedtls_test_transparent_mac_compute(
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length )
|
size_t *mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_compute(
|
mbedtls_transparent_test_driver_mac_compute(
|
||||||
attributes, key_buffer, key_buffer_size, alg,
|
attributes, key_buffer, key_buffer_size, alg,
|
||||||
input, input_length,
|
input, input_length,
|
||||||
mac, mac_size, mac_length );
|
mac, mac_size, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_sign_setup(
|
psa_status_t mbedtls_test_transparent_mac_sign_setup(
|
||||||
|
@ -67,21 +68,21 @@ psa_status_t mbedtls_test_transparent_mac_sign_setup(
|
||||||
size_t key_buffer_size,
|
size_t key_buffer_size,
|
||||||
psa_algorithm_t alg )
|
psa_algorithm_t alg )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_sign_setup(
|
mbedtls_transparent_test_driver_mac_sign_setup(
|
||||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_verify_setup(
|
psa_status_t mbedtls_test_transparent_mac_verify_setup(
|
||||||
|
@ -91,21 +92,21 @@ psa_status_t mbedtls_test_transparent_mac_verify_setup(
|
||||||
size_t key_buffer_size,
|
size_t key_buffer_size,
|
||||||
psa_algorithm_t alg )
|
psa_algorithm_t alg )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_verify_setup(
|
mbedtls_transparent_test_driver_mac_verify_setup(
|
||||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_update(
|
psa_status_t mbedtls_test_transparent_mac_update(
|
||||||
|
@ -113,21 +114,21 @@ psa_status_t mbedtls_test_transparent_mac_update(
|
||||||
const uint8_t *input,
|
const uint8_t *input,
|
||||||
size_t input_length )
|
size_t input_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_update(
|
mbedtls_transparent_test_driver_mac_update(
|
||||||
operation, input, input_length );
|
operation, input, input_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_sign_finish(
|
psa_status_t mbedtls_test_transparent_mac_sign_finish(
|
||||||
|
@ -136,21 +137,21 @@ psa_status_t mbedtls_test_transparent_mac_sign_finish(
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length )
|
size_t *mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_sign_finish(
|
mbedtls_transparent_test_driver_mac_sign_finish(
|
||||||
operation, mac, mac_size, mac_length );
|
operation, mac, mac_size, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_verify_finish(
|
psa_status_t mbedtls_test_transparent_mac_verify_finish(
|
||||||
|
@ -158,40 +159,40 @@ psa_status_t mbedtls_test_transparent_mac_verify_finish(
|
||||||
const uint8_t *mac,
|
const uint8_t *mac,
|
||||||
size_t mac_length )
|
size_t mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_verify_finish(
|
mbedtls_transparent_test_driver_mac_verify_finish(
|
||||||
operation, mac, mac_length );
|
operation, mac, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_transparent_mac_abort(
|
psa_status_t mbedtls_test_transparent_mac_abort(
|
||||||
mbedtls_transparent_test_driver_mac_operation_t *operation )
|
mbedtls_transparent_test_driver_mac_operation_t *operation )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_transparent_test_driver_mac_abort( operation );
|
mbedtls_transparent_test_driver_mac_abort( operation );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_compute(
|
psa_status_t mbedtls_test_opaque_mac_compute(
|
||||||
|
@ -205,23 +206,23 @@ psa_status_t mbedtls_test_opaque_mac_compute(
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length )
|
size_t *mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_compute(
|
mbedtls_opaque_test_driver_mac_compute(
|
||||||
attributes, key_buffer, key_buffer_size, alg,
|
attributes, key_buffer, key_buffer_size, alg,
|
||||||
input, input_length,
|
input, input_length,
|
||||||
mac, mac_size, mac_length );
|
mac, mac_size, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_sign_setup(
|
psa_status_t mbedtls_test_opaque_mac_sign_setup(
|
||||||
|
@ -231,21 +232,21 @@ psa_status_t mbedtls_test_opaque_mac_sign_setup(
|
||||||
size_t key_buffer_size,
|
size_t key_buffer_size,
|
||||||
psa_algorithm_t alg )
|
psa_algorithm_t alg )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_sign_setup(
|
mbedtls_opaque_test_driver_mac_sign_setup(
|
||||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_verify_setup(
|
psa_status_t mbedtls_test_opaque_mac_verify_setup(
|
||||||
|
@ -255,21 +256,21 @@ psa_status_t mbedtls_test_opaque_mac_verify_setup(
|
||||||
size_t key_buffer_size,
|
size_t key_buffer_size,
|
||||||
psa_algorithm_t alg )
|
psa_algorithm_t alg )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_verify_setup(
|
mbedtls_opaque_test_driver_mac_verify_setup(
|
||||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_update(
|
psa_status_t mbedtls_test_opaque_mac_update(
|
||||||
|
@ -277,21 +278,21 @@ psa_status_t mbedtls_test_opaque_mac_update(
|
||||||
const uint8_t *input,
|
const uint8_t *input,
|
||||||
size_t input_length )
|
size_t input_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_update(
|
mbedtls_opaque_test_driver_mac_update(
|
||||||
operation, input, input_length );
|
operation, input, input_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_sign_finish(
|
psa_status_t mbedtls_test_opaque_mac_sign_finish(
|
||||||
|
@ -300,21 +301,21 @@ psa_status_t mbedtls_test_opaque_mac_sign_finish(
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length )
|
size_t *mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_sign_finish(
|
mbedtls_opaque_test_driver_mac_sign_finish(
|
||||||
operation, mac, mac_size, mac_length );
|
operation, mac, mac_size, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_verify_finish(
|
psa_status_t mbedtls_test_opaque_mac_verify_finish(
|
||||||
|
@ -322,40 +323,40 @@ psa_status_t mbedtls_test_opaque_mac_verify_finish(
|
||||||
const uint8_t *mac,
|
const uint8_t *mac,
|
||||||
size_t mac_length )
|
size_t mac_length )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_verify_finish(
|
mbedtls_opaque_test_driver_mac_verify_finish(
|
||||||
operation, mac, mac_length );
|
operation, mac, mac_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_test_opaque_mac_abort(
|
psa_status_t mbedtls_test_opaque_mac_abort(
|
||||||
mbedtls_opaque_test_driver_mac_operation_t *operation )
|
mbedtls_opaque_test_driver_mac_operation_t *operation )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.hits++;
|
mbedtls_test_driver_mac_hooks.hits++;
|
||||||
|
|
||||||
if( test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
test_driver_mac_hooks.forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
test_driver_mac_hooks.driver_status =
|
mbedtls_test_driver_mac_hooks.driver_status =
|
||||||
mbedtls_opaque_test_driver_mac_abort( operation );
|
mbedtls_opaque_test_driver_mac_abort( operation );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( test_driver_mac_hooks.driver_status );
|
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */
|
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
|
|
@ -982,7 +982,7 @@ void mac_sign( int key_type_arg,
|
||||||
size_t mac_length = 0;
|
size_t mac_length = 0;
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_status_t forced_status = forced_status_arg;
|
psa_status_t forced_status = forced_status_arg;
|
||||||
test_driver_mac_hooks = test_driver_mac_hooks_init();
|
mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init();
|
||||||
|
|
||||||
TEST_ASSERT( mac_buffer_size <= PSA_MAC_MAX_SIZE );
|
TEST_ASSERT( mac_buffer_size <= PSA_MAC_MAX_SIZE );
|
||||||
/* We expect PSA_MAC_LENGTH to be exact. */
|
/* We expect PSA_MAC_LENGTH to be exact. */
|
||||||
|
@ -998,11 +998,11 @@ void mac_sign( int key_type_arg,
|
||||||
&key ) );
|
&key ) );
|
||||||
|
|
||||||
ASSERT_ALLOC( actual_mac, mac_buffer_size );
|
ASSERT_ALLOC( actual_mac, mac_buffer_size );
|
||||||
test_driver_mac_hooks.forced_status = forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status = forced_status;
|
||||||
|
|
||||||
/* Calculate the MAC. */
|
/* Calculate the MAC. */
|
||||||
status = psa_mac_sign_setup( &operation, key, alg );
|
status = psa_mac_sign_setup( &operation, key, alg );
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
|
@ -1015,9 +1015,9 @@ void mac_sign( int key_type_arg,
|
||||||
status = psa_mac_update( &operation,
|
status = psa_mac_update( &operation,
|
||||||
input->x, input->len );
|
input->x, input->len );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 2 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 2 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
{
|
{
|
||||||
|
@ -1030,9 +1030,9 @@ void mac_sign( int key_type_arg,
|
||||||
actual_mac, mac_buffer_size,
|
actual_mac, mac_buffer_size,
|
||||||
&mac_length );
|
&mac_length );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 4 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
|
@ -1044,9 +1044,9 @@ void mac_sign( int key_type_arg,
|
||||||
|
|
||||||
PSA_ASSERT( psa_mac_abort( &operation ) );
|
PSA_ASSERT( psa_mac_abort( &operation ) );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 4 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
|
@ -1062,7 +1062,7 @@ exit:
|
||||||
psa_destroy_key( key );
|
psa_destroy_key( key );
|
||||||
PSA_DONE( );
|
PSA_DONE( );
|
||||||
mbedtls_free( actual_mac );
|
mbedtls_free( actual_mac );
|
||||||
test_driver_mac_hooks = test_driver_mac_hooks_init();
|
mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ void mac_verify( int key_type_arg,
|
||||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
||||||
psa_status_t forced_status = forced_status_arg;
|
psa_status_t forced_status = forced_status_arg;
|
||||||
test_driver_mac_hooks = test_driver_mac_hooks_init();
|
mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init();
|
||||||
|
|
||||||
TEST_ASSERT( expected_mac->len <= PSA_MAC_MAX_SIZE );
|
TEST_ASSERT( expected_mac->len <= PSA_MAC_MAX_SIZE );
|
||||||
|
|
||||||
|
@ -1094,11 +1094,11 @@ void mac_verify( int key_type_arg,
|
||||||
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
||||||
&key ) );
|
&key ) );
|
||||||
|
|
||||||
test_driver_mac_hooks.forced_status = forced_status;
|
mbedtls_test_driver_mac_hooks.forced_status = forced_status;
|
||||||
|
|
||||||
/* Test the correct MAC. */
|
/* Test the correct MAC. */
|
||||||
status = psa_mac_verify_setup( &operation, key, alg );
|
status = psa_mac_verify_setup( &operation, key, alg );
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
|
@ -1111,9 +1111,9 @@ void mac_verify( int key_type_arg,
|
||||||
status = psa_mac_update( &operation,
|
status = psa_mac_update( &operation,
|
||||||
input->x, input->len );
|
input->x, input->len );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 2 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 2 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
|
@ -1127,9 +1127,9 @@ void mac_verify( int key_type_arg,
|
||||||
expected_mac->x,
|
expected_mac->x,
|
||||||
expected_mac->len );
|
expected_mac->len );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 4 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
if( forced_status == PSA_SUCCESS ||
|
if( forced_status == PSA_SUCCESS ||
|
||||||
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
forced_status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
|
@ -1142,15 +1142,15 @@ void mac_verify( int key_type_arg,
|
||||||
|
|
||||||
PSA_ASSERT( psa_mac_abort( &operation ) );
|
PSA_ASSERT( psa_mac_abort( &operation ) );
|
||||||
if( forced_status == PSA_SUCCESS )
|
if( forced_status == PSA_SUCCESS )
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 4 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 );
|
||||||
else
|
else
|
||||||
TEST_EQUAL( test_driver_mac_hooks.hits, 1 );
|
TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
psa_mac_abort( &operation );
|
psa_mac_abort( &operation );
|
||||||
psa_destroy_key( key );
|
psa_destroy_key( key );
|
||||||
PSA_DONE( );
|
PSA_DONE( );
|
||||||
test_driver_mac_hooks = test_driver_mac_hooks_init();
|
mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue