blob: a74e413438b2a409c25112fd178bbf50f4355f66 [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
Gilles Peskine7b8571f2021-07-07 21:02:36 +020048#include "mbedtls/platform_util.h"
Paul Bakker90995b52013-06-24 19:20:35 +020049
Rich Evans00ab4702015-02-06 13:43:58 +000050#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020051#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000052
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010053/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000054#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
55#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000056
Andres Amaya Garciac5380642017-11-28 19:57:51 +000057/* Error codes in range 0x0020-0x0022 */
Gilles Peskinea3974432021-07-26 18:48:10 +020058/** Invalid key length. */
59#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
60/** Invalid data input length. */
61#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
Paul Bakker2b222c82009-07-27 21:03:45 +000062
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000063/* Error codes in range 0x0021-0x0025 */
Gilles Peskinea3974432021-07-26 18:48:10 +020064/** Invalid input data. */
65#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
Ron Eldor9924bdc2018-10-04 10:59:13 +030066
67/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
Gilles Peskinea3974432021-07-26 18:48:10 +020068/** Feature not available. For example, an unsupported AES key size. */
69#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
Ron Eldor9924bdc2018-10-04 10:59:13 +030070
71/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
Gilles Peskinea3974432021-07-26 18:48:10 +020072/** AES hardware accelerator failed. */
73#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
Paul Bakker5121ce52009-01-03 21:22:43 +000074
Andres AGf5bf7182017-03-03 14:09:56 +000075#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
76 !defined(inline) && !defined(__cplusplus)
77#define inline __inline
78#endif
79
Paul Bakker407a0da2013-06-27 14:29:21 +020080#ifdef __cplusplus
81extern "C" {
82#endif
83
Ron Eldorb2aacec2017-05-18 16:53:08 +030084#if !defined(MBEDTLS_AES_ALT)
85// Regular implementation
86//
87
Paul Bakker5121ce52009-01-03 21:22:43 +000088/**
Rose Zadik7f441272018-01-22 11:48:23 +000089 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000090 */
Dawid Drozd428cc522018-07-24 10:02:47 +020091typedef struct mbedtls_aes_context
Paul Bakker5121ce52009-01-03 21:22:43 +000092{
Rose Zadik7f441272018-01-22 11:48:23 +000093 int nr; /*!< The number of rounds. */
94 uint32_t *rk; /*!< AES round keys. */
95 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
96 hold 32 extra Bytes, which can be used for
97 one of the following purposes:
98 <ul><li>Alignment if VIA padlock is
99 used.</li>
100 <li>Simplifying key expansion in the 256-bit
101 case by generating an extra round key.
102 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +0000103}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200104mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +0000105
Jaeden Amero9366feb2018-05-29 18:55:17 +0100106#if defined(MBEDTLS_CIPHER_MODE_XTS)
107/**
108 * \brief The AES XTS context-type definition.
109 */
Dawid Drozd428cc522018-07-24 10:02:47 +0200110typedef struct mbedtls_aes_xts_context
Jaeden Amero9366feb2018-05-29 18:55:17 +0100111{
112 mbedtls_aes_context crypt; /*!< The AES context to use for AES block
113 encryption or decryption. */
114 mbedtls_aes_context tweak; /*!< The AES context used for tweak
115 computation. */
116} mbedtls_aes_xts_context;
117#endif /* MBEDTLS_CIPHER_MODE_XTS */
118
Ron Eldorb2aacec2017-05-18 16:53:08 +0300119#else /* MBEDTLS_AES_ALT */
120#include "aes_alt.h"
121#endif /* MBEDTLS_AES_ALT */
122
Paul Bakker5121ce52009-01-03 21:22:43 +0000123/**
Rose Zadik7f441272018-01-22 11:48:23 +0000124 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200125 *
Rose Zadik7f441272018-01-22 11:48:23 +0000126 * It must be the first API called before using
127 * the context.
128 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500129 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200130 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200131void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200132
133/**
Rose Zadik7f441272018-01-22 11:48:23 +0000134 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200135 *
Rose Zadik7f441272018-01-22 11:48:23 +0000136 * \param ctx The AES context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500137 * If this is \c NULL, this function does nothing.
138 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200139 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200140void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200141
Jaeden Amero9366feb2018-05-29 18:55:17 +0100142#if defined(MBEDTLS_CIPHER_MODE_XTS)
143/**
144 * \brief This function initializes the specified AES XTS context.
145 *
146 * It must be the first API called before using
147 * the context.
148 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500149 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100150 */
151void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
152
153/**
154 * \brief This function releases and clears the specified AES XTS context.
155 *
156 * \param ctx The AES XTS context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500157 * If this is \c NULL, this function does nothing.
158 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100159 */
160void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
161#endif /* MBEDTLS_CIPHER_MODE_XTS */
162
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200163/**
Rose Zadik7f441272018-01-22 11:48:23 +0000164 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000165 *
Rose Zadik7f441272018-01-22 11:48:23 +0000166 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500167 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000168 * \param key The encryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500169 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000170 * \param keybits The size of data passed in bits. Valid options are:
171 * <ul><li>128 bits</li>
172 * <li>192 bits</li>
173 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000174 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100175 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100176 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000177 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200178int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200179 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000180
181/**
Rose Zadik7f441272018-01-22 11:48:23 +0000182 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000183 *
Rose Zadik7f441272018-01-22 11:48:23 +0000184 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500185 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000186 * \param key The decryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500187 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000188 * \param keybits The size of data passed. Valid options are:
189 * <ul><li>128 bits</li>
190 * <li>192 bits</li>
191 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000192 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100193 * \return \c 0 on success.
194 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000195 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200196int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200197 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000198
Jaeden Amero9366feb2018-05-29 18:55:17 +0100199#if defined(MBEDTLS_CIPHER_MODE_XTS)
200/**
201 * \brief This function prepares an XTS context for encryption and
202 * sets the encryption key.
203 *
204 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500205 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100206 * \param key The encryption key. This is comprised of the XTS key1
207 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500208 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100209 * \param keybits The size of \p key passed in bits. Valid options are:
210 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
211 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
212 *
213 * \return \c 0 on success.
214 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
215 */
216int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
217 const unsigned char *key,
218 unsigned int keybits );
219
220/**
221 * \brief This function prepares an XTS context for decryption and
222 * sets the decryption key.
223 *
224 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500225 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100226 * \param key The decryption key. This is comprised of the XTS key1
227 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500228 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100229 * \param keybits The size of \p key passed in bits. Valid options are:
230 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
231 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
232 *
233 * \return \c 0 on success.
234 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
235 */
236int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
237 const unsigned char *key,
238 unsigned int keybits );
239#endif /* MBEDTLS_CIPHER_MODE_XTS */
240
Paul Bakker5121ce52009-01-03 21:22:43 +0000241/**
Rose Zadik7f441272018-01-22 11:48:23 +0000242 * \brief This function performs an AES single-block encryption or
243 * decryption operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000244 *
Rose Zadik7f441272018-01-22 11:48:23 +0000245 * It performs the operation defined in the \p mode parameter
246 * (encrypt or decrypt), on the input data buffer defined in
247 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000248 *
Rose Zadik7f441272018-01-22 11:48:23 +0000249 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
250 * mbedtls_aes_setkey_dec() must be called before the first
251 * call to this API with the same context.
252 *
253 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500254 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000255 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
256 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500257 * \param input The buffer holding the input data.
258 * It must be readable and at least \c 16 Bytes long.
259 * \param output The buffer where the output data will be written.
260 * It must be writeable and at least \c 16 Bytes long.
Rose Zadik7f441272018-01-22 11:48:23 +0000261
262 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000263 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200264int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000265 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000266 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000267 unsigned char output[16] );
268
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200269#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000270/**
Rose Zadik7f441272018-01-22 11:48:23 +0000271 * \brief This function performs an AES-CBC encryption or decryption operation
272 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000273 *
Rose Zadik7f441272018-01-22 11:48:23 +0000274 * It performs the operation defined in the \p mode
275 * parameter (encrypt/decrypt), on the input data buffer defined in
276 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000277 *
Rose Zadik7f441272018-01-22 11:48:23 +0000278 * It can be called as many times as needed, until all the input
279 * data is processed. mbedtls_aes_init(), and either
280 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
281 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000282 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500283 * \note This function operates on full blocks, that is, the input size
284 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000285 *
286 * \note Upon exit, the content of the IV is updated so that you can
287 * call the same function again on the next
288 * block(s) of data and get the same result as if it was
289 * encrypted in one call. This allows a "streaming" usage.
290 * If you need to retain the contents of the IV, you should
291 * either save it manually or use the cipher module instead.
292 *
293 *
294 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500295 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000296 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
297 * #MBEDTLS_AES_DECRYPT.
298 * \param length The length of the input data in Bytes. This must be a
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500299 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000300 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500301 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000302 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500303 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000304 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500305 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000306 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100307 * \return \c 0 on success.
308 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000309 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000310 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200311int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000312 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000313 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000314 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000315 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000316 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200317#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000318
Aorimn5f778012016-06-09 23:22:58 +0200319#if defined(MBEDTLS_CIPHER_MODE_XTS)
320/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100321 * \brief This function performs an AES-XTS encryption or decryption
322 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200323 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100324 * AES-XTS encrypts or decrypts blocks based on their location as
325 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100326 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200327 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100328 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
329 * AES blocks. If the data unit is larger than this, this function
330 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
331 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100332 * \param ctx The AES XTS context to use for AES XTS operations.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500333 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100334 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
335 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500336 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100337 * length between 16 bytes and 2^24 bytes inclusive
338 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100339 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100340 * bytes in little-endian format. For disk encryption, this
341 * is typically the index of the block device sector that
342 * contains the data.
343 * \param input The buffer holding the input data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500344 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100345 * input.
346 * \param output The buffer holding the output data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500347 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100348 * output.
Aorimn5f778012016-06-09 23:22:58 +0200349 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100350 * \return \c 0 on success.
351 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500352 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100353 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200354 */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100355int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
356 int mode,
Jaeden Amero5162b932018-05-29 12:55:24 +0100357 size_t length,
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100358 const unsigned char data_unit[16],
Jaeden Amero9366feb2018-05-29 18:55:17 +0100359 const unsigned char *input,
360 unsigned char *output );
Aorimn5f778012016-06-09 23:22:58 +0200361#endif /* MBEDTLS_CIPHER_MODE_XTS */
362
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200363#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000364/**
Rose Zadik7f441272018-01-22 11:48:23 +0000365 * \brief This function performs an AES-CFB128 encryption or decryption
366 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000367 *
Rose Zadik7f441272018-01-22 11:48:23 +0000368 * It performs the operation defined in the \p mode
369 * parameter (encrypt or decrypt), on the input data buffer
370 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000371 *
Rose Zadik7f441272018-01-22 11:48:23 +0000372 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
373 * regardless of whether you are performing an encryption or decryption
374 * operation, that is, regardless of the \p mode parameter. This is
375 * because CFB mode uses the same key schedule for encryption and
376 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000377 *
Rose Zadik7f441272018-01-22 11:48:23 +0000378 * \note Upon exit, the content of the IV is updated so that you can
379 * call the same function again on the next
380 * block(s) of data and get the same result as if it was
381 * encrypted in one call. This allows a "streaming" usage.
382 * If you need to retain the contents of the
383 * IV, you must either save it manually or use the cipher
384 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000385 *
Rose Zadik7f441272018-01-22 11:48:23 +0000386 *
387 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500388 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000389 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
390 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500391 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000392 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500393 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000394 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500395 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000396 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500397 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000398 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500399 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000400 *
401 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000402 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200403int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000404 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000405 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000406 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000407 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000408 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000409 unsigned char *output );
410
Paul Bakker9a736322012-11-14 12:39:52 +0000411/**
Rose Zadik7f441272018-01-22 11:48:23 +0000412 * \brief This function performs an AES-CFB8 encryption or decryption
413 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100414 *
Rose Zadik7f441272018-01-22 11:48:23 +0000415 * It performs the operation defined in the \p mode
416 * parameter (encrypt/decrypt), on the input data buffer defined
417 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100418 *
Rose Zadik7f441272018-01-22 11:48:23 +0000419 * Due to the nature of CFB, you must use the same key schedule for
420 * both encryption and decryption operations. Therefore, you must
421 * use the context initialized with mbedtls_aes_setkey_enc() for
422 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000423 *
Rose Zadik7f441272018-01-22 11:48:23 +0000424 * \note Upon exit, the content of the IV is updated so that you can
425 * call the same function again on the next
426 * block(s) of data and get the same result as if it was
427 * encrypted in one call. This allows a "streaming" usage.
428 * If you need to retain the contents of the
429 * IV, you should either save it manually or use the cipher
430 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100431 *
Rose Zadik7f441272018-01-22 11:48:23 +0000432 *
433 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500434 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000435 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
436 * #MBEDTLS_AES_DECRYPT
437 * \param length The length of the input data.
438 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500439 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000440 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500441 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000442 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500443 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000444 *
445 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100446 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200447int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100448 int mode,
449 size_t length,
450 unsigned char iv[16],
451 const unsigned char *input,
452 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200453#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100454
Simon Butcher76a5b222018-04-22 22:57:27 +0100455#if defined(MBEDTLS_CIPHER_MODE_OFB)
456/**
Simon Butcher5db13622018-06-04 22:11:25 +0100457 * \brief This function performs an AES-OFB (Output Feedback Mode)
458 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100459 *
Simon Butcher5db13622018-06-04 22:11:25 +0100460 * For OFB, you must set up the context with
461 * mbedtls_aes_setkey_enc(), regardless of whether you are
462 * performing an encryption or decryption operation. This is
463 * because OFB mode uses the same key schedule for encryption and
464 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100465 *
Simon Butcher5db13622018-06-04 22:11:25 +0100466 * The OFB operation is identical for encryption or decryption,
467 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100468 *
Simon Butcher5db13622018-06-04 22:11:25 +0100469 * \note Upon exit, the content of iv, the Initialisation Vector, is
470 * updated so that you can call the same function again on the next
471 * block(s) of data and get the same result as if it was encrypted
472 * in one call. This allows a "streaming" usage, by initialising
473 * iv_off to 0 before the first call, and preserving its value
474 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100475 *
Simon Butcher5db13622018-06-04 22:11:25 +0100476 * For non-streaming use, the iv should be initialised on each call
477 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100478 *
Simon Butcher5db13622018-06-04 22:11:25 +0100479 * If you need to retain the contents of the initialisation vector,
480 * you must either save it manually or use the cipher module
481 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100482 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100483 * \warning For the OFB mode, the initialisation vector must be unique
484 * every encryption operation. Reuse of an initialisation vector
485 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100486 *
487 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500488 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100489 * \param length The length of the input data.
490 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500491 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100492 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500493 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100494 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500495 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100496 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500497 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100498 *
499 * \return \c 0 on success.
500 */
501int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
502 size_t length,
503 size_t *iv_off,
504 unsigned char iv[16],
505 const unsigned char *input,
506 unsigned char *output );
507
508#endif /* MBEDTLS_CIPHER_MODE_OFB */
509
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200510#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100511/**
Rose Zadik7f441272018-01-22 11:48:23 +0000512 * \brief This function performs an AES-CTR encryption or decryption
513 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000514 *
Rose Zadik7f441272018-01-22 11:48:23 +0000515 * This function performs the operation defined in the \p mode
516 * parameter (encrypt/decrypt), on the input data buffer
517 * defined in the \p input parameter.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000518 *
Rose Zadik7f441272018-01-22 11:48:23 +0000519 * Due to the nature of CTR, you must use the same key schedule
520 * for both encryption and decryption operations. Therefore, you
521 * must use the context initialized with mbedtls_aes_setkey_enc()
522 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000523 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100524 * \warning You must never reuse a nonce value with the same key. Doing so
525 * would void the encryption for the two messages encrypted with
526 * the same nonce and key.
527 *
528 * There are two common strategies for managing nonces with CTR:
529 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200530 * 1. You can handle everything as a single message processed over
531 * successive calls to this function. In that case, you want to
532 * set \p nonce_counter and \p nc_off to 0 for the first call, and
533 * then preserve the values of \p nonce_counter, \p nc_off and \p
534 * stream_block across calls to this function as they will be
535 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100536 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200537 * With this strategy, you must not encrypt more than 2**128
538 * blocks of data with the same key.
539 *
540 * 2. You can encrypt separate messages by dividing the \p
541 * nonce_counter buffer in two areas: the first one used for a
542 * per-message nonce, handled by yourself, and the second one
543 * updated by this function internally.
544 *
545 * For example, you might reserve the first 12 bytes for the
546 * per-message nonce, and the last 4 bytes for internal use. In that
547 * case, before calling this function on a new message you need to
548 * set the first 12 bytes of \p nonce_counter to your chosen nonce
549 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
550 * stream_block to be ignored). That way, you can encrypt at most
551 * 2**96 messages of up to 2**32 blocks each with the same key.
552 *
553 * The per-message nonce (or information sufficient to reconstruct
554 * it) needs to be communicated with the ciphertext and must be unique.
555 * The recommended way to ensure uniqueness is to use a message
556 * counter. An alternative is to generate random nonces, but this
557 * limits the number of messages that can be securely encrypted:
558 * for example, with 96-bit random nonces, you should not encrypt
559 * more than 2**32 messages with the same key.
560 *
561 * Note that for both stategies, sizes are measured in blocks and
562 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000563 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200564 * \warning Upon return, \p stream_block contains sensitive data. Its
565 * content must not be written to insecure storage and should be
566 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000567 *
Rose Zadik7f441272018-01-22 11:48:23 +0000568 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500569 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000570 * \param length The length of the input data.
571 * \param nc_off The offset in the current \p stream_block, for
572 * resuming within the current cipher stream. The
573 * offset pointer should be 0 at the start of a stream.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500574 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000575 * \param nonce_counter The 128-bit nonce and counter.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500576 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000577 * \param stream_block The saved stream block for resuming. This is
578 * overwritten by the function.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500579 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000580 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500581 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000582 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500583 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000584 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100585 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000586 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200587int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000588 size_t length,
589 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000590 unsigned char nonce_counter[16],
591 unsigned char stream_block[16],
592 const unsigned char *input,
593 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200594#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200595
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200596/**
Rose Zadik7f441272018-01-22 11:48:23 +0000597 * \brief Internal AES block encryption function. This is only
598 * exposed to allow overriding it using
599 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200600 *
Rose Zadik7f441272018-01-22 11:48:23 +0000601 * \param ctx The AES context to use for encryption.
602 * \param input The plaintext block.
603 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000604 *
Rose Zadik7f441272018-01-22 11:48:23 +0000605 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200606 */
Andres AGf5bf7182017-03-03 14:09:56 +0000607int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
608 const unsigned char input[16],
609 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200610
611/**
Rose Zadik7f441272018-01-22 11:48:23 +0000612 * \brief Internal AES block decryption function. This is only
613 * exposed to allow overriding it using see
614 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200615 *
Rose Zadik7f441272018-01-22 11:48:23 +0000616 * \param ctx The AES context to use for decryption.
617 * \param input The ciphertext block.
618 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000619 *
Rose Zadik7f441272018-01-22 11:48:23 +0000620 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200621 */
Andres AGf5bf7182017-03-03 14:09:56 +0000622int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
623 const unsigned char input[16],
624 unsigned char output[16] );
625
626#if !defined(MBEDTLS_DEPRECATED_REMOVED)
627#if defined(MBEDTLS_DEPRECATED_WARNING)
628#define MBEDTLS_DEPRECATED __attribute__((deprecated))
629#else
630#define MBEDTLS_DEPRECATED
631#endif
632/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100633 * \brief Deprecated internal AES block encryption function
634 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000635 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500636 * \deprecated Superseded by mbedtls_internal_aes_encrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000637 *
Rose Zadik7f441272018-01-22 11:48:23 +0000638 * \param ctx The AES context to use for encryption.
639 * \param input Plaintext block.
640 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000641 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100642MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
643 const unsigned char input[16],
644 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000645
646/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100647 * \brief Deprecated internal AES block decryption function
648 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000649 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500650 * \deprecated Superseded by mbedtls_internal_aes_decrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000651 *
Rose Zadik7f441272018-01-22 11:48:23 +0000652 * \param ctx The AES context to use for decryption.
653 * \param input Ciphertext block.
654 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000655 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100656MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
657 const unsigned char input[16],
658 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000659
660#undef MBEDTLS_DEPRECATED
661#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200662
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500663
664#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000665/**
Rose Zadik7f441272018-01-22 11:48:23 +0000666 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000667 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100668 * \return \c 0 on success.
669 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000670 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200671int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000672
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500673#endif /* MBEDTLS_SELF_TEST */
674
Paul Bakker5121ce52009-01-03 21:22:43 +0000675#ifdef __cplusplus
676}
677#endif
678
679#endif /* aes.h */