Seperate id checks from other state checks

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 527e44e..9c7a380 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3248,8 +3248,14 @@
         goto exit;
     }
 
-    if( operation->id || operation->nonce_set ||
-        operation->ad_started || operation->body_started )
+    if( operation->id != 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( operation->nonce_set || operation->ad_started ||
+        operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3259,9 +3265,7 @@
                  key, &slot, PSA_KEY_USAGE_ENCRYPT, alg );
 
     if( status != PSA_SUCCESS )
-    {
         goto exit;
-    }
 
     psa_key_attributes_t attributes = {
       .core = slot->attr
@@ -3272,9 +3276,7 @@
                                                     slot->key.bytes, alg );
 
     if( status != PSA_SUCCESS )
-    {
         goto exit;
-    }
 
     operation->key_type = psa_get_key_type( &attributes );
 
@@ -3310,8 +3312,14 @@
         goto exit;
     }
 
-    if( operation->id || operation->nonce_set ||
-        operation->ad_started || operation->body_started )
+    if( operation->id != 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( operation->nonce_set || operation->ad_started ||
+        operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3359,8 +3367,14 @@
 
      *nonce_length = 0;
 
-    if( !operation->id || operation->nonce_set ||
-        operation->ad_started || operation->body_started )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( operation->nonce_set || operation->ad_started ||
+        operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3401,8 +3415,14 @@
 {
     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
 
-    if( !operation->id || operation->nonce_set ||
-        operation->ad_started || operation->body_started )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( operation->nonce_set || operation->ad_started ||
+        operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3428,7 +3448,13 @@
 {
     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
 
-    if( !operation->id || operation->lengths_set )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( operation->lengths_set )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3453,7 +3479,13 @@
 {
     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
 
-    if( !operation->id || !operation->nonce_set )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( !operation->nonce_set )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3485,7 +3517,13 @@
 
     *output_length = 0;
 
-    if( !operation->id || !operation->nonce_set || !operation->ad_started )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( !operation->nonce_set || !operation->ad_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3519,8 +3557,14 @@
     *ciphertext_length = 0;
     *tag_length = 0;
 
-    if( !operation->id || !operation->nonce_set ||
-        !operation->ad_started || !operation->body_started )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( !operation->nonce_set || !operation->ad_started ||
+        !operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;
@@ -3551,8 +3595,14 @@
 
     *plaintext_length = 0;
 
-    if( !operation->id || !operation->nonce_set ||
-        !operation->ad_started || !operation->body_started )
+    if( operation->id == 0 )
+    {
+        status = PSA_ERROR_BAD_STATE;
+        goto exit;
+    }
+
+    if( !operation->nonce_set || !operation->ad_started ||
+        !operation->body_started )
     {
         status = PSA_ERROR_BAD_STATE;
         goto exit;