blob: 151affdb2eb9ed79c433f2e58423b76e1eda3bb8 [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/*
24 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
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 Bakkerb96f1542010-07-18 20:36:00 +000038 *
Rose Zadik7f441272018-01-22 11:48:23 +000039 * This file is part of Mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000040 */
Rose Zadik7f441272018-01-22 11:48:23 +000041
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020042#ifndef MBEDTLS_AES_H
43#define MBEDTLS_AES_H
Paul Bakker5121ce52009-01-03 21:22:43 +000044
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020045#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010046#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020047#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020048#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020049#endif
Paul Bakker90995b52013-06-24 19:20:35 +020050
Rich Evans00ab4702015-02-06 13:43:58 +000051#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020052#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000053
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010054/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000055#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
56#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000057
Andres Amaya Garciac5380642017-11-28 19:57:51 +000058/* Error codes in range 0x0020-0x0022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020059#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
60#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
Paul Bakker2b222c82009-07-27 21:03:45 +000061
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000062/* Error codes in range 0x0021-0x0025 */
63#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030064
65/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
Rose Zadik7f441272018-01-22 11:48:23 +000066#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030067
68/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
Gilles Peskine7ecab3d2018-01-26 17:56:38 +010069#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000070
Andres AGf5bf7182017-03-03 14:09:56 +000071#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
72 !defined(inline) && !defined(__cplusplus)
73#define inline __inline
74#endif
75
Paul Bakker407a0da2013-06-27 14:29:21 +020076#ifdef __cplusplus
77extern "C" {
78#endif
79
Ron Eldorb2aacec2017-05-18 16:53:08 +030080#if !defined(MBEDTLS_AES_ALT)
81// Regular implementation
82//
83
Paul Bakker5121ce52009-01-03 21:22:43 +000084/**
Rose Zadik7f441272018-01-22 11:48:23 +000085 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000086 */
Dawid Drozd428cc522018-07-24 10:02:47 +020087typedef struct mbedtls_aes_context
Paul Bakker5121ce52009-01-03 21:22:43 +000088{
Rose Zadik7f441272018-01-22 11:48:23 +000089 int nr; /*!< The number of rounds. */
90 uint32_t *rk; /*!< AES round keys. */
91 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
92 hold 32 extra Bytes, which can be used for
93 one of the following purposes:
94 <ul><li>Alignment if VIA padlock is
95 used.</li>
96 <li>Simplifying key expansion in the 256-bit
97 case by generating an extra round key.
98 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +000099}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +0000101
Jaeden Amero9366feb2018-05-29 18:55:17 +0100102#if defined(MBEDTLS_CIPHER_MODE_XTS)
103/**
104 * \brief The AES XTS context-type definition.
105 */
Dawid Drozd428cc522018-07-24 10:02:47 +0200106typedef struct mbedtls_aes_xts_context
Jaeden Amero9366feb2018-05-29 18:55:17 +0100107{
108 mbedtls_aes_context crypt; /*!< The AES context to use for AES block
109 encryption or decryption. */
110 mbedtls_aes_context tweak; /*!< The AES context used for tweak
111 computation. */
112} mbedtls_aes_xts_context;
113#endif /* MBEDTLS_CIPHER_MODE_XTS */
114
Ron Eldorb2aacec2017-05-18 16:53:08 +0300115#else /* MBEDTLS_AES_ALT */
116#include "aes_alt.h"
117#endif /* MBEDTLS_AES_ALT */
118
Paul Bakker5121ce52009-01-03 21:22:43 +0000119/**
Rose Zadik7f441272018-01-22 11:48:23 +0000120 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200121 *
Rose Zadik7f441272018-01-22 11:48:23 +0000122 * It must be the first API called before using
123 * the context.
124 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500125 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200126 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200127void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200128
129/**
Rose Zadik7f441272018-01-22 11:48:23 +0000130 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200131 *
Rose Zadik7f441272018-01-22 11:48:23 +0000132 * \param ctx The AES context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500133 * If this is \c NULL, this function does nothing.
134 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200135 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200136void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200137
Jaeden Amero9366feb2018-05-29 18:55:17 +0100138#if defined(MBEDTLS_CIPHER_MODE_XTS)
139/**
140 * \brief This function initializes the specified AES XTS context.
141 *
142 * It must be the first API called before using
143 * the context.
144 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500145 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100146 */
147void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
148
149/**
150 * \brief This function releases and clears the specified AES XTS context.
151 *
152 * \param ctx The AES XTS context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500153 * If this is \c NULL, this function does nothing.
154 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100155 */
156void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
157#endif /* MBEDTLS_CIPHER_MODE_XTS */
158
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200159/**
Rose Zadik7f441272018-01-22 11:48:23 +0000160 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000161 *
Rose Zadik7f441272018-01-22 11:48:23 +0000162 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500163 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000164 * \param key The encryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500165 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000166 * \param keybits The size of data passed in bits. Valid options are:
167 * <ul><li>128 bits</li>
168 * <li>192 bits</li>
169 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000170 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100171 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100172 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000173 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200174int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200175 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000176
177/**
Rose Zadik7f441272018-01-22 11:48:23 +0000178 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000179 *
Rose Zadik7f441272018-01-22 11:48:23 +0000180 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500181 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000182 * \param key The decryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500183 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000184 * \param keybits The size of data passed. Valid options are:
185 * <ul><li>128 bits</li>
186 * <li>192 bits</li>
187 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000188 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100189 * \return \c 0 on success.
190 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000191 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200192int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200193 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000194
Jaeden Amero9366feb2018-05-29 18:55:17 +0100195#if defined(MBEDTLS_CIPHER_MODE_XTS)
196/**
197 * \brief This function prepares an XTS context for encryption and
198 * sets the encryption key.
199 *
200 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500201 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100202 * \param key The encryption key. This is comprised of the XTS key1
203 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500204 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100205 * \param keybits The size of \p key passed in bits. Valid options are:
206 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
207 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
208 *
209 * \return \c 0 on success.
210 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
211 */
212int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
213 const unsigned char *key,
214 unsigned int keybits );
215
216/**
217 * \brief This function prepares an XTS context for decryption and
218 * sets the decryption key.
219 *
220 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500221 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100222 * \param key The decryption key. This is comprised of the XTS key1
223 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500224 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100225 * \param keybits The size of \p key passed in bits. Valid options are:
226 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
227 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
228 *
229 * \return \c 0 on success.
230 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
231 */
232int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
233 const unsigned char *key,
234 unsigned int keybits );
235#endif /* MBEDTLS_CIPHER_MODE_XTS */
236
Paul Bakker5121ce52009-01-03 21:22:43 +0000237/**
Rose Zadik7f441272018-01-22 11:48:23 +0000238 * \brief This function performs an AES single-block encryption or
239 * decryption operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000240 *
Rose Zadik7f441272018-01-22 11:48:23 +0000241 * It performs the operation defined in the \p mode parameter
242 * (encrypt or decrypt), on the input data buffer defined in
243 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000244 *
Rose Zadik7f441272018-01-22 11:48:23 +0000245 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
246 * mbedtls_aes_setkey_dec() must be called before the first
247 * call to this API with the same context.
248 *
249 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500250 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000251 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
252 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500253 * \param input The buffer holding the input data.
254 * It must be readable and at least \c 16 Bytes long.
255 * \param output The buffer where the output data will be written.
256 * It must be writeable and at least \c 16 Bytes long.
Rose Zadik7f441272018-01-22 11:48:23 +0000257
258 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000259 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200260int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000261 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000262 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000263 unsigned char output[16] );
264
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200265#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000266/**
Rose Zadik7f441272018-01-22 11:48:23 +0000267 * \brief This function performs an AES-CBC encryption or decryption operation
268 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000269 *
Rose Zadik7f441272018-01-22 11:48:23 +0000270 * It performs the operation defined in the \p mode
271 * parameter (encrypt/decrypt), on the input data buffer defined in
272 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000273 *
Rose Zadik7f441272018-01-22 11:48:23 +0000274 * It can be called as many times as needed, until all the input
275 * data is processed. mbedtls_aes_init(), and either
276 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
277 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000278 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500279 * \note This function operates on full blocks, that is, the input size
280 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000281 *
282 * \note Upon exit, the content of the IV is updated so that you can
283 * call the same function again on the next
284 * block(s) of data and get the same result as if it was
285 * encrypted in one call. This allows a "streaming" usage.
286 * If you need to retain the contents of the IV, you should
287 * either save it manually or use the cipher module instead.
288 *
289 *
290 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500291 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000292 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
293 * #MBEDTLS_AES_DECRYPT.
294 * \param length The length of the input data in Bytes. This must be a
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500295 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000296 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500297 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000298 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500299 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000300 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500301 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000302 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100303 * \return \c 0 on success.
304 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000305 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000306 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200307int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000308 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000309 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000310 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000311 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000312 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200313#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000314
Aorimn5f778012016-06-09 23:22:58 +0200315#if defined(MBEDTLS_CIPHER_MODE_XTS)
316/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100317 * \brief This function performs an AES-XTS encryption or decryption
318 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200319 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100320 * AES-XTS encrypts or decrypts blocks based on their location as
321 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100322 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200323 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100324 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
325 * AES blocks. If the data unit is larger than this, this function
326 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
327 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100328 * \param ctx The AES XTS context to use for AES XTS operations.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500329 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100330 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
331 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500332 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100333 * length between 16 bytes and 2^24 bytes inclusive
334 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100335 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100336 * bytes in little-endian format. For disk encryption, this
337 * is typically the index of the block device sector that
338 * contains the data.
339 * \param input The buffer holding the input data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500340 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100341 * input.
342 * \param output The buffer holding the output data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500343 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100344 * output.
Aorimn5f778012016-06-09 23:22:58 +0200345 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100346 * \return \c 0 on success.
347 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500348 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100349 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200350 */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100351int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
352 int mode,
Jaeden Amero5162b932018-05-29 12:55:24 +0100353 size_t length,
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100354 const unsigned char data_unit[16],
Jaeden Amero9366feb2018-05-29 18:55:17 +0100355 const unsigned char *input,
356 unsigned char *output );
Aorimn5f778012016-06-09 23:22:58 +0200357#endif /* MBEDTLS_CIPHER_MODE_XTS */
358
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200359#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000360/**
Rose Zadik7f441272018-01-22 11:48:23 +0000361 * \brief This function performs an AES-CFB128 encryption or decryption
362 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000363 *
Rose Zadik7f441272018-01-22 11:48:23 +0000364 * It performs the operation defined in the \p mode
365 * parameter (encrypt or decrypt), on the input data buffer
366 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000367 *
Rose Zadik7f441272018-01-22 11:48:23 +0000368 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
369 * regardless of whether you are performing an encryption or decryption
370 * operation, that is, regardless of the \p mode parameter. This is
371 * because CFB mode uses the same key schedule for encryption and
372 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000373 *
Rose Zadik7f441272018-01-22 11:48:23 +0000374 * \note Upon exit, the content of the IV is updated so that you can
375 * call the same function again on the next
376 * block(s) of data and get the same result as if it was
377 * encrypted in one call. This allows a "streaming" usage.
378 * If you need to retain the contents of the
379 * IV, you must either save it manually or use the cipher
380 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000381 *
Rose Zadik7f441272018-01-22 11:48:23 +0000382 *
383 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500384 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000385 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
386 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500387 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000388 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500389 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000390 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500391 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000392 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500393 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000394 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500395 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000396 *
397 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000398 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200399int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000400 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000401 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000402 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000403 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000404 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000405 unsigned char *output );
406
Paul Bakker9a736322012-11-14 12:39:52 +0000407/**
Rose Zadik7f441272018-01-22 11:48:23 +0000408 * \brief This function performs an AES-CFB8 encryption or decryption
409 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100410 *
Rose Zadik7f441272018-01-22 11:48:23 +0000411 * It performs the operation defined in the \p mode
412 * parameter (encrypt/decrypt), on the input data buffer defined
413 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100414 *
Rose Zadik7f441272018-01-22 11:48:23 +0000415 * Due to the nature of CFB, you must use the same key schedule for
416 * both encryption and decryption operations. Therefore, you must
417 * use the context initialized with mbedtls_aes_setkey_enc() for
418 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000419 *
Rose Zadik7f441272018-01-22 11:48:23 +0000420 * \note Upon exit, the content of the IV is updated so that you can
421 * call the same function again on the next
422 * block(s) of data and get the same result as if it was
423 * encrypted in one call. This allows a "streaming" usage.
424 * If you need to retain the contents of the
425 * IV, you should either save it manually or use the cipher
426 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100427 *
Rose Zadik7f441272018-01-22 11:48:23 +0000428 *
429 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500430 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000431 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
432 * #MBEDTLS_AES_DECRYPT
433 * \param length The length of the input data.
434 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500435 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000436 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500437 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000438 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500439 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000440 *
441 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100442 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200443int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100444 int mode,
445 size_t length,
446 unsigned char iv[16],
447 const unsigned char *input,
448 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200449#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100450
Simon Butcher76a5b222018-04-22 22:57:27 +0100451#if defined(MBEDTLS_CIPHER_MODE_OFB)
452/**
Simon Butcher5db13622018-06-04 22:11:25 +0100453 * \brief This function performs an AES-OFB (Output Feedback Mode)
454 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100455 *
Simon Butcher5db13622018-06-04 22:11:25 +0100456 * For OFB, you must set up the context with
457 * mbedtls_aes_setkey_enc(), regardless of whether you are
458 * performing an encryption or decryption operation. This is
459 * because OFB mode uses the same key schedule for encryption and
460 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100461 *
Simon Butcher5db13622018-06-04 22:11:25 +0100462 * The OFB operation is identical for encryption or decryption,
463 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100464 *
Simon Butcher5db13622018-06-04 22:11:25 +0100465 * \note Upon exit, the content of iv, the Initialisation Vector, is
466 * updated so that you can call the same function again on the next
467 * block(s) of data and get the same result as if it was encrypted
468 * in one call. This allows a "streaming" usage, by initialising
469 * iv_off to 0 before the first call, and preserving its value
470 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100471 *
Simon Butcher5db13622018-06-04 22:11:25 +0100472 * For non-streaming use, the iv should be initialised on each call
473 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100474 *
Simon Butcher5db13622018-06-04 22:11:25 +0100475 * If you need to retain the contents of the initialisation vector,
476 * you must either save it manually or use the cipher module
477 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100478 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100479 * \warning For the OFB mode, the initialisation vector must be unique
480 * every encryption operation. Reuse of an initialisation vector
481 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100482 *
483 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500484 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100485 * \param length The length of the input data.
486 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500487 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100488 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500489 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100490 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500491 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100492 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500493 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100494 *
495 * \return \c 0 on success.
496 */
497int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
498 size_t length,
499 size_t *iv_off,
500 unsigned char iv[16],
501 const unsigned char *input,
502 unsigned char *output );
503
504#endif /* MBEDTLS_CIPHER_MODE_OFB */
505
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200506#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100507/**
Rose Zadik7f441272018-01-22 11:48:23 +0000508 * \brief This function performs an AES-CTR encryption or decryption
509 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000510 *
Rose Zadik7f441272018-01-22 11:48:23 +0000511 * This function performs the operation defined in the \p mode
512 * parameter (encrypt/decrypt), on the input data buffer
513 * defined in the \p input parameter.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000514 *
Rose Zadik7f441272018-01-22 11:48:23 +0000515 * Due to the nature of CTR, you must use the same key schedule
516 * for both encryption and decryption operations. Therefore, you
517 * must use the context initialized with mbedtls_aes_setkey_enc()
518 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000519 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100520 * \warning You must never reuse a nonce value with the same key. Doing so
521 * would void the encryption for the two messages encrypted with
522 * the same nonce and key.
523 *
524 * There are two common strategies for managing nonces with CTR:
525 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200526 * 1. You can handle everything as a single message processed over
527 * successive calls to this function. In that case, you want to
528 * set \p nonce_counter and \p nc_off to 0 for the first call, and
529 * then preserve the values of \p nonce_counter, \p nc_off and \p
530 * stream_block across calls to this function as they will be
531 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100532 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200533 * With this strategy, you must not encrypt more than 2**128
534 * blocks of data with the same key.
535 *
536 * 2. You can encrypt separate messages by dividing the \p
537 * nonce_counter buffer in two areas: the first one used for a
538 * per-message nonce, handled by yourself, and the second one
539 * updated by this function internally.
540 *
541 * For example, you might reserve the first 12 bytes for the
542 * per-message nonce, and the last 4 bytes for internal use. In that
543 * case, before calling this function on a new message you need to
544 * set the first 12 bytes of \p nonce_counter to your chosen nonce
545 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
546 * stream_block to be ignored). That way, you can encrypt at most
547 * 2**96 messages of up to 2**32 blocks each with the same key.
548 *
549 * The per-message nonce (or information sufficient to reconstruct
550 * it) needs to be communicated with the ciphertext and must be unique.
551 * The recommended way to ensure uniqueness is to use a message
552 * counter. An alternative is to generate random nonces, but this
553 * limits the number of messages that can be securely encrypted:
554 * for example, with 96-bit random nonces, you should not encrypt
555 * more than 2**32 messages with the same key.
556 *
557 * Note that for both stategies, sizes are measured in blocks and
558 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000559 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200560 * \warning Upon return, \p stream_block contains sensitive data. Its
561 * content must not be written to insecure storage and should be
562 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000563 *
Rose Zadik7f441272018-01-22 11:48:23 +0000564 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500565 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000566 * \param length The length of the input data.
567 * \param nc_off The offset in the current \p stream_block, for
568 * resuming within the current cipher stream. The
569 * offset pointer should be 0 at the start of a stream.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500570 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000571 * \param nonce_counter The 128-bit nonce and counter.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500572 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000573 * \param stream_block The saved stream block for resuming. This is
574 * overwritten by the function.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500575 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000576 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500577 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000578 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500579 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000580 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100581 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000582 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200583int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000584 size_t length,
585 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000586 unsigned char nonce_counter[16],
587 unsigned char stream_block[16],
588 const unsigned char *input,
589 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200590#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200591
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200592/**
Rose Zadik7f441272018-01-22 11:48:23 +0000593 * \brief Internal AES block encryption function. This is only
594 * exposed to allow overriding it using
595 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200596 *
Rose Zadik7f441272018-01-22 11:48:23 +0000597 * \param ctx The AES context to use for encryption.
598 * \param input The plaintext block.
599 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000600 *
Rose Zadik7f441272018-01-22 11:48:23 +0000601 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200602 */
Andres AGf5bf7182017-03-03 14:09:56 +0000603int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
604 const unsigned char input[16],
605 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200606
607/**
Rose Zadik7f441272018-01-22 11:48:23 +0000608 * \brief Internal AES block decryption function. This is only
609 * exposed to allow overriding it using see
610 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200611 *
Rose Zadik7f441272018-01-22 11:48:23 +0000612 * \param ctx The AES context to use for decryption.
613 * \param input The ciphertext block.
614 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000615 *
Rose Zadik7f441272018-01-22 11:48:23 +0000616 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200617 */
Andres AGf5bf7182017-03-03 14:09:56 +0000618int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
619 const unsigned char input[16],
620 unsigned char output[16] );
621
622#if !defined(MBEDTLS_DEPRECATED_REMOVED)
623#if defined(MBEDTLS_DEPRECATED_WARNING)
624#define MBEDTLS_DEPRECATED __attribute__((deprecated))
625#else
626#define MBEDTLS_DEPRECATED
627#endif
628/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100629 * \brief Deprecated internal AES block encryption function
630 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000631 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500632 * \deprecated Superseded by mbedtls_internal_aes_encrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000633 *
Rose Zadik7f441272018-01-22 11:48:23 +0000634 * \param ctx The AES context to use for encryption.
635 * \param input Plaintext block.
636 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000637 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100638MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
639 const unsigned char input[16],
640 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000641
642/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100643 * \brief Deprecated internal AES block decryption function
644 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000645 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500646 * \deprecated Superseded by mbedtls_internal_aes_decrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000647 *
Rose Zadik7f441272018-01-22 11:48:23 +0000648 * \param ctx The AES context to use for decryption.
649 * \param input Ciphertext block.
650 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000651 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100652MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
653 const unsigned char input[16],
654 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000655
656#undef MBEDTLS_DEPRECATED
657#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200658
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500659
660#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000661/**
Rose Zadik7f441272018-01-22 11:48:23 +0000662 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000663 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100664 * \return \c 0 on success.
665 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000666 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200667int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000668
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500669#endif /* MBEDTLS_SELF_TEST */
670
Paul Bakker5121ce52009-01-03 21:22:43 +0000671#ifdef __cplusplus
672}
673#endif
674
675#endif /* aes.h */