mbed TLS v3.1.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 #include "mbedtls/private_access.h"
25 
26 #include "mbedtls/build_info.h"
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #include "mbedtls/platform_util.h"
32 
33 #define MBEDTLS_CAMELLIA_ENCRYPT 1
34 #define MBEDTLS_CAMELLIA_DECRYPT 0
35 
37 #define MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA -0x0024
38 
40 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #if !defined(MBEDTLS_CAMELLIA_ALT)
47 // Regular implementation
48 //
49 
53 typedef struct mbedtls_camellia_context
54 {
55  int MBEDTLS_PRIVATE(nr);
56  uint32_t MBEDTLS_PRIVATE(rk)[68];
57 }
58 mbedtls_camellia_context;
59 
60 #else /* MBEDTLS_CAMELLIA_ALT */
61 #include "camellia_alt.h"
62 #endif /* MBEDTLS_CAMELLIA_ALT */
63 
70 void mbedtls_camellia_init( mbedtls_camellia_context *ctx );
71 
79 void mbedtls_camellia_free( mbedtls_camellia_context *ctx );
80 
93 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
94  const unsigned char *key,
95  unsigned int keybits );
96 
109 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx,
110  const unsigned char *key,
111  unsigned int keybits );
112 
128 int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
129  int mode,
130  const unsigned char input[16],
131  unsigned char output[16] );
132 
133 #if defined(MBEDTLS_CIPHER_MODE_CBC)
134 
162 int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
163  int mode,
164  size_t length,
165  unsigned char iv[16],
166  const unsigned char *input,
167  unsigned char *output );
168 #endif /* MBEDTLS_CIPHER_MODE_CBC */
169 
170 #if defined(MBEDTLS_CIPHER_MODE_CFB)
171 
208 int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx,
209  int mode,
210  size_t length,
211  size_t *iv_off,
212  unsigned char iv[16],
213  const unsigned char *input,
214  unsigned char *output );
215 #endif /* MBEDTLS_CIPHER_MODE_CFB */
216 
217 #if defined(MBEDTLS_CIPHER_MODE_CTR)
218 
292 int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
293  size_t length,
294  size_t *nc_off,
295  unsigned char nonce_counter[16],
296  unsigned char stream_block[16],
297  const unsigned char *input,
298  unsigned char *output );
299 #endif /* MBEDTLS_CIPHER_MODE_CTR */
300 
301 #if defined(MBEDTLS_SELF_TEST)
302 
308 int mbedtls_camellia_self_test( int verbose );
309 
310 #endif /* MBEDTLS_SELF_TEST */
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 
316 #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.
#define MBEDTLS_PRIVATE(member)
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.
Macro wrapper for struct's memebrs.
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.
Build-time configuration info.
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.