blob: c43134d4567ecc6d6ede43e74ae024d31e4e9330 [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
Mateusz Starzyk846f0212021-05-19 19:44:07 +020042#include "mbedtls/private_access.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000043
Bence Szépkútic662b362021-05-27 11:25:03 +020044#include "mbedtls/build_info.h"
Mateusz Starzyke35f8f62021-08-04 15:38:09 +020045#include "mbedtls/platform_util.h"
Paul Bakker90995b52013-06-24 19:20:35 +020046
Rich Evans00ab4702015-02-06 13:43:58 +000047#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020048#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000049
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010050/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000051#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
52#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000053
Andres Amaya Garciac5380642017-11-28 19:57:51 +000054/* Error codes in range 0x0020-0x0022 */
Gilles Peskined2971572021-07-26 18:48:10 +020055/** Invalid key length. */
56#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
57/** Invalid data input length. */
58#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
Paul Bakker2b222c82009-07-27 21:03:45 +000059
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000060/* Error codes in range 0x0021-0x0025 */
Gilles Peskined2971572021-07-26 18:48:10 +020061/** Invalid input data. */
62#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
Yanray Wang0d76b6e2023-11-02 11:54:39 +080063/** The requested feature is not available. */
64#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
Ron Eldor9924bdc2018-10-04 10:59:13 +030065
Paul Bakker407a0da2013-06-27 14:29:21 +020066#ifdef __cplusplus
67extern "C" {
68#endif
69
Ron Eldorb2aacec2017-05-18 16:53:08 +030070#if !defined(MBEDTLS_AES_ALT)
71// Regular implementation
72//
73
Paul Bakker5121ce52009-01-03 21:22:43 +000074/**
Rose Zadik7f441272018-01-22 11:48:23 +000075 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000076 */
Gilles Peskine449bd832023-01-11 14:50:10 +010077typedef struct mbedtls_aes_context {
Mateusz Starzyk846f0212021-05-19 19:44:07 +020078 int MBEDTLS_PRIVATE(nr); /*!< The number of rounds. */
Werner Lewis6d719442022-06-13 12:28:07 +010079 size_t MBEDTLS_PRIVATE(rk_offset); /*!< The offset in array elements to AES
Gilles Peskine449bd832023-01-11 14:50:10 +010080 round keys in the buffer. */
Arto Kinnunenb1c626b2023-04-14 17:21:22 +080081#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && !defined(MBEDTLS_PADLOCK_C)
Yanray Wang8b9877b2023-05-05 14:46:04 +080082 uint32_t MBEDTLS_PRIVATE(buf)[44]; /*!< Aligned data buffer to hold
Yanray Wangab4fb0d2023-05-10 10:06:11 +080083 10 round keys for 128-bit case. */
Arto Kinnunenb1c626b2023-04-14 17:21:22 +080084#else
Mateusz Starzyk846f0212021-05-19 19:44:07 +020085 uint32_t MBEDTLS_PRIVATE(buf)[68]; /*!< Unaligned data buffer. This buffer can
Gilles Peskine449bd832023-01-11 14:50:10 +010086 hold 32 extra Bytes, which can be used for
87 one of the following purposes:
88 <ul><li>Alignment if VIA padlock is
89 used.</li>
90 <li>Simplifying key expansion in the 256-bit
91 case by generating an extra round key.
92 </li></ul> */
Arto Kinnunenb1c626b2023-04-14 17:21:22 +080093#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH && !MBEDTLS_PADLOCK_C */
Paul Bakker5121ce52009-01-03 21:22:43 +000094}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020095mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000096
Jaeden Amero9366feb2018-05-29 18:55:17 +010097#if defined(MBEDTLS_CIPHER_MODE_XTS)
98/**
99 * \brief The AES XTS context-type definition.
100 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100101typedef struct mbedtls_aes_xts_context {
Mateusz Starzyk846f0212021-05-19 19:44:07 +0200102 mbedtls_aes_context MBEDTLS_PRIVATE(crypt); /*!< The AES context to use for AES block
Gilles Peskine449bd832023-01-11 14:50:10 +0100103 encryption or decryption. */
Mateusz Starzyk846f0212021-05-19 19:44:07 +0200104 mbedtls_aes_context MBEDTLS_PRIVATE(tweak); /*!< The AES context used for tweak
Gilles Peskine449bd832023-01-11 14:50:10 +0100105 computation. */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100106} mbedtls_aes_xts_context;
107#endif /* MBEDTLS_CIPHER_MODE_XTS */
108
Ron Eldorb2aacec2017-05-18 16:53:08 +0300109#else /* MBEDTLS_AES_ALT */
110#include "aes_alt.h"
111#endif /* MBEDTLS_AES_ALT */
112
Paul Bakker5121ce52009-01-03 21:22:43 +0000113/**
Rose Zadik7f441272018-01-22 11:48:23 +0000114 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200115 *
Rose Zadik7f441272018-01-22 11:48:23 +0000116 * It must be the first API called before using
117 * the context.
118 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500119 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200120 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100121void mbedtls_aes_init(mbedtls_aes_context *ctx);
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200122
123/**
Rose Zadik7f441272018-01-22 11:48:23 +0000124 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200125 *
Rose Zadik7f441272018-01-22 11:48:23 +0000126 * \param ctx The AES context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500127 * If this is \c NULL, this function does nothing.
128 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200129 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100130void mbedtls_aes_free(mbedtls_aes_context *ctx);
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200131
Jaeden Amero9366feb2018-05-29 18:55:17 +0100132#if defined(MBEDTLS_CIPHER_MODE_XTS)
133/**
134 * \brief This function initializes the specified AES XTS context.
135 *
136 * It must be the first API called before using
137 * the context.
138 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500139 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100140 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100141void mbedtls_aes_xts_init(mbedtls_aes_xts_context *ctx);
Jaeden Amero9366feb2018-05-29 18:55:17 +0100142
143/**
144 * \brief This function releases and clears the specified AES XTS context.
145 *
146 * \param ctx The AES XTS context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500147 * If this is \c NULL, this function does nothing.
148 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100149 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100150void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx);
Jaeden Amero9366feb2018-05-29 18:55:17 +0100151#endif /* MBEDTLS_CIPHER_MODE_XTS */
152
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200153/**
Rose Zadik7f441272018-01-22 11:48:23 +0000154 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000155 *
Rose Zadik7f441272018-01-22 11:48:23 +0000156 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500157 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000158 * \param key The encryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500159 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000160 * \param keybits The size of data passed in bits. Valid options are:
161 * <ul><li>128 bits</li>
162 * <li>192 bits</li>
163 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000164 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100165 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100166 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000167 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200168MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100169int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
170 unsigned int keybits);
Paul Bakker5121ce52009-01-03 21:22:43 +0000171
Yanray Wangb67b4742023-10-31 17:10:32 +0800172#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
Paul Bakker5121ce52009-01-03 21:22:43 +0000173/**
Rose Zadik7f441272018-01-22 11:48:23 +0000174 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000175 *
Rose Zadik7f441272018-01-22 11:48:23 +0000176 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500177 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000178 * \param key The decryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500179 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000180 * \param keybits The size of data passed. Valid options are:
181 * <ul><li>128 bits</li>
182 * <li>192 bits</li>
183 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000184 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100185 * \return \c 0 on success.
186 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000187 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200188MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100189int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
190 unsigned int keybits);
Yanray Wangb67b4742023-10-31 17:10:32 +0800191#endif /* !MBEDTLS_BLOCK_CIPHER_NO_DECRYPT */
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 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200210MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100211int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context *ctx,
212 const unsigned char *key,
213 unsigned int keybits);
Jaeden Amero9366feb2018-05-29 18:55:17 +0100214
215/**
216 * \brief This function prepares an XTS context for decryption and
217 * sets the decryption key.
218 *
219 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500220 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100221 * \param key The decryption key. This is comprised of the XTS key1
222 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500223 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100224 * \param keybits The size of \p key passed in bits. Valid options are:
225 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
226 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
227 *
228 * \return \c 0 on success.
229 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
230 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200231MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100232int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx,
233 const unsigned char *key,
234 unsigned int keybits);
Jaeden Amero9366feb2018-05-29 18:55:17 +0100235#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 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200260MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100261int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,
262 int mode,
263 const unsigned char input[16],
264 unsigned char output[16]);
Paul Bakker5121ce52009-01-03 21:22:43 +0000265
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200266#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000267/**
Rose Zadik7f441272018-01-22 11:48:23 +0000268 * \brief This function performs an AES-CBC encryption or decryption operation
269 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000270 *
Rose Zadik7f441272018-01-22 11:48:23 +0000271 * It performs the operation defined in the \p mode
272 * parameter (encrypt/decrypt), on the input data buffer defined in
273 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000274 *
Rose Zadik7f441272018-01-22 11:48:23 +0000275 * It can be called as many times as needed, until all the input
276 * data is processed. mbedtls_aes_init(), and either
277 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
278 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000279 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500280 * \note This function operates on full blocks, that is, the input size
281 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000282 *
283 * \note Upon exit, the content of the IV is updated so that you can
284 * call the same function again on the next
285 * block(s) of data and get the same result as if it was
286 * encrypted in one call. This allows a "streaming" usage.
287 * If you need to retain the contents of the IV, you should
288 * either save it manually or use the cipher module instead.
289 *
290 *
291 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500292 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000293 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
294 * #MBEDTLS_AES_DECRYPT.
295 * \param length The length of the input data in Bytes. This must be a
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500296 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000297 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500298 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000299 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500300 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000301 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500302 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000303 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100304 * \return \c 0 on success.
305 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000306 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000307 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200308MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100309int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
310 int mode,
311 size_t length,
312 unsigned char iv[16],
313 const unsigned char *input,
314 unsigned char *output);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200315#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000316
Aorimn5f778012016-06-09 23:22:58 +0200317#if defined(MBEDTLS_CIPHER_MODE_XTS)
318/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100319 * \brief This function performs an AES-XTS encryption or decryption
320 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200321 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100322 * AES-XTS encrypts or decrypts blocks based on their location as
323 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100324 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200325 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100326 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
327 * AES blocks. If the data unit is larger than this, this function
328 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
329 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100330 * \param ctx The AES XTS context to use for AES XTS operations.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500331 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100332 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
333 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500334 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100335 * length between 16 bytes and 2^24 bytes inclusive
336 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100337 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100338 * bytes in little-endian format. For disk encryption, this
339 * is typically the index of the block device sector that
340 * contains the data.
341 * \param input The buffer holding the input data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500342 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100343 * input.
344 * \param output The buffer holding the output data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500345 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100346 * output.
Aorimn5f778012016-06-09 23:22:58 +0200347 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100348 * \return \c 0 on success.
349 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500350 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100351 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200352 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200353MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100354int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx,
355 int mode,
356 size_t length,
357 const unsigned char data_unit[16],
358 const unsigned char *input,
359 unsigned char *output);
Aorimn5f778012016-06-09 23:22:58 +0200360#endif /* MBEDTLS_CIPHER_MODE_XTS */
361
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200362#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000363/**
Rose Zadik7f441272018-01-22 11:48:23 +0000364 * \brief This function performs an AES-CFB128 encryption or decryption
365 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000366 *
Rose Zadik7f441272018-01-22 11:48:23 +0000367 * It performs the operation defined in the \p mode
368 * parameter (encrypt or decrypt), on the input data buffer
369 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000370 *
Rose Zadik7f441272018-01-22 11:48:23 +0000371 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
372 * regardless of whether you are performing an encryption or decryption
373 * operation, that is, regardless of the \p mode parameter. This is
374 * because CFB mode uses the same key schedule for encryption and
375 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000376 *
Rose Zadik7f441272018-01-22 11:48:23 +0000377 * \note Upon exit, the content of the IV is updated so that you can
378 * call the same function again on the next
379 * block(s) of data and get the same result as if it was
380 * encrypted in one call. This allows a "streaming" usage.
381 * If you need to retain the contents of the
382 * IV, you must either save it manually or use the cipher
383 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000384 *
Rose Zadik7f441272018-01-22 11:48:23 +0000385 *
386 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500387 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000388 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
389 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500390 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000391 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500392 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000393 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500394 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000395 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500396 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000397 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500398 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000399 *
400 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000401 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200402MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100403int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx,
404 int mode,
405 size_t length,
406 size_t *iv_off,
407 unsigned char iv[16],
408 const unsigned char *input,
409 unsigned char *output);
Paul Bakker5121ce52009-01-03 21:22:43 +0000410
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 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200447MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100448int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx,
449 int mode,
450 size_t length,
451 unsigned char iv[16],
452 const unsigned char *input,
453 unsigned char *output);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200454#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100455
Simon Butcher76a5b222018-04-22 22:57:27 +0100456#if defined(MBEDTLS_CIPHER_MODE_OFB)
457/**
Simon Butcher5db13622018-06-04 22:11:25 +0100458 * \brief This function performs an AES-OFB (Output Feedback Mode)
459 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100460 *
Simon Butcher5db13622018-06-04 22:11:25 +0100461 * For OFB, you must set up the context with
462 * mbedtls_aes_setkey_enc(), regardless of whether you are
463 * performing an encryption or decryption operation. This is
464 * because OFB mode uses the same key schedule for encryption and
465 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100466 *
Simon Butcher5db13622018-06-04 22:11:25 +0100467 * The OFB operation is identical for encryption or decryption,
468 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100469 *
Simon Butcher5db13622018-06-04 22:11:25 +0100470 * \note Upon exit, the content of iv, the Initialisation Vector, is
471 * updated so that you can call the same function again on the next
472 * block(s) of data and get the same result as if it was encrypted
473 * in one call. This allows a "streaming" usage, by initialising
474 * iv_off to 0 before the first call, and preserving its value
475 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100476 *
Simon Butcher5db13622018-06-04 22:11:25 +0100477 * For non-streaming use, the iv should be initialised on each call
478 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100479 *
Simon Butcher5db13622018-06-04 22:11:25 +0100480 * If you need to retain the contents of the initialisation vector,
481 * you must either save it manually or use the cipher module
482 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100483 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100484 * \warning For the OFB mode, the initialisation vector must be unique
485 * every encryption operation. Reuse of an initialisation vector
486 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100487 *
488 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500489 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100490 * \param length The length of the input data.
491 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500492 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100493 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500494 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100495 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500496 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100497 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500498 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100499 *
500 * \return \c 0 on success.
501 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200502MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100503int mbedtls_aes_crypt_ofb(mbedtls_aes_context *ctx,
504 size_t length,
505 size_t *iv_off,
506 unsigned char iv[16],
507 const unsigned char *input,
508 unsigned char *output);
Simon Butcher76a5b222018-04-22 22:57:27 +0100509
510#endif /* MBEDTLS_CIPHER_MODE_OFB */
511
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200512#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100513/**
Rose Zadik7f441272018-01-22 11:48:23 +0000514 * \brief This function performs an AES-CTR encryption or decryption
515 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000516 *
Rose Zadik7f441272018-01-22 11:48:23 +0000517 * Due to the nature of CTR, you must use the same key schedule
518 * for both encryption and decryption operations. Therefore, you
519 * must use the context initialized with mbedtls_aes_setkey_enc()
520 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000521 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100522 * \warning You must never reuse a nonce value with the same key. Doing so
523 * would void the encryption for the two messages encrypted with
524 * the same nonce and key.
525 *
526 * There are two common strategies for managing nonces with CTR:
527 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200528 * 1. You can handle everything as a single message processed over
529 * successive calls to this function. In that case, you want to
530 * set \p nonce_counter and \p nc_off to 0 for the first call, and
531 * then preserve the values of \p nonce_counter, \p nc_off and \p
532 * stream_block across calls to this function as they will be
533 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100534 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200535 * With this strategy, you must not encrypt more than 2**128
536 * blocks of data with the same key.
537 *
538 * 2. You can encrypt separate messages by dividing the \p
539 * nonce_counter buffer in two areas: the first one used for a
540 * per-message nonce, handled by yourself, and the second one
541 * updated by this function internally.
542 *
543 * For example, you might reserve the first 12 bytes for the
544 * per-message nonce, and the last 4 bytes for internal use. In that
545 * case, before calling this function on a new message you need to
546 * set the first 12 bytes of \p nonce_counter to your chosen nonce
547 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
548 * stream_block to be ignored). That way, you can encrypt at most
549 * 2**96 messages of up to 2**32 blocks each with the same key.
550 *
551 * The per-message nonce (or information sufficient to reconstruct
552 * it) needs to be communicated with the ciphertext and must be unique.
553 * The recommended way to ensure uniqueness is to use a message
554 * counter. An alternative is to generate random nonces, but this
555 * limits the number of messages that can be securely encrypted:
556 * for example, with 96-bit random nonces, you should not encrypt
557 * more than 2**32 messages with the same key.
558 *
Tom Cosgrove1e211442022-05-26 11:51:00 +0100559 * Note that for both strategies, sizes are measured in blocks and
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200560 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000561 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200562 * \warning Upon return, \p stream_block contains sensitive data. Its
563 * content must not be written to insecure storage and should be
564 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000565 *
Rose Zadik7f441272018-01-22 11:48:23 +0000566 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500567 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000568 * \param length The length of the input data.
569 * \param nc_off The offset in the current \p stream_block, for
570 * resuming within the current cipher stream. The
571 * offset pointer should be 0 at the start of a stream.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500572 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000573 * \param nonce_counter The 128-bit nonce and counter.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500574 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000575 * \param stream_block The saved stream block for resuming. This is
576 * overwritten by the function.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500577 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000578 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500579 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000580 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500581 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000582 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100583 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000584 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200585MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100586int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx,
587 size_t length,
588 size_t *nc_off,
589 unsigned char nonce_counter[16],
590 unsigned char stream_block[16],
591 const unsigned char *input,
592 unsigned char *output);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200593#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200594
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200595/**
Rose Zadik7f441272018-01-22 11:48:23 +0000596 * \brief Internal AES block encryption function. This is only
597 * exposed to allow overriding it using
598 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200599 *
Rose Zadik7f441272018-01-22 11:48:23 +0000600 * \param ctx The AES context to use for encryption.
601 * \param input The plaintext block.
602 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000603 *
Rose Zadik7f441272018-01-22 11:48:23 +0000604 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200605 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200606MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100607int 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
Yanray Wangb67b4742023-10-31 17:10:32 +0800611#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200612/**
Rose Zadik7f441272018-01-22 11:48:23 +0000613 * \brief Internal AES block decryption function. This is only
614 * exposed to allow overriding it using see
615 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200616 *
Rose Zadik7f441272018-01-22 11:48:23 +0000617 * \param ctx The AES context to use for decryption.
618 * \param input The ciphertext block.
619 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000620 *
Rose Zadik7f441272018-01-22 11:48:23 +0000621 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200622 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200623MBEDTLS_CHECK_RETURN_TYPICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100624int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx,
625 const unsigned char input[16],
626 unsigned char output[16]);
Yanray Wangb67b4742023-10-31 17:10:32 +0800627#endif /* !MBEDTLS_BLOCK_CIPHER_NO_DECRYPT */
Andres AGf5bf7182017-03-03 14:09:56 +0000628
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500629#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000630/**
Rose Zadik7f441272018-01-22 11:48:23 +0000631 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000632 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100633 * \return \c 0 on success.
634 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000635 */
Gilles Peskinee41803a2021-09-23 17:35:37 +0200636MBEDTLS_CHECK_RETURN_CRITICAL
Gilles Peskine449bd832023-01-11 14:50:10 +0100637int mbedtls_aes_self_test(int verbose);
Paul Bakker5121ce52009-01-03 21:22:43 +0000638
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500639#endif /* MBEDTLS_SELF_TEST */
640
Paul Bakker5121ce52009-01-03 21:22:43 +0000641#ifdef __cplusplus
642}
643#endif
644
645#endif /* aes.h */