diff --git a/include/mbedtls/poly1305.h b/include/mbedtls/poly1305.h index c2e2655e7..19f523774 100644 --- a/include/mbedtls/poly1305.h +++ b/include/mbedtls/poly1305.h @@ -121,8 +121,8 @@ int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, * if ctx or input are NULL. */ int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx, - size_t ilen, - const unsigned char *input ); + const unsigned char *input, + size_t ilen ); /** * \brief This function generates the Poly1305 Message @@ -158,8 +158,8 @@ int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx, * if key, input, or mac are NULL. */ int mbedtls_poly1305_mac( const unsigned char key[32], - size_t ilen, const unsigned char *input, + size_t ilen, unsigned char mac[16] ); /** diff --git a/library/chachapoly.c b/library/chachapoly.c index 0dba5ed91..d599c5240 100644 --- a/library/chachapoly.c +++ b/library/chachapoly.c @@ -66,8 +66,8 @@ static void mbedtls_chachapoly_pad_aad( mbedtls_chachapoly_context *ctx ) { memset( zeroes, 0, sizeof( zeroes ) ); (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, - 16U - partial_block_len, - zeroes ); + zeroes, + 16U - partial_block_len ); } } @@ -85,8 +85,8 @@ static void mbedtls_chachapoly_pad_ciphertext( mbedtls_chachapoly_context *ctx ) { memset( zeroes, 0, sizeof( zeroes ) ); (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, - 16U - partial_block_len, - zeroes ); + zeroes, + 16U - partial_block_len ); } } @@ -194,7 +194,7 @@ int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, ctx->aad_len += aad_len; - return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad_len, aad ) ); + return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad, aad_len ) ); } int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx, @@ -233,11 +233,11 @@ int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx, * above, we can safety ignore the return value. */ (void) mbedtls_chacha20_update( &ctx->chacha20_ctx, len, input, output ); - (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, len, output ); + (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, output, len ); } else /* DECRYPT */ { - (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, len, input ); + (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, input, len ); (void) mbedtls_chacha20_update( &ctx->chacha20_ctx, len, input, output ); } @@ -289,7 +289,7 @@ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, len_block[14] = (unsigned char) ( ctx->ciphertext_len >> 48 ); len_block[15] = (unsigned char) ( ctx->ciphertext_len >> 56 ); - (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, 16U, len_block ); + (void) mbedtls_poly1305_update( &ctx->poly1305_ctx, len_block, 16U ); (void) mbedtls_poly1305_finish( &ctx->poly1305_ctx, mac ); return( 0 ); diff --git a/library/poly1305.c b/library/poly1305.c index 66f932c4f..14c362d58 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -285,8 +285,8 @@ int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, } int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx, - size_t ilen, - const unsigned char* input ) + const unsigned char *input, + size_t ilen ) { size_t offset = 0U; size_t remaining = ilen; @@ -391,9 +391,9 @@ int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx, } int mbedtls_poly1305_mac( const unsigned char key[32], - size_t ilen, - const unsigned char *input, - unsigned char mac[16] ) + const unsigned char *input, + size_t ilen, + unsigned char mac[16] ) { mbedtls_poly1305_context ctx; int result; @@ -404,7 +404,7 @@ int mbedtls_poly1305_mac( const unsigned char key[32], if ( result != 0 ) goto cleanup; - result = mbedtls_poly1305_update( &ctx, ilen, input ); + result = mbedtls_poly1305_update( &ctx, input, ilen ); if ( result != 0 ) goto cleanup; @@ -496,8 +496,8 @@ int mbedtls_poly1305_self_test( int verbose ) } result = mbedtls_poly1305_mac( test_keys[i], - test_data_len[i], test_data[i], + test_data_len[i], mac ); if ( result != 0 ) { diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index c41966586..17f9d0e27 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -538,7 +538,7 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_POLY1305_C) if ( todo.poly1305 ) { - TIME_AND_TSC( "Poly1305", mbedtls_poly1305_mac( buf, BUFSIZE, buf, buf ) ); + TIME_AND_TSC( "Poly1305", mbedtls_poly1305_mac( buf, buf, BUFSIZE, buf ) ); } #endif diff --git a/tests/suites/test_suite_poly1305.function b/tests/suites/test_suite_poly1305.function index af69a0312..a633c2baa 100644 --- a/tests/suites/test_suite_poly1305.function +++ b/tests/suites/test_suite_poly1305.function @@ -20,7 +20,7 @@ void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src src_len = unhexify( src_str, hex_src_string ); unhexify( key, hex_key_string ); - mbedtls_poly1305_mac( key, src_len, src_str, mac ); + mbedtls_poly1305_mac( key, src_str, src_len, mac ); hexify( mac_str, mac, 16 ); TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 );