#include "common.h"
#if defined(MBEDTLS_CHACHAPOLY_C)
#include "mbedtls/chachapoly.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"
#include "mbedtls/constant_time.h"
#include <string.h>
#include "mbedtls/platform.h"
#if !defined(MBEDTLS_CHACHAPOLY_ALT)
#define CHACHAPOLY_STATE_INIT …
#define CHACHAPOLY_STATE_AAD …
#define CHACHAPOLY_STATE_CIPHERTEXT …
#define CHACHAPOLY_STATE_FINISHED …
static int chachapoly_pad_aad(mbedtls_chachapoly_context *ctx)
{ … }
static int chachapoly_pad_ciphertext(mbedtls_chachapoly_context *ctx)
{ … }
void mbedtls_chachapoly_init(mbedtls_chachapoly_context *ctx)
{ … }
void mbedtls_chachapoly_free(mbedtls_chachapoly_context *ctx)
{ … }
int mbedtls_chachapoly_setkey(mbedtls_chachapoly_context *ctx,
const unsigned char key[32])
{ … }
int mbedtls_chachapoly_starts(mbedtls_chachapoly_context *ctx,
const unsigned char nonce[12],
mbedtls_chachapoly_mode_t mode)
{ … }
int mbedtls_chachapoly_update_aad(mbedtls_chachapoly_context *ctx,
const unsigned char *aad,
size_t aad_len)
{ … }
int mbedtls_chachapoly_update(mbedtls_chachapoly_context *ctx,
size_t len,
const unsigned char *input,
unsigned char *output)
{ … }
int mbedtls_chachapoly_finish(mbedtls_chachapoly_context *ctx,
unsigned char mac[16])
{ … }
static int chachapoly_crypt_and_tag(mbedtls_chachapoly_context *ctx,
mbedtls_chachapoly_mode_t mode,
size_t length,
const unsigned char nonce[12],
const unsigned char *aad,
size_t aad_len,
const unsigned char *input,
unsigned char *output,
unsigned char tag[16])
{ … }
int mbedtls_chachapoly_encrypt_and_tag(mbedtls_chachapoly_context *ctx,
size_t length,
const unsigned char nonce[12],
const unsigned char *aad,
size_t aad_len,
const unsigned char *input,
unsigned char *output,
unsigned char tag[16])
{ … }
int mbedtls_chachapoly_auth_decrypt(mbedtls_chachapoly_context *ctx,
size_t length,
const unsigned char nonce[12],
const unsigned char *aad,
size_t aad_len,
const unsigned char tag[16],
const unsigned char *input,
unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_SELF_TEST)
static const unsigned char test_key[1][32] = …;
static const unsigned char test_nonce[1][12] = …;
static const unsigned char test_aad[1][12] = …;
static const size_t test_aad_len[1] = …;
static const unsigned char test_input[1][114] = …;
static const unsigned char test_output[1][114] = …;
static const size_t test_input_len[1] = …;
static const unsigned char test_mac[1][16] = …;
#undef ASSERT
#define ASSERT(cond, args) …
int mbedtls_chachapoly_self_test(int verbose)
{ … }
#endif
#endif