mbed TLS v3.1.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 #include "mbedtls/private_access.h"
32 
33 #include "mbedtls/build_info.h"
34 
35 #include <stddef.h>
36 #include <stdint.h>
37 
38 #include "mbedtls/platform_util.h"
39 
40 #define MBEDTLS_ARIA_ENCRYPT 1
41 #define MBEDTLS_ARIA_DECRYPT 0
43 #define MBEDTLS_ARIA_BLOCKSIZE 16
44 #define MBEDTLS_ARIA_MAX_ROUNDS 16
45 #define MBEDTLS_ARIA_MAX_KEYSIZE 32
48 #define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C
49 
51 #define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #if !defined(MBEDTLS_ARIA_ALT)
58 // Regular implementation
59 //
60 
64 typedef struct mbedtls_aria_context
65 {
66  unsigned char MBEDTLS_PRIVATE(nr);
69 }
70 mbedtls_aria_context;
71 
72 #else /* MBEDTLS_ARIA_ALT */
73 #include "aria_alt.h"
74 #endif /* MBEDTLS_ARIA_ALT */
75 
84 void mbedtls_aria_init( mbedtls_aria_context *ctx );
85 
93 void mbedtls_aria_free( mbedtls_aria_context *ctx );
94 
110 int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
111  const unsigned char *key,
112  unsigned int keybits );
113 
129 int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
130  const unsigned char *key,
131  unsigned int keybits );
132 
153 int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
154  const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
155  unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );
156 
157 #if defined(MBEDTLS_CIPHER_MODE_CBC)
158 
199 int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
200  int mode,
201  size_t length,
202  unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
203  const unsigned char *input,
204  unsigned char *output );
205 #endif /* MBEDTLS_CIPHER_MODE_CBC */
206 
207 #if defined(MBEDTLS_CIPHER_MODE_CFB)
208 
249 int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
250  int mode,
251  size_t length,
252  size_t *iv_off,
253  unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
254  const unsigned char *input,
255  unsigned char *output );
256 #endif /* MBEDTLS_CIPHER_MODE_CFB */
257 
258 #if defined(MBEDTLS_CIPHER_MODE_CTR)
259 
336 int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
337  size_t length,
338  size_t *nc_off,
339  unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
340  unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
341  const unsigned char *input,
342  unsigned char *output );
343 #endif /* MBEDTLS_CIPHER_MODE_CTR */
344 
345 #if defined(MBEDTLS_SELF_TEST)
346 
351 int mbedtls_aria_self_test( int verbose );
352 #endif /* MBEDTLS_SELF_TEST */
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 #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.
#define MBEDTLS_PRIVATE(member)
#define MBEDTLS_ARIA_MAX_ROUNDS
Definition: aria.h:44
Common and shared functions used by multiple modules in the Mbed TLS library.
Macro wrapper for struct's memebrs.
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.
Build-time configuration info.
#define MBEDTLS_ARIA_BLOCKSIZE
Definition: aria.h:43
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.