blob: 854aa699eac5ef99b7fe7d44977d116adbf185a1 [file] [log] [blame]
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +00001/**
2 * \file aria.h
3 *
4 * \brief ARIA block cipher
5 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +01006 * The ARIA algorithm is a symmetric block cipher that can encrypt and
7 * decrypt information. It is defined by the Korean Agency for
8 * Technology and Standards (KATS) in <em>KS X 1213:2004</em> (in
9 * Korean, but see http://210.104.33.10/ARIA/index-e.html in English)
10 * and also described by the IETF in <em>RFC 5794</em>.
11 */
Bence Szépkúti86974652020-06-15 11:59:37 +020012/*
Bence Szépkúti1e148272020-08-07 13:07:28 +020013 * Copyright The Mbed TLS Contributors
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000014 * 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.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000027 */
28
29#ifndef MBEDTLS_ARIA_H
30#define MBEDTLS_ARIA_H
Mateusz Starzyk846f0212021-05-19 19:44:07 +020031#include "mbedtls/private_access.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000032
33#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010034#include "mbedtls/config.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000035#else
36#include MBEDTLS_CONFIG_FILE
37#endif
38
39#include <stddef.h>
40#include <stdint.h>
41
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010042#include "mbedtls/platform_util.h"
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050043
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010044#define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */
45#define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000046
Manuel Pégourié-Gonnard8abc3492018-03-01 10:02:47 +010047#define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */
48#define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */
49#define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010050
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050051#define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C /**< Bad input data. */
52
53#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030054
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000055#ifdef __cplusplus
56extern "C" {
57#endif
58
Gilles Peskine59392b02021-05-24 22:58:37 +020059#if !defined(MBEDTLS_ARIA_ALT)
60// Regular implementation
61//
62
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000063/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010064 * \brief The ARIA context-type definition.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000065 */
Dawid Drozd428cc522018-07-24 10:02:47 +020066typedef struct mbedtls_aria_context
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000067{
Mateusz Starzyk846f0212021-05-19 19:44:07 +020068 unsigned char MBEDTLS_PRIVATE(nr); /*!< The number of rounds (12, 14 or 16) */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010069 /*! The ARIA round keys. */
Mateusz Starzyk846f0212021-05-19 19:44:07 +020070 uint32_t MBEDTLS_PRIVATE(rk)[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4];
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000071}
72mbedtls_aria_context;
73
Manuel Pégourié-Gonnard0960b802018-05-22 15:22:07 +020074#else /* MBEDTLS_ARIA_ALT */
75#include "aria_alt.h"
76#endif /* MBEDTLS_ARIA_ALT */
77
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000078/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010079 * \brief This function initializes the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000080 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010081 * It must be the first API called before using
82 * the context.
83 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050084 * \param ctx The ARIA context to initialize. This must not be \c NULL.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000085 */
86void mbedtls_aria_init( mbedtls_aria_context *ctx );
87
88/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010089 * \brief This function releases and clears the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000090 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050091 * \param ctx The ARIA context to clear. This may be \c NULL, in which
92 * case this function returns immediately. If it is not \c NULL,
93 * it must point to an initialized ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000094 */
95void mbedtls_aria_free( mbedtls_aria_context *ctx );
96
97/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010098 * \brief This function sets the encryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000099 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100100 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500101 * This must be initialized.
102 * \param key The encryption key. This must be a readable buffer
103 * of size \p keybits Bits.
104 * \param keybits The size of \p key in Bits. Valid options are:
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100105 * <ul><li>128 bits</li>
106 * <li>192 bits</li>
107 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000108 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500109 * \return \c 0 on success.
110 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000111 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100112int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
113 const unsigned char *key,
114 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000115
116/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100117 * \brief This function sets the decryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000118 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100119 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500120 * This must be initialized.
121 * \param key The decryption key. This must be a readable buffer
122 * of size \p keybits Bits.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100123 * \param keybits The size of data passed. Valid options are:
124 * <ul><li>128 bits</li>
125 * <li>192 bits</li>
126 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000127 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500128 * \return \c 0 on success.
129 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000130 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100131int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
132 const unsigned char *key,
133 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000134
135/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100136 * \brief This function performs an ARIA single-block encryption or
137 * decryption operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000138 *
Manuel Pégourié-Gonnard08c337d2018-05-22 13:18:01 +0200139 * It performs encryption or decryption (depending on whether
140 * the key was set for encryption on decryption) on the input
141 * data buffer defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000142 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200143 * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or
144 * mbedtls_aria_setkey_dec() must be called before the first
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100145 * call to this API with the same context.
146 *
147 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500148 * This must be initialized and bound to a key.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100149 * \param input The 16-Byte buffer holding the input data.
150 * \param output The 16-Byte buffer holding the output data.
151
152 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500153 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000154 */
155int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100156 const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
157 unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000158
159#if defined(MBEDTLS_CIPHER_MODE_CBC)
160/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100161 * \brief This function performs an ARIA-CBC encryption or decryption operation
162 * on full blocks.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000163 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100164 * It performs the operation defined in the \p mode
165 * parameter (encrypt/decrypt), on the input data buffer defined in
166 * the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000167 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100168 * It can be called as many times as needed, until all the input
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200169 * data is processed. mbedtls_aria_init(), and either
170 * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100171 * before the first call to this API with the same context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000172 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100173 * \note This function operates on aligned blocks, that is, the input size
174 * must be a multiple of the ARIA block size of 16 Bytes.
175 *
176 * \note Upon exit, the content of the IV is updated so that you can
177 * call the same function again on the next
178 * block(s) of data and get the same result as if it was
179 * encrypted in one call. This allows a "streaming" usage.
180 * If you need to retain the contents of the IV, you should
181 * either save it manually or use the cipher module instead.
182 *
183 *
184 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500185 * This must be initialized and bound to a key.
186 * \param mode The mode of operation. This must be either
187 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
188 * #MBEDTLS_ARIA_DECRYPT for decryption.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100189 * \param length The length of the input data in Bytes. This must be a
190 * multiple of the block size (16 Bytes).
191 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500192 * This must be a readable buffer of size 16 Bytes.
193 * \param input The buffer holding the input data. This must
194 * be a readable buffer of length \p length Bytes.
195 * \param output The buffer holding the output data. This must
196 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100197 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500198 * \return \c 0 on success.
199 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000200 */
201int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100202 int mode,
203 size_t length,
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100204 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100205 const unsigned char *input,
206 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000207#endif /* MBEDTLS_CIPHER_MODE_CBC */
208
209#if defined(MBEDTLS_CIPHER_MODE_CFB)
210/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100211 * \brief This function performs an ARIA-CFB128 encryption or decryption
212 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000213 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100214 * It performs the operation defined in the \p mode
215 * parameter (encrypt or decrypt), on the input data buffer
216 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000217 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200218 * For CFB, you must set up the context with mbedtls_aria_setkey_enc(),
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100219 * regardless of whether you are performing an encryption or decryption
220 * operation, that is, regardless of the \p mode parameter. This is
221 * because CFB mode uses the same key schedule for encryption and
222 * decryption.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000223 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100224 * \note Upon exit, the content of the IV is updated so that you can
225 * call the same function again on the next
226 * block(s) of data and get the same result as if it was
227 * encrypted in one call. This allows a "streaming" usage.
228 * If you need to retain the contents of the
229 * IV, you must either save it manually or use the cipher
230 * module instead.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000231 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100232 *
233 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500234 * This must be initialized and bound to a key.
235 * \param mode The mode of operation. This must be either
236 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
237 * #MBEDTLS_ARIA_DECRYPT for decryption.
238 * \param length The length of the input data \p input in Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100239 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500240 * This must not be larger than 15.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100241 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500242 * This must be a readable buffer of size 16 Bytes.
243 * \param input The buffer holding the input data. This must
244 * be a readable buffer of length \p length Bytes.
245 * \param output The buffer holding the output data. This must
246 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100247 *
248 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500249 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000250 */
251int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100252 int mode,
253 size_t length,
254 size_t *iv_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100255 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100256 const unsigned char *input,
257 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000258#endif /* MBEDTLS_CIPHER_MODE_CFB */
259
260#if defined(MBEDTLS_CIPHER_MODE_CTR)
261/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100262 * \brief This function performs an ARIA-CTR encryption or decryption
263 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000264 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100265 * This function performs the operation defined in the \p mode
266 * parameter (encrypt/decrypt), on the input data buffer
267 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000268 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100269 * Due to the nature of CTR, you must use the same key schedule
270 * for both encryption and decryption operations. Therefore, you
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200271 * must use the context initialized with mbedtls_aria_setkey_enc()
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100272 * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000273 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100274 * \warning You must never reuse a nonce value with the same key. Doing so
275 * would void the encryption for the two messages encrypted with
276 * the same nonce and key.
277 *
278 * There are two common strategies for managing nonces with CTR:
279 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200280 * 1. You can handle everything as a single message processed over
281 * successive calls to this function. In that case, you want to
282 * set \p nonce_counter and \p nc_off to 0 for the first call, and
283 * then preserve the values of \p nonce_counter, \p nc_off and \p
284 * stream_block across calls to this function as they will be
285 * updated by this function.
286 *
287 * With this strategy, you must not encrypt more than 2**128
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200288 * blocks of data with the same key.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100289 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200290 * 2. You can encrypt separate messages by dividing the \p
291 * nonce_counter buffer in two areas: the first one used for a
292 * per-message nonce, handled by yourself, and the second one
293 * updated by this function internally.
294 *
295 * For example, you might reserve the first 12 bytes for the
296 * per-message nonce, and the last 4 bytes for internal use. In that
297 * case, before calling this function on a new message you need to
298 * set the first 12 bytes of \p nonce_counter to your chosen nonce
299 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
300 * stream_block to be ignored). That way, you can encrypt at most
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200301 * 2**96 messages of up to 2**32 blocks each with the same key.
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200302 *
303 * The per-message nonce (or information sufficient to reconstruct
304 * it) needs to be communicated with the ciphertext and must be unique.
305 * The recommended way to ensure uniqueness is to use a message
306 * counter. An alternative is to generate random nonces, but this
307 * limits the number of messages that can be securely encrypted:
308 * for example, with 96-bit random nonces, you should not encrypt
309 * more than 2**32 messages with the same key.
310 *
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200311 * Note that for both stategies, sizes are measured in blocks and
312 * that an ARIA block is 16 bytes.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000313 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200314 * \warning Upon return, \p stream_block contains sensitive data. Its
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200315 * content must not be written to insecure storage and should be
316 * securely discarded as soon as it's no longer needed.
317 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100318 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500319 * This must be initialized and bound to a key.
320 * \param length The length of the input data \p input in Bytes.
321 * \param nc_off The offset in Bytes in the current \p stream_block,
322 * for resuming within the current cipher stream. The
323 * offset pointer should be \c 0 at the start of a
324 * stream. This must not be larger than \c 15 Bytes.
325 * \param nonce_counter The 128-bit nonce and counter. This must point to
326 * a read/write buffer of length \c 16 bytes.
327 * \param stream_block The saved stream block for resuming. This must
328 * point to a read/write buffer of length \c 16 bytes.
329 * This is overwritten by the function.
330 * \param input The buffer holding the input data. This must
331 * be a readable buffer of length \p length Bytes.
332 * \param output The buffer holding the output data. This must
333 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100334 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500335 * \return \c 0 on success.
336 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000337 */
338int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100339 size_t length,
340 size_t *nc_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100341 unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
342 unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100343 const unsigned char *input,
344 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000345#endif /* MBEDTLS_CIPHER_MODE_CTR */
346
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200347#if defined(MBEDTLS_SELF_TEST)
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000348/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100349 * \brief Checkup routine.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000350 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100351 * \return \c 0 on success, or \c 1 on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000352 */
353int mbedtls_aria_self_test( int verbose );
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200354#endif /* MBEDTLS_SELF_TEST */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000355
356#ifdef __cplusplus
357}
358#endif
359
360#endif /* aria.h */