mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 13:41:00 +00:00
tests: driver wrappers: Add hash finish tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
acf5ff3ea5
commit
1459b7af04
|
@ -306,6 +306,14 @@ Hash multi-part update: SHA-256, update failure
|
||||||
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
||||||
hash_multipart_update:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED
|
hash_multipart_update:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED
|
||||||
|
|
||||||
|
Hash multi-part finish: SHA-256, finish successful
|
||||||
|
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
||||||
|
hash_multipart_update:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS
|
||||||
|
|
||||||
|
Hash multi-part finish: SHA-256, finish failure
|
||||||
|
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
||||||
|
hash_multipart_update:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_NOT_SUPPORTED
|
||||||
|
|
||||||
Hash clone: SHA-256, clone successful
|
Hash clone: SHA-256, clone successful
|
||||||
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
||||||
hash_clone:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS
|
hash_clone:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS
|
||||||
|
|
|
@ -1207,6 +1207,58 @@ exit:
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE */
|
||||||
|
void hash_multipart_finish( int alg_arg,
|
||||||
|
data_t *input, data_t *hash,
|
||||||
|
int forced_status_arg )
|
||||||
|
{
|
||||||
|
psa_algorithm_t alg = alg_arg;
|
||||||
|
psa_status_t forced_status = forced_status_arg;
|
||||||
|
unsigned char *output = NULL;
|
||||||
|
psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT;
|
||||||
|
size_t output_length;
|
||||||
|
|
||||||
|
mbedtls_test_driver_hash_hooks = mbedtls_test_driver_hash_hooks_init();
|
||||||
|
ASSERT_ALLOC( output, PSA_HASH_LENGTH( alg ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish none active operation, the driver shouldn't be called.
|
||||||
|
*/
|
||||||
|
TEST_EQUAL( psa_hash_finish( &operation, output, PSA_HASH_LENGTH( alg ),
|
||||||
|
&output_length ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 0 );
|
||||||
|
|
||||||
|
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 );
|
||||||
|
/* Two more calls to the driver interface: finish + abort */
|
||||||
|
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 );
|
||||||
|
PSA_DONE( );
|
||||||
|
mbedtls_test_driver_hash_hooks = mbedtls_test_driver_hash_hooks_init();
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void hash_clone( int alg_arg,
|
void hash_clone( int alg_arg,
|
||||||
data_t *input, data_t *hash,
|
data_t *input, data_t *hash,
|
||||||
|
|
Loading…
Reference in a new issue