Mbed TLS v3.6.7
Toggle main menu visibility
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
22
#include "
mbedtls/private_access.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
33
extern
"C"
{
34
#endif
35
36
#if !defined(MBEDTLS_CHACHA20_ALT)
37
38
typedef
struct
mbedtls_chacha20_context
{
39
uint32_t
MBEDTLS_PRIVATE
(state)[16];
40
uint8_t
MBEDTLS_PRIVATE
(keystream8)[64];
41
size_t
MBEDTLS_PRIVATE
(keystream_bytes_used);
43
}
44
mbedtls_chacha20_context
;
45
46
#else
/* MBEDTLS_CHACHA20_ALT */
47
#include "
chacha20_alt.h
"
48
#endif
/* MBEDTLS_CHACHA20_ALT */
49
65
void
mbedtls_chacha20_init
(
mbedtls_chacha20_context
*ctx);
66
76
void
mbedtls_chacha20_free
(
mbedtls_chacha20_context
*ctx);
77
94
int
mbedtls_chacha20_setkey
(
mbedtls_chacha20_context
*ctx,
95
const
unsigned
char
key[32]);
96
116
int
mbedtls_chacha20_starts
(
mbedtls_chacha20_context
*ctx,
117
const
unsigned
char
nonce[12],
118
uint32_t counter);
119
152
int
mbedtls_chacha20_update
(
mbedtls_chacha20_context
*ctx,
153
size_t
size,
154
const
unsigned
char
*input,
155
unsigned
char
*output);
156
188
int
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)
202
int
mbedtls_chacha20_self_test
(
int
verbose);
203
#endif
/* MBEDTLS_SELF_TEST */
204
205
#ifdef __cplusplus
206
}
207
#endif
208
209
#endif
/* MBEDTLS_CHACHA20_H */
mbedtls_chacha20_free
void mbedtls_chacha20_free(mbedtls_chacha20_context *ctx)
This function releases and clears the specified ChaCha20 context.
mbedtls_chacha20_crypt
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.
mbedtls_chacha20_setkey
int mbedtls_chacha20_setkey(mbedtls_chacha20_context *ctx, const unsigned char key[32])
This function sets the encryption/decryption key.
mbedtls_chacha20_init
void mbedtls_chacha20_init(mbedtls_chacha20_context *ctx)
This function initializes the specified ChaCha20 context.
mbedtls_chacha20_starts
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.
mbedtls_chacha20_self_test
int mbedtls_chacha20_self_test(int verbose)
The ChaCha20 checkup routine.
mbedtls_chacha20_update
int mbedtls_chacha20_update(mbedtls_chacha20_context *ctx, size_t size, const unsigned char *input, unsigned char *output)
This function encrypts or decrypts data.
chacha20_alt.h
build_info.h
Build-time configuration info.
private_access.h
Macro wrapper for struct's members.
MBEDTLS_PRIVATE
#define MBEDTLS_PRIVATE(member)
Definition
private_access.h:15
mbedtls_chacha20_context
Definition
chacha20.h:38
include
mbedtls
chacha20.h
Generated on
for Mbed TLS v3.6.7 by
1.17.0