blob: 9043ddac41c2756044d6c3868746309980523a34 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file aes.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Rose Zadik7f441272018-01-22 11:48:23 +00004 * \brief The Advanced Encryption Standard (AES) specifies a FIPS-approved
5 * cryptographic algorithm that can be used to protect electronic
6 * data.
7 *
8 * The AES algorithm is a symmetric block cipher that can
9 * encrypt and decrypt information. For more information, see
10 * <em>FIPS Publication 197: Advanced Encryption Standard</em> and
11 * <em>ISO/IEC 18033-2:2006: Information technology -- Security
12 * techniques -- Encryption algorithms -- Part 2: Asymmetric
13 * ciphers</em>.
Darryl Greena40a1012018-01-05 15:33:17 +000014 */
Rose Zadik7f441272018-01-22 11:48:23 +000015/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020016 * SPDX-License-Identifier: Apache-2.0
17 *
18 * Licensed under the Apache License, Version 2.0 (the "License"); you may
19 * not use this file except in compliance with the License.
20 * You may obtain a copy of the License at
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Unless required by applicable law or agreed to in writing, software
25 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27 * See the License for the specific language governing permissions and
28 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000029 *
Rose Zadik7f441272018-01-22 11:48:23 +000030 * This file is part of Mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000031 */
Rose Zadik7f441272018-01-22 11:48:23 +000032
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#ifndef MBEDTLS_AES_H
34#define MBEDTLS_AES_H
Paul Bakker5121ce52009-01-03 21:22:43 +000035
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker90995b52013-06-24 19:20:35 +020037#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020038#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020039#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020040#endif
Paul Bakker90995b52013-06-24 19:20:35 +020041
Rich Evans00ab4702015-02-06 13:43:58 +000042#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020043#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000044
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010045/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000046#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
47#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000048
Andres Amaya Garciac5380642017-11-28 19:57:51 +000049/* Error codes in range 0x0020-0x0022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020050#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
51#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
Paul Bakker2b222c82009-07-27 21:03:45 +000052
Gilles Peskine7ecab3d2018-01-26 17:56:38 +010053/* Error codes in range 0x0023-0x0025 */
Rose Zadik7f441272018-01-22 11:48:23 +000054#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
Gilles Peskine7ecab3d2018-01-26 17:56:38 +010055#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000056
Andres AGf5bf7182017-03-03 14:09:56 +000057#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
58 !defined(inline) && !defined(__cplusplus)
59#define inline __inline
60#endif
61
Paul Bakker407a0da2013-06-27 14:29:21 +020062#ifdef __cplusplus
63extern "C" {
64#endif
65
Ron Eldorb2aacec2017-05-18 16:53:08 +030066#if !defined(MBEDTLS_AES_ALT)
67// Regular implementation
68//
69
Paul Bakker5121ce52009-01-03 21:22:43 +000070/**
Rose Zadik7f441272018-01-22 11:48:23 +000071 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000072 */
73typedef struct
74{
Rose Zadik7f441272018-01-22 11:48:23 +000075 int nr; /*!< The number of rounds. */
76 uint32_t *rk; /*!< AES round keys. */
77 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
78 hold 32 extra Bytes, which can be used for
79 one of the following purposes:
80 <ul><li>Alignment if VIA padlock is
81 used.</li>
82 <li>Simplifying key expansion in the 256-bit
83 case by generating an extra round key.
84 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +000085}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000087
Ron Eldorb2aacec2017-05-18 16:53:08 +030088#else /* MBEDTLS_AES_ALT */
89#include "aes_alt.h"
90#endif /* MBEDTLS_AES_ALT */
91
Paul Bakker5121ce52009-01-03 21:22:43 +000092/**
Rose Zadik7f441272018-01-22 11:48:23 +000093 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +020094 *
Rose Zadik7f441272018-01-22 11:48:23 +000095 * It must be the first API called before using
96 * the context.
97 *
98 * \param ctx The AES context to initialize.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +020099 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200101
102/**
Rose Zadik7f441272018-01-22 11:48:23 +0000103 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200104 *
Rose Zadik7f441272018-01-22 11:48:23 +0000105 * \param ctx The AES context to clear.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200106 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200107void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200108
109/**
Rose Zadik7f441272018-01-22 11:48:23 +0000110 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000111 *
Rose Zadik7f441272018-01-22 11:48:23 +0000112 * \param ctx The AES context to which the key should be bound.
113 * \param key The encryption key.
114 * \param keybits The size of data passed in bits. Valid options are:
115 * <ul><li>128 bits</li>
116 * <li>192 bits</li>
117 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000118 *
Rose Zadik7f441272018-01-22 11:48:23 +0000119 * \return \c 0 on success or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
120 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000121 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200122int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200123 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000124
125/**
Rose Zadik7f441272018-01-22 11:48:23 +0000126 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000127 *
Rose Zadik7f441272018-01-22 11:48:23 +0000128 * \param ctx The AES context to which the key should be bound.
129 * \param key The decryption key.
130 * \param keybits The size of data passed. Valid options are:
131 * <ul><li>128 bits</li>
132 * <li>192 bits</li>
133 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000134 *
Rose Zadik7f441272018-01-22 11:48:23 +0000135 * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000136 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200137int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200138 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000139
140/**
Rose Zadik7f441272018-01-22 11:48:23 +0000141 * \brief This function performs an AES single-block encryption or
142 * decryption operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000143 *
Rose Zadik7f441272018-01-22 11:48:23 +0000144 * It performs the operation defined in the \p mode parameter
145 * (encrypt or decrypt), on the input data buffer defined in
146 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000147 *
Rose Zadik7f441272018-01-22 11:48:23 +0000148 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
149 * mbedtls_aes_setkey_dec() must be called before the first
150 * call to this API with the same context.
151 *
152 * \param ctx The AES context to use for encryption or decryption.
153 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
154 * #MBEDTLS_AES_DECRYPT.
155 * \param input The 16-Byte buffer holding the input data.
156 * \param output The 16-Byte buffer holding the output data.
157
158 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000159 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200160int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000161 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000162 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000163 unsigned char output[16] );
164
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200165#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000166/**
Rose Zadik7f441272018-01-22 11:48:23 +0000167 * \brief This function performs an AES-CBC encryption or decryption operation
168 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000169 *
Rose Zadik7f441272018-01-22 11:48:23 +0000170 * It performs the operation defined in the \p mode
171 * parameter (encrypt/decrypt), on the input data buffer defined in
172 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000173 *
Rose Zadik7f441272018-01-22 11:48:23 +0000174 * It can be called as many times as needed, until all the input
175 * data is processed. mbedtls_aes_init(), and either
176 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
177 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000178 *
Rose Zadik7f441272018-01-22 11:48:23 +0000179 * \note This function operates on aligned blocks, that is, the input size
180 * must be a multiple of the AES block size of 16 Bytes.
181 *
182 * \note Upon exit, the content of the IV is updated so that you can
183 * call the same function again on the next
184 * block(s) of data and get the same result as if it was
185 * encrypted in one call. This allows a "streaming" usage.
186 * If you need to retain the contents of the IV, you should
187 * either save it manually or use the cipher module instead.
188 *
189 *
190 * \param ctx The AES context to use for encryption or decryption.
191 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
192 * #MBEDTLS_AES_DECRYPT.
193 * \param length The length of the input data in Bytes. This must be a
194 * multiple of the block size (16 Bytes).
195 * \param iv Initialization vector (updated after use).
196 * \param input The buffer holding the input data.
197 * \param output The buffer holding the output data.
198 *
199 * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
200 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000201 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200202int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000203 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000204 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000205 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000206 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000207 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200208#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000209
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200210#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000211/**
Rose Zadik7f441272018-01-22 11:48:23 +0000212 * \brief This function performs an AES-CFB128 encryption or decryption
213 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000214 *
Rose Zadik7f441272018-01-22 11:48:23 +0000215 * It performs the operation defined in the \p mode
216 * parameter (encrypt or decrypt), on the input data buffer
217 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000218 *
Rose Zadik7f441272018-01-22 11:48:23 +0000219 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
220 * regardless of whether you are performing an encryption or decryption
221 * operation, that is, regardless of the \p mode parameter. This is
222 * because CFB mode uses the same key schedule for encryption and
223 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000224 *
Rose Zadik7f441272018-01-22 11:48:23 +0000225 * \note Upon exit, the content of the IV is updated so that you can
226 * call the same function again on the next
227 * block(s) of data and get the same result as if it was
228 * encrypted in one call. This allows a "streaming" usage.
229 * If you need to retain the contents of the
230 * IV, you must either save it manually or use the cipher
231 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000232 *
Rose Zadik7f441272018-01-22 11:48:23 +0000233 *
234 * \param ctx The AES context to use for encryption or decryption.
235 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
236 * #MBEDTLS_AES_DECRYPT.
237 * \param length The length of the input data.
238 * \param iv_off The offset in IV (updated after use).
239 * \param iv The initialization vector (updated after use).
240 * \param input The buffer holding the input data.
241 * \param output The buffer holding the output data.
242 *
243 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000244 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200245int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000246 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000247 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000248 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000249 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000250 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000251 unsigned char *output );
252
Paul Bakker9a736322012-11-14 12:39:52 +0000253/**
Rose Zadik7f441272018-01-22 11:48:23 +0000254 * \brief This function performs an AES-CFB8 encryption or decryption
255 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100256 *
Rose Zadik7f441272018-01-22 11:48:23 +0000257 * It performs the operation defined in the \p mode
258 * parameter (encrypt/decrypt), on the input data buffer defined
259 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100260 *
Rose Zadik7f441272018-01-22 11:48:23 +0000261 * Due to the nature of CFB, you must use the same key schedule for
262 * both encryption and decryption operations. Therefore, you must
263 * use the context initialized with mbedtls_aes_setkey_enc() for
264 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000265 *
Rose Zadik7f441272018-01-22 11:48:23 +0000266 * \note Upon exit, the content of the IV is updated so that you can
267 * call the same function again on the next
268 * block(s) of data and get the same result as if it was
269 * encrypted in one call. This allows a "streaming" usage.
270 * If you need to retain the contents of the
271 * IV, you should either save it manually or use the cipher
272 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100273 *
Rose Zadik7f441272018-01-22 11:48:23 +0000274 *
275 * \param ctx The AES context to use for encryption or decryption.
276 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
277 * #MBEDTLS_AES_DECRYPT
278 * \param length The length of the input data.
279 * \param iv The initialization vector (updated after use).
280 * \param input The buffer holding the input data.
281 * \param output The buffer holding the output data.
282 *
283 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100284 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100286 int mode,
287 size_t length,
288 unsigned char iv[16],
289 const unsigned char *input,
290 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200291#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100292
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200293#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100294/**
Rose Zadik7f441272018-01-22 11:48:23 +0000295 * \brief This function performs an AES-CTR encryption or decryption
296 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000297 *
Rose Zadik7f441272018-01-22 11:48:23 +0000298 * This function performs the operation defined in the \p mode
299 * parameter (encrypt/decrypt), on the input data buffer
300 * defined in the \p input parameter.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000301 *
Rose Zadik7f441272018-01-22 11:48:23 +0000302 * Due to the nature of CTR, you must use the same key schedule
303 * for both encryption and decryption operations. Therefore, you
304 * must use the context initialized with mbedtls_aes_setkey_enc()
305 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000306 *
Rose Zadik7f441272018-01-22 11:48:23 +0000307 * \warning You must keep the maximum use of your counter in mind.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000308 *
Rose Zadik7f441272018-01-22 11:48:23 +0000309 * \param ctx The AES context to use for encryption or decryption.
310 * \param length The length of the input data.
311 * \param nc_off The offset in the current \p stream_block, for
312 * resuming within the current cipher stream. The
313 * offset pointer should be 0 at the start of a stream.
314 * \param nonce_counter The 128-bit nonce and counter.
315 * \param stream_block The saved stream block for resuming. This is
316 * overwritten by the function.
317 * \param input The buffer holding the input data.
318 * \param output The buffer holding the output data.
319 *
320 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000321 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200322int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000323 size_t length,
324 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000325 unsigned char nonce_counter[16],
326 unsigned char stream_block[16],
327 const unsigned char *input,
328 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200329#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200330
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200331/**
Rose Zadik7f441272018-01-22 11:48:23 +0000332 * \brief Internal AES block encryption function. This is only
333 * exposed to allow overriding it using
334 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200335 *
Rose Zadik7f441272018-01-22 11:48:23 +0000336 * \param ctx The AES context to use for encryption.
337 * \param input The plaintext block.
338 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000339 *
Rose Zadik7f441272018-01-22 11:48:23 +0000340 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200341 */
Andres AGf5bf7182017-03-03 14:09:56 +0000342int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
343 const unsigned char input[16],
344 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200345
346/**
Rose Zadik7f441272018-01-22 11:48:23 +0000347 * \brief Internal AES block decryption function. This is only
348 * exposed to allow overriding it using see
349 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200350 *
Rose Zadik7f441272018-01-22 11:48:23 +0000351 * \param ctx The AES context to use for decryption.
352 * \param input The ciphertext block.
353 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000354 *
Rose Zadik7f441272018-01-22 11:48:23 +0000355 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200356 */
Andres AGf5bf7182017-03-03 14:09:56 +0000357int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
358 const unsigned char input[16],
359 unsigned char output[16] );
360
361#if !defined(MBEDTLS_DEPRECATED_REMOVED)
362#if defined(MBEDTLS_DEPRECATED_WARNING)
363#define MBEDTLS_DEPRECATED __attribute__((deprecated))
364#else
365#define MBEDTLS_DEPRECATED
366#endif
367/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100368 * \brief Deprecated internal AES block encryption function
369 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000370 *
Rose Zadik7f441272018-01-22 11:48:23 +0000371 * \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
Andres AGf5bf7182017-03-03 14:09:56 +0000372 *
Rose Zadik7f441272018-01-22 11:48:23 +0000373 * \param ctx The AES context to use for encryption.
374 * \param input Plaintext block.
375 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000376 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100377MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
378 const unsigned char input[16],
379 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000380
381/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100382 * \brief Deprecated internal AES block decryption function
383 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000384 *
Rose Zadik7f441272018-01-22 11:48:23 +0000385 * \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
Andres AGf5bf7182017-03-03 14:09:56 +0000386 *
Rose Zadik7f441272018-01-22 11:48:23 +0000387 * \param ctx The AES context to use for decryption.
388 * \param input Ciphertext block.
389 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000390 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100391MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
392 const unsigned char input[16],
393 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000394
395#undef MBEDTLS_DEPRECATED
396#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200397
Paul Bakker5121ce52009-01-03 21:22:43 +0000398/**
Rose Zadik7f441272018-01-22 11:48:23 +0000399 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000400 *
Rose Zadik7f441272018-01-22 11:48:23 +0000401 * \return \c 0 on success, or \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000402 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200403int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000404
405#ifdef __cplusplus
406}
407#endif
408
409#endif /* aes.h */