Mbed TLS v2.28.10
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
22 
23 #if !defined(MBEDTLS_CONFIG_FILE)
24 #include "mbedtls/config.h"
25 #else
26 #include MBEDTLS_CONFIG_FILE
27 #endif
28 
29 /* for shared error codes */
30 #include "mbedtls/poly1305.h"
31 
33 #define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054
34 
35 #define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 typedef enum {
44 }
46 
47 #if !defined(MBEDTLS_CHACHAPOLY_ALT)
48 
49 #include "mbedtls/chacha20.h"
50 
54  uint64_t aad_len;
55  uint64_t ciphertext_len;
56  int state;
58 }
60 
61 #else /* !MBEDTLS_CHACHAPOLY_ALT */
62 #include "chachapoly_alt.h"
63 #endif /* !MBEDTLS_CHACHAPOLY_ALT */
64 
108 
117 
130  const unsigned char key[32]);
131 
158  const unsigned char nonce[12],
160 
201  const unsigned char *aad,
202  size_t aad_len);
203 
236  size_t len,
237  const unsigned char *input,
238  unsigned char *output);
239 
257  unsigned char mac[16]);
258 
289  size_t length,
290  const unsigned char nonce[12],
291  const unsigned char *aad,
292  size_t aad_len,
293  const unsigned char *input,
294  unsigned char *output,
295  unsigned char tag[16]);
296 
323  size_t length,
324  const unsigned char nonce[12],
325  const unsigned char *aad,
326  size_t aad_len,
327  const unsigned char tag[16],
328  const unsigned char *input,
329  unsigned char *output);
330 
331 #if defined(MBEDTLS_SELF_TEST)
332 
338 int mbedtls_chachapoly_self_test(int verbose);
339 #endif /* MBEDTLS_SELF_TEST */
340 
341 #ifdef __cplusplus
342 }
343 #endif
344 
345 #endif /* MBEDTLS_CHACHAPOLY_H */
void mbedtls_chachapoly_init(mbedtls_chachapoly_context *ctx)
This function initializes the specified ChaCha20-Poly1305 context.
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_mode_t mode
Definition: chachapoly.h:57
mbedtls_chachapoly_mode_t
Definition: chachapoly.h:41
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
This file contains ChaCha20 definitions and functions.
Configuration options (set of defines)
mbedtls_chacha20_context chacha20_ctx
Definition: chachapoly.h:52
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...
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_setkey(mbedtls_chachapoly_context *ctx, const unsigned char key[32])
This function sets the ChaCha20-Poly1305 symmetric encryption key.
mbedtls_poly1305_context poly1305_ctx
Definition: chachapoly.h:53
int mbedtls_chachapoly_self_test(int verbose)
The ChaCha20-Poly1305 checkup routine.
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_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.
void mbedtls_chachapoly_free(mbedtls_chachapoly_context *ctx)
This function releases and clears the specified ChaCha20-Poly1305 context.
This file contains Poly1305 definitions and functions.