mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
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.
This commit is contained in:
@ -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 @@ static const mbedtls_cipher_info_t chacha20_info = {
|
||||
};
|
||||
#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 @@ static const mbedtls_cipher_base_t aead_chacha20_poly1305_base_info = {
|
||||
#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 @@ static const mbedtls_cipher_info_t aead_chacha20_poly1305_info = {
|
||||
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 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
{ 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)
|
||||
|
Reference in New Issue
Block a user