00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MBEDTLS_CMAC_H
00027 #define MBEDTLS_CMAC_H
00028
00029 #if !defined(MBEDTLS_CONFIG_FILE)
00030 #include "config.h"
00031 #else
00032 #include MBEDTLS_CONFIG_FILE
00033 #endif
00034
00035 #include "cipher.h"
00036
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040
00041 #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A
00043 #define MBEDTLS_AES_BLOCK_SIZE 16
00044 #define MBEDTLS_DES3_BLOCK_SIZE 8
00045
00046 #if defined(MBEDTLS_AES_C)
00047 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
00048 #else
00049 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
00050 #endif
00051
00052 #if !defined(MBEDTLS_CMAC_ALT)
00053
00057 struct mbedtls_cmac_context_t
00058 {
00060 unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
00061
00064 unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
00065
00067 size_t unprocessed_len;
00068 };
00069
00087 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00088 const unsigned char *key, size_t keybits );
00089
00105 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00106 const unsigned char *input, size_t ilen );
00107
00122 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00123 unsigned char *output );
00124
00138 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
00139
00161 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00162 const unsigned char *key, size_t keylen,
00163 const unsigned char *input, size_t ilen,
00164 unsigned char *output );
00165
00166 #if defined(MBEDTLS_AES_C)
00167
00184 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
00185 const unsigned char *input, size_t in_len,
00186 unsigned char output[16] );
00187 #endif
00188
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192
00193 #else
00194 #include "cmac_alt.h"
00195 #endif
00196
00197 #ifdef __cplusplus
00198 extern "C" {
00199 #endif
00200
00201 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
00202
00207 int mbedtls_cmac_self_test( int verbose );
00208 #endif
00209
00210 #ifdef __cplusplus
00211 }
00212 #endif
00213
00214 #endif