Mbed TLS v3.6.3
Loading...
Searching...
No Matches
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
38
39#include "mbedtls/build_info.h"
40
41#include "mbedtls/cipher.h"
42
43#if defined(MBEDTLS_BLOCK_CIPHER_C)
45#endif
46
47#define MBEDTLS_CCM_DECRYPT 0
48#define MBEDTLS_CCM_ENCRYPT 1
49#define MBEDTLS_CCM_STAR_DECRYPT 2
50#define MBEDTLS_CCM_STAR_ENCRYPT 3
51
53#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
55#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61#if !defined(MBEDTLS_CCM_ALT)
62// Regular implementation
63//
64
69typedef struct mbedtls_ccm_context {
70 unsigned char MBEDTLS_PRIVATE(y)[16];
71 unsigned char MBEDTLS_PRIVATE(ctr)[16];
72 size_t MBEDTLS_PRIVATE(plaintext_len);
73 size_t MBEDTLS_PRIVATE(add_len);
74 size_t MBEDTLS_PRIVATE(tag_len);
75 size_t MBEDTLS_PRIVATE(processed);
81 unsigned int MBEDTLS_PRIVATE(q);
82 unsigned int MBEDTLS_PRIVATE(mode);
87#if defined(MBEDTLS_BLOCK_CIPHER_C)
89#else
91#endif
92 int MBEDTLS_PRIVATE(state);
94}
96
97#else /* MBEDTLS_CCM_ALT */
98#include "ccm_alt.h"
99#endif /* MBEDTLS_CCM_ALT */
100
109
124 mbedtls_cipher_id_t cipher,
125 const unsigned char *key,
126 unsigned int keybits);
127
136
174 const unsigned char *iv, size_t iv_len,
175 const unsigned char *ad, size_t ad_len,
176 const unsigned char *input, unsigned char *output,
177 unsigned char *tag, size_t tag_len);
178
223 const unsigned char *iv, size_t iv_len,
224 const unsigned char *ad, size_t ad_len,
225 const unsigned char *input, unsigned char *output,
226 unsigned char *tag, size_t tag_len);
227
260 const unsigned char *iv, size_t iv_len,
261 const unsigned char *ad, size_t ad_len,
262 const unsigned char *input, unsigned char *output,
263 const unsigned char *tag, size_t tag_len);
264
306 const unsigned char *iv, size_t iv_len,
307 const unsigned char *ad, size_t ad_len,
308 const unsigned char *input, unsigned char *output,
309 const unsigned char *tag, size_t tag_len);
310
340 int mode,
341 const unsigned char *iv,
342 size_t iv_len);
343
372 size_t total_ad_len,
373 size_t plaintext_len,
374 size_t tag_len);
375
407 const unsigned char *ad,
408 size_t ad_len);
409
474 const unsigned char *input, size_t input_len,
475 unsigned char *output, size_t output_size,
476 size_t *output_len);
477
510 unsigned char *tag, size_t tag_len);
511
512#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_CCM_GCM_CAN_AES)
519int mbedtls_ccm_self_test(int verbose);
520#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
521
522#ifdef __cplusplus
523}
524#endif
525
526#endif /* MBEDTLS_CCM_H */
Internal abstraction layer.
int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_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_self_test(int verbose)
The CCM checkup routine.
void mbedtls_ccm_free(mbedtls_ccm_context *ctx)
This function releases and clears the specified CCM context and underlying cipher sub-context.
int mbedtls_ccm_starts(mbedtls_ccm_context *ctx, int mode, const unsigned char *iv, size_t iv_len)
This function starts a CCM encryption or decryption operation.
int mbedtls_ccm_star_auth_decrypt(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_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_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_star_encrypt_and_tag(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_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_finish(mbedtls_ccm_context *ctx, unsigned char *tag, size_t tag_len)
This function finishes the CCM operation and generates the authentication tag.
int mbedtls_ccm_set_lengths(mbedtls_ccm_context *ctx, size_t total_ad_len, size_t plaintext_len, size_t tag_len)
This function declares the lengths of the message and additional data for a CCM encryption or decrypt...
int mbedtls_ccm_update(mbedtls_ccm_context *ctx, const unsigned char *input, size_t input_len, unsigned char *output, size_t output_size, size_t *output_len)
This function feeds an input buffer into an ongoing CCM encryption or decryption operation.
struct mbedtls_ccm_context mbedtls_ccm_context
The CCM context-type definition. The CCM context is passed to the APIs called.
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...
int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_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_update_ad(mbedtls_ccm_context *ctx, const unsigned char *ad, size_t ad_len)
This function feeds an input buffer as associated data (authenticated but not encrypted data) in a CC...
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:66
Build-time configuration info.
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition: ccm.h:69