mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 12:45:39 +01: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:
parent
4edd51babe
commit
dca3a5d884
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* \file aead_chacha20_poly1305.h
|
* \file chachapoly.h
|
||||||
*
|
*
|
||||||
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
|
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
|
||||||
*
|
*
|
||||||
@ -20,8 +20,8 @@
|
|||||||
*
|
*
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
*/
|
*/
|
||||||
#ifndef MBEDTLS_AEAD_CHACHA20_POLY1305_H
|
#ifndef MBEDTLS_CHACHAPOLY_H
|
||||||
#define MBEDTLS_AEAD_CHACHA20_POLY1305_H
|
#define MBEDTLS_CHACHAPOLY_H
|
||||||
|
|
||||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -29,8 +29,8 @@
|
|||||||
#include MBEDTLS_CONFIG_FILE
|
#include MBEDTLS_CONFIG_FILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA -0x00047 /**< Invalid input parameter(s). */
|
#define MBEDTLS_ERR_CHACHAPOLY_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_STATE -0x00049 /**< The requested operation is not permitted in the current state */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -38,12 +38,12 @@ extern "C" {
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
|
MBEDTLS_CHACHAPOLY_ENCRYPT,
|
||||||
MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT
|
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 "chacha20.h"
|
||||||
#include "poly1305.h"
|
#include "poly1305.h"
|
||||||
@ -55,27 +55,27 @@ typedef struct
|
|||||||
uint64_t aad_len; /** Length (bytes) of the Additional Authenticated Data */
|
uint64_t aad_len; /** Length (bytes) of the Additional Authenticated Data */
|
||||||
uint64_t ciphertext_len; /** Length (bytes) of the ciphertext */
|
uint64_t ciphertext_len; /** Length (bytes) of the ciphertext */
|
||||||
int state; /** Current state of the context */
|
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 */
|
#else /* !MBEDTLS_CHACHAPOLY_ALT */
|
||||||
#include "aead_chacha20_poly1305_alt.h"
|
#include "chachapoly_alt.h"
|
||||||
#endif /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
|
#endif /* !MBEDTLS_CHACHAPOLY_ALT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialize ChaCha20-Poly1305 context
|
* \brief Initialize ChaCha20-Poly1305 context
|
||||||
*
|
*
|
||||||
* \param ctx ChaCha20-Poly1305 context to be initialized
|
* \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
|
* \brief Clear ChaCha20-Poly1305 context
|
||||||
*
|
*
|
||||||
* \param ctx ChaCha20-Poly1305 context to be cleared
|
* \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.
|
* \brief Set the ChaCha20-Poly1305 symmetric encryption key.
|
||||||
@ -83,12 +83,12 @@ void mbedtls_aead_chacha20_poly1305_free( mbedtls_aead_chacha20_poly1305_context
|
|||||||
* \param ctx The ChaCha20-Poly1305 context.
|
* \param ctx The ChaCha20-Poly1305 context.
|
||||||
* \param key The 256-bit (32 bytes) key.
|
* \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.
|
* if \p ctx or \p key are NULL.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx,
|
||||||
const unsigned char key[32] );
|
const unsigned char key[32] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Setup ChaCha20-Poly1305 context for encryption or decryption.
|
* \brief Setup ChaCha20-Poly1305 context for encryption or decryption.
|
||||||
@ -102,13 +102,13 @@ int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
* \param mode Specifies whether the context is used to encrypt or
|
* \param mode Specifies whether the context is used to encrypt or
|
||||||
* decrypt data.
|
* 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.
|
* if \p ctx or \p mac are NULL.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx,
|
||||||
const unsigned char nonce[12],
|
const unsigned char nonce[12],
|
||||||
mbedtls_aead_chacha20_poly1305_mode_t mode );
|
mbedtls_chachapoly_mode_t mode );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Process additional authenticated data (AAD).
|
* \brief Process additional authenticated data (AAD).
|
||||||
@ -118,14 +118,14 @@ int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
*
|
*
|
||||||
* \note This function is called before data is encrypted/decrypted.
|
* \note This function is called before data is encrypted/decrypted.
|
||||||
* I.e. call this function to process the AAD before calling
|
* 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
|
* You may call this function multiple times to process
|
||||||
* an arbitrary amount of AAD. It is permitted to call
|
* an arbitrary amount of AAD. It is permitted to call
|
||||||
* this function 0 times, if no AAD is used.
|
* this function 0 times, if no AAD is used.
|
||||||
*
|
*
|
||||||
* This function cannot be called any more if data has
|
* 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.
|
* or if the context has been finished.
|
||||||
*
|
*
|
||||||
* \param ctx The ChaCha20-Poly1305 context.
|
* \param ctx The ChaCha20-Poly1305 context.
|
||||||
@ -134,23 +134,23 @@ int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
* \param aad Buffer containing the AAD.
|
* \param aad Buffer containing the AAD.
|
||||||
* This pointer can be NULL if aad_len == 0.
|
* 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.
|
* 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
|
* the context has not been setup, the context has been
|
||||||
* finished, or if the AAD has been finished.
|
* finished, or if the AAD has been finished.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx,
|
||||||
size_t aad_len,
|
size_t aad_len,
|
||||||
const unsigned char *aad );
|
const unsigned char *aad );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Encrypt/decrypt data.
|
* \brief Encrypt/decrypt data.
|
||||||
*
|
*
|
||||||
* The direction (encryption or decryption) depends on the
|
* The direction (encryption or decryption) depends on the
|
||||||
* mode that was given when calling
|
* mode that was given when calling
|
||||||
* mbedtls_aead_chacha20_poly1305_starts.
|
* mbedtls_chachapoly_starts.
|
||||||
*
|
*
|
||||||
* You may call this function multiple times to process
|
* You may call this function multiple times to process
|
||||||
* an arbitrary amount of data. It is permitted to call
|
* an arbitrary amount of data. It is permitted to call
|
||||||
@ -164,17 +164,17 @@ int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_co
|
|||||||
* \param output Buffer to where the encrypted or decrypted data is written.
|
* \param output Buffer to where the encrypted or decrypted data is written.
|
||||||
* This pointer can be NULL if len == 0.
|
* 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.
|
* 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
|
* the context has not been setup, or if the context has been
|
||||||
* finished.
|
* finished.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx,
|
||||||
size_t len,
|
size_t len,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output );
|
unsigned char *output );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compute the ChaCha20-Poly1305 MAC.
|
* \brief Compute the ChaCha20-Poly1305 MAC.
|
||||||
@ -182,14 +182,14 @@ int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
* \param ctx The ChaCha20-Poly1305 context.
|
* \param ctx The ChaCha20-Poly1305 context.
|
||||||
* \param mac Buffer to where the 128-bit (16 bytes) MAC is written.
|
* \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.
|
* 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.
|
* the context has not been setup.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
|
||||||
unsigned char mac[16] );
|
unsigned char mac[16] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Encrypt or decrypt data, and produce a MAC with ChaCha20-Poly1305.
|
* \brief Encrypt or decrypt data, and produce a MAC with ChaCha20-Poly1305.
|
||||||
@ -210,29 +210,29 @@ int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
* This pointer can be NULL if ilen == 0.
|
* This pointer can be NULL if ilen == 0.
|
||||||
* \param mac Buffer to where the computed 128-bit (16 bytes) MAC is written.
|
* \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.
|
* if one or more of the required parameters are NULL.
|
||||||
* Otherwise, 0 is returned to indicate success.
|
* Otherwise, 0 is returned to indicate success.
|
||||||
*/
|
*/
|
||||||
int mbedtls_aead_chacha20_poly1305_crypt_and_mac( const unsigned char key[32],
|
int mbedtls_chachapoly_crypt_and_mac( const unsigned char key[32],
|
||||||
const unsigned char nonce[12],
|
const unsigned char nonce[12],
|
||||||
mbedtls_aead_chacha20_poly1305_mode_t mode,
|
mbedtls_chachapoly_mode_t mode,
|
||||||
size_t aad_len,
|
size_t aad_len,
|
||||||
const unsigned char *aad,
|
const unsigned char *aad,
|
||||||
size_t ilen,
|
size_t ilen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output,
|
unsigned char *output,
|
||||||
unsigned char mac[16] );
|
unsigned char mac[16] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Checkup routine
|
* \brief Checkup routine
|
||||||
*
|
*
|
||||||
* \return 0 if successful, or 1 if the test failed
|
* \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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_H */
|
#endif /* MBEDTLS_CHACHAPOLY_H */
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#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
|
#define MBEDTLS_CIPHER_MODE_AEAD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
|
|||||||
*/
|
*/
|
||||||
int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
|
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.
|
* \brief This function adds additional data for AEAD ciphers.
|
||||||
* Currently supported with GCM and ChaCha20+Poly1305.
|
* Currently supported with GCM and ChaCha20+Poly1305.
|
||||||
@ -578,7 +578,7 @@ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
|
|||||||
*/
|
*/
|
||||||
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
|
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
|
||||||
const unsigned char *ad, size_t ad_len );
|
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
|
* \brief The generic cipher update function. It encrypts or
|
||||||
@ -636,7 +636,7 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
|
|||||||
int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
|
int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
|
||||||
unsigned char *output, size_t *olen );
|
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.
|
* \brief This function writes a tag for AEAD ciphers.
|
||||||
* Currently supported with GCM and ChaCha20+Poly1305.
|
* Currently supported with GCM and ChaCha20+Poly1305.
|
||||||
@ -666,7 +666,7 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
|
|||||||
*/
|
*/
|
||||||
int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
|
int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
|
||||||
const unsigned char *tag, size_t tag_len );
|
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,
|
* \brief The generic all-in-one encryption/decryption function,
|
||||||
|
@ -269,7 +269,7 @@
|
|||||||
* digests and ciphers instead.
|
* digests and ciphers instead.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//#define MBEDTLS_AEAD_CHACHA20_POLY1305_ALT
|
//#define MBEDTLS_CHACHAPOLY_ALT
|
||||||
//#define MBEDTLS_AES_ALT
|
//#define MBEDTLS_AES_ALT
|
||||||
//#define MBEDTLS_ARC4_ALT
|
//#define MBEDTLS_ARC4_ALT
|
||||||
//#define MBEDTLS_BLOWFISH_ALT
|
//#define MBEDTLS_BLOWFISH_ALT
|
||||||
@ -1690,15 +1690,15 @@
|
|||||||
#define MBEDTLS_AES_C
|
#define MBEDTLS_AES_C
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MBEDTLS_AEAD_CHACHA20_POLY1305_C
|
* \def MBEDTLS_CHACHAPOLY_C
|
||||||
*
|
*
|
||||||
* Enable the ChaCha20-Poly1305 AEAD algorithm.
|
* 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
|
* This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_AEAD_CHACHA20_POLY1305_C
|
#define MBEDTLS_CHACHAPOLY_C
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MBEDTLS_ARC4_C
|
* \def MBEDTLS_ARC4_C
|
||||||
@ -1855,7 +1855,7 @@
|
|||||||
* Enable the ChaCha20 block cipher.
|
* Enable the ChaCha20 block cipher.
|
||||||
*
|
*
|
||||||
* Module: library/chacha20.c
|
* Module: library/chacha20.c
|
||||||
* Caller: library/aead_chacha20_poly1305.c
|
* Caller: library/chachapoly.c
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_CHACHA20_C
|
#define MBEDTLS_CHACHA20_C
|
||||||
|
|
||||||
@ -2427,7 +2427,7 @@
|
|||||||
* Enable the Poly1305 MAC algorithm.
|
* Enable the Poly1305 MAC algorithm.
|
||||||
*
|
*
|
||||||
* Module: library/poly1305.c
|
* Module: library/poly1305.c
|
||||||
* Caller: library/aead_chacha20_poly1305.c
|
* Caller: library/chachapoly.c
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_POLY1305_C
|
#define MBEDTLS_POLY1305_C
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
* SHA512 1 0x0039-0x0039
|
* SHA512 1 0x0039-0x0039
|
||||||
* CHACHA20 1 0x003B-0x003B
|
* CHACHA20 1 0x003B-0x003B
|
||||||
* POLY1305 1 0x0041-0x0041
|
* POLY1305 1 0x0041-0x0041
|
||||||
* AEAD_CHACHA20_POLY1305 2 0x0047-0x0049
|
* CHACHAPOLY 2 0x0047-0x0049
|
||||||
*
|
*
|
||||||
* High-level module nr (3 bits - 0x0...-0x7...)
|
* High-level module nr (3 bits - 0x0...-0x7...)
|
||||||
* Name ID Nr of Errors
|
* Name ID Nr of Errors
|
||||||
|
@ -3,7 +3,6 @@ option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." OFF)
|
|||||||
option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
|
option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." OFF)
|
||||||
|
|
||||||
set(src_crypto
|
set(src_crypto
|
||||||
aead_chacha20_poly1305.c
|
|
||||||
aes.c
|
aes.c
|
||||||
aesni.c
|
aesni.c
|
||||||
arc4.c
|
arc4.c
|
||||||
@ -15,6 +14,7 @@ set(src_crypto
|
|||||||
camellia.c
|
camellia.c
|
||||||
ccm.c
|
ccm.c
|
||||||
chacha20.c
|
chacha20.c
|
||||||
|
chachapoly.c
|
||||||
cipher.c
|
cipher.c
|
||||||
cipher_wrap.c
|
cipher_wrap.c
|
||||||
cmac.c
|
cmac.c
|
||||||
|
@ -47,11 +47,10 @@ ifdef WINDOWS_BUILD
|
|||||||
DLEXT=dll
|
DLEXT=dll
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJS_CRYPTO= aead_chacha20_poly1305.o \
|
OBJS_CRYPTO= aes.o aesni.o arc4.o \
|
||||||
aes.o aesni.o arc4.o \
|
|
||||||
asn1parse.o asn1write.o base64.o \
|
asn1parse.o asn1write.o base64.o \
|
||||||
bignum.o blowfish.o camellia.o \
|
bignum.o blowfish.o camellia.o \
|
||||||
ccm.o chacha20.o \
|
ccm.o chacha20.o chachapoly.o \
|
||||||
cipher.o cipher_wrap.o \
|
cipher.o cipher_wrap.o \
|
||||||
cmac.o ctr_drbg.o des.o \
|
cmac.o ctr_drbg.o des.o \
|
||||||
dhm.o ecdh.o ecdsa.o \
|
dhm.o ecdh.o ecdsa.o \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* \file aead_chacha20_poly1305.c
|
* \file chachapoly.c
|
||||||
*
|
*
|
||||||
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
|
* \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539.
|
||||||
*
|
*
|
||||||
@ -26,9 +26,9 @@
|
|||||||
#include MBEDTLS_CONFIG_FILE
|
#include MBEDTLS_CONFIG_FILE
|
||||||
#endif
|
#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>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(MBEDTLS_SELF_TEST)
|
#if defined(MBEDTLS_SELF_TEST)
|
||||||
@ -40,12 +40,12 @@
|
|||||||
#endif /* MBEDTLS_PLATFORM_C */
|
#endif /* MBEDTLS_PLATFORM_C */
|
||||||
#endif /* MBEDTLS_SELF_TEST */
|
#endif /* MBEDTLS_SELF_TEST */
|
||||||
|
|
||||||
#if !defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
|
#if !defined(MBEDTLS_CHACHAPOLY_ALT)
|
||||||
|
|
||||||
#define AEAD_CHACHA20_POLY1305_STATE_INIT ( 0 )
|
#define CHACHAPOLY_STATE_INIT ( 0 )
|
||||||
#define AEAD_CHACHA20_POLY1305_STATE_AAD ( 1 )
|
#define CHACHAPOLY_STATE_AAD ( 1 )
|
||||||
#define AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT ( 2 ) /* Encrypting or decrypting */
|
#define CHACHAPOLY_STATE_CIPHERTEXT ( 2 ) /* Encrypting or decrypting */
|
||||||
#define AEAD_CHACHA20_POLY1305_STATE_FINISHED ( 3 )
|
#define CHACHAPOLY_STATE_FINISHED ( 3 )
|
||||||
|
|
||||||
/* Implementation that should never be optimized out by the compiler */
|
/* Implementation that should never be optimized out by the compiler */
|
||||||
static void mbedtls_zeroize( void *v, size_t n ) {
|
static void mbedtls_zeroize( void *v, size_t n ) {
|
||||||
@ -57,7 +57,7 @@ static void mbedtls_zeroize( void *v, size_t n ) {
|
|||||||
*
|
*
|
||||||
* \param ctx The ChaCha20-Poly1305 context.
|
* \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 );
|
uint32_t partial_block_len = (uint32_t) ( ctx->aad_len % 16U );
|
||||||
unsigned char zeroes[15];
|
unsigned char zeroes[15];
|
||||||
@ -76,7 +76,7 @@ static void mbedtls_aead_chacha20_poly1305_pad_aad( mbedtls_aead_chacha20_poly13
|
|||||||
*
|
*
|
||||||
* \param ctx The ChaCha20-Poly1305 context.
|
* \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 );
|
uint32_t partial_block_len = (uint32_t) ( ctx->ciphertext_len % 16U );
|
||||||
unsigned char zeroes[15];
|
unsigned char zeroes[15];
|
||||||
@ -90,7 +90,7 @@ static void mbedtls_aead_chacha20_poly1305_pad_ciphertext( mbedtls_aead_chacha20
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_aead_chacha20_poly1305_init( mbedtls_aead_chacha20_poly1305_context *ctx )
|
void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx )
|
||||||
{
|
{
|
||||||
if ( ctx != NULL )
|
if ( ctx != NULL )
|
||||||
{
|
{
|
||||||
@ -98,12 +98,12 @@ void mbedtls_aead_chacha20_poly1305_init( mbedtls_aead_chacha20_poly1305_context
|
|||||||
mbedtls_poly1305_init( &ctx->poly1305_ctx );
|
mbedtls_poly1305_init( &ctx->poly1305_ctx );
|
||||||
ctx->aad_len = 0U;
|
ctx->aad_len = 0U;
|
||||||
ctx->ciphertext_len = 0U;
|
ctx->ciphertext_len = 0U;
|
||||||
ctx->state = AEAD_CHACHA20_POLY1305_STATE_INIT;
|
ctx->state = CHACHAPOLY_STATE_INIT;
|
||||||
ctx->mode = MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT;
|
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 )
|
if ( ctx != NULL )
|
||||||
{
|
{
|
||||||
@ -111,19 +111,19 @@ void mbedtls_aead_chacha20_poly1305_free( mbedtls_aead_chacha20_poly1305_context
|
|||||||
mbedtls_poly1305_free( &ctx->poly1305_ctx );
|
mbedtls_poly1305_free( &ctx->poly1305_ctx );
|
||||||
ctx->aad_len = 0U;
|
ctx->aad_len = 0U;
|
||||||
ctx->ciphertext_len = 0U;
|
ctx->ciphertext_len = 0U;
|
||||||
ctx->state = AEAD_CHACHA20_POLY1305_STATE_INIT;
|
ctx->state = CHACHAPOLY_STATE_INIT;
|
||||||
ctx->mode = MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT;
|
ctx->mode = MBEDTLS_CHACHAPOLY_ENCRYPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx,
|
||||||
const unsigned char key[32] )
|
const unsigned char key[32] )
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if ( ( ctx == NULL ) || ( key == NULL ) )
|
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 );
|
result = mbedtls_chacha20_setkey( &ctx->chacha20_ctx, key );
|
||||||
@ -131,16 +131,16 @@ int mbedtls_aead_chacha20_poly1305_setkey( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx,
|
||||||
const unsigned char nonce[12],
|
const unsigned char nonce[12],
|
||||||
mbedtls_aead_chacha20_poly1305_mode_t mode )
|
mbedtls_chachapoly_mode_t mode )
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
unsigned char poly1305_key[64];
|
unsigned char poly1305_key[64];
|
||||||
|
|
||||||
if ( ( ctx == NULL ) || ( nonce == NULL ) )
|
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 );
|
result = mbedtls_chacha20_starts( &ctx->chacha20_ctx, nonce, 1U );
|
||||||
@ -161,7 +161,7 @@ int mbedtls_aead_chacha20_poly1305_starts( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
{
|
{
|
||||||
ctx->aad_len = 0U;
|
ctx->aad_len = 0U;
|
||||||
ctx->ciphertext_len = 0U;
|
ctx->ciphertext_len = 0U;
|
||||||
ctx->state = AEAD_CHACHA20_POLY1305_STATE_AAD;
|
ctx->state = CHACHAPOLY_STATE_AAD;
|
||||||
ctx->mode = mode;
|
ctx->mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,22 +170,22 @@ cleanup:
|
|||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx,
|
||||||
size_t aad_len,
|
size_t aad_len,
|
||||||
const unsigned char *aad )
|
const unsigned char *aad )
|
||||||
{
|
{
|
||||||
if ( ctx == NULL )
|
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 ) )
|
else if ( ( aad_len > 0U ) && ( aad == NULL ) )
|
||||||
{
|
{
|
||||||
/* aad pointer is allowed to be NULL if aad_len == 0 */
|
/* 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;
|
ctx->aad_len += aad_len;
|
||||||
@ -193,36 +193,36 @@ int mbedtls_aead_chacha20_poly1305_update_aad( mbedtls_aead_chacha20_poly1305_co
|
|||||||
return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad_len, aad ) );
|
return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad_len, aad ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx,
|
||||||
size_t len,
|
size_t len,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
if ( ( ctx == NULL ) || ( input == NULL ) || ( output == NULL ) )
|
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 ) ) )
|
else if ( ( len > 0U ) && ( ( input == NULL ) || ( output == NULL ) ) )
|
||||||
{
|
{
|
||||||
/* input and output pointers are allowed to be NULL if len == 0 */
|
/* 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 ) &&
|
else if ( ( ctx->state != CHACHAPOLY_STATE_AAD ) &&
|
||||||
( ctx->state != AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT ) )
|
( 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;
|
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
|
/* Note: the following functions return an error only if one or more of
|
||||||
* the input pointers are NULL. Since we have checked their validity
|
* the input pointers are NULL. Since we have checked their validity
|
||||||
@ -240,30 +240,30 @@ int mbedtls_aead_chacha20_poly1305_update( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_context *ctx,
|
int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx,
|
||||||
unsigned char mac[16] )
|
unsigned char mac[16] )
|
||||||
{
|
{
|
||||||
unsigned char len_block[16];
|
unsigned char len_block[16];
|
||||||
|
|
||||||
if ( ( ctx == NULL ) || ( mac == NULL ) )
|
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
|
/* The lengths of the AAD and ciphertext are processed by
|
||||||
* Poly1305 as the final 128-bit block, encoded as little-endian integers.
|
* Poly1305 as the final 128-bit block, encoded as little-endian integers.
|
||||||
@ -291,45 +291,45 @@ int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_contex
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_crypt_and_mac ( const unsigned char key[32],
|
int mbedtls_chachapoly_crypt_and_mac ( const unsigned char key[32],
|
||||||
const unsigned char nonce[12],
|
const unsigned char nonce[12],
|
||||||
mbedtls_aead_chacha20_poly1305_mode_t mode,
|
mbedtls_chachapoly_mode_t mode,
|
||||||
size_t aad_len,
|
size_t aad_len,
|
||||||
const unsigned char *aad,
|
const unsigned char *aad,
|
||||||
size_t ilen,
|
size_t ilen,
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output,
|
unsigned char *output,
|
||||||
unsigned char mac[16] )
|
unsigned char mac[16] )
|
||||||
{
|
{
|
||||||
mbedtls_aead_chacha20_poly1305_context ctx;
|
mbedtls_chachapoly_context ctx;
|
||||||
int result;
|
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 )
|
if ( result != 0 )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
result = mbedtls_aead_chacha20_poly1305_starts( &ctx, nonce, mode );
|
result = mbedtls_chachapoly_starts( &ctx, nonce, mode );
|
||||||
if ( result != 0 )
|
if ( result != 0 )
|
||||||
goto cleanup;
|
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 )
|
if ( result != 0 )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
result = mbedtls_aead_chacha20_poly1305_update( &ctx, ilen, input, output );
|
result = mbedtls_chachapoly_update( &ctx, ilen, input, output );
|
||||||
if ( result != 0 )
|
if ( result != 0 )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
result = mbedtls_aead_chacha20_poly1305_finish( &ctx, mac );
|
result = mbedtls_chachapoly_finish( &ctx, mac );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mbedtls_aead_chacha20_poly1305_free( &ctx );
|
mbedtls_chachapoly_free( &ctx );
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
|
#endif /* MBEDTLS_CHACHAPOLY_ALT */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SELF_TEST)
|
#if defined(MBEDTLS_SELF_TEST)
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ static const unsigned char test_mac[1][16] =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
|
int mbedtls_chachapoly_self_test( int verbose )
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int result;
|
int result;
|
||||||
@ -433,15 +433,15 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
|
|||||||
mbedtls_printf( " ChaCha20-Poly1305 test %u ", i );
|
mbedtls_printf( " ChaCha20-Poly1305 test %u ", i );
|
||||||
}
|
}
|
||||||
|
|
||||||
result = mbedtls_aead_chacha20_poly1305_crypt_and_mac( test_key[i],
|
result = mbedtls_chachapoly_crypt_and_mac( test_key[i],
|
||||||
test_nonce[i],
|
test_nonce[i],
|
||||||
MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
|
MBEDTLS_CHACHAPOLY_ENCRYPT,
|
||||||
test_aad_len[i],
|
test_aad_len[i],
|
||||||
test_aad[i],
|
test_aad[i],
|
||||||
test_input_len[i],
|
test_input_len[i],
|
||||||
test_input[i],
|
test_input[i],
|
||||||
output,
|
output,
|
||||||
mac );
|
mac );
|
||||||
if ( result != 0 )
|
if ( result != 0 )
|
||||||
{
|
{
|
||||||
if ( verbose != 0 )
|
if ( verbose != 0 )
|
||||||
@ -485,4 +485,4 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
|
|||||||
|
|
||||||
#endif /* MBEDTLS_SELF_TEST */
|
#endif /* MBEDTLS_SELF_TEST */
|
||||||
|
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_CHACHAPOLY_C */
|
@ -38,8 +38,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
#include "mbedtls/aead_chacha20_poly1305.h"
|
#include "mbedtls/chachapoly.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_GCM_C)
|
#if defined(MBEDTLS_GCM_C)
|
||||||
@ -70,7 +70,7 @@
|
|||||||
#endif
|
#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.
|
/* Compare the contents of two buffers in constant time.
|
||||||
* Returns 0 if the contents are bitwise identical, otherwise returns
|
* Returns 0 if the contents are bitwise identical, otherwise returns
|
||||||
* a non-zero value.
|
* a non-zero value.
|
||||||
@ -88,7 +88,7 @@ static int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t
|
|||||||
|
|
||||||
return (int)diff;
|
return (int)diff;
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */
|
||||||
|
|
||||||
static int supported_init = 0;
|
static int supported_init = 0;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx )
|
|||||||
return( 0 );
|
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,
|
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
|
||||||
const unsigned char *ad, size_t ad_len )
|
const unsigned char *ad, size_t ad_len )
|
||||||
{
|
{
|
||||||
@ -303,30 +303,30 @@ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
mbedtls_aead_chacha20_poly1305_mode_t mode;
|
mbedtls_chachapoly_mode_t mode;
|
||||||
|
|
||||||
mode = ( ctx->operation == MBEDTLS_ENCRYPT )
|
mode = ( ctx->operation == MBEDTLS_ENCRYPT )
|
||||||
? MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT
|
? MBEDTLS_CHACHAPOLY_ENCRYPT
|
||||||
: MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT;
|
: 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,
|
ctx->iv,
|
||||||
mode );
|
mode );
|
||||||
if ( result != 0 )
|
if ( result != 0 )
|
||||||
return( result );
|
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 );
|
ad_len, ad );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( 0 );
|
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,
|
int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input,
|
||||||
size_t ilen, unsigned char *output, size_t *olen )
|
size_t ilen, unsigned char *output, size_t *olen )
|
||||||
@ -394,11 +394,11 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
|
|||||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
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 )
|
if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 )
|
||||||
{
|
{
|
||||||
*olen = ilen;
|
*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 );
|
ilen, input, output );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -852,7 +852,7 @@ int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_ciph
|
|||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
#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,
|
int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
|
||||||
unsigned char *tag, size_t tag_len )
|
unsigned char *tag, size_t tag_len )
|
||||||
{
|
{
|
||||||
@ -867,14 +867,14 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
|
|||||||
return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len );
|
return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
||||||
{
|
{
|
||||||
/* Don't allow truncated MAC for Poly1305 */
|
/* Don't allow truncated MAC for Poly1305 */
|
||||||
if ( tag_len != 16U )
|
if ( tag_len != 16U )
|
||||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
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 );
|
tag );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -914,14 +914,14 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
|
|||||||
}
|
}
|
||||||
#endif /* MBEDTLS_GCM_C */
|
#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 )
|
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
||||||
{
|
{
|
||||||
/* Don't allow truncated MAC for Poly1305 */
|
/* Don't allow truncated MAC for Poly1305 */
|
||||||
if ( tag_len != sizeof( check_tag ) )
|
if ( tag_len != sizeof( check_tag ) )
|
||||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
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 );
|
check_tag );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
{
|
{
|
||||||
@ -934,11 +934,11 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||||
|
|
||||||
return( 0 );
|
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
|
* Packet-oriented wrapper for non-AEAD modes
|
||||||
@ -997,7 +997,7 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
|
|||||||
tag, tag_len ) );
|
tag, tag_len ) );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CCM_C */
|
#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 )
|
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -1010,26 +1010,26 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
*olen = ilen;
|
*olen = ilen;
|
||||||
|
|
||||||
ret = mbedtls_aead_chacha20_poly1305_starts( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
|
ret = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
|
||||||
iv, MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT );
|
iv, MBEDTLS_CHACHAPOLY_ENCRYPT );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
ad_len, ad );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
ilen, input, output );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
tag );
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||||
|
|
||||||
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||||
}
|
}
|
||||||
@ -1076,7 +1076,7 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
|
|||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CCM_C */
|
#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 )
|
if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type )
|
||||||
{
|
{
|
||||||
unsigned char check_tag[16];
|
unsigned char check_tag[16];
|
||||||
@ -1090,22 +1090,22 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
*olen = ilen;
|
*olen = ilen;
|
||||||
|
|
||||||
ret = mbedtls_aead_chacha20_poly1305_starts( (mbedtls_aead_chacha20_poly1305_context*) ctx->cipher_ctx,
|
ret = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
|
||||||
iv, MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT );
|
iv, MBEDTLS_CHACHAPOLY_DECRYPT );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
ad_len, ad );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
ilen, input, output );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
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 );
|
check_tag );
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
@ -1116,7 +1116,7 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||||
|
|
||||||
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
#include "mbedtls/cipher_internal.h"
|
#include "mbedtls/cipher_internal.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
#include "mbedtls/aead_chacha20_poly1305.h"
|
#include "mbedtls/chachapoly.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_AES_C)
|
#if defined(MBEDTLS_AES_C)
|
||||||
@ -1356,40 +1356,41 @@ static const mbedtls_cipher_info_t chacha20_info = {
|
|||||||
};
|
};
|
||||||
#endif /* MBEDTLS_CHACHA20_C */
|
#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,
|
static int chachapoly_setkey_wrap( void *ctx,
|
||||||
unsigned int key_bitlen )
|
const unsigned char *key,
|
||||||
|
unsigned int key_bitlen )
|
||||||
{
|
{
|
||||||
if( key_bitlen != 256U )
|
if( key_bitlen != 256U )
|
||||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
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( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * aead_chacha20_poly1305_ctx_alloc( void )
|
static void * chachapoly_ctx_alloc( void )
|
||||||
{
|
{
|
||||||
mbedtls_aead_chacha20_poly1305_context *ctx;
|
mbedtls_chachapoly_context *ctx;
|
||||||
ctx = mbedtls_calloc( 1, sizeof( mbedtls_aead_chacha20_poly1305_context ) );
|
ctx = mbedtls_calloc( 1, sizeof( mbedtls_chachapoly_context ) );
|
||||||
|
|
||||||
if( ctx == NULL )
|
if( ctx == NULL )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
mbedtls_aead_chacha20_poly1305_init( ctx );
|
mbedtls_chachapoly_init( ctx );
|
||||||
|
|
||||||
return( 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 );
|
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,
|
MBEDTLS_CIPHER_ID_CHACHA20,
|
||||||
NULL,
|
NULL,
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
#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)
|
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
aead_chacha20_poly1305_setkey_wrap,
|
chachapoly_setkey_wrap,
|
||||||
aead_chacha20_poly1305_setkey_wrap,
|
chachapoly_setkey_wrap,
|
||||||
aead_chacha20_poly1305_ctx_alloc,
|
chachapoly_ctx_alloc,
|
||||||
aead_chacha20_poly1305_ctx_free
|
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_CIPHER_CHACHA20_POLY1305,
|
||||||
MBEDTLS_MODE_NONE,
|
MBEDTLS_MODE_NONE,
|
||||||
256,
|
256,
|
||||||
@ -1417,9 +1418,9 @@ static const mbedtls_cipher_info_t aead_chacha20_poly1305_info = {
|
|||||||
12,
|
12,
|
||||||
0,
|
0,
|
||||||
64,
|
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)
|
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||||
static int null_crypt_stream( void *ctx, size_t length,
|
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 },
|
{ MBEDTLS_CIPHER_CHACHA20, &chacha20_info },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
{ MBEDTLS_CIPHER_CHACHA20_POLY1305, &aead_chacha20_poly1305_info },
|
{ MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||||
|
@ -41,10 +41,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
|
||||||
#include "mbedtls/aead_chacha20_poly1305.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_AES_C)
|
#if defined(MBEDTLS_AES_C)
|
||||||
#include "mbedtls/aes.h"
|
#include "mbedtls/aes.h"
|
||||||
#endif
|
#endif
|
||||||
@ -77,6 +73,10 @@
|
|||||||
#include "mbedtls/chacha20.h"
|
#include "mbedtls/chacha20.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
|
#include "mbedtls/chachapoly.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_CIPHER_C)
|
#if defined(MBEDTLS_CIPHER_C)
|
||||||
#include "mbedtls/cipher.h"
|
#include "mbedtls/cipher.h"
|
||||||
#endif
|
#endif
|
||||||
@ -579,13 +579,6 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
|||||||
// Low level error codes
|
// Low level error codes
|
||||||
//
|
//
|
||||||
// BEGIN generated code
|
// 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 defined(MBEDTLS_AES_C)
|
||||||
if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) )
|
if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) )
|
||||||
mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
|
mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
|
||||||
@ -677,6 +670,13 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
|||||||
mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" );
|
mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" );
|
||||||
#endif /* MBEDTLS_CHACHA20_C */
|
#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 defined(MBEDTLS_CMAC_C)
|
||||||
if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) )
|
if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) )
|
||||||
mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" );
|
mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" );
|
||||||
|
@ -84,9 +84,9 @@ static const char *features[] = {
|
|||||||
#if defined(MBEDTLS_TIMING_ALT)
|
#if defined(MBEDTLS_TIMING_ALT)
|
||||||
"MBEDTLS_TIMING_ALT",
|
"MBEDTLS_TIMING_ALT",
|
||||||
#endif /* MBEDTLS_TIMING_ALT */
|
#endif /* MBEDTLS_TIMING_ALT */
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
|
#if defined(MBEDTLS_CHACHAPOLY_ALT)
|
||||||
"MBEDTLS_AEAD_CHACHA20_POLY1305_ALT",
|
"MBEDTLS_CHACHAPOLY_ALT",
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
|
#endif /* MBEDTLS_CHACHAPOLY_ALT */
|
||||||
#if defined(MBEDTLS_AES_ALT)
|
#if defined(MBEDTLS_AES_ALT)
|
||||||
"MBEDTLS_AES_ALT",
|
"MBEDTLS_AES_ALT",
|
||||||
#endif /* MBEDTLS_AES_ALT */
|
#endif /* MBEDTLS_AES_ALT */
|
||||||
@ -519,9 +519,9 @@ static const char *features[] = {
|
|||||||
#if defined(MBEDTLS_AES_C)
|
#if defined(MBEDTLS_AES_C)
|
||||||
"MBEDTLS_AES_C",
|
"MBEDTLS_AES_C",
|
||||||
#endif /* MBEDTLS_AES_C */
|
#endif /* MBEDTLS_AES_C */
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
"MBEDTLS_AEAD_CHACHA20_POLY1305_C",
|
"MBEDTLS_CHACHAPOLY_C",
|
||||||
#endif /* MBEDTLS_AEAD_CHACHA20_POLY1305_C */
|
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||||
#if defined(MBEDTLS_ARC4_C)
|
#if defined(MBEDTLS_ARC4_C)
|
||||||
"MBEDTLS_ARC4_C",
|
"MBEDTLS_ARC4_C",
|
||||||
#endif /* MBEDTLS_ARC4_C */
|
#endif /* MBEDTLS_ARC4_C */
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "mbedtls/camellia.h"
|
#include "mbedtls/camellia.h"
|
||||||
#include "mbedtls/chacha20.h"
|
#include "mbedtls/chacha20.h"
|
||||||
#include "mbedtls/poly1305.h"
|
#include "mbedtls/poly1305.h"
|
||||||
#include "mbedtls/aead_chacha20_poly1305.h"
|
#include "mbedtls/chachapoly.h"
|
||||||
#include "mbedtls/base64.h"
|
#include "mbedtls/base64.h"
|
||||||
#include "mbedtls/bignum.h"
|
#include "mbedtls/bignum.h"
|
||||||
#include "mbedtls/rsa.h"
|
#include "mbedtls/rsa.h"
|
||||||
@ -216,8 +216,8 @@ const selftest_t selftests[] =
|
|||||||
#if defined(MBEDTLS_POLY1305_C)
|
#if defined(MBEDTLS_POLY1305_C)
|
||||||
{"poly1305", mbedtls_poly1305_self_test},
|
{"poly1305", mbedtls_poly1305_self_test},
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
|
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||||
{"chacha20-poly1305", mbedtls_aead_chacha20_poly1305_self_test},
|
{"chacha20-poly1305", mbedtls_chachapoly_self_test},
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_BASE64_C)
|
#if defined(MBEDTLS_BASE64_C)
|
||||||
{"base64", mbedtls_base64_self_test},
|
{"base64", mbedtls_base64_self_test},
|
||||||
|
@ -29,8 +29,8 @@ if( @ARGV ) {
|
|||||||
|
|
||||||
my $error_format_file = $data_dir.'/error.fmt';
|
my $error_format_file = $data_dir.'/error.fmt';
|
||||||
|
|
||||||
my @low_level_modules = qw( AEAD_CHACHA20_POLY1305 AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
|
my @low_level_modules = qw( AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
|
||||||
CAMELLIA CCM CHACHA20 CMAC CTR_DRBG DES
|
CAMELLIA CCM CHACHA20 CHACHAPOLY CMAC CTR_DRBG DES
|
||||||
ENTROPY GCM HMAC_DRBG MD2 MD4 MD5
|
ENTROPY GCM HMAC_DRBG MD2 MD4 MD5
|
||||||
NET OID PADLOCK PBKDF2 POLY1305 RIPEMD160
|
NET OID PADLOCK PBKDF2 POLY1305 RIPEMD160
|
||||||
SHA1 SHA256 SHA512 THREADING XTEA );
|
SHA1 SHA256 SHA512 THREADING XTEA );
|
||||||
@ -88,7 +88,6 @@ foreach my $line (@matches)
|
|||||||
$module_name = "BIGNUM" if ($module_name eq "MPI");
|
$module_name = "BIGNUM" if ($module_name eq "MPI");
|
||||||
$module_name = "CTR_DRBG" if ($module_name eq "CTR");
|
$module_name = "CTR_DRBG" if ($module_name eq "CTR");
|
||||||
$module_name = "HMAC_DRBG" if ($module_name eq "HMAC");
|
$module_name = "HMAC_DRBG" if ($module_name eq "HMAC");
|
||||||
$module_name = "AEAD_CHACHA20_POLY1305" if ($module_name eq "AEAD");
|
|
||||||
|
|
||||||
my $define_name = $module_name;
|
my $define_name = $module_name;
|
||||||
$define_name = "X509_USE,X509_CREATE" if ($define_name eq "X509");
|
$define_name = "X509_USE,X509_CREATE" if ($define_name eq "X509");
|
||||||
|
@ -44,7 +44,6 @@ if(MSVC)
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
add_test_suite(aead_chacha20_poly1305)
|
|
||||||
add_test_suite(aes aes.ecb)
|
add_test_suite(aes aes.ecb)
|
||||||
add_test_suite(aes aes.cbc)
|
add_test_suite(aes aes.cbc)
|
||||||
add_test_suite(aes aes.cfb)
|
add_test_suite(aes aes.cfb)
|
||||||
@ -56,13 +55,14 @@ add_test_suite(blowfish)
|
|||||||
add_test_suite(camellia)
|
add_test_suite(camellia)
|
||||||
add_test_suite(ccm)
|
add_test_suite(ccm)
|
||||||
add_test_suite(chacha20)
|
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.aes)
|
||||||
add_test_suite(cipher cipher.arc4)
|
add_test_suite(cipher cipher.arc4)
|
||||||
add_test_suite(cipher cipher.blowfish)
|
add_test_suite(cipher cipher.blowfish)
|
||||||
add_test_suite(cipher cipher.camellia)
|
add_test_suite(cipher cipher.camellia)
|
||||||
add_test_suite(cipher cipher.ccm)
|
add_test_suite(cipher cipher.ccm)
|
||||||
add_test_suite(cipher cipher.chacha20)
|
add_test_suite(cipher cipher.chacha20)
|
||||||
|
add_test_suite(cipher cipher.chachapoly)
|
||||||
add_test_suite(cipher cipher.des)
|
add_test_suite(cipher cipher.des)
|
||||||
add_test_suite(cipher cipher.gcm)
|
add_test_suite(cipher cipher.gcm)
|
||||||
add_test_suite(cipher cipher.null)
|
add_test_suite(cipher cipher.null)
|
||||||
|
@ -45,14 +45,14 @@ ifdef ZLIB
|
|||||||
LOCAL_LDFLAGS += -lz
|
LOCAL_LDFLAGS += -lz
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APPS = test_suite_aead_chacha20_poly1305$(EXEXT) \
|
APPS = test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \
|
||||||
test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \
|
|
||||||
test_suite_aes.cfb$(EXEXT) test_suite_aes.rest$(EXEXT) \
|
test_suite_aes.cfb$(EXEXT) test_suite_aes.rest$(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_chacha20$(EXEXT) test_suite_cmac$(EXEXT) \
|
test_suite_chacha20$(EXEXT) test_suite_chachapoly$(EXEXT) \
|
||||||
test_suite_cipher.aead_chacha20_poly1305$(EXEXT) \
|
test_suite_cmac$(EXEXT) \
|
||||||
|
test_suite_cipher.chachapoly$(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.chacha20$(EXEXT) \
|
test_suite_cipher.chacha20$(EXEXT) \
|
||||||
@ -117,10 +117,6 @@ test_suite_aes.rest.c : suites/test_suite_aes.function suites/test_suite_aes.res
|
|||||||
echo " Gen $@"
|
echo " Gen $@"
|
||||||
perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest
|
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
|
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 $@"
|
echo " Gen $@"
|
||||||
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
|
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
|
||||||
@ -137,6 +133,10 @@ test_suite_cipher.chacha20.c : suites/test_suite_cipher.function suites/test_sui
|
|||||||
echo " Gen $@"
|
echo " Gen $@"
|
||||||
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.chacha20
|
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
|
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 $@"
|
echo " Gen $@"
|
||||||
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.gcm
|
perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.gcm
|
||||||
@ -210,10 +210,6 @@ test_suite_hmac_drbg.pr.c : suites/test_suite_hmac_drbg.function suites/test_sui
|
|||||||
perl scripts/generate_code.pl suites $* $*
|
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)
|
test_suite_aes.ecb$(EXEXT): test_suite_aes.ecb.c $(DEP)
|
||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
@ -258,6 +254,10 @@ test_suite_chacha20$(EXEXT): test_suite_chacha20.c $(DEP)
|
|||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(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)
|
test_suite_cmac$(EXEXT): test_suite_cmac.c $(DEP)
|
||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
@ -266,10 +266,6 @@ test_suite_cipher.aes$(EXEXT): test_suite_cipher.aes.c $(DEP)
|
|||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(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)
|
test_suite_cipher.arc4$(EXEXT): test_suite_cipher.arc4.c $(DEP)
|
||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
@ -282,6 +278,10 @@ test_suite_cipher.chacha20$(EXEXT): test_suite_cipher.chacha20.c $(DEP)
|
|||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(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)
|
test_suite_cipher.gcm$(EXEXT): test_suite_cipher.gcm.c $(DEP)
|
||||||
echo " CC $<"
|
echo " CC $<"
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
@ -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:
|
|
19
tests/suites/test_suite_chachapoly.data
Normal file
19
tests/suites/test_suite_chachapoly.data
Normal file
@ -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:
|
@ -1,14 +1,14 @@
|
|||||||
/* BEGIN_HEADER */
|
/* BEGIN_HEADER */
|
||||||
#include "mbedtls/aead_chacha20_poly1305.h"
|
#include "mbedtls/chachapoly.h"
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
/* BEGIN_DEPENDENCIES
|
/* BEGIN_DEPENDENCIES
|
||||||
* depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C
|
* depends_on:MBEDTLS_CHACHAPOLY_C
|
||||||
* END_DEPENDENCIES
|
* END_DEPENDENCIES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* 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 key_str[32];
|
||||||
unsigned char nonce_str[12];
|
unsigned char nonce_str[12];
|
||||||
@ -43,11 +43,11 @@ void mbedtls_aead_chacha20_poly1305_enc( char *hex_key_string, char *hex_nonce_s
|
|||||||
TEST_ASSERT( nonce_len == 12 );
|
TEST_ASSERT( nonce_len == 12 );
|
||||||
TEST_ASSERT( mac_len == 16 );
|
TEST_ASSERT( mac_len == 16 );
|
||||||
|
|
||||||
mbedtls_aead_chacha20_poly1305_crypt_and_mac( key_str, nonce_str,
|
mbedtls_chachapoly_crypt_and_mac( key_str, nonce_str,
|
||||||
MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
|
MBEDTLS_CHACHAPOLY_ENCRYPT,
|
||||||
aad_len, aad_str,
|
aad_len, aad_str,
|
||||||
input_len, input_str, output,
|
input_len, input_str, output,
|
||||||
mac );
|
mac );
|
||||||
|
|
||||||
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
||||||
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
|
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
|
||||||
@ -55,7 +55,7 @@ void mbedtls_aead_chacha20_poly1305_enc( char *hex_key_string, char *hex_nonce_s
|
|||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_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 key_str[32];
|
||||||
unsigned char nonce_str[12];
|
unsigned char nonce_str[12];
|
||||||
@ -90,11 +90,11 @@ void mbedtls_aead_chacha20_poly1305_dec( char *hex_key_string, char *hex_nonce_s
|
|||||||
TEST_ASSERT( nonce_len == 12 );
|
TEST_ASSERT( nonce_len == 12 );
|
||||||
TEST_ASSERT( mac_len == 16 );
|
TEST_ASSERT( mac_len == 16 );
|
||||||
|
|
||||||
mbedtls_aead_chacha20_poly1305_crypt_and_mac( key_str, nonce_str,
|
mbedtls_chachapoly_crypt_and_mac( key_str, nonce_str,
|
||||||
MBEDTLS_AEAD_CHACHA20_POLY1305_DECRYPT,
|
MBEDTLS_CHACHAPOLY_DECRYPT,
|
||||||
aad_len, aad_str,
|
aad_len, aad_str,
|
||||||
input_len, input_str, output,
|
input_len, input_str, output,
|
||||||
mac );
|
mac );
|
||||||
|
|
||||||
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
||||||
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
|
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
|
||||||
@ -102,8 +102,8 @@ void mbedtls_aead_chacha20_poly1305_dec( char *hex_key_string, char *hex_nonce_s
|
|||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
|
/* 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 */
|
/* END_CASE */
|
@ -1,111 +1,111 @@
|
|||||||
Decrypt empty buffer
|
Decrypt empty buffer
|
||||||
depends_on:MBEDTLS_AEAD_CHACHA20_POLY1305_C:
|
depends_on:MBEDTLS_CHACHAPOLY_C:
|
||||||
dec_empty_buf:
|
dec_empty_buf:
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 0 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:0:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 1 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:1:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 2 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:2:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 7 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:7:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 8 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:8:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 9 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:9:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 15 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:15:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 16 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:16:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 17 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:17:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 31 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:31:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 32 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:32:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 33 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:33:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 47 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:47:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 48 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:48:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 49 bytes
|
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
|
enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:49:-1
|
||||||
|
|
||||||
ChaCha20+Poly1305 Encrypt and decrypt 0 bytes in multiple parts 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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:16:-1:16:16:16:16
|
@ -60,7 +60,7 @@ void cipher_null_args( )
|
|||||||
TEST_ASSERT( mbedtls_cipher_reset( NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
TEST_ASSERT( mbedtls_cipher_reset( NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||||
TEST_ASSERT( mbedtls_cipher_reset( &ctx ) == 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 )
|
TEST_ASSERT( mbedtls_cipher_update_ad( NULL, buf, 0 )
|
||||||
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||||
TEST_ASSERT( mbedtls_cipher_update_ad( &ctx, buf, 0 )
|
TEST_ASSERT( mbedtls_cipher_update_ad( &ctx, buf, 0 )
|
||||||
@ -77,7 +77,7 @@ void cipher_null_args( )
|
|||||||
TEST_ASSERT( mbedtls_cipher_finish( &ctx, buf, &olen )
|
TEST_ASSERT( mbedtls_cipher_finish( &ctx, buf, &olen )
|
||||||
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
== 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 )
|
TEST_ASSERT( mbedtls_cipher_write_tag( NULL, buf, olen )
|
||||||
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
== MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||||
TEST_ASSERT( mbedtls_cipher_write_tag( &ctx, buf, olen )
|
TEST_ASSERT( mbedtls_cipher_write_tag( &ctx, buf, olen )
|
||||||
@ -195,7 +195,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len,
|
|||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
|
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_dec, ad, sizeof( ad ) - i ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) );
|
||||||
#endif
|
#endif
|
||||||
@ -215,7 +215,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len,
|
|||||||
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
|
||||||
total_len += 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 ) ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_write_tag( &ctx_enc, tag, sizeof( tag ) ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len,
|
|||||||
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
|
||||||
total_len += 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 ) ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_check_tag( &ctx_dec, tag, sizeof( tag ) ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ void enc_fail( int cipher_id, int pad_mode, int key_len,
|
|||||||
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, 16 ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, 16 ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
|
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 ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, NULL, 0 ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ void dec_empty_buf()
|
|||||||
|
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
|
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 ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val,
|
|||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) );
|
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_dec, NULL, 0 ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, NULL, 0 ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, NULL, 0 ) );
|
||||||
#endif
|
#endif
|
||||||
@ -484,7 +484,7 @@ void decrypt_test_vec( int cipher_id, int pad_mode,
|
|||||||
unsigned char ad[200];
|
unsigned char ad[200];
|
||||||
unsigned char tag[20];
|
unsigned char tag[20];
|
||||||
size_t key_len, iv_len, cipher_len, clear_len;
|
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;
|
size_t ad_len, tag_len;
|
||||||
#endif
|
#endif
|
||||||
mbedtls_cipher_context_t ctx;
|
mbedtls_cipher_context_t ctx;
|
||||||
@ -505,7 +505,7 @@ void decrypt_test_vec( int cipher_id, int pad_mode,
|
|||||||
iv_len = unhexify( iv, hex_iv );
|
iv_len = unhexify( iv, hex_iv );
|
||||||
cipher_len = unhexify( cipher, hex_cipher );
|
cipher_len = unhexify( cipher, hex_cipher );
|
||||||
clear_len = unhexify( clear, hex_clear );
|
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 );
|
ad_len = unhexify( ad, hex_ad );
|
||||||
tag_len = unhexify( tag, hex_tag );
|
tag_len = unhexify( tag, hex_tag );
|
||||||
#else
|
#else
|
||||||
@ -525,7 +525,7 @@ void decrypt_test_vec( int cipher_id, int pad_mode,
|
|||||||
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, iv_len ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, iv_len ) );
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) );
|
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 ) );
|
TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, ad, ad_len ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ void decrypt_test_vec( int cipher_id, int pad_mode,
|
|||||||
TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen,
|
TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen,
|
||||||
&outlen ) );
|
&outlen ) );
|
||||||
total_len += 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 ) );
|
TEST_ASSERT( tag_result == mbedtls_cipher_check_tag( &ctx, tag, tag_len ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,6 +158,8 @@
|
|||||||
<ClInclude Include="..\..\include\mbedtls\camellia.h" />
|
<ClInclude Include="..\..\include\mbedtls\camellia.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\ccm.h" />
|
<ClInclude Include="..\..\include\mbedtls\ccm.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\certs.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\check_config.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\cipher.h" />
|
<ClInclude Include="..\..\include\mbedtls\cipher.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\cipher_internal.h" />
|
<ClInclude Include="..\..\include\mbedtls\cipher_internal.h" />
|
||||||
@ -198,6 +200,7 @@
|
|||||||
<ClInclude Include="..\..\include\mbedtls\platform.h" />
|
<ClInclude Include="..\..\include\mbedtls\platform.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\platform_time.h" />
|
<ClInclude Include="..\..\include\mbedtls\platform_time.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\platform_util.h" />
|
<ClInclude Include="..\..\include\mbedtls\platform_util.h" />
|
||||||
|
<ClInclude Include="..\..\include\mbedtls\poly1305.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\ripemd160.h" />
|
<ClInclude Include="..\..\include\mbedtls\ripemd160.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\rsa.h" />
|
<ClInclude Include="..\..\include\mbedtls\rsa.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\rsa_internal.h" />
|
<ClInclude Include="..\..\include\mbedtls\rsa_internal.h" />
|
||||||
@ -231,6 +234,8 @@
|
|||||||
<ClCompile Include="..\..\library\camellia.c" />
|
<ClCompile Include="..\..\library\camellia.c" />
|
||||||
<ClCompile Include="..\..\library\ccm.c" />
|
<ClCompile Include="..\..\library\ccm.c" />
|
||||||
<ClCompile Include="..\..\library\certs.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.c" />
|
||||||
<ClCompile Include="..\..\library\cipher_wrap.c" />
|
<ClCompile Include="..\..\library\cipher_wrap.c" />
|
||||||
<ClCompile Include="..\..\library\cmac.c" />
|
<ClCompile Include="..\..\library\cmac.c" />
|
||||||
@ -268,6 +273,7 @@
|
|||||||
<ClCompile Include="..\..\library\pkwrite.c" />
|
<ClCompile Include="..\..\library\pkwrite.c" />
|
||||||
<ClCompile Include="..\..\library\platform.c" />
|
<ClCompile Include="..\..\library\platform.c" />
|
||||||
<ClCompile Include="..\..\library\platform_util.c" />
|
<ClCompile Include="..\..\library\platform_util.c" />
|
||||||
|
<ClCompile Include="..\..\library\poly1305.c" />
|
||||||
<ClCompile Include="..\..\library\ripemd160.c" />
|
<ClCompile Include="..\..\library\ripemd160.c" />
|
||||||
<ClCompile Include="..\..\library\rsa.c" />
|
<ClCompile Include="..\..\library\rsa.c" />
|
||||||
<ClCompile Include="..\..\library\rsa_internal.c" />
|
<ClCompile Include="..\..\library\rsa_internal.c" />
|
||||||
|
Loading…
Reference in New Issue
Block a user