mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-29 09:22:45 +08:00
Add Multipart Hash Compare fail tests
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
161ec5c368
commit
55a1be1f48
@ -1904,15 +1904,39 @@ void hash_compare_fail( int alg_arg, data_t *input,
|
|||||||
{
|
{
|
||||||
psa_algorithm_t alg = alg_arg;
|
psa_algorithm_t alg = alg_arg;
|
||||||
psa_status_t expected_status = expected_status_arg;
|
psa_status_t expected_status = expected_status_arg;
|
||||||
|
psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT;
|
||||||
psa_status_t status;
|
psa_status_t status;
|
||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
|
/* Hash Compare, one-shot */
|
||||||
status = psa_hash_compare( alg, input->x, input->len,
|
status = psa_hash_compare( alg, input->x, input->len,
|
||||||
reference_hash->x, reference_hash->len );
|
reference_hash->x, reference_hash->len );
|
||||||
TEST_EQUAL( status, expected_status );
|
TEST_EQUAL( status, expected_status );
|
||||||
|
|
||||||
|
/* Hash Compare, multi-part */
|
||||||
|
status = psa_hash_setup( &operation, alg );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
status = psa_hash_update( &operation, input->x, input->len );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
{
|
||||||
|
status = psa_hash_verify( &operation, reference_hash->x,
|
||||||
|
reference_hash->len );
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TEST_EQUAL( status, expected_status );
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
PSA_ASSERT( psa_hash_abort( &operation ) );
|
||||||
PSA_DONE( );
|
PSA_DONE( );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user