Bignum: Declare loop variable in loop head

In the new bignum files (bignum_core.c, bignum_mod_raw.c and
bignum_mod.c) the loop variables are declared in the loop head wherever
this change is beneficial.

There are loops where the loop variable is used after the end of the
loop (this might not be good practice, but that is out of scope for this
commit) and others where there are several loop variables and declaring
them there would hurt readability.

Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index 431921a..c015fc7 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -216,7 +216,6 @@
 {
     size_t stored_bytes = nx * ciL;
     size_t bytes_to_copy;
-    size_t i;
 
     if( stored_bytes < buflen )
     {
@@ -228,14 +227,14 @@
 
         /* The output buffer is smaller than the allocated size of X.
          * However X may fit if its leading bytes are zero. */
-        for( i = bytes_to_copy; i < stored_bytes; i++ )
+        for( size_t i = bytes_to_copy; i < stored_bytes; i++ )
         {
             if( GET_BYTE( X, i ) != 0 )
                 return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
         }
     }
 
-    for( i = 0; i < bytes_to_copy; i++ )
+    for( size_t i = 0; i < bytes_to_copy; i++ )
         buf[i] = GET_BYTE( X, i );
 
     if( stored_bytes < buflen )
@@ -255,7 +254,6 @@
     size_t stored_bytes;
     size_t bytes_to_copy;
     unsigned char *p;
-    size_t i;
 
     stored_bytes = nx * ciL;
 
@@ -276,14 +274,14 @@
          * However X may fit if its leading bytes are zero. */
         bytes_to_copy = buflen;
         p = buf;
-        for( i = bytes_to_copy; i < stored_bytes; i++ )
+        for( size_t i = bytes_to_copy; i < stored_bytes; i++ )
         {
             if( GET_BYTE( X, i ) != 0 )
                 return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
         }
     }
 
-    for( i = 0; i < bytes_to_copy; i++ )
+    for( size_t i = 0; i < bytes_to_copy; i++ )
         p[bytes_to_copy - i - 1] = GET_BYTE( X, i );
 
     return( 0 );