00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MBEDTLS_CAMELLIA_H
00025 #define MBEDTLS_CAMELLIA_H
00026
00027 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032
00033 #include <stddef.h>
00034 #include <stdint.h>
00035
00036 #define MBEDTLS_CAMELLIA_ENCRYPT 1
00037 #define MBEDTLS_CAMELLIA_DECRYPT 0
00038
00039 #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024
00040 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
00041 #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027
00043 #if !defined(MBEDTLS_CAMELLIA_ALT)
00044
00045
00046
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050
00054 typedef struct
00055 {
00056 int nr;
00057 uint32_t rk[68];
00058 }
00059 mbedtls_camellia_context;
00060
00066 void mbedtls_camellia_init( mbedtls_camellia_context *ctx );
00067
00073 void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
00074
00084 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key,
00085 unsigned int keybits );
00086
00096 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key,
00097 unsigned int keybits );
00098
00109 int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
00110 int mode,
00111 const unsigned char input[16],
00112 unsigned char output[16] );
00113
00114 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00115
00138 int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
00139 int mode,
00140 size_t length,
00141 unsigned char iv[16],
00142 const unsigned char *input,
00143 unsigned char *output );
00144 #endif
00145
00146 #if defined(MBEDTLS_CIPHER_MODE_CFB)
00147
00173 int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
00174 int mode,
00175 size_t length,
00176 size_t *iv_off,
00177 unsigned char iv[16],
00178 const unsigned char *input,
00179 unsigned char *output );
00180 #endif
00181
00182 #if defined(MBEDTLS_CIPHER_MODE_CTR)
00183
00205 int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
00206 size_t length,
00207 size_t *nc_off,
00208 unsigned char nonce_counter[16],
00209 unsigned char stream_block[16],
00210 const unsigned char *input,
00211 unsigned char *output );
00212 #endif
00213
00214 #ifdef __cplusplus
00215 }
00216 #endif
00217
00218 #else
00219 #include "camellia_alt.h"
00220 #endif
00221
00222 #ifdef __cplusplus
00223 extern "C" {
00224 #endif
00225
00231 int mbedtls_camellia_self_test( int verbose );
00232
00233 #ifdef __cplusplus
00234 }
00235 #endif
00236
00237 #endif