mbed TLS v2.7.14
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
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may
20  * not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  *
23  * http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  *
31  * This file is part of Mbed TLS (https://tls.mbed.org)
32  */
33 
34 #ifndef MBEDTLS_CCM_H
35 #define MBEDTLS_CCM_H
36 
37 #if !defined(MBEDTLS_CONFIG_FILE)
38 #include "config.h"
39 #else
40 #include MBEDTLS_CONFIG_FILE
41 #endif
42 
43 #include "cipher.h"
44 
45 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
46 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
47 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
49 #if !defined(MBEDTLS_CCM_ALT)
50 // Regular implementation
51 //
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
61 typedef struct {
63 }
65 
74 
87  mbedtls_cipher_id_t cipher,
88  const unsigned char *key,
89  unsigned int keybits );
90 
98 
124 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
125  const unsigned char *iv, size_t iv_len,
126  const unsigned char *add, size_t add_len,
127  const unsigned char *input, unsigned char *output,
128  unsigned char *tag, size_t tag_len );
129 
151 int mbedtls_ccm_auth_decrypt( 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  const unsigned char *tag, size_t tag_len );
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #else /* MBEDTLS_CCM_ALT */
162 #include "ccm_alt.h"
163 #endif /* MBEDTLS_CCM_ALT */
164 
165 #ifdef __cplusplus
166 extern "C" {
167 #endif
168 
169 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
170 
175 int mbedtls_ccm_self_test( int verbose );
176 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #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:61
Configuration options (set of defines)
mbedtls_cipher_id_t
An enumeration of supported ciphers.
Definition: cipher.h:78
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:62
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...