mbed TLS v2.16.7
cmac.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (C) 2015-2018, Arm Limited (or its affiliates), All Rights Reserved
11  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
12  *
13  * This file is provided under the Apache License 2.0, or the
14  * GNU General Public License v2.0 or later.
15  *
16  * **********
17  * Apache License 2.0:
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may
20  * not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  *
23  * http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  *
31  * **********
32  *
33  * **********
34  * GNU General Public License v2.0 or later:
35  *
36  * This program is free software; you can redistribute it and/or modify
37  * it under the terms of the GNU General Public License as published by
38  * the Free Software Foundation; either version 2 of the License, or
39  * (at your option) any later version.
40  *
41  * This program is distributed in the hope that it will be useful,
42  * but WITHOUT ANY WARRANTY; without even the implied warranty of
43  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44  * GNU General Public License for more details.
45  *
46  * You should have received a copy of the GNU General Public License along
47  * with this program; if not, write to the Free Software Foundation, Inc.,
48  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
49  *
50  * **********
51  *
52  * This file is part of Mbed TLS (https://tls.mbed.org)
53  */
54 
55 #ifndef MBEDTLS_CMAC_H
56 #define MBEDTLS_CMAC_H
57 
58 #if !defined(MBEDTLS_CONFIG_FILE)
59 #include "config.h"
60 #else
61 #include MBEDTLS_CONFIG_FILE
62 #endif
63 
64 #include "cipher.h"
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 /* MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED is deprecated and should not be used. */
71 #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A
73 #define MBEDTLS_AES_BLOCK_SIZE 16
74 #define MBEDTLS_DES3_BLOCK_SIZE 8
75 
76 #if defined(MBEDTLS_AES_C)
77 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
78 #else
79 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
80 #endif
81 
82 #if !defined(MBEDTLS_CMAC_ALT)
83 
88 {
91 
95 
98 };
99 
100 #else /* !MBEDTLS_CMAC_ALT */
101 #include "cmac_alt.h"
102 #endif /* !MBEDTLS_CMAC_ALT */
103 
121  const unsigned char *key, size_t keybits );
122 
140  const unsigned char *input, size_t ilen );
141 
158  unsigned char *output );
159 
175 
199  const unsigned char *key, size_t keylen,
200  const unsigned char *input, size_t ilen,
201  unsigned char *output );
202 
203 #if defined(MBEDTLS_AES_C)
204 
221 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
222  const unsigned char *input, size_t in_len,
223  unsigned char output[16] );
224 #endif /* MBEDTLS_AES_C */
225 
226 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
227 
233 int mbedtls_cmac_self_test( int verbose );
234 #endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* MBEDTLS_CMAC_H */
mbedtls_cipher_cmac_starts
int mbedtls_cipher_cmac_starts(mbedtls_cipher_context_t *ctx, const unsigned char *key, size_t keybits)
This function sets the CMAC key, and prepares to authenticate the input data. Must be called with an ...
mbedtls_cmac_context_t::state
unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX]
Definition: cmac.h:90
mbedtls_cipher_cmac
int mbedtls_cipher_cmac(const mbedtls_cipher_info_t *cipher_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output)
This function calculates the full generic CMAC on the input buffer with the provided key.
mbedtls_cmac_context_t::unprocessed_len
size_t unprocessed_len
Definition: cmac.h:97
MBEDTLS_CIPHER_BLKSIZE_MAX
#define MBEDTLS_CIPHER_BLKSIZE_MAX
Definition: cmac.h:77
mbedtls_cmac_context_t::unprocessed_block
unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX]
Definition: cmac.h:94
mbedtls_cipher_info_t
Definition: cipher.h:270
mbedtls_cipher_cmac_reset
int mbedtls_cipher_cmac_reset(mbedtls_cipher_context_t *ctx)
This function prepares the authentication of another message with the same key as the previous CMAC o...
mbedtls_cmac_context_t
Definition: cmac.h:88
mbedtls_cipher_cmac_finish
int mbedtls_cipher_cmac_finish(mbedtls_cipher_context_t *ctx, unsigned char *output)
This function finishes the CMAC operation, and writes the result to the output buffer.
cipher.h
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_aes_cmac_prf_128
int mbedtls_aes_cmac_prf_128(const unsigned char *key, size_t key_len, const unsigned char *input, size_t in_len, unsigned char output[16])
This function implements the AES-CMAC-PRF-128 pseudorandom function, as defined in RFC-4615: The Adva...
mbedtls_cmac_self_test
int mbedtls_cmac_self_test(int verbose)
The CMAC checkup routine.
mbedtls_cipher_context_t
Definition: cipher.h:312
config.h
Configuration options (set of defines)
mbedtls_cipher_cmac_update
int mbedtls_cipher_cmac_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing CMAC computation.