mbed TLS v2.24.0
camellia.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 #ifndef MBEDTLS_CAMELLIA_H
23 #define MBEDTLS_CAMELLIA_H
24 
25 #if !defined(MBEDTLS_CONFIG_FILE)
26 #include "mbedtls/config.h"
27 #else
28 #include MBEDTLS_CONFIG_FILE
29 #endif
30 
31 #include <stddef.h>
32 #include <stdint.h>
33 
34 #include "mbedtls/platform_util.h"
35 
36 #define MBEDTLS_CAMELLIA_ENCRYPT 1
37 #define MBEDTLS_CAMELLIA_DECRYPT 0
38 
39 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
40 #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0024 )
41 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
42 #define MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA -0x0024
44 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
46 /* MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED is deprecated and should not be used.
47  */
48 #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #if !defined(MBEDTLS_CAMELLIA_ALT)
55 // Regular implementation
56 //
57 
61 typedef struct mbedtls_camellia_context
62 {
63  int nr;
64  uint32_t rk[68];
65 }
66 mbedtls_camellia_context;
67 
68 #else /* MBEDTLS_CAMELLIA_ALT */
69 #include "camellia_alt.h"
70 #endif /* MBEDTLS_CAMELLIA_ALT */
71 
78 void mbedtls_camellia_init( mbedtls_camellia_context *ctx );
79 
87 void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
88 
101 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
102  const unsigned char *key,
103  unsigned int keybits );
104 
117 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx,
118  const unsigned char *key,
119  unsigned int keybits );
120 
136 int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
137  int mode,
138  const unsigned char input[16],
139  unsigned char output[16] );
140 
141 #if defined(MBEDTLS_CIPHER_MODE_CBC)
142 
170 int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
171  int mode,
172  size_t length,
173  unsigned char iv[16],
174  const unsigned char *input,
175  unsigned char *output );
176 #endif /* MBEDTLS_CIPHER_MODE_CBC */
177 
178 #if defined(MBEDTLS_CIPHER_MODE_CFB)
179 
216 int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
217  int mode,
218  size_t length,
219  size_t *iv_off,
220  unsigned char iv[16],
221  const unsigned char *input,
222  unsigned char *output );
223 #endif /* MBEDTLS_CIPHER_MODE_CFB */
224 
225 #if defined(MBEDTLS_CIPHER_MODE_CTR)
226 
300 int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
301  size_t length,
302  size_t *nc_off,
303  unsigned char nonce_counter[16],
304  unsigned char stream_block[16],
305  const unsigned char *input,
306  unsigned char *output );
307 #endif /* MBEDTLS_CIPHER_MODE_CTR */
308 
309 #if defined(MBEDTLS_SELF_TEST)
310 
316 int mbedtls_camellia_self_test( int verbose );
317 
318 #endif /* MBEDTLS_SELF_TEST */
319 
320 #ifdef __cplusplus
321 }
322 #endif
323 
324 #endif /* camellia.h */
int mbedtls_camellia_crypt_ecb(mbedtls_camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
Perform a CAMELLIA-ECB block encryption/decryption operation.
int mbedtls_camellia_self_test(int verbose)
Checkup routine.
void mbedtls_camellia_free(mbedtls_camellia_context *ctx)
Clear a CAMELLIA context.
Configuration options (set of defines)
Common and shared functions used by multiple modules in the Mbed TLS library.
int mbedtls_camellia_crypt_cfb128(mbedtls_camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CFB128 buffer encryption/decryption operation.
int mbedtls_camellia_setkey_enc(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a CAMELLIA key schedule operation for encryption.
int mbedtls_camellia_setkey_dec(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a CAMELLIA key schedule operation for decryption.
int mbedtls_camellia_crypt_ctr(mbedtls_camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CTR buffer encryption/decryption operation.
void mbedtls_camellia_init(mbedtls_camellia_context *ctx)
Initialize a CAMELLIA context.
int mbedtls_camellia_crypt_cbc(mbedtls_camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CBC buffer encryption/decryption operation.