[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/ecp.c b/library/ecp.c
index 3cdd566..ff13e88 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -82,6 +82,7 @@
#include "mbedtls/threading.h"
#include "mbedtls/platform_util.h"
+#include <stdint.h>
#include <string.h>
#if !defined(MBEDTLS_ECP_ALT)
@@ -183,7 +184,7 @@
*/
static void ecp_restart_rsm_free( mbedtls_ecp_restart_mul_ctx *ctx )
{
- unsigned char i;
+ uint_fast8_t i;
if( ctx == NULL )
return;
@@ -1753,7 +1754,7 @@
unsigned char i )
{
int ret;
- unsigned char ii, j;
+ uint_fast8_t ii, j;
/* Ignore the "sign" bit and scale down */
ii = ( i & 0x7Fu ) >> 1;
@@ -2019,7 +2020,8 @@
mbedtls_ecp_restart_ctx *rs_ctx )
{
int ret;
- unsigned char w, p_eq_g, i;
+ unsigned char w, p_eq_g;
+ uint_fast8_t i;
size_t d;
unsigned char T_size, T_ok;
mbedtls_ecp_point *T;