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
00145 int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
00146 const unsigned char *iv, size_t iv_len,
00147 const unsigned char *add, size_t add_len,
00148 const unsigned char *input, unsigned char *output,
00149 const unsigned char *tag, size_t tag_len );
00150
00151 #ifdef __cplusplus
00152 }
00153 #endif
00154
00155 #else
00156 #include "ccm_alt.h"
00157 #endif
00158
00159 #ifdef __cplusplus
00160 extern "C" {
00161 #endif
00162
00163 #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
00164
00169 int mbedtls_ccm_self_test( int verbose );
00170 #endif
00171
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175
00176 #endif