blob: 7dd960f29a26fd8fdd86df6ecb90914bfb738a7d [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
31
32#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010033#include "mbedtls/config.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000034#else
35#include MBEDTLS_CONFIG_FILE
36#endif
37
38#include <stddef.h>
39#include <stdint.h>
40
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010041#include "mbedtls/platform_util.h"
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050042
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010043#define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */
44#define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000045
Manuel Pégourié-Gonnard8abc3492018-03-01 10:02:47 +010046#define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */
47#define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */
48#define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010049
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050050#define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C /**< Bad input data. */
51
52#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030053
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000054#if !defined(MBEDTLS_ARIA_ALT)
55// Regular implementation
56//
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010063 * \brief The ARIA context-type definition.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000064 */
Dawid Drozd428cc522018-07-24 10:02:47 +020065typedef struct mbedtls_aria_context
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000066{
Manuel Pégourié-Gonnard906bc902018-03-01 09:39:01 +010067 unsigned char nr; /*!< The number of rounds (12, 14 or 16) */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010068 /*! The ARIA round keys. */
69 uint32_t rk[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4];
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000070}
71mbedtls_aria_context;
72
Manuel Pégourié-Gonnard0960b802018-05-22 15:22:07 +020073#else /* MBEDTLS_ARIA_ALT */
74#include "aria_alt.h"
75#endif /* MBEDTLS_ARIA_ALT */
76
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000077/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010078 * \brief This function initializes the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000079 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010080 * It must be the first API called before using
81 * the context.
82 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050083 * \param ctx The ARIA context to initialize. This must not be \c NULL.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000084 */
85void mbedtls_aria_init( mbedtls_aria_context *ctx );
86
87/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010088 * \brief This function releases and clears the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000089 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050090 * \param ctx The ARIA context to clear. This may be \c NULL, in which
91 * case this function returns immediately. If it is not \c NULL,
92 * it must point to an initialized ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000093 */
94void mbedtls_aria_free( mbedtls_aria_context *ctx );
95
96/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010097 * \brief This function sets the encryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000098 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010099 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500100 * This must be initialized.
101 * \param key The encryption key. This must be a readable buffer
102 * of size \p keybits Bits.
103 * \param keybits The size of \p key in Bits. Valid options are:
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100104 * <ul><li>128 bits</li>
105 * <li>192 bits</li>
106 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000107 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500108 * \return \c 0 on success.
109 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000110 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100111int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
112 const unsigned char *key,
113 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000114
115/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100116 * \brief This function sets the decryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000117 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100118 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500119 * This must be initialized.
120 * \param key The decryption key. This must be a readable buffer
121 * of size \p keybits Bits.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100122 * \param keybits The size of data passed. Valid options are:
123 * <ul><li>128 bits</li>
124 * <li>192 bits</li>
125 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000126 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500127 * \return \c 0 on success.
128 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000129 */
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100130int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
131 const unsigned char *key,
132 unsigned int keybits );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000133
134/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100135 * \brief This function performs an ARIA single-block encryption or
136 * decryption operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000137 *
Manuel Pégourié-Gonnard08c337d2018-05-22 13:18:01 +0200138 * It performs encryption or decryption (depending on whether
139 * the key was set for encryption on decryption) on the input
140 * data buffer defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000141 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200142 * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or
143 * mbedtls_aria_setkey_dec() must be called before the first
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100144 * call to this API with the same context.
145 *
146 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500147 * This must be initialized and bound to a key.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100148 * \param input The 16-Byte buffer holding the input data.
149 * \param output The 16-Byte buffer holding the output data.
150
151 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500152 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000153 */
154int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100155 const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
156 unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000157
158#if defined(MBEDTLS_CIPHER_MODE_CBC)
159/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100160 * \brief This function performs an ARIA-CBC encryption or decryption operation
161 * on full blocks.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000162 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100163 * It performs the operation defined in the \p mode
164 * parameter (encrypt/decrypt), on the input data buffer defined in
165 * the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000166 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100167 * It can be called as many times as needed, until all the input
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200168 * data is processed. mbedtls_aria_init(), and either
169 * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100170 * before the first call to this API with the same context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000171 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100172 * \note This function operates on aligned blocks, that is, the input size
173 * must be a multiple of the ARIA block size of 16 Bytes.
174 *
175 * \note Upon exit, the content of the IV is updated so that you can
176 * call the same function again on the next
177 * block(s) of data and get the same result as if it was
178 * encrypted in one call. This allows a "streaming" usage.
179 * If you need to retain the contents of the IV, you should
180 * either save it manually or use the cipher module instead.
181 *
182 *
183 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500184 * This must be initialized and bound to a key.
185 * \param mode The mode of operation. This must be either
186 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
187 * #MBEDTLS_ARIA_DECRYPT for decryption.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100188 * \param length The length of the input data in Bytes. This must be a
189 * multiple of the block size (16 Bytes).
190 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500191 * This must be a readable buffer of size 16 Bytes.
192 * \param input The buffer holding the input data. This must
193 * be a readable buffer of length \p length Bytes.
194 * \param output The buffer holding the output data. This must
195 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100196 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500197 * \return \c 0 on success.
198 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000199 */
200int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100201 int mode,
202 size_t length,
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100203 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100204 const unsigned char *input,
205 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000206#endif /* MBEDTLS_CIPHER_MODE_CBC */
207
208#if defined(MBEDTLS_CIPHER_MODE_CFB)
209/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100210 * \brief This function performs an ARIA-CFB128 encryption or decryption
211 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000212 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100213 * It performs the operation defined in the \p mode
214 * parameter (encrypt or decrypt), on the input data buffer
215 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000216 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200217 * For CFB, you must set up the context with mbedtls_aria_setkey_enc(),
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100218 * regardless of whether you are performing an encryption or decryption
219 * operation, that is, regardless of the \p mode parameter. This is
220 * because CFB mode uses the same key schedule for encryption and
221 * decryption.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000222 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100223 * \note Upon exit, the content of the IV is updated so that you can
224 * call the same function again on the next
225 * block(s) of data and get the same result as if it was
226 * encrypted in one call. This allows a "streaming" usage.
227 * If you need to retain the contents of the
228 * IV, you must either save it manually or use the cipher
229 * module instead.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000230 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100231 *
232 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500233 * This must be initialized and bound to a key.
234 * \param mode The mode of operation. This must be either
235 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
236 * #MBEDTLS_ARIA_DECRYPT for decryption.
237 * \param length The length of the input data \p input in Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100238 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500239 * This must not be larger than 15.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100240 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500241 * This must be a readable buffer of size 16 Bytes.
242 * \param input The buffer holding the input data. This must
243 * be a readable buffer of length \p length Bytes.
244 * \param output The buffer holding the output data. This must
245 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100246 *
247 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500248 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000249 */
250int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100251 int mode,
252 size_t length,
253 size_t *iv_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100254 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100255 const unsigned char *input,
256 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000257#endif /* MBEDTLS_CIPHER_MODE_CFB */
258
259#if defined(MBEDTLS_CIPHER_MODE_CTR)
260/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100261 * \brief This function performs an ARIA-CTR encryption or decryption
262 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000263 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100264 * This function performs the operation defined in the \p mode
265 * parameter (encrypt/decrypt), on the input data buffer
266 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000267 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100268 * Due to the nature of CTR, you must use the same key schedule
269 * for both encryption and decryption operations. Therefore, you
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200270 * must use the context initialized with mbedtls_aria_setkey_enc()
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100271 * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000272 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100273 * \warning You must never reuse a nonce value with the same key. Doing so
274 * would void the encryption for the two messages encrypted with
275 * the same nonce and key.
276 *
277 * There are two common strategies for managing nonces with CTR:
278 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200279 * 1. You can handle everything as a single message processed over
280 * successive calls to this function. In that case, you want to
281 * set \p nonce_counter and \p nc_off to 0 for the first call, and
282 * then preserve the values of \p nonce_counter, \p nc_off and \p
283 * stream_block across calls to this function as they will be
284 * updated by this function.
285 *
286 * With this strategy, you must not encrypt more than 2**128
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200287 * blocks of data with the same key.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100288 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200289 * 2. You can encrypt separate messages by dividing the \p
290 * nonce_counter buffer in two areas: the first one used for a
291 * per-message nonce, handled by yourself, and the second one
292 * updated by this function internally.
293 *
294 * For example, you might reserve the first 12 bytes for the
295 * per-message nonce, and the last 4 bytes for internal use. In that
296 * case, before calling this function on a new message you need to
297 * set the first 12 bytes of \p nonce_counter to your chosen nonce
298 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
299 * stream_block to be ignored). That way, you can encrypt at most
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200300 * 2**96 messages of up to 2**32 blocks each with the same key.
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200301 *
302 * The per-message nonce (or information sufficient to reconstruct
303 * it) needs to be communicated with the ciphertext and must be unique.
304 * The recommended way to ensure uniqueness is to use a message
305 * counter. An alternative is to generate random nonces, but this
306 * limits the number of messages that can be securely encrypted:
307 * for example, with 96-bit random nonces, you should not encrypt
308 * more than 2**32 messages with the same key.
309 *
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200310 * Note that for both stategies, sizes are measured in blocks and
311 * that an ARIA block is 16 bytes.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000312 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200313 * \warning Upon return, \p stream_block contains sensitive data. Its
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200314 * content must not be written to insecure storage and should be
315 * securely discarded as soon as it's no longer needed.
316 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100317 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500318 * This must be initialized and bound to a key.
319 * \param length The length of the input data \p input in Bytes.
320 * \param nc_off The offset in Bytes in the current \p stream_block,
321 * for resuming within the current cipher stream. The
322 * offset pointer should be \c 0 at the start of a
323 * stream. This must not be larger than \c 15 Bytes.
324 * \param nonce_counter The 128-bit nonce and counter. This must point to
325 * a read/write buffer of length \c 16 bytes.
326 * \param stream_block The saved stream block for resuming. This must
327 * point to a read/write buffer of length \c 16 bytes.
328 * This is overwritten by the function.
329 * \param input The buffer holding the input data. This must
330 * be a readable buffer of length \p length Bytes.
331 * \param output The buffer holding the output data. This must
332 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100333 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500334 * \return \c 0 on success.
335 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000336 */
337int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100338 size_t length,
339 size_t *nc_off,
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +0100340 unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
341 unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
Manuel Pégourié-Gonnard4231e7f2018-02-28 10:54:31 +0100342 const unsigned char *input,
343 unsigned char *output );
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000344#endif /* MBEDTLS_CIPHER_MODE_CTR */
345
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200346#if defined(MBEDTLS_SELF_TEST)
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000347/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100348 * \brief Checkup routine.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000349 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100350 * \return \c 0 on success, or \c 1 on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000351 */
352int mbedtls_aria_self_test( int verbose );
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200353#endif /* MBEDTLS_SELF_TEST */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000354
355#ifdef __cplusplus
356}
357#endif
358
359#endif /* aria.h */