mbed TLS v2.16.1
ccm.h
Go to the documentation of this file.
1 
30 /*
31  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
32  * SPDX-License-Identifier: GPL-2.0
33  *
34  * This program is free software; you can redistribute it and/or modify
35  * it under the terms of the GNU General Public License as published by
36  * the Free Software Foundation; either version 2 of the License, or
37  * (at your option) any later version.
38  *
39  * This program is distributed in the hope that it will be useful,
40  * but WITHOUT ANY WARRANTY; without even the implied warranty of
41  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42  * GNU General Public License for more details.
43  *
44  * You should have received a copy of the GNU General Public License along
45  * with this program; if not, write to the Free Software Foundation, Inc.,
46  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
47  *
48  * This file is part of Mbed TLS (https://tls.mbed.org)
49  */
50 
51 #ifndef MBEDTLS_CCM_H
52 #define MBEDTLS_CCM_H
53 
54 #if !defined(MBEDTLS_CONFIG_FILE)
55 #include "config.h"
56 #else
57 #include MBEDTLS_CONFIG_FILE
58 #endif
59 
60 #include "cipher.h"
61 
62 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
63 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
65 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
66 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 #if !defined(MBEDTLS_CCM_ALT)
73 // Regular implementation
74 //
75 
80 typedef struct mbedtls_ccm_context
81 {
83 }
85 
86 #else /* MBEDTLS_CCM_ALT */
87 #include "ccm_alt.h"
88 #endif /* MBEDTLS_CCM_ALT */
89 
98 
113  mbedtls_cipher_id_t cipher,
114  const unsigned char *key,
115  unsigned int keybits );
116 
125 
162 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
163  const unsigned char *iv, size_t iv_len,
164  const unsigned char *add, size_t add_len,
165  const unsigned char *input, unsigned char *output,
166  unsigned char *tag, size_t tag_len );
167 
211  const unsigned char *iv, size_t iv_len,
212  const unsigned char *add, size_t add_len,
213  const unsigned char *input, unsigned char *output,
214  unsigned char *tag, size_t tag_len );
215 
247 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
248  const unsigned char *iv, size_t iv_len,
249  const unsigned char *add, size_t add_len,
250  const unsigned char *input, unsigned char *output,
251  const unsigned char *tag, size_t tag_len );
252 
292 int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
293  const unsigned char *iv, size_t iv_len,
294  const unsigned char *add, size_t add_len,
295  const unsigned char *input, unsigned char *output,
296  const unsigned char *tag, size_t tag_len );
297 
298 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
299 
305 int mbedtls_ccm_self_test( int verbose );
306 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
307 
308 #ifdef __cplusplus
309 }
310 #endif
311 
312 #endif /* MBEDTLS_CCM_H */