mbed TLS v2.16.1
chacha20.h
Go to the documentation of this file.
1 
15 /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
16  * SPDX-License-Identifier: GPL-2.0
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, write to the Free Software Foundation, Inc.,
30  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31  *
32  * This file is part of Mbed TLS (https://tls.mbed.org)
33  */
34 
35 #ifndef MBEDTLS_CHACHA20_H
36 #define MBEDTLS_CHACHA20_H
37 
38 #if !defined(MBEDTLS_CONFIG_FILE)
39 #include "config.h"
40 #else
41 #include MBEDTLS_CONFIG_FILE
42 #endif
43 
44 #include <stdint.h>
45 #include <stddef.h>
46 
47 #define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051
49 /* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be
50  * used. */
51 #define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053
53 /* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used.
54  */
55 #define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #if !defined(MBEDTLS_CHACHA20_ALT)
62 
64 {
65  uint32_t state[16];
66  uint8_t keystream8[64];
68 }
70 
71 #else /* MBEDTLS_CHACHA20_ALT */
72 #include "chacha20_alt.h"
73 #endif /* MBEDTLS_CHACHA20_ALT */
74 
91 
102 
120  const unsigned char key[32] );
121 
142  const unsigned char nonce[12],
143  uint32_t counter );
144 
175  size_t size,
176  const unsigned char *input,
177  unsigned char *output );
178 
207 int mbedtls_chacha20_crypt( const unsigned char key[32],
208  const unsigned char nonce[12],
209  uint32_t counter,
210  size_t size,
211  const unsigned char* input,
212  unsigned char* output );
213 
214 #if defined(MBEDTLS_SELF_TEST)
215 
221 int mbedtls_chacha20_self_test( int verbose );
222 #endif /* MBEDTLS_SELF_TEST */
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif /* MBEDTLS_CHACHA20_H */
struct mbedtls_chacha20_context mbedtls_chacha20_context
Configuration options (set of defines)
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_self_test(int verbose)
The ChaCha20 checkup routine.
uint8_t keystream8[64]
Definition: chacha20.h:66
int mbedtls_chacha20_setkey(mbedtls_chacha20_context *ctx, const unsigned char key[32])
This function sets the encryption/decryption key.
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.
void mbedtls_chacha20_free(mbedtls_chacha20_context *ctx)
This function releases and clears the specified 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.
void mbedtls_chacha20_init(mbedtls_chacha20_context *ctx)
This function initializes the specified ChaCha20 context.
uint32_t state[16]
Definition: chacha20.h:65