@@ -2012,6 +2012,12 @@ void hash_bad_order( )
2012
2012
2013
2013
PSA_ASSERT( psa_crypto_init( ) );
2014
2014
2015
+ /* Call setup twice in a row. */
2016
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
2017
+ TEST_EQUAL( psa_hash_setup( &operation, alg ),
2018
+ PSA_ERROR_BAD_STATE );
2019
+ PSA_ASSERT( psa_hash_abort( &operation ) );
2020
+
2015
2021
/* Call update without calling setup beforehand. */
2016
2022
TEST_EQUAL( psa_hash_update( &operation, input, sizeof( input ) ),
2017
2023
PSA_ERROR_BAD_STATE );
@@ -2336,6 +2342,14 @@ void mac_bad_order( )
2336
2342
PSA_ERROR_BAD_STATE );
2337
2343
PSA_ASSERT( psa_mac_abort( &operation ) );
2338
2344
2345
+ /* Call setup twice in a row. */
2346
+ PSA_ASSERT( psa_mac_sign_setup( &operation,
2347
+ handle, alg ) );
2348
+ TEST_EQUAL( psa_mac_sign_setup( &operation,
2349
+ handle, alg ),
2350
+ PSA_ERROR_BAD_STATE );
2351
+ PSA_ASSERT( psa_mac_abort( &operation ) );
2352
+
2339
2353
/* Call update after sign finish. */
2340
2354
PSA_ASSERT( psa_mac_sign_setup( &operation,
2341
2355
handle, alg ) );
@@ -2609,6 +2623,18 @@ void cipher_bad_order( )
2609
2623
key, sizeof(key) ) );
2610
2624
2611
2625
2626
+ /* Call encrypt setup twice in a row. */
2627
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation, handle, alg ) );
2628
+ TEST_EQUAL( psa_cipher_encrypt_setup( &operation, handle, alg ),
2629
+ PSA_ERROR_BAD_STATE );
2630
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
2631
+
2632
+ /* Call decrypt setup twice in a row. */
2633
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation, handle, alg ) );
2634
+ TEST_EQUAL( psa_cipher_decrypt_setup( &operation, handle, alg ),
2635
+ PSA_ERROR_BAD_STATE );
2636
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
2637
+
2612
2638
/* Generate an IV without calling setup beforehand. */
2613
2639
TEST_EQUAL( psa_cipher_generate_iv( &operation,
2614
2640
buffer, sizeof( buffer ),
0 commit comments