Update slot management tests now that {close,destroy}_key(0) succeed
@@ -643,12 +643,21 @@ void invalid_handle( )
TEST_ASSERT( handle1 != 0 );
/* Attempt to close and destroy some invalid handles. */
- TEST_EQUAL( psa_close_key( 0 ), PSA_ERROR_INVALID_HANDLE );
+ if( handle1 - 1 != 0 )
+ {
TEST_EQUAL( psa_close_key( handle1 - 1 ), PSA_ERROR_INVALID_HANDLE );
- TEST_EQUAL( psa_close_key( handle1 + 1 ), PSA_ERROR_INVALID_HANDLE );
- TEST_EQUAL( psa_destroy_key( 0 ), PSA_ERROR_INVALID_HANDLE );
TEST_EQUAL( psa_destroy_key( handle1 - 1 ), PSA_ERROR_INVALID_HANDLE );
+ }
+ if( handle1 + 1 != 0 )
+ {
+ TEST_EQUAL( psa_close_key( handle1 + 1 ), PSA_ERROR_INVALID_HANDLE );
TEST_EQUAL( psa_destroy_key( handle1 + 1 ), PSA_ERROR_INVALID_HANDLE );
+ }
+
+ /* 0 is special: it isn't a valid handle, but close/destroy
+ * succeeds on it. */
+ TEST_EQUAL( psa_close_key( 0 ), PSA_SUCCESS );
+ TEST_EQUAL( psa_destroy_key( 0 ), PSA_SUCCESS );
/* After all this, check that the original handle is intact. */
PSA_ASSERT( psa_get_key_attributes( handle1, &attributes ) );
