From 5ef92d309a759d9d2acdaf613021d7bfc66d6241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 9 May 2018 09:34:25 +0200 Subject: [PATCH] chachapoly: adjust parameter order This module used (len, pointer) while (pointer, len) is more common in the rest of the library, in particular it's what's used in the GCM API that very comparable to it, so switch to (pointer, len) for consistency. Note that the crypt_and_tag() and auth_decrypt() functions were already using the same convention as GCM, so this also increases intra-module consistency. --- include/mbedtls/chachapoly.h | 4 ++-- library/chachapoly.c | 6 +++--- library/cipher.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mbedtls/chachapoly.h b/include/mbedtls/chachapoly.h index ddcd54972..ce9737c2b 100644 --- a/include/mbedtls/chachapoly.h +++ b/include/mbedtls/chachapoly.h @@ -183,8 +183,8 @@ int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx, * finished, or if the AAD has been finished. */ int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, - size_t aad_len, - const unsigned char *aad ); + const unsigned char *aad, + size_t aad_len ); /** * \brief Thus function feeds data to be encrypted or decrypted diff --git a/library/chachapoly.c b/library/chachapoly.c index d599c5240..9ca21b39a 100644 --- a/library/chachapoly.c +++ b/library/chachapoly.c @@ -175,8 +175,8 @@ cleanup: } int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, - size_t aad_len, - const unsigned char *aad ) + const unsigned char *aad, + size_t aad_len ) { if ( ctx == NULL ) { @@ -311,7 +311,7 @@ int mbedtls_chachapoly_crypt_and_tag( mbedtls_chachapoly_context *ctx, if ( result != 0 ) goto cleanup; - result = mbedtls_chachapoly_update_aad( ctx, aad_len, aad ); + result = mbedtls_chachapoly_update_aad( ctx, aad, aad_len ); if ( result != 0 ) goto cleanup; diff --git a/library/cipher.c b/library/cipher.c index 1827770b1..2463a6148 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -320,7 +320,7 @@ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, return( result ); return mbedtls_chachapoly_update_aad( (mbedtls_chachapoly_context*) ctx->cipher_ctx, - ad_len, ad ); + ad, ad_len ); } #endif