mbed TLS v2.24.0
aria.h
Go to the documentation of this file.
1 
12 /*
13  * Copyright The Mbed TLS Contributors
14  * SPDX-License-Identifier: Apache-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 #ifndef MBEDTLS_ARIA_H
30 #define MBEDTLS_ARIA_H
31 
32 #if !defined(MBEDTLS_CONFIG_FILE)
33 #include "mbedtls/config.h"
34 #else
35 #include MBEDTLS_CONFIG_FILE
36 #endif
37 
38 #include <stddef.h>
39 #include <stdint.h>
40 
41 #include "mbedtls/platform_util.h"
42 
43 #define MBEDTLS_ARIA_ENCRYPT 1
44 #define MBEDTLS_ARIA_DECRYPT 0
46 #define MBEDTLS_ARIA_BLOCKSIZE 16
47 #define MBEDTLS_ARIA_MAX_ROUNDS 16
48 #define MBEDTLS_ARIA_MAX_KEYSIZE 32
50 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
51 #define MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x005C )
52 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
53 #define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C
55 #define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E
57 /* MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE is deprecated and should not be used.
58  */
59 #define MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE -0x005A
61 /* MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED is deprecated and should not be used. */
62 #define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058
64 #if !defined(MBEDTLS_ARIA_ALT)
65 // Regular implementation
66 //
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
75 typedef struct mbedtls_aria_context
76 {
77  unsigned char nr;
79  uint32_t rk[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4];
80 }
81 mbedtls_aria_context;
82 
83 #else /* MBEDTLS_ARIA_ALT */
84 #include "aria_alt.h"
85 #endif /* MBEDTLS_ARIA_ALT */
86 
95 void mbedtls_aria_init( mbedtls_aria_context *ctx );
96 
104 void mbedtls_aria_free( mbedtls_aria_context *ctx );
105 
121 int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
122  const unsigned char *key,
123  unsigned int keybits );
124 
140 int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
141  const unsigned char *key,
142  unsigned int keybits );
143 
164 int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
165  const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
166  unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );
167 
168 #if defined(MBEDTLS_CIPHER_MODE_CBC)
169 
210 int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
211  int mode,
212  size_t length,
213  unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
214  const unsigned char *input,
215  unsigned char *output );
216 #endif /* MBEDTLS_CIPHER_MODE_CBC */
217 
218 #if defined(MBEDTLS_CIPHER_MODE_CFB)
219 
260 int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
261  int mode,
262  size_t length,
263  size_t *iv_off,
264  unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
265  const unsigned char *input,
266  unsigned char *output );
267 #endif /* MBEDTLS_CIPHER_MODE_CFB */
268 
269 #if defined(MBEDTLS_CIPHER_MODE_CTR)
270 
347 int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
348  size_t length,
349  size_t *nc_off,
350  unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
351  unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
352  const unsigned char *input,
353  unsigned char *output );
354 #endif /* MBEDTLS_CIPHER_MODE_CTR */
355 
356 #if defined(MBEDTLS_SELF_TEST)
357 
362 int mbedtls_aria_self_test( int verbose );
363 #endif /* MBEDTLS_SELF_TEST */
364 
365 #ifdef __cplusplus
366 }
367 #endif
368 
369 #endif /* aria.h */
int mbedtls_aria_crypt_cfb128(mbedtls_aria_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CFB128 encryption or decryption operation.
int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
Configuration options (set of defines)
#define MBEDTLS_ARIA_MAX_ROUNDS
Definition: aria.h:47
Common and shared functions used by multiple modules in the Mbed TLS library.
int mbedtls_aria_crypt_ctr(mbedtls_aria_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CTR encryption or decryption operation.
#define MBEDTLS_ARIA_BLOCKSIZE
Definition: aria.h:46
void mbedtls_aria_free(mbedtls_aria_context *ctx)
This function releases and clears the specified ARIA context.
int mbedtls_aria_crypt_ecb(mbedtls_aria_context *ctx, const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], unsigned char output[MBEDTLS_ARIA_BLOCKSIZE])
This function performs an ARIA single-block encryption or decryption operation.
int mbedtls_aria_self_test(int verbose)
Checkup routine.
int mbedtls_aria_setkey_enc(mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
void mbedtls_aria_init(mbedtls_aria_context *ctx)
This function initializes the specified ARIA context.
int mbedtls_aria_crypt_cbc(mbedtls_aria_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CBC encryption or decryption operation on full blocks.