mbed TLS v2.7.17
camellia.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  *
10  * This file is provided under the Apache License 2.0, or the
11  * GNU General Public License v2.0 or later.
12  *
13  * **********
14  * Apache License 2.0:
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  *
28  * **********
29  *
30  * **********
31  * GNU General Public License v2.0 or later:
32  *
33  * This program is free software; you can redistribute it and/or modify
34  * it under the terms of the GNU General Public License as published by
35  * the Free Software Foundation; either version 2 of the License, or
36  * (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41  * GNU General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License along
44  * with this program; if not, write to the Free Software Foundation, Inc.,
45  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46  *
47  * **********
48  */
49 #ifndef MBEDTLS_CAMELLIA_H
50 #define MBEDTLS_CAMELLIA_H
51 
52 #if !defined(MBEDTLS_CONFIG_FILE)
53 #include "config.h"
54 #else
55 #include MBEDTLS_CONFIG_FILE
56 #endif
57 
58 #include <stddef.h>
59 #include <stdint.h>
60 
61 #define MBEDTLS_CAMELLIA_ENCRYPT 1
62 #define MBEDTLS_CAMELLIA_DECRYPT 0
63 
64 #define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024
65 #define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026
66 #define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027
68 #if !defined(MBEDTLS_CAMELLIA_ALT)
69 // Regular implementation
70 //
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
79 typedef struct
80 {
81  int nr;
82  uint32_t rk[68];
83 }
85 
92 
99 
109 int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key,
110  unsigned int keybits );
111 
121 int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key,
122  unsigned int keybits );
123 
135  int mode,
136  const unsigned char input[16],
137  unsigned char output[16] );
138 
139 #if defined(MBEDTLS_CIPHER_MODE_CBC)
140 
164  int mode,
165  size_t length,
166  unsigned char iv[16],
167  const unsigned char *input,
168  unsigned char *output );
169 #endif /* MBEDTLS_CIPHER_MODE_CBC */
170 
171 #if defined(MBEDTLS_CIPHER_MODE_CFB)
172 
199  int mode,
200  size_t length,
201  size_t *iv_off,
202  unsigned char iv[16],
203  const unsigned char *input,
204  unsigned char *output );
205 #endif /* MBEDTLS_CIPHER_MODE_CFB */
206 
207 #if defined(MBEDTLS_CIPHER_MODE_CTR)
208 
231  size_t length,
232  size_t *nc_off,
233  unsigned char nonce_counter[16],
234  unsigned char stream_block[16],
235  const unsigned char *input,
236  unsigned char *output );
237 #endif /* MBEDTLS_CIPHER_MODE_CTR */
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #else /* MBEDTLS_CAMELLIA_ALT */
244 #include "camellia_alt.h"
245 #endif /* MBEDTLS_CAMELLIA_ALT */
246 
247 #ifdef __cplusplus
248 extern "C" {
249 #endif
250 
256 int mbedtls_camellia_self_test( int verbose );
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* camellia.h */
int mbedtls_camellia_crypt_ecb(mbedtls_camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
CAMELLIA-ECB block encryption/decryption.
int mbedtls_camellia_self_test(int verbose)
Checkup routine.
void mbedtls_camellia_free(mbedtls_camellia_context *ctx)
Clear CAMELLIA context.
Configuration options (set of defines)
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)
CAMELLIA-CFB128 buffer encryption/decryption.
int mbedtls_camellia_setkey_enc(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
CAMELLIA key schedule (encryption)
int mbedtls_camellia_setkey_dec(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
CAMELLIA key schedule (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)
CAMELLIA-CTR buffer encryption/decryption.
void mbedtls_camellia_init(mbedtls_camellia_context *ctx)
Initialize 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)
CAMELLIA-CBC buffer encryption/decryption Length should be a multiple of the block size (16 bytes) ...
CAMELLIA context structure.
Definition: camellia.h:79