mbed TLS v2.26.0
chacha20.h
Go to the documentation of this file.
1
15/*
16 * Copyright The Mbed TLS Contributors
17 * SPDX-License-Identifier: Apache-2.0
18 *
19 * Licensed under the Apache License, Version 2.0 (the "License"); you may
20 * not use this file except in compliance with the License.
21 * You may obtain a copy of the License at
22 *
23 * http://www.apache.org/licenses/LICENSE-2.0
24 *
25 * Unless required by applicable law or agreed to in writing, software
26 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 * See the License for the specific language governing permissions and
29 * limitations under the License.
30 */
31
32#ifndef MBEDTLS_CHACHA20_H
33#define MBEDTLS_CHACHA20_H
34
35#if !defined(MBEDTLS_CONFIG_FILE)
36#include "mbedtls/config.h"
37#else
38#include MBEDTLS_CONFIG_FILE
39#endif
40
41#include <stdint.h>
42#include <stddef.h>
43
44#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051
46/* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be
47 * used. */
48#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053
50/* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used.
51 */
52#define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#if !defined(MBEDTLS_CHACHA20_ALT)
59
61{
62 uint32_t state[16];
63 uint8_t keystream8[64];
65}
67
68#else /* MBEDTLS_CHACHA20_ALT */
69#include "chacha20_alt.h"
70#endif /* MBEDTLS_CHACHA20_ALT */
71
88
99
117 const unsigned char key[32] );
118
139 const unsigned char nonce[12],
140 uint32_t counter );
141
172 size_t size,
173 const unsigned char *input,
174 unsigned char *output );
175
204int mbedtls_chacha20_crypt( const unsigned char key[32],
205 const unsigned char nonce[12],
206 uint32_t counter,
207 size_t size,
208 const unsigned char* input,
209 unsigned char* output );
210
211#if defined(MBEDTLS_SELF_TEST)
218int mbedtls_chacha20_self_test( int verbose );
219#endif /* MBEDTLS_SELF_TEST */
220
221#ifdef __cplusplus
222}
223#endif
224
225#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.
struct mbedtls_chacha20_context mbedtls_chacha20_context
int mbedtls_chacha20_update(mbedtls_chacha20_context *ctx, size_t size, const unsigned char *input, unsigned char *output)
This function encrypts or decrypts data.
Configuration options (set of defines)
uint8_t keystream8[64]
Definition: chacha20.h:63
uint32_t state[16]
Definition: chacha20.h:62