Mbed TLS v3.6.0
Loading...
Searching...
No Matches
chachapoly.h
Go to the documentation of this file.
1
15/*
16 * Copyright The Mbed TLS Contributors
17 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18 */
19
20#ifndef MBEDTLS_CHACHAPOLY_H
21#define MBEDTLS_CHACHAPOLY_H
23
24#include "mbedtls/build_info.h"
25
26/* for shared error codes */
27#include "mbedtls/poly1305.h"
28
30#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054
32#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38typedef enum {
43
44#if !defined(MBEDTLS_CHACHAPOLY_ALT)
45
46#include "mbedtls/chacha20.h"
47
51 uint64_t MBEDTLS_PRIVATE(aad_len);
52 uint64_t MBEDTLS_PRIVATE(ciphertext_len);
53 int MBEDTLS_PRIVATE(state);
55}
57
58#else /* !MBEDTLS_CHACHAPOLY_ALT */
59#include "chachapoly_alt.h"
60#endif /* !MBEDTLS_CHACHAPOLY_ALT */
61
105
114
127 const unsigned char key[32]);
128
155 const unsigned char nonce[12],
157
198 const unsigned char *aad,
199 size_t aad_len);
200
233 size_t len,
234 const unsigned char *input,
235 unsigned char *output);
236
254 unsigned char mac[16]);
255
286 size_t length,
287 const unsigned char nonce[12],
288 const unsigned char *aad,
289 size_t aad_len,
290 const unsigned char *input,
291 unsigned char *output,
292 unsigned char tag[16]);
293
320 size_t length,
321 const unsigned char nonce[12],
322 const unsigned char *aad,
323 size_t aad_len,
324 const unsigned char tag[16],
325 const unsigned char *input,
326 unsigned char *output);
327
328#if defined(MBEDTLS_SELF_TEST)
336#endif /* MBEDTLS_SELF_TEST */
337
338#ifdef __cplusplus
339}
340#endif
341
342#endif /* MBEDTLS_CHACHAPOLY_H */
This file contains ChaCha20 definitions and functions.
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).
struct mbedtls_chachapoly_context mbedtls_chachapoly_context
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 ...
int mbedtls_chachapoly_self_test(int verbose)
The ChaCha20-Poly1305 checkup routine.
mbedtls_chachapoly_mode_t
Definition chachapoly.h:38
@ MBEDTLS_CHACHAPOLY_ENCRYPT
Definition chachapoly.h:39
@ MBEDTLS_CHACHAPOLY_DECRYPT
Definition chachapoly.h:40
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.
Build-time configuration info.
This file contains Poly1305 definitions and functions.
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)