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 #ifndef MBEDTLS_CMAC_H
00052 #define MBEDTLS_CMAC_H
00053
00054 #if !defined(MBEDTLS_CONFIG_FILE)
00055 #include "config.h"
00056 #else
00057 #include MBEDTLS_CONFIG_FILE
00058 #endif
00059
00060 #include "cipher.h"
00061
00062 #ifdef __cplusplus
00063 extern "C" {
00064 #endif
00065
00066 #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A
00068 #define MBEDTLS_AES_BLOCK_SIZE 16
00069 #define MBEDTLS_DES3_BLOCK_SIZE 8
00070
00071 #if defined(MBEDTLS_AES_C)
00072 #define MBEDTLS_CIPHER_BLKSIZE_MAX 16
00073 #else
00074 #define MBEDTLS_CIPHER_BLKSIZE_MAX 8
00075 #endif
00076
00077 #if !defined(MBEDTLS_CMAC_ALT)
00078
00082 struct mbedtls_cmac_context_t
00083 {
00085 unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
00086
00089 unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
00090
00092 size_t unprocessed_len;
00093 };
00094
00112 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00113 const unsigned char *key, size_t keybits );
00114
00130 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00131 const unsigned char *input, size_t ilen );
00132
00147 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00148 unsigned char *output );
00149
00163 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
00164
00186 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00187 const unsigned char *key, size_t keylen,
00188 const unsigned char *input, size_t ilen,
00189 unsigned char *output );
00190
00191 #if defined(MBEDTLS_AES_C)
00192
00209 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
00210 const unsigned char *input, size_t in_len,
00211 unsigned char output[16] );
00212 #endif
00213
00214 #ifdef __cplusplus
00215 }
00216 #endif
00217
00218 #else
00219 #include "cmac_alt.h"
00220 #endif
00221
00222 #ifdef __cplusplus
00223 extern "C" {
00224 #endif
00225
00226 #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
00227
00232 int mbedtls_cmac_self_test( int verbose );
00233 #endif
00234
00235 #ifdef __cplusplus
00236 }
00237 #endif
00238
00239 #endif