blob: 08547068c70616f08b8df8a5c8b0ab8e7370f70c [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
Bence Szépkútic662b362021-05-27 11:25:03 +020033#include "mbedtls/build_info.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000034
35#include <stddef.h>
36#include <stdint.h>
37
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010038#include "mbedtls/platform_util.h"
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050039
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010040#define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */
41#define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000042
Manuel Pégourié-Gonnard8abc3492018-03-01 10:02:47 +010043#define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */
44#define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */
45#define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010046
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050047#define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C /**< Bad input data. */
48
49#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030050
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000051#ifdef __cplusplus
52extern "C" {
53#endif
54
Gilles Peskine59392b02021-05-24 22:58:37 +020055#if !defined(MBEDTLS_ARIA_ALT)
56// Regular implementation
57//
58
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000059/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010060 * \brief The ARIA context-type definition.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000061 */
Dawid Drozd428cc522018-07-24 10:02:47 +020062typedef struct mbedtls_aria_context
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000063{
Mateusz Starzyk846f0212021-05-19 19:44:07 +020064 unsigned char MBEDTLS_PRIVATE(nr); /*!< The number of rounds (12, 14 or 16) */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010065 /*! The ARIA round keys. */
Mateusz Starzyk846f0212021-05-19 19:44:07 +020066 uint32_t MBEDTLS_PRIVATE(rk)[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4];
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000067}
68mbedtls_aria_context;
69
Manuel Pégourié-Gonnard0960b802018-05-22 15:22:07 +020070#else /* MBEDTLS_ARIA_ALT */
71#include "aria_alt.h"
72#endif /* MBEDTLS_ARIA_ALT */
73
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000074/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010075 * \brief This function initializes the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000076 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010077 * It must be the first API called before using
78 * the context.
79 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050080 * \param ctx The ARIA context to initialize. This must not be \c NULL.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000081 */
82void mbedtls_aria_init( mbedtls_aria_context *ctx );
83
84/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010085 * \brief This function releases and clears the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000086 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050087 * \param ctx The ARIA context to clear. This may be \c NULL, in which
88 * case this function returns immediately. If it is not \c NULL,
89 * it must point to an initialized ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000090 */
91void mbedtls_aria_free( mbedtls_aria_context *ctx );
92
93/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010094 * \brief This function sets the encryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000095 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010096 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050097 * This must be initialized.
98 * \param key The encryption key. This must be a readable buffer
99 * of size \p keybits Bits.
100 * \param keybits The size of \p key in Bits. Valid options are:
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100101 * <ul><li>128 bits</li>
102 * <li>192 bits</li>
103 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000104 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500105 * \return \c 0 on success.
106 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000107 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100108int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
109 const unsigned char *key,
110 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000111
112/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100113 * \brief This function sets the decryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000114 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100115 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500116 * This must be initialized.
117 * \param key The decryption key. This must be a readable buffer
118 * of size \p keybits Bits.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100119 * \param keybits The size of data passed. Valid options are:
120 * <ul><li>128 bits</li>
121 * <li>192 bits</li>
122 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000123 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500124 * \return \c 0 on success.
125 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000126 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100127int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
128 const unsigned char *key,
129 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000130
131/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100132 * \brief This function performs an ARIA single-block encryption or
133 * decryption operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000134 *
Manuel Pégourié-Gonnard08c337d2018-05-22 13:18:01 +0200135 * It performs encryption or decryption (depending on whether
136 * the key was set for encryption on decryption) on the input
137 * data buffer defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000138 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200139 * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or
140 * mbedtls_aria_setkey_dec() must be called before the first
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100141 * call to this API with the same context.
142 *
143 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500144 * This must be initialized and bound to a key.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100145 * \param input The 16-Byte buffer holding the input data.
146 * \param output The 16-Byte buffer holding the output data.
147
148 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500149 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000150 */
151int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100152 const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
153 unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000154
155#if defined(MBEDTLS_CIPHER_MODE_CBC)
156/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100157 * \brief This function performs an ARIA-CBC encryption or decryption operation
158 * on full blocks.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000159 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100160 * It performs the operation defined in the \p mode
161 * parameter (encrypt/decrypt), on the input data buffer defined in
162 * the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000163 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100164 * It can be called as many times as needed, until all the input
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200165 * data is processed. mbedtls_aria_init(), and either
166 * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100167 * before the first call to this API with the same context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000168 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100169 * \note This function operates on aligned blocks, that is, the input size
170 * must be a multiple of the ARIA block size of 16 Bytes.
171 *
172 * \note Upon exit, the content of the IV is updated so that you can
173 * call the same function again on the next
174 * block(s) of data and get the same result as if it was
175 * encrypted in one call. This allows a "streaming" usage.
176 * If you need to retain the contents of the IV, you should
177 * either save it manually or use the cipher module instead.
178 *
179 *
180 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500181 * This must be initialized and bound to a key.
182 * \param mode The mode of operation. This must be either
183 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
184 * #MBEDTLS_ARIA_DECRYPT for decryption.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100185 * \param length The length of the input data in Bytes. This must be a
186 * multiple of the block size (16 Bytes).
187 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500188 * This must be a readable buffer of size 16 Bytes.
189 * \param input The buffer holding the input data. This must
190 * be a readable buffer of length \p length Bytes.
191 * \param output The buffer holding the output data. This must
192 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100193 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500194 * \return \c 0 on success.
195 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000196 */
197int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100198 int mode,
199 size_t length,
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100200 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100201 const unsigned char *input,
202 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000203#endif /* MBEDTLS_CIPHER_MODE_CBC */
204
205#if defined(MBEDTLS_CIPHER_MODE_CFB)
206/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100207 * \brief This function performs an ARIA-CFB128 encryption or decryption
208 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000209 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100210 * It performs the operation defined in the \p mode
211 * parameter (encrypt or decrypt), on the input data buffer
212 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000213 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200214 * For CFB, you must set up the context with mbedtls_aria_setkey_enc(),
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100215 * regardless of whether you are performing an encryption or decryption
216 * operation, that is, regardless of the \p mode parameter. This is
217 * because CFB mode uses the same key schedule for encryption and
218 * decryption.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000219 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100220 * \note Upon exit, the content of the IV is updated so that you can
221 * call the same function again on the next
222 * block(s) of data and get the same result as if it was
223 * encrypted in one call. This allows a "streaming" usage.
224 * If you need to retain the contents of the
225 * IV, you must either save it manually or use the cipher
226 * module instead.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000227 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100228 *
229 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500230 * This must be initialized and bound to a key.
231 * \param mode The mode of operation. This must be either
232 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
233 * #MBEDTLS_ARIA_DECRYPT for decryption.
234 * \param length The length of the input data \p input in Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100235 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500236 * This must not be larger than 15.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100237 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500238 * This must be a readable buffer of size 16 Bytes.
239 * \param input The buffer holding the input data. This must
240 * be a readable buffer of length \p length Bytes.
241 * \param output The buffer holding the output data. This must
242 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100243 *
244 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500245 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000246 */
247int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100248 int mode,
249 size_t length,
250 size_t *iv_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100251 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100252 const unsigned char *input,
253 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000254#endif /* MBEDTLS_CIPHER_MODE_CFB */
255
256#if defined(MBEDTLS_CIPHER_MODE_CTR)
257/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100258 * \brief This function performs an ARIA-CTR encryption or decryption
259 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000260 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100261 * This function performs the operation defined in the \p mode
262 * parameter (encrypt/decrypt), on the input data buffer
263 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000264 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100265 * Due to the nature of CTR, you must use the same key schedule
266 * for both encryption and decryption operations. Therefore, you
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200267 * must use the context initialized with mbedtls_aria_setkey_enc()
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100268 * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000269 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100270 * \warning You must never reuse a nonce value with the same key. Doing so
271 * would void the encryption for the two messages encrypted with
272 * the same nonce and key.
273 *
274 * There are two common strategies for managing nonces with CTR:
275 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200276 * 1. You can handle everything as a single message processed over
277 * successive calls to this function. In that case, you want to
278 * set \p nonce_counter and \p nc_off to 0 for the first call, and
279 * then preserve the values of \p nonce_counter, \p nc_off and \p
280 * stream_block across calls to this function as they will be
281 * updated by this function.
282 *
283 * With this strategy, you must not encrypt more than 2**128
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200284 * blocks of data with the same key.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100285 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200286 * 2. You can encrypt separate messages by dividing the \p
287 * nonce_counter buffer in two areas: the first one used for a
288 * per-message nonce, handled by yourself, and the second one
289 * updated by this function internally.
290 *
291 * For example, you might reserve the first 12 bytes for the
292 * per-message nonce, and the last 4 bytes for internal use. In that
293 * case, before calling this function on a new message you need to
294 * set the first 12 bytes of \p nonce_counter to your chosen nonce
295 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
296 * stream_block to be ignored). That way, you can encrypt at most
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200297 * 2**96 messages of up to 2**32 blocks each with the same key.
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200298 *
299 * The per-message nonce (or information sufficient to reconstruct
300 * it) needs to be communicated with the ciphertext and must be unique.
301 * The recommended way to ensure uniqueness is to use a message
302 * counter. An alternative is to generate random nonces, but this
303 * limits the number of messages that can be securely encrypted:
304 * for example, with 96-bit random nonces, you should not encrypt
305 * more than 2**32 messages with the same key.
306 *
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200307 * Note that for both stategies, sizes are measured in blocks and
308 * that an ARIA block is 16 bytes.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000309 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200310 * \warning Upon return, \p stream_block contains sensitive data. Its
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200311 * content must not be written to insecure storage and should be
312 * securely discarded as soon as it's no longer needed.
313 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100314 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500315 * This must be initialized and bound to a key.
316 * \param length The length of the input data \p input in Bytes.
317 * \param nc_off The offset in Bytes in the current \p stream_block,
318 * for resuming within the current cipher stream. The
319 * offset pointer should be \c 0 at the start of a
320 * stream. This must not be larger than \c 15 Bytes.
321 * \param nonce_counter The 128-bit nonce and counter. This must point to
322 * a read/write buffer of length \c 16 bytes.
323 * \param stream_block The saved stream block for resuming. This must
324 * point to a read/write buffer of length \c 16 bytes.
325 * This is overwritten by the function.
326 * \param input The buffer holding the input data. This must
327 * be a readable buffer of length \p length Bytes.
328 * \param output The buffer holding the output data. This must
329 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100330 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500331 * \return \c 0 on success.
332 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000333 */
334int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100335 size_t length,
336 size_t *nc_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100337 unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
338 unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100339 const unsigned char *input,
340 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000341#endif /* MBEDTLS_CIPHER_MODE_CTR */
342
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200343#if defined(MBEDTLS_SELF_TEST)
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000344/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100345 * \brief Checkup routine.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000346 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100347 * \return \c 0 on success, or \c 1 on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000348 */
349int mbedtls_aria_self_test( int verbose );
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200350#endif /* MBEDTLS_SELF_TEST */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000351
352#ifdef __cplusplus
353}
354#endif
355
356#endif /* aria.h */