Clean up of formatting, and potential integer overflow fix
This commit is contained in:
parent
d241f1cf17
commit
a592dcc1c6
@ -48,7 +48,7 @@ struct mbedtls_cmac_context_t
|
|||||||
/** Internal state of the CMAC algorithm */
|
/** Internal state of the CMAC algorithm */
|
||||||
unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
||||||
|
|
||||||
/** Unprocessed data - either data that was not block aligned and is still
|
/** Unprocessed data - either data that was not block aligned and is still
|
||||||
* pending to be processed, or the final block */
|
* pending to be processed, or the final block */
|
||||||
unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
|
|||||||
{
|
{
|
||||||
mbedtls_cmac_context_t* cmac_ctx;
|
mbedtls_cmac_context_t* cmac_ctx;
|
||||||
unsigned char *state;
|
unsigned char *state;
|
||||||
int n, j, ret = 0;
|
int n, j, ret = 0;
|
||||||
size_t olen, block_size;
|
size_t olen, block_size;
|
||||||
|
|
||||||
if( ctx == NULL || ctx->cipher_info == NULL || input == NULL ||
|
if( ctx == NULL || ctx->cipher_info == NULL || input == NULL ||
|
||||||
@ -259,7 +259,7 @@ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
|
|||||||
/* Is their data still to process from the last call, that's equal to
|
/* Is their data still to process from the last call, that's equal to
|
||||||
* or greater than a block? */
|
* or greater than a block? */
|
||||||
if( cmac_ctx->unprocessed_len > 0 &&
|
if( cmac_ctx->unprocessed_len > 0 &&
|
||||||
ilen + cmac_ctx->unprocessed_len > block_size )
|
ilen > block_size - cmac_ctx->unprocessed_len )
|
||||||
{
|
{
|
||||||
memcpy( &cmac_ctx->unprocessed_block[cmac_ctx->unprocessed_len],
|
memcpy( &cmac_ctx->unprocessed_block[cmac_ctx->unprocessed_len],
|
||||||
input,
|
input,
|
||||||
@ -387,7 +387,7 @@ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx )
|
|||||||
/* Reset the internal state */
|
/* Reset the internal state */
|
||||||
cmac_ctx->unprocessed_len = 0;
|
cmac_ctx->unprocessed_len = 0;
|
||||||
mbedtls_zeroize( cmac_ctx->unprocessed_block,
|
mbedtls_zeroize( cmac_ctx->unprocessed_block,
|
||||||
sizeof( cmac_ctx->unprocessed_block ));
|
sizeof( cmac_ctx->unprocessed_block ) );
|
||||||
mbedtls_zeroize( cmac_ctx->state,
|
mbedtls_zeroize( cmac_ctx->state,
|
||||||
sizeof( cmac_ctx->state ) );
|
sizeof( cmac_ctx->state ) );
|
||||||
cmac_ctx->padding_flag = 1;
|
cmac_ctx->padding_flag = 1;
|
||||||
@ -822,7 +822,7 @@ static int cmac_test_wth_cipher( int verbose,
|
|||||||
for( i = 0; i < num_tests; i++ )
|
for( i = 0; i < num_tests; i++ )
|
||||||
{
|
{
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
mbedtls_printf( " %s CMAC #%u: ", testname, i +1 );
|
mbedtls_printf( " %s CMAC #%u: ", testname, i + 1 );
|
||||||
|
|
||||||
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages,
|
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages,
|
||||||
message_lengths[i], output ) ) != 0 )
|
message_lengths[i], output ) ) != 0 )
|
||||||
|
@ -494,8 +494,8 @@ int main( int argc, char *argv[] )
|
|||||||
cipher_info = mbedtls_cipher_info_from_type( cipher_type );
|
cipher_info = mbedtls_cipher_info_from_type( cipher_type );
|
||||||
|
|
||||||
TIME_AND_TSC( title,
|
TIME_AND_TSC( title,
|
||||||
mbedtls_cipher_cmac( cipher_info, tmp, keysize,
|
mbedtls_cipher_cmac( cipher_info, tmp, keysize,
|
||||||
buf, BUFSIZE, output ) );
|
buf, BUFSIZE, output ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
memset( buf, 0, sizeof( buf ) );
|
memset( buf, 0, sizeof( buf ) );
|
||||||
|
@ -50,7 +50,7 @@ APPS = test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \
|
|||||||
test_suite_arc4$(EXEXT) test_suite_asn1write$(EXEXT) \
|
test_suite_arc4$(EXEXT) test_suite_asn1write$(EXEXT) \
|
||||||
test_suite_base64$(EXEXT) test_suite_blowfish$(EXEXT) \
|
test_suite_base64$(EXEXT) test_suite_blowfish$(EXEXT) \
|
||||||
test_suite_camellia$(EXEXT) test_suite_ccm$(EXEXT) \
|
test_suite_camellia$(EXEXT) test_suite_ccm$(EXEXT) \
|
||||||
test_suite_cmac$(EXEXT) \
|
test_suite_cmac$(EXEXT) \
|
||||||
test_suite_cipher.aes$(EXEXT) \
|
test_suite_cipher.aes$(EXEXT) \
|
||||||
test_suite_cipher.arc4$(EXEXT) test_suite_cipher.ccm$(EXEXT) \
|
test_suite_cipher.arc4$(EXEXT) test_suite_cipher.ccm$(EXEXT) \
|
||||||
test_suite_cipher.gcm$(EXEXT) \
|
test_suite_cipher.gcm$(EXEXT) \
|
||||||
|
Loading…
Reference in New Issue
Block a user