[baremetal] Avoid narrow loop counters etc

Use `uint_fast8_t` instead of `unsigned char` in various loop-type
situations. This avoids the need for a 16 or 32-bit system to insert
explicit narrow-to-8-bit instructions.

Not the result of an exhaustive source analysis, rather inspecting
the disassembly output for a cut-down Cortex-M0+ build looking for
UXTB etc instructions, so there could well be more in the complete
configuration.

Signed-off-by: Kevin Bracey <kevin.bracey@arm.com>
diff --git a/library/ccm.c b/library/ccm.c
index 750ec9e..e54a995 100644
--- a/library/ccm.c
+++ b/library/ccm.c
@@ -40,6 +40,7 @@
 #include "mbedtls/platform.h"
 #include "mbedtls/platform_util.h"
 
+#include <stdint.h>
 #include <string.h>
 
 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
@@ -157,8 +158,8 @@
                            unsigned char *tag, size_t tag_len )
 {
     int ret = MBEDTLS_ERR_PLATFORM_FAULT_DETECTED;
-    unsigned char i;
-    unsigned char q;
+    uint_fast8_t i;
+    uint_fast8_t q;
     size_t len_left, olen;
     unsigned char b[16];
     unsigned char y[16];
@@ -183,7 +184,7 @@
     if( add_len > 0xFF00 )
         return( MBEDTLS_ERR_CCM_BAD_INPUT );
 
-    q = 16 - 1 - (unsigned char) iv_len;
+    q = (uint_fast8_t) (16 - 1 - iv_len);
 
     /*
      * First block B_0:
@@ -368,7 +369,7 @@
 {
     int ret = MBEDTLS_ERR_PLATFORM_FAULT_DETECTED;
     unsigned char check_tag[16];
-    unsigned char i;
+    uint_fast8_t i;
     int diff;
 
     CCM_VALIDATE_RET( ctx != NULL );