Mbed TLS v2.28.7
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 
35 #ifndef MBEDTLS_CCM_H
36 #define MBEDTLS_CCM_H
37 
38 #if !defined(MBEDTLS_CONFIG_FILE)
39 #include "mbedtls/config.h"
40 #else
41 #include MBEDTLS_CONFIG_FILE
42 #endif
43 
44 #include "mbedtls/cipher.h"
45 
47 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
48 
49 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
50 
51 /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
53 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #if !defined(MBEDTLS_CCM_ALT)
60 // Regular implementation
61 //
62 
67 typedef struct mbedtls_ccm_context {
69 }
71 
72 #else /* MBEDTLS_CCM_ALT */
73 #include "ccm_alt.h"
74 #endif /* MBEDTLS_CCM_ALT */
75 
84 
99  mbedtls_cipher_id_t cipher,
100  const unsigned char *key,
101  unsigned int keybits);
102 
111 
148 int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context *ctx, size_t length,
149  const unsigned char *iv, size_t iv_len,
150  const unsigned char *add, size_t add_len,
151  const unsigned char *input, unsigned char *output,
152  unsigned char *tag, size_t tag_len);
153 
197  const unsigned char *iv, size_t iv_len,
198  const unsigned char *add, size_t add_len,
199  const unsigned char *input, unsigned char *output,
200  unsigned char *tag, size_t tag_len);
201 
233 int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context *ctx, size_t length,
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  const unsigned char *tag, size_t tag_len);
238 
278 int mbedtls_ccm_star_auth_decrypt(mbedtls_ccm_context *ctx, size_t length,
279  const unsigned char *iv, size_t iv_len,
280  const unsigned char *add, size_t add_len,
281  const unsigned char *input, unsigned char *output,
282  const unsigned char *tag, size_t tag_len);
283 
284 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
285 
291 int mbedtls_ccm_self_test(int verbose);
292 #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
293 
294 #ifdef __cplusplus
295 }
296 #endif
297 
298 #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:67
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: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.
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:68
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...