From 55a1be1f485eaddd0fadafa76a798961b230779d Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 7 Feb 2022 11:23:20 +0100 Subject: [PATCH] Add Multipart Hash Compare fail tests Signed-off-by: Neil Armstrong --- tests/suites/test_suite_psa_crypto.function | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 79235d718..c3bd487d5 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1904,15 +1904,39 @@ void hash_compare_fail( int alg_arg, data_t *input, { psa_algorithm_t alg = alg_arg; psa_status_t expected_status = expected_status_arg; + psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT; psa_status_t status; PSA_ASSERT( psa_crypto_init( ) ); + /* Hash Compare, one-shot */ status = psa_hash_compare( alg, input->x, input->len, reference_hash->x, reference_hash->len ); 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: + PSA_ASSERT( psa_hash_abort( &operation ) ); PSA_DONE( ); } /* END_CASE */