Rename aead_chacha20_poly1305 to chachapoly
While the old name is explicit and aligned with the RFC, it's also very long,
so with the mbedtls_ prefix prepended we get a 31-char prefix to each
identifier, which quickly conflicts with our 80-column policy.
The new name is shorter, it's what a lot of people use when speaking about
that construction anyway, and hopefully should not introduce confusion at
it seems unlikely that variants other than 20/1305 be standardised in the
foreseeable future.
diff --git a/include/mbedtls/aead_chacha20_poly1305.h b/include/mbedtls/chachapoly.h
similarity index 64%
rename from include/mbedtls/aead_chacha20_poly1305.h
rename to include/mbedtls/chachapoly.h
index 21c3158..810675d 100644
--- a/include/mbedtls/aead_chacha20_poly1305.h
+++ b/include/mbedtls/chachapoly.h
@@ -1,5 +1,5 @@
/**
- * \file aead_chacha20_poly1305.h
+ * \file chachapoly.h
*
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
*
@@ -20,8 +20,8 @@
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
-#ifndef MBEDTLS_AEAD_CHACHA20_POLY1305_H
-#define MBEDTLS_AEAD_CHACHA20_POLY1305_H
+#ifndef MBEDTLS_CHACHAPOLY_H
+#define MBEDTLS_CHACHAPOLY_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
@@ -29,8 +29,8 @@
#include MBEDTLS_CONFIG_FILE
#endif
-#define MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA -0x00047 /**< Invalid input parameter(s). */
-#define MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE -0x00049 /**< The requested operation is not permitted in the current state */
+#define MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA -0x00047 /**< Invalid input parameter(s). */
+#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x00049 /**< The requested operation is not permitted in the current state */
#ifdef __cplusplus
extern "C" {
@@ -38,12 +38,12 @@
typedef enum
{
- MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
- MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT
+ MBEDTLS_CHACHAPOLY_ENCRYPT,
+ MBEDTLS_CHACHAPOLY_DECRYPT
}
-mbedtls_aead_chacha20_poly1305_mode_t;
+mbedtls_chachapoly_mode_t;
-#if !defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
+#if !defined(MBEDTLS_CHACHAPOLY_ALT)
#include "chacha20.h"
#include "poly1305.h"
@@ -55,27 +55,27 @@
uint64_t aad_len; /** Length (bytes) of the Additional Authenticated Data */
uint64_t ciphertext_len; /** Length (bytes) of the ciphertext */
int state; /** Current state of the context */
- mbedtls_aead_chacha20_poly1305_mode_t mode; /** Cipher mode (encrypt or decrypt) */
+ mbedtls_chachapoly_mode_t mode; /** Cipher mode (encrypt or decrypt) */
}
-mbedtls_aead_chacha20_poly1305_context;
+mbedtls_chachapoly_context;
-#else /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
-#include "aead_chacha20_poly1305_alt.h"
-#endif /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
+#else /* !MBEDTLS_CHACHAPOLY_ALT */
+#include "chachapoly_alt.h"
+#endif /* !MBEDTLS_CHACHAPOLY_ALT */
/**
* \brief Initialize ChaCha20-Poly1305 context
*
* \param ctx ChaCha20-Poly1305 context to be initialized
*/
-void mbedtls_aead_chacha20_poly1305_init( mbedtls_aead_chacha20_poly1305_context *ctx );
+void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx );
/**
* \brief Clear ChaCha20-Poly1305 context
*
* \param ctx ChaCha20-Poly1305 context to be cleared
*/
-void mbedtls_aead_chacha20_poly1305_free( mbedtls_aead_chacha20_poly1305_context *ctx );
+void mbedtls_chachapoly_free( mbedtls_chachapoly_context *ctx );
/**
* \brief Set the ChaCha20-Poly1305 symmetric encryption key.
@@ -83,12 +83,12 @@
* \param ctx The ChaCha20-Poly1305 context.
* \param key The 256-bit (32 bytes) key.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if \p ctx or \p key are NULL.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_context *ctx,
- const unsigned char key[32] );
+int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx,
+ const unsigned char key[32] );
/**
* \brief Setup ChaCha20-Poly1305 context for encryption or decryption.
@@ -102,13 +102,13 @@
* \param mode Specifies whether the context is used to encrypt or
* decrypt data.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if \p ctx or \p mac are NULL.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_context *ctx,
- const unsigned char nonce[12],
- mbedtls_aead_chacha20_poly1305_mode_t mode );
+int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx,
+ const unsigned char nonce[12],
+ mbedtls_chachapoly_mode_t mode );
/**
* \brief Process additional authenticated data (AAD).
@@ -118,14 +118,14 @@
*
* \note This function is called before data is encrypted/decrypted.
* I.e. call this function to process the AAD before calling
- * mbedtls_aead_chacha20_poly1305_update.
+ * mbedtls_chachapoly_update.
*
* You may call this function multiple times to process
* an arbitrary amount of AAD. It is permitted to call
* this function 0 times, if no AAD is used.
*
* This function cannot be called any more if data has
- * been processed by mbedtls_aead_chacha20_poly1305_update,
+ * been processed by mbedtls_chachapoly_update,
* or if the context has been finished.
*
* \param ctx The ChaCha20-Poly1305 context.
@@ -134,23 +134,23 @@
* \param aad Buffer containing the AAD.
* This pointer can be NULL if aad_len == 0.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if \p ctx or \p aad are NULL.
- * MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE is returned if
+ * MBEDTLS_ERR_CHACHAPOLY_BAD_STATE is returned if
* the context has not been setup, the context has been
* finished, or if the AAD has been finished.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_context *ctx,
- size_t aad_len,
- const unsigned char *aad );
+int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx,
+ size_t aad_len,
+ const unsigned char *aad );
/**
* \brief Encrypt/decrypt data.
*
* The direction (encryption or decryption) depends on the
* mode that was given when calling
- * mbedtls_aead_chacha20_poly1305_starts.
+ * mbedtls_chachapoly_starts.
*
* You may call this function multiple times to process
* an arbitrary amount of data. It is permitted to call
@@ -164,17 +164,17 @@
* \param output Buffer to where the encrypted or decrypted data is written.
* This pointer can be NULL if len == 0.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if \p ctx, \p input, or \p output are NULL.
- * MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE is returned if
+ * MBEDTLS_ERR_CHACHAPOLY_BAD_STATE is returned if
* the context has not been setup, or if the context has been
* finished.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_context *ctx,
- size_t len,
- const unsigned char *input,
- unsigned char *output );
+int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx,
+ size_t len,
+ const unsigned char *input,
+ unsigned char *output );
/**
* \brief Compute the ChaCha20-Poly1305 MAC.
@@ -182,14 +182,14 @@
* \param ctx The ChaCha20-Poly1305 context.
* \param mac Buffer to where the 128-bit (16 bytes) MAC is written.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if \p ctx or \p mac are NULL.
- * MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE is returned if
+ * MBEDTLS_ERR_CHACHAPOLY_BAD_STATE is returned if
* the context has not been setup.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_context *ctx,
- unsigned char mac[16] );
+int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
+ unsigned char mac[16] );
/**
* \brief Encrypt or decrypt data, and produce a MAC with ChaCha20-Poly1305.
@@ -210,29 +210,29 @@
* This pointer can be NULL if ilen == 0.
* \param mac Buffer to where the computed 128-bit (16 bytes) MAC is written.
*
- * \return MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA is returned
+ * \return MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA is returned
* if one or more of the required parameters are NULL.
* Otherwise, 0 is returned to indicate success.
*/
-int mbedtls_aead_chacha20_poly1305_crypt_and_mac( const unsigned char key[32],
- const unsigned char nonce[12],
- mbedtls_aead_chacha20_poly1305_mode_t mode,
- size_t aad_len,
- const unsigned char *aad,
- size_t ilen,
- const unsigned char *input,
- unsigned char *output,
- unsigned char mac[16] );
+int mbedtls_chachapoly_crypt_and_mac( const unsigned char key[32],
+ const unsigned char nonce[12],
+ mbedtls_chachapoly_mode_t mode,
+ size_t aad_len,
+ const unsigned char *aad,
+ size_t ilen,
+ const unsigned char *input,
+ unsigned char *output,
+ unsigned char mac[16] );
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
-int mbedtls_aead_chacha20_poly1305_self_test( int verbose );
+int mbedtls_chachapoly_self_test( int verbose );
#ifdef __cplusplus
}
#endif
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_H */
+#endif /* MBEDTLS_CHACHAPOLY_H */
diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h
index f954cce..ac1f564 100644
--- a/include/mbedtls/cipher.h
+++ b/include/mbedtls/cipher.h
@@ -37,7 +37,7 @@
#include <stddef.h>
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
#define MBEDTLS_CIPHER_MODE_AEAD
#endif
@@ -563,7 +563,7 @@
*/
int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
/**
* \brief This function adds additional data for AEAD ciphers.
* Currently supported with GCM and ChaCha20+Poly1305.
@@ -578,7 +578,7 @@
*/
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
const unsigned char *ad, size_t ad_len );
-#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
/**
* \brief The generic cipher update function. It encrypts or
@@ -636,7 +636,7 @@
int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
unsigned char *output, size_t *olen );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
/**
* \brief This function writes a tag for AEAD ciphers.
* Currently supported with GCM and ChaCha20+Poly1305.
@@ -666,7 +666,7 @@
*/
int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
const unsigned char *tag, size_t tag_len );
-#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
/**
* \brief The generic all-in-one encryption/decryption function,
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 22d465c..69d2b63 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -269,7 +269,7 @@
* digests and ciphers instead.
*
*/
-//#define MBEDTLS_AEAD_CHACHA20_POLY1305_ALT
+//#define MBEDTLS_CHACHAPOLY_ALT
//#define MBEDTLS_AES_ALT
//#define MBEDTLS_ARC4_ALT
//#define MBEDTLS_BLOWFISH_ALT
@@ -1690,15 +1690,15 @@
#define MBEDTLS_AES_C
/**
- * \def MBEDTLS_AEAD_CHACHA20_POLY1305_C
+ * \def MBEDTLS_CHACHAPOLY_C
*
* Enable the ChaCha20-Poly1305 AEAD algorithm.
*
- * Module: library/aead_chacha20_poly1305.c
+ * Module: library/chachapoly.c
*
* This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C
*/
-#define MBEDTLS_AEAD_CHACHA20_POLY1305_C
+#define MBEDTLS_CHACHAPOLY_C
/**
* \def MBEDTLS_ARC4_C
@@ -1855,7 +1855,7 @@
* Enable the ChaCha20 block cipher.
*
* Module: library/chacha20.c
- * Caller: library/aead_chacha20_poly1305.c
+ * Caller: library/chachapoly.c
*/
#define MBEDTLS_CHACHA20_C
@@ -2427,7 +2427,7 @@
* Enable the Poly1305 MAC algorithm.
*
* Module: library/poly1305.c
- * Caller: library/aead_chacha20_poly1305.c
+ * Caller: library/chachapoly.c
*/
#define MBEDTLS_POLY1305_C
diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
index 72b7f18..e056975 100644
--- a/include/mbedtls/error.h
+++ b/include/mbedtls/error.h
@@ -78,7 +78,7 @@
* SHA512 1 0x0039-0x0039
* CHACHA20 1 0x003B-0x003B
* POLY1305 1 0x0041-0x0041
- * AEAD_CHACHA20_POLY1305 2 0x0047-0x0049
+ * CHACHAPOLY 2 0x0047-0x0049
*
* High-level module nr (3 bits - 0x0...-0x7...)
* Name ID Nr of Errors
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index b8f663d..582769b 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -3,7 +3,6 @@
option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
set(src_crypto
- aead_chacha20_poly1305.c
aes.c
aesni.c
arc4.c
@@ -15,6 +14,7 @@
camellia.c
ccm.c
chacha20.c
+ chachapoly.c
cipher.c
cipher_wrap.c
cmac.c
diff --git a/library/Makefile b/library/Makefile
index de4bd5c..a4c6e35 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -47,11 +47,10 @@
DLEXT=dll
endif
-OBJS_CRYPTO= aead_chacha20_poly1305.o \
- aes.o aesni.o arc4.o \
+OBJS_CRYPTO= aes.o aesni.o arc4.o \
asn1parse.o asn1write.o base64.o \
bignum.o blowfish.o camellia.o \
- ccm.o chacha20.o \
+ ccm.o chacha20.o chachapoly.o \
cipher.o cipher_wrap.o \
cmac.o ctr_drbg.o des.o \
dhm.o ecdh.o ecdsa.o \
diff --git a/library/aead_chacha20_poly1305.c b/library/chachapoly.c
similarity index 64%
rename from library/aead_chacha20_poly1305.c
rename to library/chachapoly.c
index 0418008..3ba1954 100644
--- a/library/aead_chacha20_poly1305.c
+++ b/library/chachapoly.c
@@ -1,5 +1,5 @@
/**
- * \file aead_chacha20_poly1305.c
+ * \file chachapoly.c
*
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
*
@@ -26,9 +26,9 @@
#include MBEDTLS_CONFIG_FILE
#endif
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
-#include "mbedtls/aead_chacha20_poly1305.h"
+#include "mbedtls/chachapoly.h"
#include <string.h>
#if defined(MBEDTLS_SELF_TEST)
@@ -40,12 +40,12 @@
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_SELF_TEST */
-#if !defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
+#if !defined(MBEDTLS_CHACHAPOLY_ALT)
-#define AEAD_CHACHA20_POLY1305_STATE_INIT ( 0 )
-#define AEAD_CHACHA20_POLY1305_STATE_AAD ( 1 )
-#define AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT ( 2 ) /* Encrypting or decrypting */
-#define AEAD_CHACHA20_POLY1305_STATE_FINISHED ( 3 )
+#define CHACHAPOLY_STATE_INIT ( 0 )
+#define CHACHAPOLY_STATE_AAD ( 1 )
+#define CHACHAPOLY_STATE_CIPHERTEXT ( 2 ) /* Encrypting or decrypting */
+#define CHACHAPOLY_STATE_FINISHED ( 3 )
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
@@ -57,7 +57,7 @@
*
* \param ctx The ChaCha20-Poly1305 context.
*/
-static void mbedtls_aead_chacha20_poly1305_pad_aad( mbedtls_aead_chacha20_poly1305_context *ctx )
+static void mbedtls_chachapoly_pad_aad( mbedtls_chachapoly_context *ctx )
{
uint32_t partial_block_len = (uint32_t) ( ctx->aad_len % 16U );
unsigned char zeroes[15];
@@ -76,7 +76,7 @@
*
* \param ctx The ChaCha20-Poly1305 context.
*/
-static void mbedtls_aead_chacha20_poly1305_pad_ciphertext( mbedtls_aead_chacha20_poly1305_context *ctx )
+static void mbedtls_chachapoly_pad_ciphertext( mbedtls_chachapoly_context *ctx )
{
uint32_t partial_block_len = (uint32_t) ( ctx->ciphertext_len % 16U );
unsigned char zeroes[15];
@@ -90,7 +90,7 @@
}
}
-void mbedtls_aead_chacha20_poly1305_init( mbedtls_aead_chacha20_poly1305_context *ctx )
+void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx )
{
if ( ctx != NULL )
{
@@ -98,12 +98,12 @@
mbedtls_poly1305_init( &ctx->poly1305_ctx );
ctx->aad_len = 0U;
ctx->ciphertext_len = 0U;
- ctx->state = AEAD_CHACHA20_POLY1305_STATE_INIT;
- ctx->mode = MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT;
+ ctx->state = CHACHAPOLY_STATE_INIT;
+ ctx->mode = MBEDTLS_CHACHAPOLY_ENCRYPT;
}
}
-void mbedtls_aead_chacha20_poly1305_free( mbedtls_aead_chacha20_poly1305_context *ctx )
+void mbedtls_chachapoly_free( mbedtls_chachapoly_context *ctx )
{
if ( ctx != NULL )
{
@@ -111,19 +111,19 @@
mbedtls_poly1305_free( &ctx->poly1305_ctx );
ctx->aad_len = 0U;
ctx->ciphertext_len = 0U;
- ctx->state = AEAD_CHACHA20_POLY1305_STATE_INIT;
- ctx->mode = MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT;
+ ctx->state = CHACHAPOLY_STATE_INIT;
+ ctx->mode = MBEDTLS_CHACHAPOLY_ENCRYPT;
}
}
-int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_context *ctx,
- const unsigned char key[32] )
+int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx,
+ const unsigned char key[32] )
{
int result;
if ( ( ctx == NULL ) || ( key == NULL ) )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
result = mbedtls_chacha20_setkey( &ctx->chacha20_ctx, key );
@@ -131,16 +131,16 @@
return( result );
}
-int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_context *ctx,
- const unsigned char nonce[12],
- mbedtls_aead_chacha20_poly1305_mode_t mode )
+int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx,
+ const unsigned char nonce[12],
+ mbedtls_chachapoly_mode_t mode )
{
int result;
unsigned char poly1305_key[64];
if ( ( ctx == NULL ) || ( nonce == NULL ) )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
result = mbedtls_chacha20_starts( &ctx->chacha20_ctx, nonce, 1U );
@@ -161,7 +161,7 @@
{
ctx->aad_len = 0U;
ctx->ciphertext_len = 0U;
- ctx->state = AEAD_CHACHA20_POLY1305_STATE_AAD;
+ ctx->state = CHACHAPOLY_STATE_AAD;
ctx->mode = mode;
}
@@ -170,22 +170,22 @@
return( result );
}
-int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_context *ctx,
- size_t aad_len,
- const unsigned char *aad )
+int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx,
+ size_t aad_len,
+ const unsigned char *aad )
{
if ( ctx == NULL )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
else if ( ( aad_len > 0U ) && ( aad == NULL ) )
{
/* aad pointer is allowed to be NULL if aad_len == 0 */
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
- else if ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_AAD )
+ else if ( ctx->state != CHACHAPOLY_STATE_AAD )
{
- return(MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE );
+ return(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE );
}
ctx->aad_len += aad_len;
@@ -193,36 +193,36 @@
return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad_len, aad ) );
}
-int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_context *ctx,
- size_t len,
- const unsigned char *input,
- unsigned char *output )
+int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx,
+ size_t len,
+ const unsigned char *input,
+ unsigned char *output )
{
if ( ( ctx == NULL ) || ( input == NULL ) || ( output == NULL ) )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
else if ( ( len > 0U ) && ( ( input == NULL ) || ( output == NULL ) ) )
{
/* input and output pointers are allowed to be NULL if len == 0 */
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
- else if ( ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_AAD ) &&
- ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT ) )
+ else if ( ( ctx->state != CHACHAPOLY_STATE_AAD ) &&
+ ( ctx->state != CHACHAPOLY_STATE_CIPHERTEXT ) )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_STATE );
}
- if ( ctx->state == AEAD_CHACHA20_POLY1305_STATE_AAD )
+ if ( ctx->state == CHACHAPOLY_STATE_AAD )
{
- ctx->state = AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT;
+ ctx->state = CHACHAPOLY_STATE_CIPHERTEXT;
- mbedtls_aead_chacha20_poly1305_pad_aad( ctx );
+ mbedtls_chachapoly_pad_aad( ctx );
}
ctx->ciphertext_len += len;
- if ( ctx->mode == MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT )
+ if ( ctx->mode == MBEDTLS_CHACHAPOLY_ENCRYPT )
{
/* Note: the following functions return an error only if one or more of
* the input pointers are NULL. Since we have checked their validity
@@ -240,30 +240,30 @@
return( 0 );
}
-int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_context *ctx,
- unsigned char mac[16] )
+int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
+ unsigned char mac[16] )
{
unsigned char len_block[16];
if ( ( ctx == NULL ) || ( mac == NULL ) )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA );
}
- else if ( ctx->state == AEAD_CHACHA20_POLY1305_STATE_INIT )
+ else if ( ctx->state == CHACHAPOLY_STATE_INIT )
{
- return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE );
+ return( MBEDTLS_ERR_CHACHAPOLY_BAD_STATE );
}
- if ( ctx->state == AEAD_CHACHA20_POLY1305_STATE_AAD )
+ if ( ctx->state == CHACHAPOLY_STATE_AAD )
{
- mbedtls_aead_chacha20_poly1305_pad_aad( ctx );
+ mbedtls_chachapoly_pad_aad( ctx );
}
- else if ( ctx->state == AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT )
+ else if ( ctx->state == CHACHAPOLY_STATE_CIPHERTEXT )
{
- mbedtls_aead_chacha20_poly1305_pad_ciphertext( ctx );
+ mbedtls_chachapoly_pad_ciphertext( ctx );
}
- ctx->state = AEAD_CHACHA20_POLY1305_STATE_FINISHED;
+ ctx->state = CHACHAPOLY_STATE_FINISHED;
/* The lengths of the AAD and ciphertext are processed by
* Poly1305 as the final 128-bit block, encoded as little-endian integers.
@@ -291,45 +291,45 @@
return( 0 );
}
-int mbedtls_aead_chacha20_poly1305_crypt_and_mac ( const unsigned char key[32],
- const unsigned char nonce[12],
- mbedtls_aead_chacha20_poly1305_mode_t mode,
- size_t aad_len,
- const unsigned char *aad,
- size_t ilen,
- const unsigned char *input,
- unsigned char *output,
- unsigned char mac[16] )
+int mbedtls_chachapoly_crypt_and_mac ( const unsigned char key[32],
+ const unsigned char nonce[12],
+ mbedtls_chachapoly_mode_t mode,
+ size_t aad_len,
+ const unsigned char *aad,
+ size_t ilen,
+ const unsigned char *input,
+ unsigned char *output,
+ unsigned char mac[16] )
{
- mbedtls_aead_chacha20_poly1305_context ctx;
+ mbedtls_chachapoly_context ctx;
int result;
- mbedtls_aead_chacha20_poly1305_init( &ctx );
+ mbedtls_chachapoly_init( &ctx );
- result = mbedtls_aead_chacha20_poly1305_setkey( &ctx, key );
+ result = mbedtls_chachapoly_setkey( &ctx, key );
if ( result != 0 )
goto cleanup;
- result = mbedtls_aead_chacha20_poly1305_starts( &ctx, nonce, mode );
+ result = mbedtls_chachapoly_starts( &ctx, nonce, mode );
if ( result != 0 )
goto cleanup;
- result = mbedtls_aead_chacha20_poly1305_update_aad( &ctx, aad_len, aad );
+ result = mbedtls_chachapoly_update_aad( &ctx, aad_len, aad );
if ( result != 0 )
goto cleanup;
- result = mbedtls_aead_chacha20_poly1305_update( &ctx, ilen, input, output );
+ result = mbedtls_chachapoly_update( &ctx, ilen, input, output );
if ( result != 0 )
goto cleanup;
- result = mbedtls_aead_chacha20_poly1305_finish( &ctx, mac );
+ result = mbedtls_chachapoly_finish( &ctx, mac );
cleanup:
- mbedtls_aead_chacha20_poly1305_free( &ctx );
+ mbedtls_chachapoly_free( &ctx );
return( result );
}
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
+#endif /* MBEDTLS_CHACHAPOLY_ALT */
#if defined(MBEDTLS_SELF_TEST)
@@ -419,7 +419,7 @@
}
};
-int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
+int mbedtls_chachapoly_self_test( int verbose )
{
unsigned i;
int result;
@@ -433,15 +433,15 @@
mbedtls_printf( " ChaCha20-Poly1305 test %u ", i );
}
- result = mbedtls_aead_chacha20_poly1305_crypt_and_mac( test_key[i],
- test_nonce[i],
- MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
- test_aad_len[i],
- test_aad[i],
- test_input_len[i],
- test_input[i],
- output,
- mac );
+ result = mbedtls_chachapoly_crypt_and_mac( test_key[i],
+ test_nonce[i],
+ MBEDTLS_CHACHAPOLY_ENCRYPT,
+ test_aad_len[i],
+ test_aad[i],
+ test_input_len[i],
+ test_input[i],
+ output,
+ mac );
if ( result != 0 )
{
if ( verbose != 0 )
@@ -485,4 +485,4 @@
#endif /* MBEDTLS_SELF_TEST */
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_CHACHAPOLY_C */
diff --git a/library/cipher.c b/library/cipher.c
index 71fa6f5..acc986f 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -38,8 +38,8 @@
#include <stdlib.h>
#include <string.h>
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
-#include "mbedtls/aead_chacha20_poly1305.h"
+#if defined(MBEDTLS_CHACHAPOLY_C)
+#include "mbedtls/chachapoly.h"
#endif
#if defined(MBEDTLS_GCM_C)
@@ -70,7 +70,7 @@
#endif
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
/* Compare the contents of two buffers in constant time.
* Returns 0 if the contents are bitwise identical, otherwise returns
* a non-zero value.
@@ -88,7 +88,7 @@
return (int)diff;
}
-#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
static int supported_init = 0;
@@ -288,7 +288,7 @@
return( 0 );
}
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
const unsigned char *ad, size_t ad_len )
{
@@ -303,30 +303,30 @@
}
#endif
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
{
int result;
- mbedtls_aead_chacha20_poly1305_mode_t mode;
+ mbedtls_chachapoly_mode_t mode;
mode = ( ctx->operation == MBEDTLS_ENCRYPT )
- ? MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT
- : MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT;
+ ? MBEDTLS_CHACHAPOLY_ENCRYPT
+ : MBEDTLS_CHACHAPOLY_DECRYPT;
- result = mbedtls_aead_chacha20_poly1305_starts( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ result = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ctx->iv,
mode );
if ( result != 0 )
return( result );
- return mbedtls_aead_chacha20_poly1305_update_aad( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ return mbedtls_chachapoly_update_aad( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ad_len, ad );
}
#endif
return( 0 );
}
-#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input,
size_t ilen, unsigned char *output, size_t *olen )
@@ -394,11 +394,11 @@
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
}
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 )
{
*olen = ilen;
- return mbedtls_aead_chacha20_poly1305_update( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ return mbedtls_chachapoly_update( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ilen, input, output );
}
#endif
@@ -852,7 +852,7 @@
}
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
unsigned char *tag, size_t tag_len )
{
@@ -867,14 +867,14 @@
return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len );
#endif
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
{
/* Don't allow truncated MAC for Poly1305 */
if ( tag_len != 16U )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- return mbedtls_aead_chacha20_poly1305_finish( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ return mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
tag );
}
#endif
@@ -914,14 +914,14 @@
}
#endif /* MBEDTLS_GCM_C */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
{
/* Don't allow truncated MAC for Poly1305 */
if ( tag_len != sizeof( check_tag ) )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- ret = mbedtls_aead_chacha20_poly1305_finish( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
check_tag );
if ( ret != 0 )
{
@@ -934,11 +934,11 @@
return( 0 );
}
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_CHACHAPOLY_C */
return( 0 );
}
-#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
/*
* Packet-oriented wrapper for non-AEAD modes
@@ -997,7 +997,7 @@
tag, tag_len ) );
}
#endif /* MBEDTLS_CCM_C */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
{
int ret;
@@ -1010,26 +1010,26 @@
*olen = ilen;
- ret = mbedtls_aead_chacha20_poly1305_starts( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
- iv, MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT );
+ ret = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
+ iv, MBEDTLS_CHACHAPOLY_ENCRYPT );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_update_aad( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_update_aad( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ad_len, ad );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_update( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_update( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ilen, input, output );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_finish( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
tag );
return( ret );
}
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_CHACHAPOLY_C */
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
@@ -1076,7 +1076,7 @@
return( ret );
}
#endif /* MBEDTLS_CCM_C */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
{
unsigned char check_tag[16];
@@ -1090,22 +1090,22 @@
*olen = ilen;
- ret = mbedtls_aead_chacha20_poly1305_starts( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
- iv, MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT );
+ ret = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
+ iv, MBEDTLS_CHACHAPOLY_DECRYPT );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_update_aad( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_update_aad( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ad_len, ad );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_update( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_update( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
ilen, input, output );
if ( ret != 0 )
return( ret );
- ret = mbedtls_aead_chacha20_poly1305_finish( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
+ ret = mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
check_tag );
if ( ret != 0 )
return( ret );
@@ -1116,7 +1116,7 @@
return( 0 );
}
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_CHACHAPOLY_C */
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c
index d8c5f06..5c80828 100644
--- a/library/cipher_wrap.c
+++ b/library/cipher_wrap.c
@@ -33,8 +33,8 @@
#include "mbedtls/cipher_internal.h"
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
-#include "mbedtls/aead_chacha20_poly1305.h"
+#if defined(MBEDTLS_CHACHAPOLY_C)
+#include "mbedtls/chachapoly.h"
#endif
#if defined(MBEDTLS_AES_C)
@@ -1356,40 +1356,41 @@
};
#endif /* MBEDTLS_CHACHA20_C */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_CHACHAPOLY_C)
-static int aead_chacha20_poly1305_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int chachapoly_setkey_wrap( void *ctx,
+ const unsigned char *key,
+ unsigned int key_bitlen )
{
if( key_bitlen != 256U )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- if ( 0 != mbedtls_aead_chacha20_poly1305_setkey( (mbedtls_aead_chacha20_poly1305_context*)ctx, key ) )
+ if ( 0 != mbedtls_chachapoly_setkey( (mbedtls_chachapoly_context*)ctx, key ) )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
return( 0 );
}
-static void * aead_chacha20_poly1305_ctx_alloc( void )
+static void * chachapoly_ctx_alloc( void )
{
- mbedtls_aead_chacha20_poly1305_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_aead_chacha20_poly1305_context ) );
+ mbedtls_chachapoly_context *ctx;
+ ctx = mbedtls_calloc( 1, sizeof( mbedtls_chachapoly_context ) );
if( ctx == NULL )
return( NULL );
- mbedtls_aead_chacha20_poly1305_init( ctx );
+ mbedtls_chachapoly_init( ctx );
return( ctx );
}
-static void aead_chacha20_poly1305_ctx_free( void *ctx )
+static void chachapoly_ctx_free( void *ctx )
{
- mbedtls_aead_chacha20_poly1305_free( (mbedtls_aead_chacha20_poly1305_context *) ctx );
+ mbedtls_chachapoly_free( (mbedtls_chachapoly_context *) ctx );
mbedtls_free( ctx );
}
-static const mbedtls_cipher_base_t aead_chacha20_poly1305_base_info = {
+static const mbedtls_cipher_base_t chachapoly_base_info = {
MBEDTLS_CIPHER_ID_CHACHA20,
NULL,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
@@ -1404,12 +1405,12 @@
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
NULL,
#endif
- aead_chacha20_poly1305_setkey_wrap,
- aead_chacha20_poly1305_setkey_wrap,
- aead_chacha20_poly1305_ctx_alloc,
- aead_chacha20_poly1305_ctx_free
+ chachapoly_setkey_wrap,
+ chachapoly_setkey_wrap,
+ chachapoly_ctx_alloc,
+ chachapoly_ctx_free
};
-static const mbedtls_cipher_info_t aead_chacha20_poly1305_info = {
+static const mbedtls_cipher_info_t chachapoly_info = {
MBEDTLS_CIPHER_CHACHA20_POLY1305,
MBEDTLS_MODE_NONE,
256,
@@ -1417,9 +1418,9 @@
12,
0,
64,
- &aead_chacha20_poly1305_base_info
+ &chachapoly_base_info
};
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#endif /* MBEDTLS_CHACHAPOLY_C */
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
static int null_crypt_stream( void *ctx, size_t length,
@@ -1580,8 +1581,8 @@
{ MBEDTLS_CIPHER_CHACHA20, &chacha20_info },
#endif
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
- { MBEDTLS_CIPHER_CHACHA20_POLY1305, &aead_chacha20_poly1305_info },
+#if defined(MBEDTLS_CHACHAPOLY_C)
+ { MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info },
#endif
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
diff --git a/library/error.c b/library/error.c
index d0a75ca..aeef930 100644
--- a/library/error.c
+++ b/library/error.c
@@ -41,10 +41,6 @@
#include <stdio.h>
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
-#include "mbedtls/aead_chacha20_poly1305.h"
-#endif
-
#if defined(MBEDTLS_AES_C)
#include "mbedtls/aes.h"
#endif
@@ -77,6 +73,10 @@
#include "mbedtls/chacha20.h"
#endif
+#if defined(MBEDTLS_CHACHAPOLY_C)
+#include "mbedtls/chachapoly.h"
+#endif
+
#if defined(MBEDTLS_CIPHER_C)
#include "mbedtls/cipher.h"
#endif
@@ -579,13 +579,6 @@
// Low level error codes
//
// BEGIN generated code
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
- if( use_ret == -(MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA) )
- mbedtls_snprintf( buf, buflen, "AEAD_CHACHA20_POLY1305 - Invalid input parameter(s)" );
- if( use_ret == -(MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE) )
- mbedtls_snprintf( buf, buflen, "AEAD_CHACHA20_POLY1305 - The requested operation is not permitted in the current state" );
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
-
#if defined(MBEDTLS_AES_C)
if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) )
mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
@@ -677,6 +670,13 @@
mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" );
#endif /* MBEDTLS_CHACHA20_C */
+#if defined(MBEDTLS_CHACHAPOLY_C)
+ if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA) )
+ mbedtls_snprintf( buf, buflen, "CHACHAPOLY - Invalid input parameter(s)" );
+ if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE) )
+ mbedtls_snprintf( buf, buflen, "CHACHAPOLY - The requested operation is not permitted in the current state" );
+#endif /* MBEDTLS_CHACHAPOLY_C */
+
#if defined(MBEDTLS_CMAC_C)
if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) )
mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" );
diff --git a/library/version_features.c b/library/version_features.c
index b73410c..cce1a38 100644
--- a/library/version_features.c
+++ b/library/version_features.c
@@ -84,9 +84,9 @@
#if defined(MBEDTLS_TIMING_ALT)
"MBEDTLS_TIMING_ALT",
#endif /* MBEDTLS_TIMING_ALT */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
- "MBEDTLS_AEAD_CHACHA20_POLY1305_ALT",
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
+#if defined(MBEDTLS_CHACHAPOLY_ALT)
+ "MBEDTLS_CHACHAPOLY_ALT",
+#endif /* MBEDTLS_CHACHAPOLY_ALT */
#if defined(MBEDTLS_AES_ALT)
"MBEDTLS_AES_ALT",
#endif /* MBEDTLS_AES_ALT */
@@ -519,9 +519,9 @@
#if defined(MBEDTLS_AES_C)
"MBEDTLS_AES_C",
#endif /* MBEDTLS_AES_C */
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
- "MBEDTLS_AEAD_CHACHA20_POLY1305_C",
-#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
+#if defined(MBEDTLS_CHACHAPOLY_C)
+ "MBEDTLS_CHACHAPOLY_C",
+#endif /* MBEDTLS_CHACHAPOLY_C */
#if defined(MBEDTLS_ARC4_C)
"MBEDTLS_ARC4_C",
#endif /* MBEDTLS_ARC4_C */
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index 57f9924..13fa98c 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -46,7 +46,7 @@
#include "mbedtls/camellia.h"
#include "mbedtls/chacha20.h"
#include "mbedtls/poly1305.h"
-#include "mbedtls/aead_chacha20_poly1305.h"
+#include "mbedtls/chachapoly.h"
#include "mbedtls/base64.h"
#include "mbedtls/bignum.h"
#include "mbedtls/rsa.h"
@@ -216,8 +216,8 @@
#if defined(MBEDTLS_POLY1305_C)
{"poly1305", mbedtls_poly1305_self_test},
#endif
-#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
- {"chacha20-poly1305", mbedtls_aead_chacha20_poly1305_self_test},
+#if defined(MBEDTLS_CHACHAPOLY_C)
+ {"chacha20-poly1305", mbedtls_chachapoly_self_test},
#endif
#if defined(MBEDTLS_BASE64_C)
{"base64", mbedtls_base64_self_test},
diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl
index b5d1413..811648a 100755
--- a/scripts/generate_errors.pl
+++ b/scripts/generate_errors.pl
@@ -29,8 +29,8 @@
my $error_format_file = $data_dir.'/error.fmt';
-my @low_level_modules = qw( AEAD_CHACHA20_POLY1305 AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
- CAMELLIA CCM CHACHA20 CMAC CTR_DRBG DES
+my @low_level_modules = qw( AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
+ CAMELLIA CCM CHACHA20 CHACHAPOLY CMAC CTR_DRBG DES
ENTROPY GCM HMAC_DRBG MD2 MD4 MD5
NET OID PADLOCK PBKDF2 POLY1305 RIPEMD160
SHA1 SHA256 SHA512 THREADING XTEA );
@@ -88,7 +88,6 @@
$module_name = "BIGNUM" if ($module_name eq "MPI");
$module_name = "CTR_DRBG" if ($module_name eq "CTR");
$module_name = "HMAC_DRBG" if ($module_name eq "HMAC");
- $module_name = "AEAD_CHACHA20_POLY1305" if ($module_name eq "AEAD");
my $define_name = $module_name;
$define_name = "X509_USE,X509_CREATE" if ($define_name eq "X509");
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c7d9fad..9630538 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -44,7 +44,6 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
endif(MSVC)
-add_test_suite(aead_chacha20_poly1305)
add_test_suite(aes aes.ecb)
add_test_suite(aes aes.cbc)
add_test_suite(aes aes.cfb)
@@ -56,13 +55,14 @@
add_test_suite(camellia)
add_test_suite(ccm)
add_test_suite(chacha20)
-add_test_suite(cipher cipher.aead_chacha20_poly1305)
+add_test_suite(chachapoly)
add_test_suite(cipher cipher.aes)
add_test_suite(cipher cipher.arc4)
add_test_suite(cipher cipher.blowfish)
add_test_suite(cipher cipher.camellia)
add_test_suite(cipher cipher.ccm)
add_test_suite(cipher cipher.chacha20)
+add_test_suite(cipher cipher.chachapoly)
add_test_suite(cipher cipher.des)
add_test_suite(cipher cipher.gcm)
add_test_suite(cipher cipher.null)
diff --git a/tests/Makefile b/tests/Makefile
index e6ff26c..f9d9768 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -45,14 +45,14 @@
LOCAL_LDFLAGS += -lz
endif
-APPS = test_suite_aead_chacha20_poly1305$(EXEXT) \
- test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \
+APPS = test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \
test_suite_aes.cfb$(EXEXT) test_suite_aes.rest$(EXEXT) \
test_suite_arc4$(EXEXT) test_suite_asn1write$(EXEXT) \
test_suite_base64$(EXEXT) test_suite_blowfish$(EXEXT) \
test_suite_camellia$(EXEXT) test_suite_ccm$(EXEXT) \
- test_suite_chacha20$(EXEXT) test_suite_cmac$(EXEXT) \
- test_suite_cipher.aead_chacha20_poly1305$(EXEXT) \
+ test_suite_chacha20$(EXEXT) test_suite_chachapoly$(EXEXT) \
+ test_suite_cmac$(EXEXT) \
+ test_suite_cipher.chachapoly$(EXEXT) \
test_suite_cipher.aes$(EXEXT) \
test_suite_cipher.arc4$(EXEXT) test_suite_cipher.ccm$(EXEXT) \
test_suite_cipher.chacha20$(EXEXT) \
@@ -117,10 +117,6 @@
echo " Gen $@"
perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest
-test_suite_cipher.aead_chacha20_poly1305.c : suites/test_suite_cipher.function suites/test_suite_cipher.aead_chacha20_poly1305.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
- echo " Gen $@"
- perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aead_chacha20_poly1305
-
test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
echo " Gen $@"
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
@@ -137,6 +133,10 @@
echo " Gen $@"
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.chacha20
+test_suite_cipher.chachapoly.c : suites/test_suite_cipher.function suites/test_suite_cipher.chachapoly.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
+ echo " Gen $@"
+ perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.chachapoly
+
test_suite_cipher.gcm.c : suites/test_suite_cipher.function suites/test_suite_cipher.gcm.data scripts/generate_code.pl suites/helpers.function suites/main_test.function
echo " Gen $@"
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.gcm
@@ -210,10 +210,6 @@
perl scripts/generate_code.pl suites $* $*
-test_suite_aead_chacha20_poly1305$(EXEXT): test_suite_aead_chacha20_poly1305.c $(DEP)
- echo " CC $<"
- $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-
test_suite_aes.ecb$(EXEXT): test_suite_aes.ecb.c $(DEP)
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
@@ -258,6 +254,10 @@
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
+test_suite_chachapoly$(EXEXT): test_suite_chachapoly.c $(DEP)
+ echo " CC $<"
+ $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
+
test_suite_cmac$(EXEXT): test_suite_cmac.c $(DEP)
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
@@ -266,10 +266,6 @@
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-test_suite_cipher.aead_chacha20_poly1305$(EXEXT): test_suite_cipher.aead_chacha20_poly1305.c $(DEP)
- echo " CC $<"
- $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
-
test_suite_cipher.arc4$(EXEXT): test_suite_cipher.arc4.c $(DEP)
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
@@ -282,6 +278,10 @@
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
+test_suite_cipher.chachapoly$(EXEXT): test_suite_cipher.chachapoly.c $(DEP)
+ echo " CC $<"
+ $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
+
test_suite_cipher.gcm$(EXEXT): test_suite_cipher.gcm.c $(DEP)
echo " CC $<"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
diff --git a/tests/suites/test_suite_aead_chacha20_poly1305.data b/tests/suites/test_suite_aead_chacha20_poly1305.data
deleted file mode 100644
index 1cbfa24..0000000
--- a/tests/suites/test_suite_aead_chacha20_poly1305.data
+++ /dev/null
@@ -1,19 +0,0 @@
-ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Encrypt)
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
-mbedtls_aead_chacha20_poly1305_enc:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600691"
-
-ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Encrypt)
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
-mbedtls_aead_chacha20_poly1305_dec:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"1ae10b594f09e26a7e902ecbd0600691"
-
-ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Encrypt)
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
-mbedtls_aead_chacha20_poly1305_enc:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"eead9d67890cbb22392336fea1851f38"
-
-ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Decrypt)
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
-mbedtls_aead_chacha20_poly1305_dec:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"eead9d67890cbb22392336fea1851f38"
-
-ChaCha20-Poly1305 Selftest
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C:MBEDTLS_SELF_TEST
-aead_chacha20_poly1305_selftest:
diff --git a/tests/suites/test_suite_chachapoly.data b/tests/suites/test_suite_chachapoly.data
new file mode 100644
index 0000000..08129aa
--- /dev/null
+++ b/tests/suites/test_suite_chachapoly.data
@@ -0,0 +1,19 @@
+ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Encrypt)
+depends_on:MBEDTLS_CHACHAPOLY_C
+mbedtls_chachapoly_enc:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600691"
+
+ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Encrypt)
+depends_on:MBEDTLS_CHACHAPOLY_C
+mbedtls_chachapoly_dec:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"1ae10b594f09e26a7e902ecbd0600691"
+
+ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Encrypt)
+depends_on:MBEDTLS_CHACHAPOLY_C
+mbedtls_chachapoly_enc:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"eead9d67890cbb22392336fea1851f38"
+
+ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Decrypt)
+depends_on:MBEDTLS_CHACHAPOLY_C
+mbedtls_chachapoly_dec:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"eead9d67890cbb22392336fea1851f38"
+
+ChaCha20-Poly1305 Selftest
+depends_on:MBEDTLS_CHACHAPOLY_C:MBEDTLS_SELF_TEST
+chachapoly_selftest:
diff --git a/tests/suites/test_suite_aead_chacha20_poly1305.function b/tests/suites/test_suite_chachapoly.function
similarity index 67%
rename from tests/suites/test_suite_aead_chacha20_poly1305.function
rename to tests/suites/test_suite_chachapoly.function
index 6abd054..fb1a738 100644
--- a/tests/suites/test_suite_aead_chacha20_poly1305.function
+++ b/tests/suites/test_suite_chachapoly.function
@@ -1,14 +1,14 @@
/* BEGIN_HEADER */
-#include "mbedtls/aead_chacha20_poly1305.h"
+#include "mbedtls/chachapoly.h"
/* END_HEADER */
/* BEGIN_DEPENDENCIES
- * depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+ * depends_on:MBEDTLS_CHACHAPOLY_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
-void mbedtls_aead_chacha20_poly1305_enc( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
+void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
{
unsigned char key_str[32];
unsigned char nonce_str[12];
@@ -43,11 +43,11 @@
TEST_ASSERT( nonce_len == 12 );
TEST_ASSERT( mac_len == 16 );
- mbedtls_aead_chacha20_poly1305_crypt_and_mac( key_str, nonce_str,
- MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
- aad_len, aad_str,
- input_len, input_str, output,
- mac );
+ mbedtls_chachapoly_crypt_and_mac( key_str, nonce_str,
+ MBEDTLS_CHACHAPOLY_ENCRYPT,
+ aad_len, aad_str,
+ input_len, input_str, output,
+ mac );
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
@@ -55,7 +55,7 @@
/* END_CASE */
/* BEGIN_CASE */
-void mbedtls_aead_chacha20_poly1305_dec( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
+void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
{
unsigned char key_str[32];
unsigned char nonce_str[12];
@@ -90,11 +90,11 @@
TEST_ASSERT( nonce_len == 12 );
TEST_ASSERT( mac_len == 16 );
- mbedtls_aead_chacha20_poly1305_crypt_and_mac( key_str, nonce_str,
- MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT,
- aad_len, aad_str,
- input_len, input_str, output,
- mac );
+ mbedtls_chachapoly_crypt_and_mac( key_str, nonce_str,
+ MBEDTLS_CHACHAPOLY_DECRYPT,
+ aad_len, aad_str,
+ input_len, input_str, output,
+ mac );
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
@@ -102,8 +102,8 @@
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
-void aead_chacha20_poly1305_selftest()
+void chachapoly_selftest()
{
- TEST_ASSERT( mbedtls_aead_chacha20_poly1305_self_test( 1 ) == 0 );
+ TEST_ASSERT( mbedtls_chachapoly_self_test( 1 ) == 0 );
}
/* END_CASE */
diff --git a/tests/suites/test_suite_cipher.aead_chacha20_poly1305.data b/tests/suites/test_suite_cipher.chachapoly.data
similarity index 74%
rename from tests/suites/test_suite_cipher.aead_chacha20_poly1305.data
rename to tests/suites/test_suite_cipher.chachapoly.data
index 9cd1ed0..de5b3d6 100644
--- a/tests/suites/test_suite_cipher.aead_chacha20_poly1305.data
+++ b/tests/suites/test_suite_cipher.chachapoly.data
@@ -1,111 +1,111 @@
Decrypt empty buffer
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C:
+depends_on:MBEDTLS_CHACHAPOLY_C:
dec_empty_buf:
ChaCha20+Poly1305 Encrypt and decrypt 0 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:0:-1
ChaCha20+Poly1305 Encrypt and decrypt 1 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:1:-1
ChaCha20+Poly1305 Encrypt and decrypt 2 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:2:-1
ChaCha20+Poly1305 Encrypt and decrypt 7 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:7:-1
ChaCha20+Poly1305 Encrypt and decrypt 8 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:8:-1
ChaCha20+Poly1305 Encrypt and decrypt 9 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:9:-1
ChaCha20+Poly1305 Encrypt and decrypt 15 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:15:-1
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:16:-1
ChaCha20+Poly1305 Encrypt and decrypt 17 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:17:-1
ChaCha20+Poly1305 Encrypt and decrypt 31 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:31:-1
ChaCha20+Poly1305 Encrypt and decrypt 32 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:32:-1
ChaCha20+Poly1305 Encrypt and decrypt 33 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:33:-1
ChaCha20+Poly1305 Encrypt and decrypt 47 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:47:-1
ChaCha20+Poly1305 Encrypt and decrypt 48 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:48:-1
ChaCha20+Poly1305 Encrypt and decrypt 49 bytes
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:49:-1
ChaCha20+Poly1305 Encrypt and decrypt 0 bytes in multiple parts 1
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:0:-1:0:0:0:0
ChaCha20+Poly1305 Encrypt and decrypt 1 bytes in multiple parts 1
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:1:0:-1:1:0:1:0
ChaCha20+Poly1305 Encrypt and decrypt 1 bytes in multiple parts 2
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:1:-1:0:1:0:1
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 1
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:0:-1:16:0:16:0
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 2
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:16:-1:0:16:0:16
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 3
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:1:15:-1:1:15:1:15
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 4
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:15:1:-1:15:1:15:1
ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 1
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:15:7:-1:15:7:15:7
ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 2
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:7:15:-1:7:15:7:15
ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 3
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:6:-1:16:6:16:6
ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 4
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:6:16:-1:6:16:6:16
ChaCha20+Poly1305 Encrypt and decrypt 32 bytes in multiple parts
-depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
+depends_on:MBEDTLS_CHACHAPOLY_C
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:16:-1:16:16:16:16
diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function
index e5a252f..92462e5 100644
--- a/tests/suites/test_suite_cipher.function
+++ b/tests/suites/test_suite_cipher.function
@@ -60,7 +60,7 @@
TEST_ASSERT( mbedtls_cipher_reset( NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_cipher_reset( &ctx ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( mbedtls_cipher_update_ad( NULL, buf, 0 )
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_cipher_update_ad( &ctx, buf, 0 )
@@ -77,7 +77,7 @@
TEST_ASSERT( mbedtls_cipher_finish( &ctx, buf, &olen )
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( mbedtls_cipher_write_tag( NULL, buf, olen )
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_cipher_write_tag( &ctx, buf, olen )
@@ -195,7 +195,7 @@
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, ad, sizeof( ad ) - i ) );
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) );
#endif
@@ -215,7 +215,7 @@
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
total_len += outlen;
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_write_tag( &ctx_enc, tag, sizeof( tag ) ) );
#endif
@@ -236,7 +236,7 @@
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
total_len += outlen;
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_check_tag( &ctx_dec, tag, sizeof( tag ) ) );
#endif
@@ -292,7 +292,7 @@
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, 16 ) );
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, NULL, 0 ) );
#endif
@@ -340,7 +340,7 @@
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) );
#endif
@@ -416,7 +416,7 @@
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) );
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, NULL, 0 ) );
#endif
@@ -484,7 +484,7 @@
unsigned char ad[200];
unsigned char tag[20];
size_t key_len, iv_len, cipher_len, clear_len;
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
size_t ad_len, tag_len;
#endif
mbedtls_cipher_context_t ctx;
@@ -505,7 +505,7 @@
iv_len = unhexify( iv, hex_iv );
cipher_len = unhexify( cipher, hex_cipher );
clear_len = unhexify( clear, hex_clear );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
ad_len = unhexify( ad, hex_ad );
tag_len = unhexify( tag, hex_tag );
#else
@@ -525,7 +525,7 @@
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, iv_len ) );
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, ad, ad_len ) );
#endif
@@ -536,7 +536,7 @@
TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen,
&outlen ) );
total_len += outlen;
-#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C)
TEST_ASSERT( tag_result == mbedtls_cipher_check_tag( &ctx, tag, tag_len ) );
#endif
diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj
index 802cce7..b04935a 100644
--- a/visualc/VS2010/mbedTLS.vcxproj
+++ b/visualc/VS2010/mbedTLS.vcxproj
@@ -158,6 +158,8 @@
<ClInclude Include="..\..\include\mbedtls\camellia.h" />
<ClInclude Include="..\..\include\mbedtls\ccm.h" />
<ClInclude Include="..\..\include\mbedtls\certs.h" />
+ <ClInclude Include="..\..\include\mbedtls\chacha20.h" />
+ <ClInclude Include="..\..\include\mbedtls\chachapoly.h" />
<ClInclude Include="..\..\include\mbedtls\check_config.h" />
<ClInclude Include="..\..\include\mbedtls\cipher.h" />
<ClInclude Include="..\..\include\mbedtls\cipher_internal.h" />
@@ -198,6 +200,7 @@
<ClInclude Include="..\..\include\mbedtls\platform.h" />
<ClInclude Include="..\..\include\mbedtls\platform_time.h" />
<ClInclude Include="..\..\include\mbedtls\platform_util.h" />
+ <ClInclude Include="..\..\include\mbedtls\poly1305.h" />
<ClInclude Include="..\..\include\mbedtls\ripemd160.h" />
<ClInclude Include="..\..\include\mbedtls\rsa.h" />
<ClInclude Include="..\..\include\mbedtls\rsa_internal.h" />
@@ -231,6 +234,8 @@
<ClCompile Include="..\..\library\camellia.c" />
<ClCompile Include="..\..\library\ccm.c" />
<ClCompile Include="..\..\library\certs.c" />
+ <ClCompile Include="..\..\library\chacha20.c" />
+ <ClCompile Include="..\..\library\chachapoly.c" />
<ClCompile Include="..\..\library\cipher.c" />
<ClCompile Include="..\..\library\cipher_wrap.c" />
<ClCompile Include="..\..\library\cmac.c" />
@@ -268,6 +273,7 @@
<ClCompile Include="..\..\library\pkwrite.c" />
<ClCompile Include="..\..\library\platform.c" />
<ClCompile Include="..\..\library\platform_util.c" />
+ <ClCompile Include="..\..\library\poly1305.c" />
<ClCompile Include="..\..\library\ripemd160.c" />
<ClCompile Include="..\..\library\rsa.c" />
<ClCompile Include="..\..\library\rsa_internal.c" />