From edb20865c7a9cf9c608d0bf32ccc38461a37d267 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 7 Feb 2022 15:47:44 +0100 Subject: [PATCH] Add One-Shot Hash setup test Signed-off-by: Neil Armstrong --- tests/suites/test_suite_psa_crypto.function | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index c94c37e8a..9874d58dc 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1803,12 +1803,24 @@ void hash_setup( int alg_arg, int expected_status_arg ) { psa_algorithm_t alg = alg_arg; + uint8_t *output = NULL; + size_t output_size = 0; + size_t output_length = 0; 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 Setup, one-shot */ + output_size = PSA_HASH_LENGTH(alg); + ASSERT_ALLOC( output, output_size ); + + status = psa_hash_compute( alg, NULL, 0, + output, output_size, &output_length ); + TEST_EQUAL( status, expected_status ); + + /* Hash Setup, multi-part */ status = psa_hash_setup( &operation, alg ); TEST_EQUAL( status, expected_status ); @@ -1827,6 +1839,7 @@ void hash_setup( int alg_arg, #endif exit: + mbedtls_free( output ); PSA_DONE( ); } /* END_CASE */