mbed TLS v2.7.16
ccm.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
17  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18  *
19  * This file is provided under the Apache License 2.0, or the
20  * GNU General Public License v2.0 or later.
21  *
22  * **********
23  * Apache License 2.0:
24  *
25  * Licensed under the Apache License, Version 2.0 (the "License"); you may
26  * not use this file except in compliance with the License.
27  * You may obtain a copy of the License at
28  *
29  * http://www.apache.org/licenses/LICENSE-2.0
30  *
31  * Unless required by applicable law or agreed to in writing, software
32  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
33  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34  * See the License for the specific language governing permissions and
35  * limitations under the License.
36  *
37  * **********
38  *
39  * **********
40  * GNU General Public License v2.0 or later:
41  *
42  * This program is free software; you can redistribute it and/or modify
43  * it under the terms of the GNU General Public License as published by
44  * the Free Software Foundation; either version 2 of the License, or
45  * (at your option) any later version.
46  *
47  * This program is distributed in the hope that it will be useful,
48  * but WITHOUT ANY WARRANTY; without even the implied warranty of
49  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50  * GNU General Public License for more details.
51  *
52  * You should have received a copy of the GNU General Public License along
53  * with this program; if not, write to the Free Software Foundation, Inc.,
54  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
55  *
56  * **********
57  *
58  * This file is part of Mbed TLS (https://tls.mbed.org)
59  */
60 
61 #ifndef MBEDTLS_CCM_H
62 #define MBEDTLS_CCM_H
63 
64 #if !defined(MBEDTLS_CONFIG_FILE)
65 #include "config.h"
66 #else
67 #include MBEDTLS_CONFIG_FILE
68 #endif
69 
70 #include "cipher.h"
71 
72 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
73 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
74 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
76 #if !defined(MBEDTLS_CCM_ALT)
77 // Regular implementation
78 //
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
88 typedef struct {
90 }
92 
101 
114  mbedtls_cipher_id_t cipher,
115  const unsigned char *key,
116  unsigned int keybits );
117 
125 
151 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
152  const unsigned char *iv, size_t iv_len,
153  const unsigned char *add, size_t add_len,
154  const unsigned char *input, unsigned char *output,
155  unsigned char *tag, size_t tag_len );
156 
178 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
179  const unsigned char *iv, size_t iv_len,
180  const unsigned char *add, size_t add_len,
181  const unsigned char *input, unsigned char *output,
182  const unsigned char *tag, size_t tag_len );
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #else /* MBEDTLS_CCM_ALT */
189 #include "ccm_alt.h"
190 #endif /* MBEDTLS_CCM_ALT */
191 
192 #ifdef __cplusplus
193 extern "C" {
194 #endif
195 
196 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
197 
202 int mbedtls_ccm_self_test( int verbose );
203 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* MBEDTLS_CCM_H */
void mbedtls_ccm_free(mbedtls_ccm_context *ctx)
This function releases and clears the specified CCM context and underlying cipher sub-context...
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition: ccm.h:88
Configuration options (set of defines)
mbedtls_cipher_id_t
An enumeration of supported ciphers.
Definition: cipher.h:105
int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len)
This function encrypts a buffer using CCM.
The generic cipher wrapper.
int mbedtls_ccm_setkey(mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
This function initializes the CCM context set in the ctx parameter and sets the encryption key...
int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len)
This function performs a CCM authenticated decryption of a buffer.
int mbedtls_ccm_self_test(int verbose)
The CCM checkup routine.
mbedtls_cipher_context_t cipher_ctx
Definition: ccm.h:89
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...