mbed TLS v3.3.0
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
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
50
51#include "mbedtls/build_info.h"
52
53#include "mbedtls/cipher.h"
54
55#define MBEDTLS_CCM_DECRYPT 0
56#define MBEDTLS_CCM_ENCRYPT 1
57#define MBEDTLS_CCM_STAR_DECRYPT 2
58#define MBEDTLS_CCM_STAR_ENCRYPT 3
59
61#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
63#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69#if !defined(MBEDTLS_CCM_ALT)
70// Regular implementation
71//
72
77typedef struct mbedtls_ccm_context
78{
79 unsigned char MBEDTLS_PRIVATE(y)[16];
80 unsigned char MBEDTLS_PRIVATE(ctr)[16];
82 size_t MBEDTLS_PRIVATE(plaintext_len);
83 size_t MBEDTLS_PRIVATE(add_len);
84 size_t MBEDTLS_PRIVATE(tag_len);
85 size_t MBEDTLS_PRIVATE(processed);
91 unsigned char MBEDTLS_PRIVATE(q);
92 unsigned char MBEDTLS_PRIVATE(mode);
97 int MBEDTLS_PRIVATE(state);
100}
102
103#else /* MBEDTLS_CCM_ALT */
104#include "ccm_alt.h"
105#endif /* MBEDTLS_CCM_ALT */
106
115
130 mbedtls_cipher_id_t cipher,
131 const unsigned char *key,
132 unsigned int keybits );
133
142
180 const unsigned char *iv, size_t iv_len,
181 const unsigned char *ad, size_t ad_len,
182 const unsigned char *input, unsigned char *output,
183 unsigned char *tag, size_t tag_len );
184
229 const unsigned char *iv, size_t iv_len,
230 const unsigned char *ad, size_t ad_len,
231 const unsigned char *input, unsigned char *output,
232 unsigned char *tag, size_t tag_len );
233
266 const unsigned char *iv, size_t iv_len,
267 const unsigned char *ad, size_t ad_len,
268 const unsigned char *input, unsigned char *output,
269 const unsigned char *tag, size_t tag_len );
270
312 const unsigned char *iv, size_t iv_len,
313 const unsigned char *ad, size_t ad_len,
314 const unsigned char *input, unsigned char *output,
315 const unsigned char *tag, size_t tag_len );
316
346 int mode,
347 const unsigned char *iv,
348 size_t iv_len );
349
378 size_t total_ad_len,
379 size_t plaintext_len,
380 size_t tag_len );
381
413 const unsigned char *ad,
414 size_t ad_len );
415
480 const unsigned char *input, size_t input_len,
481 unsigned char *output, size_t output_size,
482 size_t *output_len );
483
516 unsigned char *tag, size_t tag_len );
517
518#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
525int mbedtls_ccm_self_test( int verbose );
526#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
527
528#ifdef __cplusplus
529}
530#endif
531
532#endif /* MBEDTLS_CCM_H */
Build-time configuration info.
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.
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:78
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:78