blob: 052f47c9d1cc2a298b0c026a33fcaf0c79002311 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file aes.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +01004 * \brief This file contains AES definitions and functions.
5 *
6 * The Advanced Encryption Standard (AES) specifies a FIPS-approved
Rose Zadik7f441272018-01-22 11:48:23 +00007 * cryptographic algorithm that can be used to protect electronic
8 * data.
9 *
10 * The AES algorithm is a symmetric block cipher that can
11 * encrypt and decrypt information. For more information, see
12 * <em>FIPS Publication 197: Advanced Encryption Standard</em> and
13 * <em>ISO/IEC 18033-2:2006: Information technology -- Security
14 * techniques -- Encryption algorithms -- Part 2: Asymmetric
15 * ciphers</em>.
Jaeden Amerof167deb2018-05-30 19:20:48 +010016 *
17 * The AES-XTS block mode is standardized by NIST SP 800-38E
18 * <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf>
19 * and described in detail by IEEE P1619
20 * <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>.
Darryl Greena40a1012018-01-05 15:33:17 +000021 */
Rose Zadik5ad7aea2018-03-26 12:00:09 +010022
Bence Szépkúti86974652020-06-15 11:59:37 +020023/*
Bence Szépkúti1e148272020-08-07 13:07:28 +020024 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020025 * SPDX-License-Identifier: Apache-2.0
26 *
27 * Licensed under the Apache License, Version 2.0 (the "License"); you may
28 * not use this file except in compliance with the License.
29 * You may obtain a copy of the License at
30 *
31 * http://www.apache.org/licenses/LICENSE-2.0
32 *
33 * Unless required by applicable law or agreed to in writing, software
34 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
35 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 * See the License for the specific language governing permissions and
37 * limitations under the License.
Paul Bakker5121ce52009-01-03 21:22:43 +000038 */
Rose Zadik7f441272018-01-22 11:48:23 +000039
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020040#ifndef MBEDTLS_AES_H
41#define MBEDTLS_AES_H
Paul Bakker5121ce52009-01-03 21:22:43 +000042
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010044#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020045#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020046#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020047#endif
Paul Bakker90995b52013-06-24 19:20:35 +020048
Rich Evans00ab4702015-02-06 13:43:58 +000049#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020050#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000051
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010052/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000053#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
54#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000055
Andres Amaya Garciac5380642017-11-28 19:57:51 +000056/* Error codes in range 0x0020-0x0022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020057#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
58#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
Paul Bakker2b222c82009-07-27 21:03:45 +000059
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000060/* Error codes in range 0x0021-0x0025 */
61#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030062
63/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
Rose Zadik7f441272018-01-22 11:48:23 +000064#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030065
66/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
Gilles Peskine7ecab3d2018-01-26 17:56:38 +010067#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000068
Andres AGf5bf7182017-03-03 14:09:56 +000069#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
70 !defined(inline) && !defined(__cplusplus)
71#define inline __inline
72#endif
73
Paul Bakker407a0da2013-06-27 14:29:21 +020074#ifdef __cplusplus
75extern "C" {
76#endif
77
Ron Eldorb2aacec2017-05-18 16:53:08 +030078#if !defined(MBEDTLS_AES_ALT)
79// Regular implementation
80//
81
Paul Bakker5121ce52009-01-03 21:22:43 +000082/**
Rose Zadik7f441272018-01-22 11:48:23 +000083 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000084 */
Dawid Drozd428cc522018-07-24 10:02:47 +020085typedef struct mbedtls_aes_context
Paul Bakker5121ce52009-01-03 21:22:43 +000086{
Rose Zadik7f441272018-01-22 11:48:23 +000087 int nr; /*!< The number of rounds. */
88 uint32_t *rk; /*!< AES round keys. */
89 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
90 hold 32 extra Bytes, which can be used for
91 one of the following purposes:
92 <ul><li>Alignment if VIA padlock is
93 used.</li>
94 <li>Simplifying key expansion in the 256-bit
95 case by generating an extra round key.
96 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +000097}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020098mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000099
Jaeden Amero9366feb2018-05-29 18:55:17 +0100100#if defined(MBEDTLS_CIPHER_MODE_XTS)
101/**
102 * \brief The AES XTS context-type definition.
103 */
Dawid Drozd428cc522018-07-24 10:02:47 +0200104typedef struct mbedtls_aes_xts_context
Jaeden Amero9366feb2018-05-29 18:55:17 +0100105{
106 mbedtls_aes_context crypt; /*!< The AES context to use for AES block
107 encryption or decryption. */
108 mbedtls_aes_context tweak; /*!< The AES context used for tweak
109 computation. */
110} mbedtls_aes_xts_context;
111#endif /* MBEDTLS_CIPHER_MODE_XTS */
112
Ron Eldorb2aacec2017-05-18 16:53:08 +0300113#else /* MBEDTLS_AES_ALT */
114#include "aes_alt.h"
115#endif /* MBEDTLS_AES_ALT */
116
Paul Bakker5121ce52009-01-03 21:22:43 +0000117/**
Rose Zadik7f441272018-01-22 11:48:23 +0000118 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200119 *
Rose Zadik7f441272018-01-22 11:48:23 +0000120 * It must be the first API called before using
121 * the context.
122 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500123 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200124 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200125void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200126
127/**
Rose Zadik7f441272018-01-22 11:48:23 +0000128 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200129 *
Rose Zadik7f441272018-01-22 11:48:23 +0000130 * \param ctx The AES context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500131 * If this is \c NULL, this function does nothing.
132 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200133 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200134void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200135
Jaeden Amero9366feb2018-05-29 18:55:17 +0100136#if defined(MBEDTLS_CIPHER_MODE_XTS)
137/**
138 * \brief This function initializes the specified AES XTS context.
139 *
140 * It must be the first API called before using
141 * the context.
142 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500143 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100144 */
145void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
146
147/**
148 * \brief This function releases and clears the specified AES XTS context.
149 *
150 * \param ctx The AES XTS context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500151 * If this is \c NULL, this function does nothing.
152 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100153 */
154void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
155#endif /* MBEDTLS_CIPHER_MODE_XTS */
156
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200157/**
Rose Zadik7f441272018-01-22 11:48:23 +0000158 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000159 *
Rose Zadik7f441272018-01-22 11:48:23 +0000160 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500161 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000162 * \param key The encryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500163 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000164 * \param keybits The size of data passed in bits. Valid options are:
165 * <ul><li>128 bits</li>
166 * <li>192 bits</li>
167 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000168 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100169 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100170 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000171 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200172int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200173 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000174
175/**
Rose Zadik7f441272018-01-22 11:48:23 +0000176 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000177 *
Rose Zadik7f441272018-01-22 11:48:23 +0000178 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500179 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000180 * \param key The decryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500181 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000182 * \param keybits The size of data passed. Valid options are:
183 * <ul><li>128 bits</li>
184 * <li>192 bits</li>
185 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000186 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100187 * \return \c 0 on success.
188 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000189 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200191 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000192
Jaeden Amero9366feb2018-05-29 18:55:17 +0100193#if defined(MBEDTLS_CIPHER_MODE_XTS)
194/**
195 * \brief This function prepares an XTS context for encryption and
196 * sets the encryption key.
197 *
198 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500199 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100200 * \param key The encryption key. This is comprised of the XTS key1
201 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500202 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100203 * \param keybits The size of \p key passed in bits. Valid options are:
204 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
205 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
206 *
207 * \return \c 0 on success.
208 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
209 */
210int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
211 const unsigned char *key,
212 unsigned int keybits );
213
214/**
215 * \brief This function prepares an XTS context for decryption and
216 * sets the decryption key.
217 *
218 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500219 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100220 * \param key The decryption key. This is comprised of the XTS key1
221 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500222 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100223 * \param keybits The size of \p key passed in bits. Valid options are:
224 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
225 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
226 *
227 * \return \c 0 on success.
228 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
229 */
230int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
231 const unsigned char *key,
232 unsigned int keybits );
233#endif /* MBEDTLS_CIPHER_MODE_XTS */
234
Paul Bakker5121ce52009-01-03 21:22:43 +0000235/**
Rose Zadik7f441272018-01-22 11:48:23 +0000236 * \brief This function performs an AES single-block encryption or
237 * decryption operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000238 *
Rose Zadik7f441272018-01-22 11:48:23 +0000239 * It performs the operation defined in the \p mode parameter
240 * (encrypt or decrypt), on the input data buffer defined in
241 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000242 *
Rose Zadik7f441272018-01-22 11:48:23 +0000243 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
244 * mbedtls_aes_setkey_dec() must be called before the first
245 * call to this API with the same context.
246 *
247 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500248 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000249 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
250 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500251 * \param input The buffer holding the input data.
252 * It must be readable and at least \c 16 Bytes long.
253 * \param output The buffer where the output data will be written.
254 * It must be writeable and at least \c 16 Bytes long.
Rose Zadik7f441272018-01-22 11:48:23 +0000255
256 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000257 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200258int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000259 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000260 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000261 unsigned char output[16] );
262
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200263#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000264/**
Rose Zadik7f441272018-01-22 11:48:23 +0000265 * \brief This function performs an AES-CBC encryption or decryption operation
266 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000267 *
Rose Zadik7f441272018-01-22 11:48:23 +0000268 * It performs the operation defined in the \p mode
269 * parameter (encrypt/decrypt), on the input data buffer defined in
270 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000271 *
Rose Zadik7f441272018-01-22 11:48:23 +0000272 * It can be called as many times as needed, until all the input
273 * data is processed. mbedtls_aes_init(), and either
274 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
275 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000276 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500277 * \note This function operates on full blocks, that is, the input size
278 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000279 *
280 * \note Upon exit, the content of the IV is updated so that you can
281 * call the same function again on the next
282 * block(s) of data and get the same result as if it was
283 * encrypted in one call. This allows a "streaming" usage.
284 * If you need to retain the contents of the IV, you should
285 * either save it manually or use the cipher module instead.
286 *
287 *
288 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500289 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000290 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
291 * #MBEDTLS_AES_DECRYPT.
292 * \param length The length of the input data in Bytes. This must be a
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500293 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000294 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500295 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000296 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500297 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000298 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500299 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000300 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100301 * \return \c 0 on success.
302 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000303 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000304 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200305int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000306 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000307 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000308 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000309 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000310 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200311#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000312
Aorimn5f778012016-06-09 23:22:58 +0200313#if defined(MBEDTLS_CIPHER_MODE_XTS)
314/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100315 * \brief This function performs an AES-XTS encryption or decryption
316 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200317 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100318 * AES-XTS encrypts or decrypts blocks based on their location as
319 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100320 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200321 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100322 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
323 * AES blocks. If the data unit is larger than this, this function
324 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
325 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100326 * \param ctx The AES XTS context to use for AES XTS operations.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500327 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100328 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
329 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500330 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100331 * length between 16 bytes and 2^24 bytes inclusive
332 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100333 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100334 * bytes in little-endian format. For disk encryption, this
335 * is typically the index of the block device sector that
336 * contains the data.
337 * \param input The buffer holding the input data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500338 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100339 * input.
340 * \param output The buffer holding the output data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500341 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100342 * output.
Aorimn5f778012016-06-09 23:22:58 +0200343 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100344 * \return \c 0 on success.
345 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500346 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100347 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200348 */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100349int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
350 int mode,
Jaeden Amero5162b932018-05-29 12:55:24 +0100351 size_t length,
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100352 const unsigned char data_unit[16],
Jaeden Amero9366feb2018-05-29 18:55:17 +0100353 const unsigned char *input,
354 unsigned char *output );
Aorimn5f778012016-06-09 23:22:58 +0200355#endif /* MBEDTLS_CIPHER_MODE_XTS */
356
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200357#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000358/**
Rose Zadik7f441272018-01-22 11:48:23 +0000359 * \brief This function performs an AES-CFB128 encryption or decryption
360 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000361 *
Rose Zadik7f441272018-01-22 11:48:23 +0000362 * It performs the operation defined in the \p mode
363 * parameter (encrypt or decrypt), on the input data buffer
364 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000365 *
Rose Zadik7f441272018-01-22 11:48:23 +0000366 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
367 * regardless of whether you are performing an encryption or decryption
368 * operation, that is, regardless of the \p mode parameter. This is
369 * because CFB mode uses the same key schedule for encryption and
370 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000371 *
Rose Zadik7f441272018-01-22 11:48:23 +0000372 * \note Upon exit, the content of the IV is updated so that you can
373 * call the same function again on the next
374 * block(s) of data and get the same result as if it was
375 * encrypted in one call. This allows a "streaming" usage.
376 * If you need to retain the contents of the
377 * IV, you must either save it manually or use the cipher
378 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000379 *
Rose Zadik7f441272018-01-22 11:48:23 +0000380 *
381 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500382 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000383 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
384 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500385 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000386 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500387 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000388 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500389 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000390 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500391 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000392 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500393 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000394 *
395 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000396 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200397int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000398 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000399 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000400 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000401 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000402 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000403 unsigned char *output );
404
Paul Bakker9a736322012-11-14 12:39:52 +0000405/**
Rose Zadik7f441272018-01-22 11:48:23 +0000406 * \brief This function performs an AES-CFB8 encryption or decryption
407 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100408 *
Rose Zadik7f441272018-01-22 11:48:23 +0000409 * It performs the operation defined in the \p mode
410 * parameter (encrypt/decrypt), on the input data buffer defined
411 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100412 *
Rose Zadik7f441272018-01-22 11:48:23 +0000413 * Due to the nature of CFB, you must use the same key schedule for
414 * both encryption and decryption operations. Therefore, you must
415 * use the context initialized with mbedtls_aes_setkey_enc() for
416 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000417 *
Rose Zadik7f441272018-01-22 11:48:23 +0000418 * \note Upon exit, the content of the IV is updated so that you can
419 * call the same function again on the next
420 * block(s) of data and get the same result as if it was
421 * encrypted in one call. This allows a "streaming" usage.
422 * If you need to retain the contents of the
423 * IV, you should either save it manually or use the cipher
424 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100425 *
Rose Zadik7f441272018-01-22 11:48:23 +0000426 *
427 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500428 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000429 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
430 * #MBEDTLS_AES_DECRYPT
431 * \param length The length of the input data.
432 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500433 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000434 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500435 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000436 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500437 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000438 *
439 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100440 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200441int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100442 int mode,
443 size_t length,
444 unsigned char iv[16],
445 const unsigned char *input,
446 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200447#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100448
Simon Butcher76a5b222018-04-22 22:57:27 +0100449#if defined(MBEDTLS_CIPHER_MODE_OFB)
450/**
Simon Butcher5db13622018-06-04 22:11:25 +0100451 * \brief This function performs an AES-OFB (Output Feedback Mode)
452 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100453 *
Simon Butcher5db13622018-06-04 22:11:25 +0100454 * For OFB, you must set up the context with
455 * mbedtls_aes_setkey_enc(), regardless of whether you are
456 * performing an encryption or decryption operation. This is
457 * because OFB mode uses the same key schedule for encryption and
458 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100459 *
Simon Butcher5db13622018-06-04 22:11:25 +0100460 * The OFB operation is identical for encryption or decryption,
461 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100462 *
Simon Butcher5db13622018-06-04 22:11:25 +0100463 * \note Upon exit, the content of iv, the Initialisation Vector, is
464 * updated so that you can call the same function again on the next
465 * block(s) of data and get the same result as if it was encrypted
466 * in one call. This allows a "streaming" usage, by initialising
467 * iv_off to 0 before the first call, and preserving its value
468 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100469 *
Simon Butcher5db13622018-06-04 22:11:25 +0100470 * For non-streaming use, the iv should be initialised on each call
471 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100472 *
Simon Butcher5db13622018-06-04 22:11:25 +0100473 * If you need to retain the contents of the initialisation vector,
474 * you must either save it manually or use the cipher module
475 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100476 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100477 * \warning For the OFB mode, the initialisation vector must be unique
478 * every encryption operation. Reuse of an initialisation vector
479 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100480 *
481 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500482 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100483 * \param length The length of the input data.
484 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500485 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100486 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500487 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100488 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500489 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100490 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500491 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100492 *
493 * \return \c 0 on success.
494 */
495int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
496 size_t length,
497 size_t *iv_off,
498 unsigned char iv[16],
499 const unsigned char *input,
500 unsigned char *output );
501
502#endif /* MBEDTLS_CIPHER_MODE_OFB */
503
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200504#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100505/**
Rose Zadik7f441272018-01-22 11:48:23 +0000506 * \brief This function performs an AES-CTR encryption or decryption
507 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000508 *
Rose Zadik7f441272018-01-22 11:48:23 +0000509 * This function performs the operation defined in the \p mode
510 * parameter (encrypt/decrypt), on the input data buffer
511 * defined in the \p input parameter.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000512 *
Rose Zadik7f441272018-01-22 11:48:23 +0000513 * Due to the nature of CTR, you must use the same key schedule
514 * for both encryption and decryption operations. Therefore, you
515 * must use the context initialized with mbedtls_aes_setkey_enc()
516 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000517 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100518 * \warning You must never reuse a nonce value with the same key. Doing so
519 * would void the encryption for the two messages encrypted with
520 * the same nonce and key.
521 *
522 * There are two common strategies for managing nonces with CTR:
523 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200524 * 1. You can handle everything as a single message processed over
525 * successive calls to this function. In that case, you want to
526 * set \p nonce_counter and \p nc_off to 0 for the first call, and
527 * then preserve the values of \p nonce_counter, \p nc_off and \p
528 * stream_block across calls to this function as they will be
529 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100530 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200531 * With this strategy, you must not encrypt more than 2**128
532 * blocks of data with the same key.
533 *
534 * 2. You can encrypt separate messages by dividing the \p
535 * nonce_counter buffer in two areas: the first one used for a
536 * per-message nonce, handled by yourself, and the second one
537 * updated by this function internally.
538 *
539 * For example, you might reserve the first 12 bytes for the
540 * per-message nonce, and the last 4 bytes for internal use. In that
541 * case, before calling this function on a new message you need to
542 * set the first 12 bytes of \p nonce_counter to your chosen nonce
543 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
544 * stream_block to be ignored). That way, you can encrypt at most
545 * 2**96 messages of up to 2**32 blocks each with the same key.
546 *
547 * The per-message nonce (or information sufficient to reconstruct
548 * it) needs to be communicated with the ciphertext and must be unique.
549 * The recommended way to ensure uniqueness is to use a message
550 * counter. An alternative is to generate random nonces, but this
551 * limits the number of messages that can be securely encrypted:
552 * for example, with 96-bit random nonces, you should not encrypt
553 * more than 2**32 messages with the same key.
554 *
555 * Note that for both stategies, sizes are measured in blocks and
556 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000557 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200558 * \warning Upon return, \p stream_block contains sensitive data. Its
559 * content must not be written to insecure storage and should be
560 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000561 *
Rose Zadik7f441272018-01-22 11:48:23 +0000562 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500563 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000564 * \param length The length of the input data.
565 * \param nc_off The offset in the current \p stream_block, for
566 * resuming within the current cipher stream. The
567 * offset pointer should be 0 at the start of a stream.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500568 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000569 * \param nonce_counter The 128-bit nonce and counter.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500570 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000571 * \param stream_block The saved stream block for resuming. This is
572 * overwritten by the function.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500573 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000574 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500575 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000576 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500577 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000578 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100579 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000580 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200581int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000582 size_t length,
583 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000584 unsigned char nonce_counter[16],
585 unsigned char stream_block[16],
586 const unsigned char *input,
587 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200588#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200589
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200590/**
Rose Zadik7f441272018-01-22 11:48:23 +0000591 * \brief Internal AES block encryption function. This is only
592 * exposed to allow overriding it using
593 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200594 *
Rose Zadik7f441272018-01-22 11:48:23 +0000595 * \param ctx The AES context to use for encryption.
596 * \param input The plaintext block.
597 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000598 *
Rose Zadik7f441272018-01-22 11:48:23 +0000599 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200600 */
Andres AGf5bf7182017-03-03 14:09:56 +0000601int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
602 const unsigned char input[16],
603 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200604
605/**
Rose Zadik7f441272018-01-22 11:48:23 +0000606 * \brief Internal AES block decryption function. This is only
607 * exposed to allow overriding it using see
608 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200609 *
Rose Zadik7f441272018-01-22 11:48:23 +0000610 * \param ctx The AES context to use for decryption.
611 * \param input The ciphertext block.
612 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000613 *
Rose Zadik7f441272018-01-22 11:48:23 +0000614 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200615 */
Andres AGf5bf7182017-03-03 14:09:56 +0000616int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
617 const unsigned char input[16],
618 unsigned char output[16] );
619
620#if !defined(MBEDTLS_DEPRECATED_REMOVED)
621#if defined(MBEDTLS_DEPRECATED_WARNING)
622#define MBEDTLS_DEPRECATED __attribute__((deprecated))
623#else
624#define MBEDTLS_DEPRECATED
625#endif
626/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100627 * \brief Deprecated internal AES block encryption function
628 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000629 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500630 * \deprecated Superseded by mbedtls_internal_aes_encrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000631 *
Rose Zadik7f441272018-01-22 11:48:23 +0000632 * \param ctx The AES context to use for encryption.
633 * \param input Plaintext block.
634 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000635 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100636MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
637 const unsigned char input[16],
638 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000639
640/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100641 * \brief Deprecated internal AES block decryption function
642 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000643 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500644 * \deprecated Superseded by mbedtls_internal_aes_decrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000645 *
Rose Zadik7f441272018-01-22 11:48:23 +0000646 * \param ctx The AES context to use for decryption.
647 * \param input Ciphertext block.
648 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000649 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100650MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
651 const unsigned char input[16],
652 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000653
654#undef MBEDTLS_DEPRECATED
655#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200656
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500657
658#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000659/**
Rose Zadik7f441272018-01-22 11:48:23 +0000660 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000661 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100662 * \return \c 0 on success.
663 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000664 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200665int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000666
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500667#endif /* MBEDTLS_SELF_TEST */
668
Paul Bakker5121ce52009-01-03 21:22:43 +0000669#ifdef __cplusplus
670}
671#endif
672
673#endif /* aes.h */