00001
00006
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 #ifndef MBEDTLS_CAMELLIA_H
00050 #define MBEDTLS_CAMELLIA_H
00051
00052 #if !defined(MBEDTLS_CONFIG_FILE)
00053 #include "config.h"
00054 #else
00055 #include MBEDTLS_CONFIG_FILE
00056 #endif
00057
00058 #include <stddef.h>
00059 #include <stdint.h>
00060
00061 #define MBEDTLS_CAMELLIA_ENCRYPT 1
00062 #define MBEDTLS_CAMELLIA_DECRYPT 0
00063
00064 #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024
00065 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
00066 #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027
00068 #if !defined(MBEDTLS_CAMELLIA_ALT)
00069
00070
00071
00072 #ifdef __cplusplus
00073 extern "C" {
00074 #endif
00075
00079 typedef struct
00080 {
00081 int nr;
00082 uint32_t rk[68];
00083 }
00084 mbedtls_camellia_context;
00085
00091 void mbedtls_camellia_init( mbedtls_camellia_context *ctx );
00092
00098 void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
00099
00109 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key,
00110 unsigned int keybits );
00111
00121 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key,
00122 unsigned int keybits );
00123
00134 int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
00135 int mode,
00136 const unsigned char input[16],
00137 unsigned char output[16] );
00138
00139 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00140
00163 int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
00164 int mode,
00165 size_t length,
00166 unsigned char iv[16],
00167 const unsigned char *input,
00168 unsigned char *output );
00169 #endif
00170
00171 #if defined(MBEDTLS_CIPHER_MODE_CFB)
00172
00198 int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
00199 int mode,
00200 size_t length,
00201 size_t *iv_off,
00202 unsigned char iv[16],
00203 const unsigned char *input,
00204 unsigned char *output );
00205 #endif
00206
00207 #if defined(MBEDTLS_CIPHER_MODE_CTR)
00208
00230 int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
00231 size_t length,
00232 size_t *nc_off,
00233 unsigned char nonce_counter[16],
00234 unsigned char stream_block[16],
00235 const unsigned char *input,
00236 unsigned char *output );
00237 #endif
00238
00239 #ifdef __cplusplus
00240 }
00241 #endif
00242
00243 #else
00244 #include "camellia_alt.h"
00245 #endif
00246
00247 #ifdef __cplusplus
00248 extern "C" {
00249 #endif
00250
00256 int mbedtls_camellia_self_test( int verbose );
00257
00258 #ifdef __cplusplus
00259 }
00260 #endif
00261
00262 #endif