blob: dc5ae199ca6ea73fe7d243a944ece1db80d7868d [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útif744bd72020-06-05 13:02:18 +020023/*
Bence Szépkútia2947ac2020-08-19 16:37:36 +020024 * Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +020025 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
26 *
27 * This file is provided under the Apache License 2.0, or the
28 * GNU General Public License v2.0 or later.
29 *
30 * **********
31 * Apache License 2.0:
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020032 *
33 * Licensed under the Apache License, Version 2.0 (the "License"); you may
34 * not use this file except in compliance with the License.
35 * You may obtain a copy of the License at
36 *
37 * http://www.apache.org/licenses/LICENSE-2.0
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
41 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000044 *
Bence Szépkútif744bd72020-06-05 13:02:18 +020045 * **********
46 *
47 * **********
48 * GNU General Public License v2.0 or later:
49 *
50 * This program is free software; you can redistribute it and/or modify
51 * it under the terms of the GNU General Public License as published by
52 * the Free Software Foundation; either version 2 of the License, or
53 * (at your option) any later version.
54 *
55 * This program is distributed in the hope that it will be useful,
56 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 * GNU General Public License for more details.
59 *
60 * You should have received a copy of the GNU General Public License along
61 * with this program; if not, write to the Free Software Foundation, Inc.,
62 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
63 *
64 * **********
Paul Bakker5121ce52009-01-03 21:22:43 +000065 */
Rose Zadik7f441272018-01-22 11:48:23 +000066
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020067#ifndef MBEDTLS_AES_H
68#define MBEDTLS_AES_H
Paul Bakker5121ce52009-01-03 21:22:43 +000069
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020070#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker90995b52013-06-24 19:20:35 +020071#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020072#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020073#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020074#endif
Paul Bakker90995b52013-06-24 19:20:35 +020075
Rich Evans00ab4702015-02-06 13:43:58 +000076#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020077#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000078
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010079/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000080#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
81#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000082
Andres Amaya Garciac5380642017-11-28 19:57:51 +000083/* Error codes in range 0x0020-0x0022 */
Gilles Peskine1990fab2021-07-26 18:48:10 +020084/** Invalid key length. */
85#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
86/** Invalid data input length. */
87#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
Paul Bakker2b222c82009-07-27 21:03:45 +000088
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000089/* Error codes in range 0x0021-0x0025 */
Gilles Peskine1990fab2021-07-26 18:48:10 +020090/** Invalid input data. */
91#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
Ron Eldor9924bdc2018-10-04 10:59:13 +030092
93/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
Gilles Peskine1990fab2021-07-26 18:48:10 +020094/** Feature not available. For example, an unsupported AES key size. */
95#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
Ron Eldor9924bdc2018-10-04 10:59:13 +030096
97/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
Gilles Peskine1990fab2021-07-26 18:48:10 +020098/** AES hardware accelerator failed. */
99#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
Paul Bakker5121ce52009-01-03 21:22:43 +0000100
Andres AGf5bf7182017-03-03 14:09:56 +0000101#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
102 !defined(inline) && !defined(__cplusplus)
103#define inline __inline
104#endif
105
Paul Bakker407a0da2013-06-27 14:29:21 +0200106#ifdef __cplusplus
107extern "C" {
108#endif
109
Ron Eldorb2aacec2017-05-18 16:53:08 +0300110#if !defined(MBEDTLS_AES_ALT)
111// Regular implementation
112//
113
Paul Bakker5121ce52009-01-03 21:22:43 +0000114/**
Rose Zadik7f441272018-01-22 11:48:23 +0000115 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +0000116 */
Dawid Drozd428cc522018-07-24 10:02:47 +0200117typedef struct mbedtls_aes_context
Paul Bakker5121ce52009-01-03 21:22:43 +0000118{
Rose Zadik7f441272018-01-22 11:48:23 +0000119 int nr; /*!< The number of rounds. */
120 uint32_t *rk; /*!< AES round keys. */
121 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
122 hold 32 extra Bytes, which can be used for
123 one of the following purposes:
124 <ul><li>Alignment if VIA padlock is
125 used.</li>
126 <li>Simplifying key expansion in the 256-bit
127 case by generating an extra round key.
128 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +0000129}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200130mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +0000131
Jaeden Amero9366feb2018-05-29 18:55:17 +0100132#if defined(MBEDTLS_CIPHER_MODE_XTS)
133/**
134 * \brief The AES XTS context-type definition.
135 */
Dawid Drozd428cc522018-07-24 10:02:47 +0200136typedef struct mbedtls_aes_xts_context
Jaeden Amero9366feb2018-05-29 18:55:17 +0100137{
138 mbedtls_aes_context crypt; /*!< The AES context to use for AES block
139 encryption or decryption. */
140 mbedtls_aes_context tweak; /*!< The AES context used for tweak
141 computation. */
142} mbedtls_aes_xts_context;
143#endif /* MBEDTLS_CIPHER_MODE_XTS */
144
Ron Eldorb2aacec2017-05-18 16:53:08 +0300145#else /* MBEDTLS_AES_ALT */
146#include "aes_alt.h"
147#endif /* MBEDTLS_AES_ALT */
148
Paul Bakker5121ce52009-01-03 21:22:43 +0000149/**
Rose Zadik7f441272018-01-22 11:48:23 +0000150 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200151 *
Rose Zadik7f441272018-01-22 11:48:23 +0000152 * It must be the first API called before using
153 * the context.
154 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100155 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200156 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200157void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200158
159/**
Rose Zadik7f441272018-01-22 11:48:23 +0000160 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200161 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100162 * \param ctx The AES context to clear.
163 * If this is \c NULL, this function does nothing.
164 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200165 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200167
Jaeden Amero9366feb2018-05-29 18:55:17 +0100168#if defined(MBEDTLS_CIPHER_MODE_XTS)
169/**
170 * \brief This function initializes the specified AES XTS context.
171 *
172 * It must be the first API called before using
173 * the context.
174 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100175 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100176 */
177void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
178
179/**
180 * \brief This function releases and clears the specified AES XTS context.
181 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100182 * \param ctx The AES XTS context to clear.
183 * If this is \c NULL, this function does nothing.
184 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100185 */
186void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
187#endif /* MBEDTLS_CIPHER_MODE_XTS */
188
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200189/**
Rose Zadik7f441272018-01-22 11:48:23 +0000190 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000191 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100192 * \param ctx The AES context to which the key should be bound.
193 * It must be initialized.
194 * \param key The encryption key.
195 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000196 * \param keybits The size of data passed in bits. Valid options are:
197 * <ul><li>128 bits</li>
198 * <li>192 bits</li>
199 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000200 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100201 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100202 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000203 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200204int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200205 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000206
207/**
Rose Zadik7f441272018-01-22 11:48:23 +0000208 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000209 *
Manuel Pégourié-Gonnarded459e62018-12-12 10:20:33 +0100210 * \param ctx The AES context to which the key should be bound.
211 * It must be initialized.
212 * \param key The decryption key.
213 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000214 * \param keybits The size of data passed. Valid options are:
215 * <ul><li>128 bits</li>
216 * <li>192 bits</li>
217 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000218 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100219 * \return \c 0 on success.
220 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000221 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200222int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200223 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000224
Jaeden Amero9366feb2018-05-29 18:55:17 +0100225#if defined(MBEDTLS_CIPHER_MODE_XTS)
226/**
227 * \brief This function prepares an XTS context for encryption and
228 * sets the encryption key.
229 *
230 * \param ctx The AES XTS context to which the key should be bound.
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100231 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100232 * \param key The encryption key. This is comprised of the XTS key1
233 * concatenated with the XTS key2.
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100234 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100235 * \param keybits The size of \p key passed in bits. Valid options are:
236 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
237 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
238 *
239 * \return \c 0 on success.
240 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
241 */
242int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
243 const unsigned char *key,
244 unsigned int keybits );
245
246/**
247 * \brief This function prepares an XTS context for decryption and
248 * sets the decryption key.
249 *
250 * \param ctx The AES XTS context to which the key should be bound.
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100251 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100252 * \param key The decryption key. This is comprised of the XTS key1
253 * concatenated with the XTS key2.
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100254 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100255 * \param keybits The size of \p key passed in bits. Valid options are:
256 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
257 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
258 *
259 * \return \c 0 on success.
260 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
261 */
262int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
263 const unsigned char *key,
264 unsigned int keybits );
265#endif /* MBEDTLS_CIPHER_MODE_XTS */
266
Paul Bakker5121ce52009-01-03 21:22:43 +0000267/**
Rose Zadik7f441272018-01-22 11:48:23 +0000268 * \brief This function performs an AES single-block encryption or
269 * decryption operation.
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 parameter
272 * (encrypt or decrypt), on the input data buffer defined in
273 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000274 *
Rose Zadik7f441272018-01-22 11:48:23 +0000275 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
276 * mbedtls_aes_setkey_dec() must be called before the first
277 * call to this API with the same context.
278 *
279 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard1aca2602018-12-12 12:56:55 +0100280 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000281 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
282 * #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard1aca2602018-12-12 12:56:55 +0100283 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100284 * It must be readable and at least \c 16 Bytes long.
Manuel Pégourié-Gonnard1aca2602018-12-12 12:56:55 +0100285 * \param output The buffer where the output data will be written.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100286 * It must be writeable and at least \c 16 Bytes long.
Rose Zadik7f441272018-01-22 11:48:23 +0000287
288 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000289 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200290int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000291 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000292 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000293 unsigned char output[16] );
294
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200295#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000296/**
Rose Zadik7f441272018-01-22 11:48:23 +0000297 * \brief This function performs an AES-CBC encryption or decryption operation
298 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000299 *
Rose Zadik7f441272018-01-22 11:48:23 +0000300 * It performs the operation defined in the \p mode
301 * parameter (encrypt/decrypt), on the input data buffer defined in
302 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000303 *
Rose Zadik7f441272018-01-22 11:48:23 +0000304 * It can be called as many times as needed, until all the input
305 * data is processed. mbedtls_aes_init(), and either
306 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
307 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000308 *
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100309 * \note This function operates on full blocks, that is, the input size
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100310 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000311 *
312 * \note Upon exit, the content of the IV is updated so that you can
313 * call the same function again on the next
314 * block(s) of data and get the same result as if it was
315 * encrypted in one call. This allows a "streaming" usage.
316 * If you need to retain the contents of the IV, you should
317 * either save it manually or use the cipher module instead.
318 *
319 *
320 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100321 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000322 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
323 * #MBEDTLS_AES_DECRYPT.
324 * \param length The length of the input data in Bytes. This must be a
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100325 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000326 * \param iv Initialization vector (updated after use).
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100327 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000328 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100329 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000330 * \param output The buffer holding the output data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100331 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000332 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100333 * \return \c 0 on success.
334 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000335 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000336 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200337int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000338 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000339 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000340 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000341 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000342 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200343#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000344
Aorimn5f778012016-06-09 23:22:58 +0200345#if defined(MBEDTLS_CIPHER_MODE_XTS)
346/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100347 * \brief This function performs an AES-XTS encryption or decryption
348 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200349 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100350 * AES-XTS encrypts or decrypts blocks based on their location as
351 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100352 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200353 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100354 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
355 * AES blocks. If the data unit is larger than this, this function
356 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
357 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100358 * \param ctx The AES XTS context to use for AES XTS operations.
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100359 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100360 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
361 * #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100362 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100363 * length between 16 bytes and 2^24 bytes inclusive
364 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100365 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100366 * bytes in little-endian format. For disk encryption, this
367 * is typically the index of the block device sector that
368 * contains the data.
369 * \param input The buffer holding the input data (which is an entire
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100370 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100371 * input.
372 * \param output The buffer holding the output data (which is an entire
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100373 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100374 * output.
Aorimn5f778012016-06-09 23:22:58 +0200375 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100376 * \return \c 0 on success.
377 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100378 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100379 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200380 */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100381int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
382 int mode,
Jaeden Amero5162b932018-05-29 12:55:24 +0100383 size_t length,
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100384 const unsigned char data_unit[16],
Jaeden Amero9366feb2018-05-29 18:55:17 +0100385 const unsigned char *input,
386 unsigned char *output );
Aorimn5f778012016-06-09 23:22:58 +0200387#endif /* MBEDTLS_CIPHER_MODE_XTS */
388
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200389#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000390/**
Rose Zadik7f441272018-01-22 11:48:23 +0000391 * \brief This function performs an AES-CFB128 encryption or decryption
392 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000393 *
Rose Zadik7f441272018-01-22 11:48:23 +0000394 * It performs the operation defined in the \p mode
395 * parameter (encrypt or decrypt), on the input data buffer
396 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000397 *
Rose Zadik7f441272018-01-22 11:48:23 +0000398 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
399 * regardless of whether you are performing an encryption or decryption
400 * operation, that is, regardless of the \p mode parameter. This is
401 * because CFB mode uses the same key schedule for encryption and
402 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000403 *
Rose Zadik7f441272018-01-22 11:48:23 +0000404 * \note Upon exit, the content of the IV is updated so that you can
405 * call the same function again on the next
406 * block(s) of data and get the same result as if it was
407 * encrypted in one call. This allows a "streaming" usage.
408 * If you need to retain the contents of the
409 * IV, you must either save it manually or use the cipher
410 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000411 *
Rose Zadik7f441272018-01-22 11:48:23 +0000412 *
413 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard1677cca2018-12-13 10:27:13 +0100414 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000415 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
416 * #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100417 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000418 * \param iv_off The offset in IV (updated after use).
Manuel Pégourié-Gonnard1677cca2018-12-13 10:27:13 +0100419 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000420 * \param iv The initialization vector (updated after use).
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100421 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000422 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100423 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000424 * \param output The buffer holding the output data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100425 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000426 *
427 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000428 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200429int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000430 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000431 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000432 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000433 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000434 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000435 unsigned char *output );
436
Paul Bakker9a736322012-11-14 12:39:52 +0000437/**
Rose Zadik7f441272018-01-22 11:48:23 +0000438 * \brief This function performs an AES-CFB8 encryption or decryption
439 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100440 *
Rose Zadik7f441272018-01-22 11:48:23 +0000441 * It performs the operation defined in the \p mode
442 * parameter (encrypt/decrypt), on the input data buffer defined
443 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100444 *
Rose Zadik7f441272018-01-22 11:48:23 +0000445 * Due to the nature of CFB, you must use the same key schedule for
446 * both encryption and decryption operations. Therefore, you must
447 * use the context initialized with mbedtls_aes_setkey_enc() for
448 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000449 *
Rose Zadik7f441272018-01-22 11:48:23 +0000450 * \note Upon exit, the content of the IV is updated so that you can
451 * call the same function again on the next
452 * block(s) of data and get the same result as if it was
453 * encrypted in one call. This allows a "streaming" usage.
454 * If you need to retain the contents of the
455 * IV, you should either save it manually or use the cipher
456 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100457 *
Rose Zadik7f441272018-01-22 11:48:23 +0000458 *
459 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard1677cca2018-12-13 10:27:13 +0100460 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000461 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
462 * #MBEDTLS_AES_DECRYPT
463 * \param length The length of the input data.
464 * \param iv The initialization vector (updated after use).
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100465 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000466 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100467 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000468 * \param output The buffer holding the output data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100469 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000470 *
471 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100472 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200473int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100474 int mode,
475 size_t length,
476 unsigned char iv[16],
477 const unsigned char *input,
478 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200479#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100480
Simon Butcher76a5b222018-04-22 22:57:27 +0100481#if defined(MBEDTLS_CIPHER_MODE_OFB)
482/**
Simon Butcher5db13622018-06-04 22:11:25 +0100483 * \brief This function performs an AES-OFB (Output Feedback Mode)
484 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100485 *
Simon Butcher5db13622018-06-04 22:11:25 +0100486 * For OFB, you must set up the context with
487 * mbedtls_aes_setkey_enc(), regardless of whether you are
488 * performing an encryption or decryption operation. This is
489 * because OFB mode uses the same key schedule for encryption and
490 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100491 *
Simon Butcher5db13622018-06-04 22:11:25 +0100492 * The OFB operation is identical for encryption or decryption,
493 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100494 *
Simon Butcher5db13622018-06-04 22:11:25 +0100495 * \note Upon exit, the content of iv, the Initialisation Vector, is
496 * updated so that you can call the same function again on the next
497 * block(s) of data and get the same result as if it was encrypted
498 * in one call. This allows a "streaming" usage, by initialising
499 * iv_off to 0 before the first call, and preserving its value
500 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100501 *
Simon Butcher5db13622018-06-04 22:11:25 +0100502 * For non-streaming use, the iv should be initialised on each call
503 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100504 *
Simon Butcher5db13622018-06-04 22:11:25 +0100505 * If you need to retain the contents of the initialisation vector,
506 * you must either save it manually or use the cipher module
507 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100508 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100509 * \warning For the OFB mode, the initialisation vector must be unique
510 * every encryption operation. Reuse of an initialisation vector
511 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100512 *
513 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard8e41eb72018-12-13 11:00:56 +0100514 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100515 * \param length The length of the input data.
516 * \param iv_off The offset in IV (updated after use).
Manuel Pégourié-Gonnard8e41eb72018-12-13 11:00:56 +0100517 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100518 * \param iv The initialization vector (updated after use).
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100519 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100520 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100521 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100522 * \param output The buffer holding the output data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100523 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100524 *
525 * \return \c 0 on success.
526 */
527int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
528 size_t length,
529 size_t *iv_off,
530 unsigned char iv[16],
531 const unsigned char *input,
532 unsigned char *output );
533
534#endif /* MBEDTLS_CIPHER_MODE_OFB */
535
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200536#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100537/**
Rose Zadik7f441272018-01-22 11:48:23 +0000538 * \brief This function performs an AES-CTR encryption or decryption
539 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000540 *
Rose Zadik7f441272018-01-22 11:48:23 +0000541 * Due to the nature of CTR, you must use the same key schedule
542 * for both encryption and decryption operations. Therefore, you
543 * must use the context initialized with mbedtls_aes_setkey_enc()
544 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000545 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100546 * \warning You must never reuse a nonce value with the same key. Doing so
547 * would void the encryption for the two messages encrypted with
548 * the same nonce and key.
549 *
550 * There are two common strategies for managing nonces with CTR:
551 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200552 * 1. You can handle everything as a single message processed over
553 * successive calls to this function. In that case, you want to
554 * set \p nonce_counter and \p nc_off to 0 for the first call, and
555 * then preserve the values of \p nonce_counter, \p nc_off and \p
556 * stream_block across calls to this function as they will be
557 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100558 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200559 * With this strategy, you must not encrypt more than 2**128
560 * blocks of data with the same key.
561 *
562 * 2. You can encrypt separate messages by dividing the \p
563 * nonce_counter buffer in two areas: the first one used for a
564 * per-message nonce, handled by yourself, and the second one
565 * updated by this function internally.
566 *
567 * For example, you might reserve the first 12 bytes for the
568 * per-message nonce, and the last 4 bytes for internal use. In that
569 * case, before calling this function on a new message you need to
570 * set the first 12 bytes of \p nonce_counter to your chosen nonce
571 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
572 * stream_block to be ignored). That way, you can encrypt at most
573 * 2**96 messages of up to 2**32 blocks each with the same key.
574 *
575 * The per-message nonce (or information sufficient to reconstruct
576 * it) needs to be communicated with the ciphertext and must be unique.
577 * The recommended way to ensure uniqueness is to use a message
578 * counter. An alternative is to generate random nonces, but this
579 * limits the number of messages that can be securely encrypted:
580 * for example, with 96-bit random nonces, you should not encrypt
581 * more than 2**32 messages with the same key.
582 *
583 * Note that for both stategies, sizes are measured in blocks and
584 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000585 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200586 * \warning Upon return, \p stream_block contains sensitive data. Its
587 * content must not be written to insecure storage and should be
588 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000589 *
Rose Zadik7f441272018-01-22 11:48:23 +0000590 * \param ctx The AES context to use for encryption or decryption.
Manuel Pégourié-Gonnard2bc535b2018-12-13 11:08:36 +0100591 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000592 * \param length The length of the input data.
593 * \param nc_off The offset in the current \p stream_block, for
594 * resuming within the current cipher stream. The
595 * offset pointer should be 0 at the start of a stream.
Manuel Pégourié-Gonnard2bc535b2018-12-13 11:08:36 +0100596 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000597 * \param nonce_counter The 128-bit nonce and counter.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100598 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000599 * \param stream_block The saved stream block for resuming. This is
600 * overwritten by the function.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100601 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000602 * \param input The buffer holding the input data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100603 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000604 * \param output The buffer holding the output data.
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100605 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000606 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100607 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000608 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200609int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000610 size_t length,
611 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000612 unsigned char nonce_counter[16],
613 unsigned char stream_block[16],
614 const unsigned char *input,
615 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200616#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200617
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200618/**
Rose Zadik7f441272018-01-22 11:48:23 +0000619 * \brief Internal AES block encryption function. This is only
620 * exposed to allow overriding it using
621 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200622 *
Rose Zadik7f441272018-01-22 11:48:23 +0000623 * \param ctx The AES context to use for encryption.
624 * \param input The plaintext block.
625 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000626 *
Rose Zadik7f441272018-01-22 11:48:23 +0000627 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200628 */
Andres AGf5bf7182017-03-03 14:09:56 +0000629int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
630 const unsigned char input[16],
631 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200632
633/**
Rose Zadik7f441272018-01-22 11:48:23 +0000634 * \brief Internal AES block decryption function. This is only
635 * exposed to allow overriding it using see
636 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200637 *
Rose Zadik7f441272018-01-22 11:48:23 +0000638 * \param ctx The AES context to use for decryption.
639 * \param input The ciphertext block.
640 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000641 *
Rose Zadik7f441272018-01-22 11:48:23 +0000642 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200643 */
Andres AGf5bf7182017-03-03 14:09:56 +0000644int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
645 const unsigned char input[16],
646 unsigned char output[16] );
647
648#if !defined(MBEDTLS_DEPRECATED_REMOVED)
649#if defined(MBEDTLS_DEPRECATED_WARNING)
650#define MBEDTLS_DEPRECATED __attribute__((deprecated))
651#else
652#define MBEDTLS_DEPRECATED
653#endif
654/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100655 * \brief Deprecated internal AES block encryption function
656 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000657 *
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100658 * \deprecated Superseded by mbedtls_internal_aes_encrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000659 *
Rose Zadik7f441272018-01-22 11:48:23 +0000660 * \param ctx The AES context to use for encryption.
661 * \param input Plaintext block.
662 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000663 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100664MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
665 const unsigned char input[16],
666 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000667
668/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100669 * \brief Deprecated internal AES block decryption function
670 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000671 *
Manuel Pégourié-Gonnardb66e7db2018-12-18 09:57:18 +0100672 * \deprecated Superseded by mbedtls_internal_aes_decrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000673 *
Rose Zadik7f441272018-01-22 11:48:23 +0000674 * \param ctx The AES context to use for decryption.
675 * \param input Ciphertext block.
676 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000677 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100678MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
679 const unsigned char input[16],
680 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000681
682#undef MBEDTLS_DEPRECATED
683#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200684
Ron Eldorfa8f6352017-06-20 15:48:46 +0300685
686#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000687/**
Rose Zadik7f441272018-01-22 11:48:23 +0000688 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000689 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100690 * \return \c 0 on success.
691 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000692 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200693int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000694
Ron Eldorfa8f6352017-06-20 15:48:46 +0300695#endif /* MBEDTLS_SELF_TEST */
696
Paul Bakker5121ce52009-01-03 21:22:43 +0000697#ifdef __cplusplus
698}
699#endif
700
701#endif /* aes.h */