00001
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef MBEDTLS_CCM_H
00035 #define MBEDTLS_CCM_H
00036
00037 #include "cipher.h"
00038
00039 #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D
00040 #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F
00041 #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011
00043 #if !defined(MBEDTLS_CCM_ALT)
00044
00045
00046
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050
00055 typedef struct {
00056 mbedtls_cipher_context_t cipher_ctx;
00057 }
00058 mbedtls_ccm_context;
00059
00067 void mbedtls_ccm_init( mbedtls_ccm_context *ctx );
00068
00080 int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
00081 mbedtls_cipher_id_t cipher,
00082 const unsigned char *key,
00083 unsigned int keybits );
00084
00091 void mbedtls_ccm_free( mbedtls_ccm_context *ctx );
00092
00118 int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
00119 const unsigned char *iv, size_t iv_len,
00120 const unsigned char *add, size_t add_len,
00121 const unsigned char *input, unsigned char *output,
00122 unsigned char *tag, size_t tag_len );
00123
00142 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
00143 const unsigned char *iv, size_t iv_len,
00144 const unsigned char *add, size_t add_len,
00145 const unsigned char *input, unsigned char *output,
00146 const unsigned char *tag, size_t tag_len );
00147
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151
00152 #else
00153 #include "ccm_alt.h"
00154 #endif
00155
00156 #ifdef __cplusplus
00157 extern "C" {
00158 #endif
00159
00160 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
00161
00166 int mbedtls_ccm_self_test( int verbose );
00167 #endif
00168
00169 #ifdef __cplusplus
00170 }
00171 #endif
00172
00173 #endif