@@ -1950,6 +1950,7 @@ exit:
1950
1950
/* BEGIN_CASE */
1951
1951
void hash_operation_init( )
1952
1952
{
1953
+ const uint8_t input[1];
1953
1954
/* Test each valid way of initializing the object, except for `= {0}`, as
1954
1955
* Clang 5 complains when `-Wmissing-field-initializers` is used, even
1955
1956
* though it's OK by the C standard. We could test for this, but we'd need
@@ -1960,6 +1961,14 @@ void hash_operation_init( )
1960
1961
1961
1962
memset( &zero, 0, sizeof( zero ) );
1962
1963
1964
+ /* A default hash operation should not be usable. */
1965
+ TEST_EQUAL( psa_hash_update( &func, input, sizeof( input ) ),
1966
+ PSA_ERROR_BAD_STATE );
1967
+ TEST_EQUAL( psa_hash_update( &init, input, sizeof( input ) ),
1968
+ PSA_ERROR_BAD_STATE );
1969
+ TEST_EQUAL( psa_hash_update( &zero, input, sizeof( input ) ),
1970
+ PSA_ERROR_BAD_STATE );
1971
+
1963
1972
/* A default hash operation should be abortable without error. */
1964
1973
PSA_ASSERT( psa_hash_abort( &func ) );
1965
1974
PSA_ASSERT( psa_hash_abort( &init ) );
@@ -2004,18 +2013,18 @@ void hash_bad_order( )
2004
2013
/* psa_hash_update without calling psa_hash_setup beforehand */
2005
2014
memset( &operation, 0, sizeof( operation ) );
2006
2015
TEST_EQUAL( psa_hash_update( &operation, input, sizeof( input ) ),
2007
- PSA_ERROR_INVALID_ARGUMENT );
2016
+ PSA_ERROR_BAD_STATE );
2008
2017
2009
2018
/* psa_hash_verify without calling psa_hash_setup beforehand */
2010
2019
memset( &operation, 0, sizeof( operation ) );
2011
2020
TEST_EQUAL( psa_hash_verify( &operation, hash, sizeof( hash ) ),
2012
- PSA_ERROR_INVALID_ARGUMENT );
2021
+ PSA_ERROR_BAD_STATE );
2013
2022
2014
2023
/* psa_hash_finish without calling psa_hash_setup beforehand */
2015
2024
memset( &operation, 0, sizeof( operation ) );
2016
2025
TEST_EQUAL( psa_hash_finish( &operation,
2017
2026
hash, sizeof( hash ), &hash_len ),
2018
- PSA_ERROR_INVALID_ARGUMENT );
2027
+ PSA_ERROR_BAD_STATE );
2019
2028
2020
2029
exit:
2021
2030
mbedtls_psa_crypto_free( );
0 commit comments