tests: driver wrappers: Specialize hash multi-part test on setup only

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2021-05-01 14:38:42 +02:00
parent eba3c87100
commit 6e12b7b50c
2 changed files with 12 additions and 65 deletions

View File

@ -283,20 +283,20 @@ hash_compute:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e994148
Hash compute: SHA-256, INSUFFICIENT_MEMORY
hash_compute:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_INSUFFICIENT_MEMORY:PSA_ERROR_INSUFFICIENT_MEMORY
Hash multi-part: SHA-256, computed by the driver
Hash multi-part setup: SHA-256, computed by the driver
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
hash_multipart:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS:PSA_SUCCESS
hash_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS:PSA_SUCCESS
Hash multi-part: SHA-256, fallback
Hash multi-part setup: SHA-256, fallback
depends_on:MBEDTLS_PSA_BUILTIN_ALG_SHA_256
hash_multipart:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED:PSA_SUCCESS
hash_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED:PSA_SUCCESS
Hash multi-part: SHA-256, no fallback
Hash multi-part setup: SHA-256, no fallback
depends_on:!MBEDTLS_PSA_BUILTIN_ALG_SHA_256
hash_multipart:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED:PSA_ERROR_NOT_SUPPORTED
hash_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED:PSA_ERROR_NOT_SUPPORTED
Hash multi-part: SHA-256, INSUFFICIENT_MEMORY
hash_compute:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_INSUFFICIENT_MEMORY:PSA_ERROR_INSUFFICIENT_MEMORY
Hash multi-part setup: SHA-256, INSUFFICIENT_MEMORY
hash_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_INSUFFICIENT_MEMORY:PSA_ERROR_INSUFFICIENT_MEMORY
Hash clone: SHA-256, clone successful
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256

View File

@ -1104,10 +1104,10 @@ exit:
/* END_CASE */
/* BEGIN_CASE */
void hash_multipart( int alg_arg,
data_t *input, data_t *hash,
int forced_status_arg,
int expected_status_arg )
void hash_multipart_setup( int alg_arg,
data_t *input, data_t *hash,
int forced_status_arg,
int expected_status_arg )
{
psa_algorithm_t alg = alg_arg;
psa_status_t forced_status = forced_status_arg;
@ -1121,9 +1121,6 @@ void hash_multipart( int alg_arg,
PSA_ASSERT( psa_crypto_init( ) );
/*
* Case 1: Force the driver return status for setup.
*/
mbedtls_test_driver_hash_hooks.forced_status = forced_status;
TEST_EQUAL( psa_hash_setup( &operation, alg ), expected_status );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 1 );
@ -1146,56 +1143,6 @@ void hash_multipart( int alg_arg,
ASSERT_COMPARE( output, output_length, hash->x, hash->len );
}
/*
* Case 2: Force the driver return status for update.
*/
mbedtls_test_driver_hash_hooks = mbedtls_test_driver_hash_hooks_init();
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 1 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, PSA_SUCCESS );
mbedtls_test_driver_hash_hooks.forced_status = forced_status;
TEST_EQUAL( psa_hash_update( &operation, input->x, input->len ),
forced_status );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits,
forced_status != PSA_SUCCESS ? 3 : 2 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, forced_status );
if( forced_status == PSA_SUCCESS )
{
PSA_ASSERT( psa_hash_finish( &operation,
output, PSA_HASH_LENGTH( alg ),
&output_length ) );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 4 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, forced_status );
ASSERT_COMPARE( output, output_length, hash->x, hash->len );
}
/*
* Case 3: Force the driver return status for finish.
*/
mbedtls_test_driver_hash_hooks = mbedtls_test_driver_hash_hooks_init();
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 1 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, PSA_SUCCESS );
PSA_ASSERT( psa_hash_update( &operation, input->x, input->len ) );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 2 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, PSA_SUCCESS );
mbedtls_test_driver_hash_hooks.forced_status = forced_status;
TEST_EQUAL( psa_hash_finish( &operation,
output, PSA_HASH_LENGTH( alg ),
&output_length ), forced_status );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 4 );
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, forced_status );
if( forced_status == PSA_SUCCESS )
{
ASSERT_COMPARE( output, output_length, hash->x, hash->len );
}
exit:
psa_hash_abort( &operation );
mbedtls_free( output );