Fix various compiler warnings with MSVC
Fixes various compiler warnings found with Microsoft Visual Studio 2015
(and earlier versions).
diff --git a/library/cmac.c b/library/cmac.c
index 04aca7c..0fa5b58 100644
--- a/library/cmac.c
+++ b/library/cmac.c
@@ -105,7 +105,7 @@
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
}
- for( i = blocksize - 1; i >= 0; i-- )
+ for( i = (int)blocksize - 1; i >= 0; i-- )
{
output[i] = input[i] << 1 | overflow;
overflow = input[i] >> 7;
@@ -209,7 +209,7 @@
if( ctx == NULL || ctx->cipher_info == NULL || key == NULL )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- if( ( retval = mbedtls_cipher_setkey( ctx, key, keybits,
+ if( ( retval = mbedtls_cipher_setkey( ctx, key, (int)keybits,
MBEDTLS_ENCRYPT ) ) != 0 )
return( retval );
@@ -244,8 +244,8 @@
{
mbedtls_cmac_context_t* cmac_ctx;
unsigned char *state;
- int n, j, ret = 0;
- size_t olen, block_size;
+ int ret = 0;
+ size_t n, j, olen, block_size;
if( ctx == NULL || ctx->cipher_info == NULL || input == NULL ||
ctx->cmac_ctx == NULL )
@@ -280,8 +280,9 @@
/* n is the number of blocks including any final partial block */
n = ( ilen + block_size - 1 ) / block_size;
- /* Iterate across the input data in block sized chunks */
- for( j = 0; j < n - 1; j++ )
+ /* Iterate across the input data in block sized chunks, excluding any
+ * final partial or complete block */
+ for( j = 1; j < n; j++ )
{
cmac_xor_block( state, input, state, block_size );