mbed TLS v2.16.9
ccm.h
Go to the documentation of this file.
1 
30 /*
31  * Copyright The Mbed TLS Contributors
32  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
33  *
34  * This file is provided under the Apache License 2.0, or the
35  * GNU General Public License v2.0 or later.
36  *
37  * **********
38  * Apache License 2.0:
39  *
40  * Licensed under the Apache License, Version 2.0 (the "License"); you may
41  * not use this file except in compliance with the License.
42  * You may obtain a copy of the License at
43  *
44  * http://www.apache.org/licenses/LICENSE-2.0
45  *
46  * Unless required by applicable law or agreed to in writing, software
47  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
48  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49  * See the License for the specific language governing permissions and
50  * limitations under the License.
51  *
52  * **********
53  *
54  * **********
55  * GNU General Public License v2.0 or later:
56  *
57  * This program is free software; you can redistribute it and/or modify
58  * it under the terms of the GNU General Public License as published by
59  * the Free Software Foundation; either version 2 of the License, or
60  * (at your option) any later version.
61  *
62  * This program is distributed in the hope that it will be useful,
63  * but WITHOUT ANY WARRANTY; without even the implied warranty of
64  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65  * GNU General Public License for more details.
66  *
67  * You should have received a copy of the GNU General Public License along
68  * with this program; if not, write to the Free Software Foundation, Inc.,
69  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
70  *
71  * **********
72  */
73 
74 #ifndef MBEDTLS_CCM_H
75 #define MBEDTLS_CCM_H
76 
77 #if !defined(MBEDTLS_CONFIG_FILE)
78 #include "config.h"
79 #else
80 #include MBEDTLS_CONFIG_FILE
81 #endif
82 
83 #include "cipher.h"
84 
85 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
86 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
88 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
89 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 #if !defined(MBEDTLS_CCM_ALT)
96 // Regular implementation
97 //
98 
103 typedef struct mbedtls_ccm_context
104 {
106 }
108 
109 #else /* MBEDTLS_CCM_ALT */
110 #include "ccm_alt.h"
111 #endif /* MBEDTLS_CCM_ALT */
112 
121 
136  mbedtls_cipher_id_t cipher,
137  const unsigned char *key,
138  unsigned int keybits );
139 
148 
186  const unsigned char *iv, size_t iv_len,
187  const unsigned char *add, size_t add_len,
188  const unsigned char *input, unsigned char *output,
189  unsigned char *tag, size_t tag_len );
190 
234  const unsigned char *iv, size_t iv_len,
235  const unsigned char *add, size_t add_len,
236  const unsigned char *input, unsigned char *output,
237  unsigned char *tag, size_t tag_len );
238 
271  const unsigned char *iv, size_t iv_len,
272  const unsigned char *add, size_t add_len,
273  const unsigned char *input, unsigned char *output,
274  const unsigned char *tag, size_t tag_len );
275 
316  const unsigned char *iv, size_t iv_len,
317  const unsigned char *add, size_t add_len,
318  const unsigned char *input, unsigned char *output,
319  const unsigned char *tag, size_t tag_len );
320 
321 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
322 
328 int mbedtls_ccm_self_test( int verbose );
329 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
330 
331 #ifdef __cplusplus
332 }
333 #endif
334 
335 #endif /* MBEDTLS_CCM_H */
mbedtls_ccm_context
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition: ccm.h:104
mbedtls_cipher_id_t
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:109
mbedtls_ccm_self_test
int mbedtls_ccm_self_test(int verbose)
The CCM checkup routine.
mbedtls_ccm_encrypt_and_tag
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.
mbedtls_ccm_star_auth_decrypt
int mbedtls_ccm_star_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.
mbedtls_ccm_init
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...
cipher.h
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_ccm_context::cipher_ctx
mbedtls_cipher_context_t cipher_ctx
Definition: ccm.h:105
mbedtls_ccm_setkey
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.
mbedtls_ccm_context
struct mbedtls_ccm_context mbedtls_ccm_context
The CCM context-type definition. The CCM context is passed to the APIs called.
mbedtls_ccm_free
void mbedtls_ccm_free(mbedtls_ccm_context *ctx)
This function releases and clears the specified CCM context and underlying cipher sub-context.
mbedtls_cipher_context_t
Definition: cipher.h:310
mbedtls_ccm_auth_decrypt
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.
mbedtls_ccm_star_encrypt_and_tag
int mbedtls_ccm_star_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*.
config.h
Configuration options (set of defines)