mbed TLS v2.16.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 #if !defined(MBEDTLS_CONFIG_FILE)
53 #include "config.h"
54 #else
55 #include MBEDTLS_CONFIG_FILE
56 #endif
57 
58 #include "cipher.h"
59 
60 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
61 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
63 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
64 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 #if !defined(MBEDTLS_CCM_ALT)
71 // Regular implementation
72 //
73 
78 typedef struct mbedtls_ccm_context
79 {
81 }
83 
84 #else /* MBEDTLS_CCM_ALT */
85 #include "ccm_alt.h"
86 #endif /* MBEDTLS_CCM_ALT */
87 
96 
111  mbedtls_cipher_id_t cipher,
112  const unsigned char *key,
113  unsigned int keybits );
114 
123 
160 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
161  const unsigned char *iv, size_t iv_len,
162  const unsigned char *add, size_t add_len,
163  const unsigned char *input, unsigned char *output,
164  unsigned char *tag, size_t tag_len );
165 
209  const unsigned char *iv, size_t iv_len,
210  const unsigned char *add, size_t add_len,
211  const unsigned char *input, unsigned char *output,
212  unsigned char *tag, size_t tag_len );
213 
245 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
246  const unsigned char *iv, size_t iv_len,
247  const unsigned char *add, size_t add_len,
248  const unsigned char *input, unsigned char *output,
249  const unsigned char *tag, size_t tag_len );
250 
290 int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
291  const unsigned char *iv, size_t iv_len,
292  const unsigned char *add, size_t add_len,
293  const unsigned char *input, unsigned char *output,
294  const unsigned char *tag, size_t tag_len );
295 
296 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
297 
303 int mbedtls_ccm_self_test( int verbose );
304 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
305 
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #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:78
Configuration options (set of defines)
struct mbedtls_ccm_context mbedtls_ccm_context
The CCM context-type definition. The CCM context is passed to the APIs called.
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*.
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:84
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.
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.
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
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:80
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...