blob: c685fc314127b05d1bf2fafa4c1518966e0a4564 [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
Dave Rodgman16799db2023-11-02 19:47:20 +000014 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000015 */
16
17#ifndef MBEDTLS_ARIA_H
18#define MBEDTLS_ARIA_H
Mateusz Starzyk846f0212021-05-19 19:44:07 +020019#include "mbedtls/private_access.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000020
Bence Szépkútic662b362021-05-27 11:25:03 +020021#include "mbedtls/build_info.h"
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000022
23#include <stddef.h>
24#include <stdint.h>
25
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010026#include "mbedtls/platform_util.h"
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050027
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010028#define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */
29#define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000030
Manuel Pégourié-Gonnard8abc3492018-03-01 10:02:47 +010031#define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */
Shaun Case8b0ecbc2021-12-20 21:14:10 -080032#define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maximum number of rounds in ARIA. */
Manuel Pégourié-Gonnard8abc3492018-03-01 10:02:47 +010033#define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010034
Gilles Peskined2971572021-07-26 18:48:10 +020035/** Bad input data. */
36#define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050037
Gilles Peskined2971572021-07-26 18:48:10 +020038/** Invalid data input length. */
39#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E
Ron Eldor9924bdc2018-10-04 10:59:13 +030040
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000041#ifdef __cplusplus
42extern "C" {
43#endif
44
Gilles Peskine59392b02021-05-24 22:58:37 +020045#if !defined(MBEDTLS_ARIA_ALT)
46// Regular implementation
47//
48
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000049/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010050 * \brief The ARIA context-type definition.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000051 */
Gilles Peskine449bd832023-01-11 14:50:10 +010052typedef struct mbedtls_aria_context {
Mateusz Starzyk846f0212021-05-19 19:44:07 +020053 unsigned char MBEDTLS_PRIVATE(nr); /*!< The number of rounds (12, 14 or 16) */
Manuel Pégourié-Gonnard5ad88b62018-03-01 09:20:47 +010054 /*! The ARIA round keys. */
Mateusz Starzyk846f0212021-05-19 19:44:07 +020055 uint32_t MBEDTLS_PRIVATE(rk)[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4];
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000056}
57mbedtls_aria_context;
58
Manuel Pégourié-Gonnard0960b802018-05-22 15:22:07 +020059#else /* MBEDTLS_ARIA_ALT */
60#include "aria_alt.h"
61#endif /* MBEDTLS_ARIA_ALT */
62
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000063/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010064 * \brief This function initializes the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000065 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010066 * It must be the first API called before using
67 * the context.
68 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050069 * \param ctx The ARIA context to initialize. This must not be \c NULL.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000070 */
Gilles Peskine449bd832023-01-11 14:50:10 +010071void mbedtls_aria_init(mbedtls_aria_context *ctx);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000072
73/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010074 * \brief This function releases and clears the specified ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000075 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050076 * \param ctx The ARIA context to clear. This may be \c NULL, in which
77 * case this function returns immediately. If it is not \c NULL,
78 * it must point to an initialized ARIA context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000079 */
Gilles Peskine449bd832023-01-11 14:50:10 +010080void mbedtls_aria_free(mbedtls_aria_context *ctx);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000081
82/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010083 * \brief This function sets the encryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000084 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010085 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050086 * This must be initialized.
87 * \param key The encryption key. This must be a readable buffer
88 * of size \p keybits Bits.
89 * \param keybits The size of \p key in Bits. Valid options are:
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +010090 * <ul><li>128 bits</li>
91 * <li>192 bits</li>
92 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000093 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -050094 * \return \c 0 on success.
95 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +000096 */
Gilles Peskine449bd832023-01-11 14:50:10 +010097int mbedtls_aria_setkey_enc(mbedtls_aria_context *ctx,
98 const unsigned char *key,
99 unsigned int keybits);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000100
Yanray Wangb67b4742023-10-31 17:10:32 +0800101#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000102/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100103 * \brief This function sets the decryption key.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000104 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100105 * \param ctx The ARIA context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500106 * This must be initialized.
107 * \param key The decryption key. This must be a readable buffer
108 * of size \p keybits Bits.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100109 * \param keybits The size of data passed. Valid options are:
110 * <ul><li>128 bits</li>
111 * <li>192 bits</li>
112 * <li>256 bits</li></ul>
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000113 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500114 * \return \c 0 on success.
115 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000116 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100117int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx,
118 const unsigned char *key,
119 unsigned int keybits);
Yanray Wangb67b4742023-10-31 17:10:32 +0800120#endif /* !MBEDTLS_BLOCK_CIPHER_NO_DECRYPT */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000121
122/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100123 * \brief This function performs an ARIA single-block encryption or
124 * decryption operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000125 *
Manuel Pégourié-Gonnard08c337d2018-05-22 13:18:01 +0200126 * It performs encryption or decryption (depending on whether
127 * the key was set for encryption on decryption) on the input
128 * data buffer defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000129 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200130 * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or
131 * mbedtls_aria_setkey_dec() must be called before the first
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100132 * call to this API with the same context.
133 *
134 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500135 * This must be initialized and bound to a key.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100136 * \param input The 16-Byte buffer holding the input data.
137 * \param output The 16-Byte buffer holding the output data.
138
139 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500140 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000141 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100142int mbedtls_aria_crypt_ecb(mbedtls_aria_context *ctx,
143 const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
144 unsigned char output[MBEDTLS_ARIA_BLOCKSIZE]);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000145
146#if defined(MBEDTLS_CIPHER_MODE_CBC)
147/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100148 * \brief This function performs an ARIA-CBC encryption or decryption operation
149 * on full blocks.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000150 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100151 * It performs the operation defined in the \p mode
152 * parameter (encrypt/decrypt), on the input data buffer defined in
153 * the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000154 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100155 * It can be called as many times as needed, until all the input
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200156 * data is processed. mbedtls_aria_init(), and either
157 * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100158 * before the first call to this API with the same context.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000159 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100160 * \note This function operates on aligned blocks, that is, the input size
161 * must be a multiple of the ARIA block size of 16 Bytes.
162 *
163 * \note Upon exit, the content of the IV is updated so that you can
164 * call the same function again on the next
165 * block(s) of data and get the same result as if it was
166 * encrypted in one call. This allows a "streaming" usage.
167 * If you need to retain the contents of the IV, you should
168 * either save it manually or use the cipher module instead.
169 *
170 *
171 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500172 * This must be initialized and bound to a key.
173 * \param mode The mode of operation. This must be either
174 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
175 * #MBEDTLS_ARIA_DECRYPT for decryption.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100176 * \param length The length of the input data in Bytes. This must be a
177 * multiple of the block size (16 Bytes).
178 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500179 * This must be a readable buffer of size 16 Bytes.
180 * \param input The buffer holding the input data. This must
181 * be a readable buffer of length \p length Bytes.
182 * \param output The buffer holding the output data. This must
183 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100184 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500185 * \return \c 0 on success.
186 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000187 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100188int mbedtls_aria_crypt_cbc(mbedtls_aria_context *ctx,
189 int mode,
190 size_t length,
191 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
192 const unsigned char *input,
193 unsigned char *output);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000194#endif /* MBEDTLS_CIPHER_MODE_CBC */
195
196#if defined(MBEDTLS_CIPHER_MODE_CFB)
197/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100198 * \brief This function performs an ARIA-CFB128 encryption or decryption
199 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000200 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100201 * It performs the operation defined in the \p mode
202 * parameter (encrypt or decrypt), on the input data buffer
203 * defined in the \p input parameter.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000204 *
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200205 * For CFB, you must set up the context with mbedtls_aria_setkey_enc(),
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100206 * regardless of whether you are performing an encryption or decryption
207 * operation, that is, regardless of the \p mode parameter. This is
208 * because CFB mode uses the same key schedule for encryption and
209 * decryption.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000210 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100211 * \note Upon exit, the content of the IV is updated so that you can
212 * call the same function again on the next
213 * block(s) of data and get the same result as if it was
214 * encrypted in one call. This allows a "streaming" usage.
215 * If you need to retain the contents of the
216 * IV, you must either save it manually or use the cipher
217 * module instead.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000218 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100219 *
220 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500221 * This must be initialized and bound to a key.
222 * \param mode The mode of operation. This must be either
223 * #MBEDTLS_ARIA_ENCRYPT for encryption, or
224 * #MBEDTLS_ARIA_DECRYPT for decryption.
225 * \param length The length of the input data \p input in Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100226 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500227 * This must not be larger than 15.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100228 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500229 * This must be a readable buffer of size 16 Bytes.
230 * \param input The buffer holding the input data. This must
231 * be a readable buffer of length \p length Bytes.
232 * \param output The buffer holding the output data. This must
233 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100234 *
235 * \return \c 0 on success.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500236 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000237 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100238int mbedtls_aria_crypt_cfb128(mbedtls_aria_context *ctx,
239 int mode,
240 size_t length,
241 size_t *iv_off,
242 unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
243 const unsigned char *input,
244 unsigned char *output);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000245#endif /* MBEDTLS_CIPHER_MODE_CFB */
246
247#if defined(MBEDTLS_CIPHER_MODE_CTR)
248/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100249 * \brief This function performs an ARIA-CTR encryption or decryption
250 * operation.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000251 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100252 * Due to the nature of CTR, you must use the same key schedule
253 * for both encryption and decryption operations. Therefore, you
Manuel Pégourié-Gonnard9d410732018-05-22 12:49:22 +0200254 * must use the context initialized with mbedtls_aria_setkey_enc()
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100255 * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000256 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100257 * \warning You must never reuse a nonce value with the same key. Doing so
258 * would void the encryption for the two messages encrypted with
259 * the same nonce and key.
260 *
261 * There are two common strategies for managing nonces with CTR:
262 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200263 * 1. You can handle everything as a single message processed over
264 * successive calls to this function. In that case, you want to
265 * set \p nonce_counter and \p nc_off to 0 for the first call, and
266 * then preserve the values of \p nonce_counter, \p nc_off and \p
267 * stream_block across calls to this function as they will be
268 * updated by this function.
269 *
270 * With this strategy, you must not encrypt more than 2**128
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200271 * blocks of data with the same key.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100272 *
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200273 * 2. You can encrypt separate messages by dividing the \p
274 * nonce_counter buffer in two areas: the first one used for a
275 * per-message nonce, handled by yourself, and the second one
276 * updated by this function internally.
277 *
278 * For example, you might reserve the first 12 bytes for the
279 * per-message nonce, and the last 4 bytes for internal use. In that
280 * case, before calling this function on a new message you need to
281 * set the first 12 bytes of \p nonce_counter to your chosen nonce
282 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
283 * stream_block to be ignored). That way, you can encrypt at most
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200284 * 2**96 messages of up to 2**32 blocks each with the same key.
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200285 *
286 * The per-message nonce (or information sufficient to reconstruct
287 * it) needs to be communicated with the ciphertext and must be unique.
288 * The recommended way to ensure uniqueness is to use a message
289 * counter. An alternative is to generate random nonces, but this
290 * limits the number of messages that can be securely encrypted:
291 * for example, with 96-bit random nonces, you should not encrypt
292 * more than 2**32 messages with the same key.
293 *
Tom Cosgrove1e211442022-05-26 11:51:00 +0100294 * Note that for both strategies, sizes are measured in blocks and
Manuel Pégourié-Gonnardf5842862018-05-24 11:51:58 +0200295 * that an ARIA block is 16 bytes.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000296 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200297 * \warning Upon return, \p stream_block contains sensitive data. Its
Manuel Pégourié-Gonnard8a1b2c82018-05-23 13:26:22 +0200298 * content must not be written to insecure storage and should be
299 * securely discarded as soon as it's no longer needed.
300 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100301 * \param ctx The ARIA context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500302 * This must be initialized and bound to a key.
303 * \param length The length of the input data \p input in Bytes.
304 * \param nc_off The offset in Bytes in the current \p stream_block,
305 * for resuming within the current cipher stream. The
306 * offset pointer should be \c 0 at the start of a
307 * stream. This must not be larger than \c 15 Bytes.
308 * \param nonce_counter The 128-bit nonce and counter. This must point to
309 * a read/write buffer of length \c 16 bytes.
310 * \param stream_block The saved stream block for resuming. This must
311 * point to a read/write buffer of length \c 16 bytes.
312 * This is overwritten by the function.
313 * \param input The buffer holding the input data. This must
314 * be a readable buffer of length \p length Bytes.
315 * \param output The buffer holding the output data. This must
316 * be a writable buffer of length \p length Bytes.
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100317 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500318 * \return \c 0 on success.
319 * \return A negative error code on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000320 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100321int mbedtls_aria_crypt_ctr(mbedtls_aria_context *ctx,
322 size_t length,
323 size_t *nc_off,
324 unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
325 unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
326 const unsigned char *input,
327 unsigned char *output);
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000328#endif /* MBEDTLS_CIPHER_MODE_CTR */
329
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200330#if defined(MBEDTLS_SELF_TEST)
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000331/**
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100332 * \brief Checkup routine.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000333 *
Manuel Pégourié-Gonnard5aa4e3b2018-02-28 11:55:49 +0100334 * \return \c 0 on success, or \c 1 on failure.
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000335 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100336int mbedtls_aria_self_test(int verbose);
Manuel Pégourié-Gonnardc0893122018-05-22 15:17:20 +0200337#endif /* MBEDTLS_SELF_TEST */
Markku-Juhani O. Saarinen41efbaa2017-11-30 11:37:55 +0000338
339#ifdef __cplusplus
340}
341#endif
342
343#endif /* aria.h */