mbed TLS v2.14.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: Apache-2.0
33  *
34  * Licensed under the Apache License, Version 2.0 (the "License"); you may
35  * not use this file except in compliance with the License.
36  * You may obtain a copy of the License at
37  *
38  * http://www.apache.org/licenses/LICENSE-2.0
39  *
40  * Unless required by applicable law or agreed to in writing, software
41  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
42  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43  * See the License for the specific language governing permissions and
44  * limitations under the License.
45  *
46  * This file is part of Mbed TLS (https://tls.mbed.org)
47  */
48 
49 #ifndef MBEDTLS_CCM_H
50 #define MBEDTLS_CCM_H
51 
52 #include "cipher.h"
53 
54 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
55 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
57 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
58 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #if !defined(MBEDTLS_CCM_ALT)
66 // Regular implementation
67 //
68 
73 typedef struct mbedtls_ccm_context
74 {
76 }
78 
79 #else /* MBEDTLS_CCM_ALT */
80 #include "ccm_alt.h"
81 #endif /* MBEDTLS_CCM_ALT */
82 
91 
105  mbedtls_cipher_id_t cipher,
106  const unsigned char *key,
107  unsigned int keybits );
108 
116 
145 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
146  const unsigned char *iv, size_t iv_len,
147  const unsigned char *add, size_t add_len,
148  const unsigned char *input, unsigned char *output,
149  unsigned char *tag, size_t tag_len );
150 
187  const unsigned char *iv, size_t iv_len,
188  const unsigned char *add, size_t add_len,
189  const unsigned char *input, unsigned char *output,
190  unsigned char *tag, size_t tag_len );
191 
216 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
217  const unsigned char *iv, size_t iv_len,
218  const unsigned char *add, size_t add_len,
219  const unsigned char *input, unsigned char *output,
220  const unsigned char *tag, size_t tag_len );
221 
254 int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
255  const unsigned char *iv, size_t iv_len,
256  const unsigned char *add, size_t add_len,
257  const unsigned char *input, unsigned char *output,
258  const unsigned char *tag, size_t tag_len );
259 
260 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
261 
267 int mbedtls_ccm_self_test( int verbose );
268 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
269 
270 #ifdef __cplusplus
271 }
272 #endif
273 
274 #endif /* MBEDTLS_CCM_H */