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
00050
00051 #ifndef MBEDTLS_CAMELLIA_H
00052 #define MBEDTLS_CAMELLIA_H
00053
00054 #if !defined(MBEDTLS_CONFIG_FILE)
00055 #include "config.h"
00056 #else
00057 #include MBEDTLS_CONFIG_FILE
00058 #endif
00059
00060 #include <stddef.h>
00061 #include <stdint.h>
00062
00063 #define MBEDTLS_CAMELLIA_ENCRYPT 1
00064 #define MBEDTLS_CAMELLIA_DECRYPT 0
00065
00066 #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024
00067 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
00068 #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027
00070 #if !defined(MBEDTLS_CAMELLIA_ALT)
00071
00072
00073
00074 #ifdef __cplusplus
00075 extern "C" {
00076 #endif
00077
00081 typedef struct
00082 {
00083 int nr;
00084 uint32_t rk[68];
00085 }
00086 mbedtls_camellia_context;
00087
00093 void mbedtls_camellia_init( mbedtls_camellia_context *ctx );
00094
00100 void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
00101
00111 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key,
00112 unsigned int keybits );
00113
00123 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key,
00124 unsigned int keybits );
00125
00136 int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
00137 int mode,
00138 const unsigned char input[16],
00139 unsigned char output[16] );
00140
00141 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00142
00165 int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
00166 int mode,
00167 size_t length,
00168 unsigned char iv[16],
00169 const unsigned char *input,
00170 unsigned char *output );
00171 #endif
00172
00173 #if defined(MBEDTLS_CIPHER_MODE_CFB)
00174
00200 int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
00201 int mode,
00202 size_t length,
00203 size_t *iv_off,
00204 unsigned char iv[16],
00205 const unsigned char *input,
00206 unsigned char *output );
00207 #endif
00208
00209 #if defined(MBEDTLS_CIPHER_MODE_CTR)
00210
00232 int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
00233 size_t length,
00234 size_t *nc_off,
00235 unsigned char nonce_counter[16],
00236 unsigned char stream_block[16],
00237 const unsigned char *input,
00238 unsigned char *output );
00239 #endif
00240
00241 #ifdef __cplusplus
00242 }
00243 #endif
00244
00245 #else
00246 #include "camellia_alt.h"
00247 #endif
00248
00249 #ifdef __cplusplus
00250 extern "C" {
00251 #endif
00252
00258 int mbedtls_camellia_self_test( int verbose );
00259
00260 #ifdef __cplusplus
00261 }
00262 #endif
00263
00264 #endif