00001
00024 #ifndef MBEDTLS_CMAC_H
00025 #define MBEDTLS_CMAC_H
00026
00027 #include "mbedtls/cipher.h"
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #define MBEDTLS_AES_BLOCK_SIZE 16
00034 #define MBEDTLS_DES3_BLOCK_SIZE 8
00035
00036 #if defined(MBEDTLS_AES_C)
00037 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
00038 #else
00039 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
00040 #endif
00041
00045 struct mbedtls_cmac_context_t
00046 {
00048 unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
00049
00052 unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
00053
00055 size_t unprocessed_len;
00056 };
00057
00074 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00075 const unsigned char *key, size_t keybits );
00076
00091 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00092 const unsigned char *input, size_t ilen );
00093
00106 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00107 unsigned char *output );
00108
00119 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
00120
00134 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00135 const unsigned char *key, size_t keylen,
00136 const unsigned char *input, size_t ilen,
00137 unsigned char *output );
00138
00139 #if defined(MBEDTLS_AES_C)
00140
00152 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
00153 const unsigned char *input, size_t in_len,
00154 unsigned char output[16] );
00155 #endif
00156
00157 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
00158
00163 int mbedtls_cmac_self_test( int verbose );
00164 #endif
00165
00166 #ifdef __cplusplus
00167 }
00168 #endif
00169
00170 #endif