mbed TLS v2.16.1
chachapoly.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_CHACHAPOLY_H
36 #define MBEDTLS_CHACHAPOLY_H
37 
38 #if !defined(MBEDTLS_CONFIG_FILE)
39 #include "config.h"
40 #else
41 #include MBEDTLS_CONFIG_FILE
42 #endif
43 
44 /* for shared error codes */
45 #include "poly1305.h"
46 
47 #define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054
48 #define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 typedef enum
55 {
58 }
60 
61 #if !defined(MBEDTLS_CHACHAPOLY_ALT)
62 
63 #include "chacha20.h"
64 
66 {
69  uint64_t aad_len;
70  uint64_t ciphertext_len;
71  int state;
73 }
75 
76 #else /* !MBEDTLS_CHACHAPOLY_ALT */
77 #include "chachapoly_alt.h"
78 #endif /* !MBEDTLS_CHACHAPOLY_ALT */
79 
123 
132 
145  const unsigned char key[32] );
146 
173  const unsigned char nonce[12],
175 
216  const unsigned char *aad,
217  size_t aad_len );
218 
251  size_t len,
252  const unsigned char *input,
253  unsigned char *output );
254 
272  unsigned char mac[16] );
273 
304  size_t length,
305  const unsigned char nonce[12],
306  const unsigned char *aad,
307  size_t aad_len,
308  const unsigned char *input,
309  unsigned char *output,
310  unsigned char tag[16] );
311 
338  size_t length,
339  const unsigned char nonce[12],
340  const unsigned char *aad,
341  size_t aad_len,
342  const unsigned char tag[16],
343  const unsigned char *input,
344  unsigned char *output );
345 
346 #if defined(MBEDTLS_SELF_TEST)
347 
353 int mbedtls_chachapoly_self_test( int verbose );
354 #endif /* MBEDTLS_SELF_TEST */
355 
356 #ifdef __cplusplus
357 }
358 #endif
359 
360 #endif /* MBEDTLS_CHACHAPOLY_H */