mbed TLS v2.24.0
ccm.h
Go to the documentation of this file.
1 
30 /*
31  * Copyright The Mbed TLS Contributors
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 
47 #ifndef MBEDTLS_CCM_H
48 #define MBEDTLS_CCM_H
49 
50 #if !defined(MBEDTLS_CONFIG_FILE)
51 #include "mbedtls/config.h"
52 #else
53 #include MBEDTLS_CONFIG_FILE
54 #endif
55 
56 #include "mbedtls/cipher.h"
57 
58 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
59 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
61 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
62 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 #if !defined(MBEDTLS_CCM_ALT)
69 // Regular implementation
70 //
71 
76 typedef struct mbedtls_ccm_context
77 {
78  mbedtls_cipher_context_t cipher_ctx;
79 }
80 mbedtls_ccm_context;
81 
82 #else /* MBEDTLS_CCM_ALT */
83 #include "ccm_alt.h"
84 #endif /* MBEDTLS_CCM_ALT */
85 
93 void mbedtls_ccm_init( mbedtls_ccm_context *ctx );
94 
108 int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
109  mbedtls_cipher_id_t cipher,
110  const unsigned char *key,
111  unsigned int keybits );
112 
120 void mbedtls_ccm_free( mbedtls_ccm_context *ctx );
121 
158 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
159  const unsigned char *iv, size_t iv_len,
160  const unsigned char *add, size_t add_len,
161  const unsigned char *input, unsigned char *output,
162  unsigned char *tag, size_t tag_len );
163 
206 int mbedtls_ccm_star_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
207  const unsigned char *iv, size_t iv_len,
208  const unsigned char *add, size_t add_len,
209  const unsigned char *input, unsigned char *output,
210  unsigned char *tag, size_t tag_len );
211 
243 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
244  const unsigned char *iv, size_t iv_len,
245  const unsigned char *add, size_t add_len,
246  const unsigned char *input, unsigned char *output,
247  const unsigned char *tag, size_t tag_len );
248 
288 int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
289  const unsigned char *iv, size_t iv_len,
290  const unsigned char *add, size_t add_len,
291  const unsigned char *input, unsigned char *output,
292  const unsigned char *tag, size_t tag_len );
293 
294 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
295 
301 int mbedtls_ccm_self_test( int verbose );
302 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
303 
304 #ifdef __cplusplus
305 }
306 #endif
307 
308 #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...
Configuration options (set of defines)
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:82
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.
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...