Mbed TLS v3.6.7
 
Loading...
Searching...
No Matches
chacha20.h
Go to the documentation of this file.
1
14
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_CHACHA20_H
21#define MBEDTLS_CHACHA20_H
23
24#include "mbedtls/build_info.h"
25
26#include <stdint.h>
27#include <stddef.h>
28
30#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#if !defined(MBEDTLS_CHACHA20_ALT)
37
39 uint32_t MBEDTLS_PRIVATE(state)[16];
40 uint8_t MBEDTLS_PRIVATE(keystream8)[64];
41 size_t MBEDTLS_PRIVATE(keystream_bytes_used);
43}
45
46#else /* MBEDTLS_CHACHA20_ALT */
47#include "chacha20_alt.h"
48#endif /* MBEDTLS_CHACHA20_ALT */
49
66
77
95 const unsigned char key[32]);
96
117 const unsigned char nonce[12],
118 uint32_t counter);
119
153 size_t size,
154 const unsigned char *input,
155 unsigned char *output);
156
188int mbedtls_chacha20_crypt(const unsigned char key[32],
189 const unsigned char nonce[12],
190 uint32_t counter,
191 size_t size,
192 const unsigned char *input,
193 unsigned char *output);
194
195#if defined(MBEDTLS_SELF_TEST)
203#endif /* MBEDTLS_SELF_TEST */
204
205#ifdef __cplusplus
206}
207#endif
208
209#endif /* MBEDTLS_CHACHA20_H */
void mbedtls_chacha20_free(mbedtls_chacha20_context *ctx)
This function releases and clears the specified ChaCha20 context.
int mbedtls_chacha20_crypt(const unsigned char key[32], const unsigned char nonce[12], uint32_t counter, size_t size, const unsigned char *input, unsigned char *output)
This function encrypts or decrypts data with ChaCha20 and the given key and nonce.
int mbedtls_chacha20_setkey(mbedtls_chacha20_context *ctx, const unsigned char key[32])
This function sets the encryption/decryption key.
void mbedtls_chacha20_init(mbedtls_chacha20_context *ctx)
This function initializes the specified ChaCha20 context.
int mbedtls_chacha20_starts(mbedtls_chacha20_context *ctx, const unsigned char nonce[12], uint32_t counter)
This function sets the nonce and initial counter value.
int mbedtls_chacha20_self_test(int verbose)
The ChaCha20 checkup routine.
int mbedtls_chacha20_update(mbedtls_chacha20_context *ctx, size_t size, const unsigned char *input, unsigned char *output)
This function encrypts or decrypts data.
Build-time configuration info.
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)