Fix issues with get_{sign/verify}_num_ops

Move to accumulate ops in context rather than attempting to read straight out
of structures due to structure ops getting reset per operation, and also
issues with _abort clearing internal data. Fix usage of size_t in structures

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index b31d51b..e3be650 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3146,13 +3146,13 @@
 uint32_t psa_sign_hash_get_num_ops(
     const psa_sign_hash_interruptible_operation_t *operation)
 {
-    return psa_driver_wrapper_sign_hash_get_num_ops(operation);
+    return operation->num_ops;
 }
 
 uint32_t psa_verify_hash_get_num_ops(
     const psa_verify_hash_interruptible_operation_t *operation)
 {
-    return psa_driver_wrapper_verify_hash_get_num_ops(operation);
+    return operation->num_ops;
 }
 
 psa_status_t psa_sign_hash_start(
@@ -3192,6 +3192,9 @@
         .core = slot->attr
     };
 
+    /* Ensure ops count gets reset, in case of operation re-use. */
+    operation->num_ops = 0;
+
     status = psa_driver_wrapper_sign_hash_start(operation, &attributes,
                                                 slot->key.data,
                                                 slot->key.bytes, alg,
@@ -3238,6 +3241,9 @@
                                                    signature_length);
 exit:
 
+    /* Update ops count with work done. */
+    operation->num_ops += psa_driver_wrapper_sign_hash_get_num_ops(operation);
+
     if (status != PSA_OPERATION_INCOMPLETE) {
         /* Fill the unused part of the output buffer (the whole buffer on error,
          * the trailing part on success) with something that isn't a valid
@@ -3308,6 +3314,9 @@
         .core = slot->attr
     };
 
+    /* Ensure ops count gets reset, in case of operation re-use. */
+    operation->num_ops = 0;
+
     status = psa_driver_wrapper_verify_hash_start(operation, &attributes,
                                                   slot->key.data,
                                                   slot->key.bytes,
@@ -3340,6 +3349,10 @@
 
 exit:
 
+    /* Update ops count with work done. */
+    operation->num_ops += psa_driver_wrapper_verify_hash_get_num_ops(
+        operation);
+
     if (status != PSA_OPERATION_INCOMPLETE) {
         psa_verify_hash_abort(operation);
     }