32#ifndef MBEDTLS_CHACHAPOLY_H
33#define MBEDTLS_CHACHAPOLY_H
35#if !defined(MBEDTLS_CONFIG_FILE)
38#include MBEDTLS_CONFIG_FILE
44#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054
45#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056
63#if !defined(MBEDTLS_CHACHAPOLY_ALT)
79#include "chachapoly_alt.h"
147 const unsigned char key[32] );
175 const unsigned char nonce[12],
218 const unsigned char *aad,
254 const unsigned char *input,
255 unsigned char *output );
274 unsigned char mac[16] );
307 const unsigned char nonce[12],
308 const unsigned char *aad,
310 const unsigned char *input,
311 unsigned char *output,
312 unsigned char tag[16] );
341 const unsigned char nonce[12],
342 const unsigned char *aad,
344 const unsigned char tag[16],
345 const unsigned char *input,
346 unsigned char *output );
348#if defined(MBEDTLS_SELF_TEST)
355int mbedtls_chachapoly_self_test(
int verbose );
This file contains ChaCha20 definitions and functions.
Configuration options (set of defines)
int mbedtls_chachapoly_finish(mbedtls_chachapoly_context *ctx, unsigned char mac[16])
This function finished the ChaCha20-Poly1305 operation and generates the MAC (authentication tag).
void mbedtls_chachapoly_init(mbedtls_chachapoly_context *ctx)
This function initializes the specified ChaCha20-Poly1305 context.
int mbedtls_chachapoly_starts(mbedtls_chachapoly_context *ctx, const unsigned char nonce[12], mbedtls_chachapoly_mode_t mode)
This function starts a ChaCha20-Poly1305 encryption or decryption operation.
int mbedtls_chachapoly_setkey(mbedtls_chachapoly_context *ctx, const unsigned char key[32])
This function sets the ChaCha20-Poly1305 symmetric encryption key.
int mbedtls_chachapoly_update(mbedtls_chachapoly_context *ctx, size_t len, const unsigned char *input, unsigned char *output)
Thus function feeds data to be encrypted or decrypted into an on-going ChaCha20-Poly1305 operation.
void mbedtls_chachapoly_free(mbedtls_chachapoly_context *ctx)
This function releases and clears the specified ChaCha20-Poly1305 context.
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])
This function performs a complete ChaCha20-Poly1305 authenticated encryption with the previously-set ...
mbedtls_chachapoly_mode_t
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)
This function performs a complete ChaCha20-Poly1305 authenticated decryption with the previously-set ...
int mbedtls_chachapoly_update_aad(mbedtls_chachapoly_context *ctx, const unsigned char *aad, size_t aad_len)
This function feeds additional data to be authenticated into an ongoing ChaCha20-Poly1305 operation.
@ MBEDTLS_CHACHAPOLY_ENCRYPT
The mode value for performing encryption.
@ MBEDTLS_CHACHAPOLY_DECRYPT
The mode value for performing decryption.
This file contains Poly1305 definitions and functions.
mbedtls_chachapoly_mode_t mode
Cipher mode (encrypt or decrypt).
uint64_t aad_len
The length (bytes) of the Additional Authenticated Data.
mbedtls_poly1305_context poly1305_ctx
The Poly1305 context.
uint64_t ciphertext_len
The length (bytes) of the ciphertext.
int state
The current state of the context.
mbedtls_chacha20_context chacha20_ctx
The ChaCha20 context.