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 #include "cipher.h"
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034
00035 #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A
00037 #define MBEDTLS_AES_BLOCK_SIZE 16
00038 #define MBEDTLS_DES3_BLOCK_SIZE 8
00039
00040 #if defined(MBEDTLS_AES_C)
00041 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
00042 #else
00043 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
00044 #endif
00045
00046 #if !defined(MBEDTLS_CMAC_ALT)
00047
00051 struct mbedtls_cmac_context_t
00052 {
00054 unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
00055
00058 unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
00059
00061 size_t unprocessed_len;
00062 };
00063
00081 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00082 const unsigned char *key, size_t keybits );
00083
00099 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00100 const unsigned char *input, size_t ilen );
00101
00116 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00117 unsigned char *output );
00118
00132 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
00133
00155 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00156 const unsigned char *key, size_t keylen,
00157 const unsigned char *input, size_t ilen,
00158 unsigned char *output );
00159
00160 #if defined(MBEDTLS_AES_C)
00161
00178 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
00179 const unsigned char *input, size_t in_len,
00180 unsigned char output[16] );
00181 #endif
00182
00183 #ifdef __cplusplus
00184 }
00185 #endif
00186
00187 #else
00188 #include "cmac_alt.h"
00189 #endif
00190
00191 #ifdef __cplusplus
00192 extern "C" {
00193 #endif
00194
00195 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
00196
00201 int mbedtls_cmac_self_test( int verbose );
00202 #endif
00203
00204 #ifdef __cplusplus
00205 }
00206 #endif
00207
00208 #endif