mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-24 08:56:50 +00:00
tests: driver wrappers: Add hash update tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
32dee6e3d0
commit
acf5ff3ea5
|
@ -298,6 +298,14 @@ hash_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e
|
||||||
Hash multi-part setup: SHA-256, 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_multipart_setup:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_ERROR_INSUFFICIENT_MEMORY:PSA_ERROR_INSUFFICIENT_MEMORY
|
||||||
|
|
||||||
|
Hash multi-part update: SHA-256, update successful
|
||||||
|
depends_on:MBEDTLS_PSA_ACCEL_ALG_SHA_256
|
||||||
|
hash_multipart_update:PSA_ALG_SHA_256:"b0bd69":"4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803":PSA_SUCCESS
|
||||||
|
|
||||||
|
Hash multi-part update: SHA-256, update 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
|
||||||
|
|
|
@ -1151,6 +1151,62 @@ exit:
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE */
|
||||||
|
void hash_multipart_update( 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( ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update none active operation, the driver shouldn't be called.
|
||||||
|
*/
|
||||||
|
TEST_EQUAL( psa_hash_update( &operation, input->x, input->len ),
|
||||||
|
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 );
|
||||||
|
|
||||||
|
mbedtls_test_driver_hash_hooks.forced_status = forced_status;
|
||||||
|
TEST_EQUAL( psa_hash_update( &operation, input->x, input->len ),
|
||||||
|
forced_status );
|
||||||
|
/* One or two more calls to the driver interface: update or update + abort */
|
||||||
|
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits,
|
||||||
|
forced_status == PSA_SUCCESS ? 2 : 3 );
|
||||||
|
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_status, forced_status );
|
||||||
|
|
||||||
|
if( forced_status == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
mbedtls_test_driver_hash_hooks = mbedtls_test_driver_hash_hooks_init();
|
||||||
|
PSA_ASSERT( psa_hash_finish( &operation,
|
||||||
|
output, PSA_HASH_LENGTH( alg ),
|
||||||
|
&output_length ) );
|
||||||
|
/* Two calls to the driver interface: update + abort */
|
||||||
|
TEST_EQUAL( mbedtls_test_driver_hash_hooks.hits, 2 );
|
||||||
|
TEST_EQUAL( mbedtls_test_driver_hash_hooks.driver_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