PolarSSL v1.1.4
camellia.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_CAMELLIA_H
28 #define POLARSSL_CAMELLIA_H
29 
30 #include <string.h>
31 
32 #ifdef _MSC_VER
33 #include <basetsd.h>
34 typedef UINT32 uint32_t;
35 #else
36 #include <inttypes.h>
37 #endif
38 
39 #define CAMELLIA_ENCRYPT 1
40 #define CAMELLIA_DECRYPT 0
41 
42 #define POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024
43 #define POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
48 typedef struct
49 {
50  int nr;
51  uint32_t rk[68];
52 }
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
68 int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize );
69 
79 int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize );
80 
92  int mode,
93  const unsigned char input[16],
94  unsigned char output[16] );
95 
111  int mode,
112  size_t length,
113  unsigned char iv[16],
114  const unsigned char *input,
115  unsigned char *output );
116 
135  int mode,
136  size_t length,
137  size_t *iv_off,
138  unsigned char iv[16],
139  const unsigned char *input,
140  unsigned char *output );
141 
142 /*
143  * \brief CAMELLIA-CTR buffer encryption/decryption
144  *
145  * Warning: You have to keep the maximum use of your counter in mind!
146  *
147  * Note: Due to the nature of CTR you should use the same key schedule for
148  * both encryption and decryption. So a context initialized with
149  * camellia_setkey_enc() for both CAMELLIA_ENCRYPT and CAMELLIA_DECRYPT.
150  *
151  * \param length The length of the data
152  * \param nc_off The offset in the current stream_block (for resuming
153  * within current cipher stream). The offset pointer to
154  * should be 0 at the start of a stream.
155  * \param nonce_counter The 128-bit nonce and counter.
156  * \param stream_block The saved stream-block for resuming. Is overwritten
157  * by the function.
158  * \param input The input data stream
159  * \param output The output data stream
160  *
161  * \return 0 if successful
162  */
164  size_t length,
165  size_t *nc_off,
166  unsigned char nonce_counter[16],
167  unsigned char stream_block[16],
168  const unsigned char *input,
169  unsigned char *output );
170 
176 int camellia_self_test( int verbose );
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif /* camellia.h */