00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef MBEDTLS_CMAC_H
00054 #define MBEDTLS_CMAC_H
00055
00056 #if !defined(MBEDTLS_CONFIG_FILE)
00057 #include "config.h"
00058 #else
00059 #include MBEDTLS_CONFIG_FILE
00060 #endif
00061
00062 #include "cipher.h"
00063
00064 #ifdef __cplusplus
00065 extern "C" {
00066 #endif
00067
00068 #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A
00070 #define MBEDTLS_AES_BLOCK_SIZE 16
00071 #define MBEDTLS_DES3_BLOCK_SIZE 8
00072
00073 #if defined(MBEDTLS_AES_C)
00074 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
00075 #else
00076 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
00077 #endif
00078
00079 #if !defined(MBEDTLS_CMAC_ALT)
00080
00084 struct mbedtls_cmac_context_t
00085 {
00087 unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
00088
00091 unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
00092
00094 size_t unprocessed_len;
00095 };
00096
00114 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00115 const unsigned char *key, size_t keybits );
00116
00132 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00133 const unsigned char *input, size_t ilen );
00134
00149 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00150 unsigned char *output );
00151
00165 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
00166
00188 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00189 const unsigned char *key, size_t keylen,
00190 const unsigned char *input, size_t ilen,
00191 unsigned char *output );
00192
00193 #if defined(MBEDTLS_AES_C)
00194
00211 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
00212 const unsigned char *input, size_t in_len,
00213 unsigned char output[16] );
00214 #endif
00215
00216 #ifdef __cplusplus
00217 }
00218 #endif
00219
00220 #else
00221 #include "cmac_alt.h"
00222 #endif
00223
00224 #ifdef __cplusplus
00225 extern "C" {
00226 #endif
00227
00228 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
00229
00234 int mbedtls_cmac_self_test( int verbose );
00235 #endif
00236
00237 #ifdef __cplusplus
00238 }
00239 #endif
00240
00241 #endif