Crypto: Use loop variable declaration under conditional flows

If the flow is conditional, declare loop variables in the loop
initialisation itself. This helps removing cppcheck warnings.

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
Change-Id: Id2ce422d2a4706ce02ed370c4bd84ba661d1e5a6
diff --git a/interface/src/tfm_crypto_ipc_api.c b/interface/src/tfm_crypto_ipc_api.c
index 8404899..fbb69d3 100644
--- a/interface/src/tfm_crypto_ipc_api.c
+++ b/interface/src/tfm_crypto_ipc_api.c
@@ -786,7 +786,6 @@
         return PSA_ERROR_INVALID_ARGUMENT;
     }
 
-    size_t idx = 0;
     psa_invec in_vec[] = {
         {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
         {.base = plaintext, .len = plaintext_length},
@@ -801,7 +800,7 @@
     }
 
     if (nonce != NULL) {
-        for (idx = 0; idx < nonce_length; idx++) {
+        for (size_t idx = 0; idx < nonce_length; idx++) {
             iov.aead_in.nonce[idx] = nonce[idx];
         }
     }
@@ -843,7 +842,6 @@
         return PSA_ERROR_INVALID_ARGUMENT;
     }
 
-    size_t idx = 0;
     psa_invec in_vec[] = {
         {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
         {.base = ciphertext, .len = ciphertext_length},
@@ -858,7 +856,7 @@
     }
 
     if (nonce != NULL) {
-        for (idx = 0; idx < nonce_length; idx++) {
+        for (size_t idx = 0; idx < nonce_length; idx++) {
             iov.aead_in.nonce[idx] = nonce[idx];
         }
     }