mbed TLS v2.7.17
ccm.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright The Mbed TLS Contributors
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 
59 #ifndef MBEDTLS_CCM_H
60 #define MBEDTLS_CCM_H
61 
62 #if !defined(MBEDTLS_CONFIG_FILE)
63 #include "config.h"
64 #else
65 #include MBEDTLS_CONFIG_FILE
66 #endif
67 
68 #include "cipher.h"
69 
70 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
71 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
72 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
74 #if !defined(MBEDTLS_CCM_ALT)
75 // Regular implementation
76 //
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
86 typedef struct {
88 }
90 
99 
112  mbedtls_cipher_id_t cipher,
113  const unsigned char *key,
114  unsigned int keybits );
115 
123 
149 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
150  const unsigned char *iv, size_t iv_len,
151  const unsigned char *add, size_t add_len,
152  const unsigned char *input, unsigned char *output,
153  unsigned char *tag, size_t tag_len );
154 
176 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
177  const unsigned char *iv, size_t iv_len,
178  const unsigned char *add, size_t add_len,
179  const unsigned char *input, unsigned char *output,
180  const unsigned char *tag, size_t tag_len );
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #else /* MBEDTLS_CCM_ALT */
187 #include "ccm_alt.h"
188 #endif /* MBEDTLS_CCM_ALT */
189 
190 #ifdef __cplusplus
191 extern "C" {
192 #endif
193 
194 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
195 
200 int mbedtls_ccm_self_test( int verbose );
201 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #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:86
Configuration options (set of defines)
mbedtls_cipher_id_t
An enumeration of supported ciphers.
Definition: cipher.h:103
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:87
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...