00001
00023 #ifndef MBEDTLS_XTEA_H
00024 #define MBEDTLS_XTEA_H
00025
00026 #if !defined(MBEDTLS_CONFIG_FILE)
00027 #include "config.h"
00028 #else
00029 #include MBEDTLS_CONFIG_FILE
00030 #endif
00031
00032 #include <stddef.h>
00033 #include <stdint.h>
00034
00035 #define MBEDTLS_XTEA_ENCRYPT 1
00036 #define MBEDTLS_XTEA_DECRYPT 0
00037
00038 #define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028
00040 #if !defined(MBEDTLS_XTEA_ALT)
00041
00042
00043
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047
00051 typedef struct
00052 {
00053 uint32_t k[4];
00054 }
00055 mbedtls_xtea_context;
00056
00062 void mbedtls_xtea_init( mbedtls_xtea_context *ctx );
00063
00069 void mbedtls_xtea_free( mbedtls_xtea_context *ctx );
00070
00077 void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] );
00078
00089 int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx,
00090 int mode,
00091 const unsigned char input[8],
00092 unsigned char output[8] );
00093
00094 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00095
00108 int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx,
00109 int mode,
00110 size_t length,
00111 unsigned char iv[8],
00112 const unsigned char *input,
00113 unsigned char *output);
00114 #endif
00115
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119
00120 #else
00121 #include "xtea_alt.h"
00122 #endif
00123
00124 #ifdef __cplusplus
00125 extern "C" {
00126 #endif
00127
00133 int mbedtls_xtea_self_test( int verbose );
00134
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138
00139 #endif