blob: 25accb65af2cd4fded34a2c27f0befee17d61b6f [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file aes.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +01004 * \brief This file contains AES definitions and functions.
5 *
6 * The Advanced Encryption Standard (AES) specifies a FIPS-approved
Rose Zadik7f441272018-01-22 11:48:23 +00007 * cryptographic algorithm that can be used to protect electronic
8 * data.
9 *
10 * The AES algorithm is a symmetric block cipher that can
11 * encrypt and decrypt information. For more information, see
12 * <em>FIPS Publication 197: Advanced Encryption Standard</em> and
13 * <em>ISO/IEC 18033-2:2006: Information technology -- Security
14 * techniques -- Encryption algorithms -- Part 2: Asymmetric
15 * ciphers</em>.
Jaeden Amerof167deb2018-05-30 19:20:48 +010016 *
17 * The AES-XTS block mode is standardized by NIST SP 800-38E
18 * <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf>
19 * and described in detail by IEEE P1619
20 * <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>.
Darryl Greena40a1012018-01-05 15:33:17 +000021 */
Rose Zadik5ad7aea2018-03-26 12:00:09 +010022
Bence Szépkúti86974652020-06-15 11:59:37 +020023/*
Bence Szépkúti1e148272020-08-07 13:07:28 +020024 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020025 * SPDX-License-Identifier: Apache-2.0
26 *
27 * Licensed under the Apache License, Version 2.0 (the "License"); you may
28 * not use this file except in compliance with the License.
29 * You may obtain a copy of the License at
30 *
31 * http://www.apache.org/licenses/LICENSE-2.0
32 *
33 * Unless required by applicable law or agreed to in writing, software
34 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
35 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 * See the License for the specific language governing permissions and
37 * limitations under the License.
Paul Bakker5121ce52009-01-03 21:22:43 +000038 */
Rose Zadik7f441272018-01-22 11:48:23 +000039
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020040#ifndef MBEDTLS_AES_H
41#define MBEDTLS_AES_H
Paul Bakker5121ce52009-01-03 21:22:43 +000042
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010044#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020045#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020046#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020047#endif
Paul Bakker90995b52013-06-24 19:20:35 +020048
Rich Evans00ab4702015-02-06 13:43:58 +000049#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020050#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000051
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010052/* padlock.c and aesni.c rely on these values! */
Rose Zadik7f441272018-01-22 11:48:23 +000053#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
54#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
Paul Bakker5121ce52009-01-03 21:22:43 +000055
Andres Amaya Garciac5380642017-11-28 19:57:51 +000056/* Error codes in range 0x0020-0x0022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020057#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
58#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
Paul Bakker2b222c82009-07-27 21:03:45 +000059
Mohammad Azim Khane5b5bd72017-11-24 10:52:51 +000060/* Error codes in range 0x0021-0x0025 */
61#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */
Ron Eldor9924bdc2018-10-04 10:59:13 +030062
Andres AGf5bf7182017-03-03 14:09:56 +000063#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
64 !defined(inline) && !defined(__cplusplus)
65#define inline __inline
66#endif
67
Paul Bakker407a0da2013-06-27 14:29:21 +020068#ifdef __cplusplus
69extern "C" {
70#endif
71
Ron Eldorb2aacec2017-05-18 16:53:08 +030072#if !defined(MBEDTLS_AES_ALT)
73// Regular implementation
74//
75
Paul Bakker5121ce52009-01-03 21:22:43 +000076/**
Rose Zadik7f441272018-01-22 11:48:23 +000077 * \brief The AES context-type definition.
Paul Bakker5121ce52009-01-03 21:22:43 +000078 */
Dawid Drozd428cc522018-07-24 10:02:47 +020079typedef struct mbedtls_aes_context
Paul Bakker5121ce52009-01-03 21:22:43 +000080{
Rose Zadik7f441272018-01-22 11:48:23 +000081 int nr; /*!< The number of rounds. */
82 uint32_t *rk; /*!< AES round keys. */
83 uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
84 hold 32 extra Bytes, which can be used for
85 one of the following purposes:
86 <ul><li>Alignment if VIA padlock is
87 used.</li>
88 <li>Simplifying key expansion in the 256-bit
89 case by generating an extra round key.
90 </li></ul> */
Paul Bakker5121ce52009-01-03 21:22:43 +000091}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092mbedtls_aes_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000093
Jaeden Amero9366feb2018-05-29 18:55:17 +010094#if defined(MBEDTLS_CIPHER_MODE_XTS)
95/**
96 * \brief The AES XTS context-type definition.
97 */
Dawid Drozd428cc522018-07-24 10:02:47 +020098typedef struct mbedtls_aes_xts_context
Jaeden Amero9366feb2018-05-29 18:55:17 +010099{
100 mbedtls_aes_context crypt; /*!< The AES context to use for AES block
101 encryption or decryption. */
102 mbedtls_aes_context tweak; /*!< The AES context used for tweak
103 computation. */
104} mbedtls_aes_xts_context;
105#endif /* MBEDTLS_CIPHER_MODE_XTS */
106
Ron Eldorb2aacec2017-05-18 16:53:08 +0300107#else /* MBEDTLS_AES_ALT */
108#include "aes_alt.h"
109#endif /* MBEDTLS_AES_ALT */
110
Paul Bakker5121ce52009-01-03 21:22:43 +0000111/**
Rose Zadik7f441272018-01-22 11:48:23 +0000112 * \brief This function initializes the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200113 *
Rose Zadik7f441272018-01-22 11:48:23 +0000114 * It must be the first API called before using
115 * the context.
116 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500117 * \param ctx The AES context to initialize. This must not be \c NULL.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200118 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200119void mbedtls_aes_init( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200120
121/**
Rose Zadik7f441272018-01-22 11:48:23 +0000122 * \brief This function releases and clears the specified AES context.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200123 *
Rose Zadik7f441272018-01-22 11:48:23 +0000124 * \param ctx The AES context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500125 * If this is \c NULL, this function does nothing.
126 * Otherwise, the context must have been at least initialized.
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200127 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200128void mbedtls_aes_free( mbedtls_aes_context *ctx );
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200129
Jaeden Amero9366feb2018-05-29 18:55:17 +0100130#if defined(MBEDTLS_CIPHER_MODE_XTS)
131/**
132 * \brief This function initializes the specified AES XTS context.
133 *
134 * It must be the first API called before using
135 * the context.
136 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500137 * \param ctx The AES XTS context to initialize. This must not be \c NULL.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100138 */
139void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
140
141/**
142 * \brief This function releases and clears the specified AES XTS context.
143 *
144 * \param ctx The AES XTS context to clear.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500145 * If this is \c NULL, this function does nothing.
146 * Otherwise, the context must have been at least initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100147 */
148void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
149#endif /* MBEDTLS_CIPHER_MODE_XTS */
150
Paul Bakkerc7ea99a2014-06-18 11:12:03 +0200151/**
Rose Zadik7f441272018-01-22 11:48:23 +0000152 * \brief This function sets the encryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000153 *
Rose Zadik7f441272018-01-22 11:48:23 +0000154 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500155 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000156 * \param key The encryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500157 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000158 * \param keybits The size of data passed in bits. Valid options are:
159 * <ul><li>128 bits</li>
160 * <li>192 bits</li>
161 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000162 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100163 * \return \c 0 on success.
Rose Zadik819d13d2018-04-16 09:35:15 +0100164 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000165 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200167 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000168
169/**
Rose Zadik7f441272018-01-22 11:48:23 +0000170 * \brief This function sets the decryption key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000171 *
Rose Zadik7f441272018-01-22 11:48:23 +0000172 * \param ctx The AES context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500173 * It must be initialized.
Rose Zadik7f441272018-01-22 11:48:23 +0000174 * \param key The decryption key.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500175 * This must be a readable buffer of size \p keybits bits.
Rose Zadik7f441272018-01-22 11:48:23 +0000176 * \param keybits The size of data passed. Valid options are:
177 * <ul><li>128 bits</li>
178 * <li>192 bits</li>
179 * <li>256 bits</li></ul>
Paul Bakker2b222c82009-07-27 21:03:45 +0000180 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100181 * \return \c 0 on success.
182 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000183 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200184int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +0200185 unsigned int keybits );
Paul Bakker5121ce52009-01-03 21:22:43 +0000186
Jaeden Amero9366feb2018-05-29 18:55:17 +0100187#if defined(MBEDTLS_CIPHER_MODE_XTS)
188/**
189 * \brief This function prepares an XTS context for encryption and
190 * sets the encryption key.
191 *
192 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500193 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100194 * \param key The encryption key. This is comprised of the XTS key1
195 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500196 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100197 * \param keybits The size of \p key passed in bits. Valid options are:
198 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
199 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
200 *
201 * \return \c 0 on success.
202 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
203 */
204int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
205 const unsigned char *key,
206 unsigned int keybits );
207
208/**
209 * \brief This function prepares an XTS context for decryption and
210 * sets the decryption key.
211 *
212 * \param ctx The AES XTS context to which the key should be bound.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500213 * It must be initialized.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100214 * \param key The decryption key. This is comprised of the XTS key1
215 * concatenated with the XTS key2.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500216 * This must be a readable buffer of size \p keybits bits.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100217 * \param keybits The size of \p key passed in bits. Valid options are:
218 * <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
219 * <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
220 *
221 * \return \c 0 on success.
222 * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
223 */
224int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
225 const unsigned char *key,
226 unsigned int keybits );
227#endif /* MBEDTLS_CIPHER_MODE_XTS */
228
Paul Bakker5121ce52009-01-03 21:22:43 +0000229/**
Rose Zadik7f441272018-01-22 11:48:23 +0000230 * \brief This function performs an AES single-block encryption or
231 * decryption operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000232 *
Rose Zadik7f441272018-01-22 11:48:23 +0000233 * It performs the operation defined in the \p mode parameter
234 * (encrypt or decrypt), on the input data buffer defined in
235 * the \p input parameter.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000236 *
Rose Zadik7f441272018-01-22 11:48:23 +0000237 * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
238 * mbedtls_aes_setkey_dec() must be called before the first
239 * call to this API with the same context.
240 *
241 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500242 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000243 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
244 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500245 * \param input The buffer holding the input data.
246 * It must be readable and at least \c 16 Bytes long.
247 * \param output The buffer where the output data will be written.
248 * It must be writeable and at least \c 16 Bytes long.
Rose Zadik7f441272018-01-22 11:48:23 +0000249
250 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000251 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200252int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000253 int mode,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000254 const unsigned char input[16],
Paul Bakker5121ce52009-01-03 21:22:43 +0000255 unsigned char output[16] );
256
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200257#if defined(MBEDTLS_CIPHER_MODE_CBC)
Paul Bakker5121ce52009-01-03 21:22:43 +0000258/**
Rose Zadik7f441272018-01-22 11:48:23 +0000259 * \brief This function performs an AES-CBC encryption or decryption operation
260 * on full blocks.
Paul Bakker5121ce52009-01-03 21:22:43 +0000261 *
Rose Zadik7f441272018-01-22 11:48:23 +0000262 * It performs the operation defined in the \p mode
263 * parameter (encrypt/decrypt), on the input data buffer defined in
264 * the \p input parameter.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000265 *
Rose Zadik7f441272018-01-22 11:48:23 +0000266 * It can be called as many times as needed, until all the input
267 * data is processed. mbedtls_aes_init(), and either
268 * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
269 * before the first call to this API with the same context.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000270 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500271 * \note This function operates on full blocks, that is, the input size
272 * must be a multiple of the AES block size of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000273 *
274 * \note Upon exit, the content of the IV is updated so that you can
275 * call the same function again on the next
276 * block(s) of data and get the same result as if it was
277 * encrypted in one call. This allows a "streaming" usage.
278 * If you need to retain the contents of the IV, you should
279 * either save it manually or use the cipher module instead.
280 *
281 *
282 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500283 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000284 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
285 * #MBEDTLS_AES_DECRYPT.
286 * \param length The length of the input data in Bytes. This must be a
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500287 * multiple of the block size (\c 16 Bytes).
Rose Zadik7f441272018-01-22 11:48:23 +0000288 * \param iv Initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500289 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000290 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500291 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000292 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500293 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000294 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100295 * \return \c 0 on success.
296 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
Rose Zadik7f441272018-01-22 11:48:23 +0000297 * on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000298 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200299int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000300 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000301 size_t length,
Paul Bakker5121ce52009-01-03 21:22:43 +0000302 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000303 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000304 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200305#endif /* MBEDTLS_CIPHER_MODE_CBC */
Paul Bakker5121ce52009-01-03 21:22:43 +0000306
Aorimn5f778012016-06-09 23:22:58 +0200307#if defined(MBEDTLS_CIPHER_MODE_XTS)
308/**
Jaeden Amero9366feb2018-05-29 18:55:17 +0100309 * \brief This function performs an AES-XTS encryption or decryption
310 * operation for an entire XTS data unit.
Aorimn5f778012016-06-09 23:22:58 +0200311 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100312 * AES-XTS encrypts or decrypts blocks based on their location as
313 * defined by a data unit number. The data unit number must be
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100314 * provided by \p data_unit.
Aorimn5f778012016-06-09 23:22:58 +0200315 *
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100316 * NIST SP 800-38E limits the maximum size of a data unit to 2^20
317 * AES blocks. If the data unit is larger than this, this function
318 * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
319 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100320 * \param ctx The AES XTS context to use for AES XTS operations.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500321 * It must be initialized and bound to a key.
Jaeden Amero9366feb2018-05-29 18:55:17 +0100322 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
323 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500324 * \param length The length of a data unit in Bytes. This can be any
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100325 * length between 16 bytes and 2^24 bytes inclusive
326 * (between 1 and 2^20 block cipher blocks).
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100327 * \param data_unit The address of the data unit encoded as an array of 16
Jaeden Amero9366feb2018-05-29 18:55:17 +0100328 * bytes in little-endian format. For disk encryption, this
329 * is typically the index of the block device sector that
330 * contains the data.
331 * \param input The buffer holding the input data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500332 * data unit). This function reads \p length Bytes from \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100333 * input.
334 * \param output The buffer holding the output data (which is an entire
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500335 * data unit). This function writes \p length Bytes to \p
Jaeden Amero9366feb2018-05-29 18:55:17 +0100336 * output.
Aorimn5f778012016-06-09 23:22:58 +0200337 *
Jaeden Amero9366feb2018-05-29 18:55:17 +0100338 * \return \c 0 on success.
339 * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500340 * smaller than an AES block in size (16 Bytes) or if \p
Jaeden Amero0a8b0202018-05-30 15:36:06 +0100341 * length is larger than 2^20 blocks (16 MiB).
Aorimn5f778012016-06-09 23:22:58 +0200342 */
Jaeden Amero9366feb2018-05-29 18:55:17 +0100343int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
344 int mode,
Jaeden Amero5162b932018-05-29 12:55:24 +0100345 size_t length,
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100346 const unsigned char data_unit[16],
Jaeden Amero9366feb2018-05-29 18:55:17 +0100347 const unsigned char *input,
348 unsigned char *output );
Aorimn5f778012016-06-09 23:22:58 +0200349#endif /* MBEDTLS_CIPHER_MODE_XTS */
350
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200351#if defined(MBEDTLS_CIPHER_MODE_CFB)
Paul Bakker5121ce52009-01-03 21:22:43 +0000352/**
Rose Zadik7f441272018-01-22 11:48:23 +0000353 * \brief This function performs an AES-CFB128 encryption or decryption
354 * operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000355 *
Rose Zadik7f441272018-01-22 11:48:23 +0000356 * It performs the operation defined in the \p mode
357 * parameter (encrypt or decrypt), on the input data buffer
358 * defined in the \p input parameter.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000359 *
Rose Zadik7f441272018-01-22 11:48:23 +0000360 * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
361 * regardless of whether you are performing an encryption or decryption
362 * operation, that is, regardless of the \p mode parameter. This is
363 * because CFB mode uses the same key schedule for encryption and
364 * decryption.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000365 *
Rose Zadik7f441272018-01-22 11:48:23 +0000366 * \note Upon exit, the content of the IV is updated so that you can
367 * call the same function again on the next
368 * block(s) of data and get the same result as if it was
369 * encrypted in one call. This allows a "streaming" usage.
370 * If you need to retain the contents of the
371 * IV, you must either save it manually or use the cipher
372 * module instead.
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000373 *
Rose Zadik7f441272018-01-22 11:48:23 +0000374 *
375 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500376 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000377 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
378 * #MBEDTLS_AES_DECRYPT.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500379 * \param length The length of the input data in Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000380 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500381 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000382 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500383 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000384 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500385 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000386 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500387 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000388 *
389 * \return \c 0 on success.
Paul Bakker5121ce52009-01-03 21:22:43 +0000390 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200391int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000392 int mode,
Paul Bakker23986e52011-04-24 08:57:21 +0000393 size_t length,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000394 size_t *iv_off,
Paul Bakker5121ce52009-01-03 21:22:43 +0000395 unsigned char iv[16],
Paul Bakkerff60ee62010-03-16 21:09:09 +0000396 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000397 unsigned char *output );
398
Paul Bakker9a736322012-11-14 12:39:52 +0000399/**
Rose Zadik7f441272018-01-22 11:48:23 +0000400 * \brief This function performs an AES-CFB8 encryption or decryption
401 * operation.
Paul Bakker556efba2014-01-24 15:38:12 +0100402 *
Rose Zadik7f441272018-01-22 11:48:23 +0000403 * It performs the operation defined in the \p mode
404 * parameter (encrypt/decrypt), on the input data buffer defined
405 * in the \p input parameter.
Paul Bakker556efba2014-01-24 15:38:12 +0100406 *
Rose Zadik7f441272018-01-22 11:48:23 +0000407 * Due to the nature of CFB, you must use the same key schedule for
408 * both encryption and decryption operations. Therefore, you must
409 * use the context initialized with mbedtls_aes_setkey_enc() for
410 * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Manuel Pégourié-Gonnard2be147a2015-01-23 16:19:47 +0000411 *
Rose Zadik7f441272018-01-22 11:48:23 +0000412 * \note Upon exit, the content of the IV is updated so that you can
413 * call the same function again on the next
414 * block(s) of data and get the same result as if it was
415 * encrypted in one call. This allows a "streaming" usage.
416 * If you need to retain the contents of the
417 * IV, you should either save it manually or use the cipher
418 * module instead.
Paul Bakker556efba2014-01-24 15:38:12 +0100419 *
Rose Zadik7f441272018-01-22 11:48:23 +0000420 *
421 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500422 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000423 * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
424 * #MBEDTLS_AES_DECRYPT
425 * \param length The length of the input data.
426 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500427 * It must be a readable and writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000428 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500429 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000430 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500431 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000432 *
433 * \return \c 0 on success.
Paul Bakker556efba2014-01-24 15:38:12 +0100434 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200435int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
Paul Bakker556efba2014-01-24 15:38:12 +0100436 int mode,
437 size_t length,
438 unsigned char iv[16],
439 const unsigned char *input,
440 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200441#endif /*MBEDTLS_CIPHER_MODE_CFB */
Paul Bakker556efba2014-01-24 15:38:12 +0100442
Simon Butcher76a5b222018-04-22 22:57:27 +0100443#if defined(MBEDTLS_CIPHER_MODE_OFB)
444/**
Simon Butcher5db13622018-06-04 22:11:25 +0100445 * \brief This function performs an AES-OFB (Output Feedback Mode)
446 * encryption or decryption operation.
Simon Butcher76a5b222018-04-22 22:57:27 +0100447 *
Simon Butcher5db13622018-06-04 22:11:25 +0100448 * For OFB, you must set up the context with
449 * mbedtls_aes_setkey_enc(), regardless of whether you are
450 * performing an encryption or decryption operation. This is
451 * because OFB mode uses the same key schedule for encryption and
452 * decryption.
Simon Butcher76a5b222018-04-22 22:57:27 +0100453 *
Simon Butcher5db13622018-06-04 22:11:25 +0100454 * The OFB operation is identical for encryption or decryption,
455 * therefore no operation mode needs to be specified.
Simon Butcher76a5b222018-04-22 22:57:27 +0100456 *
Simon Butcher5db13622018-06-04 22:11:25 +0100457 * \note Upon exit, the content of iv, the Initialisation Vector, is
458 * updated so that you can call the same function again on the next
459 * block(s) of data and get the same result as if it was encrypted
460 * in one call. This allows a "streaming" usage, by initialising
461 * iv_off to 0 before the first call, and preserving its value
462 * between calls.
Simon Butcher968646c2018-06-02 18:27:04 +0100463 *
Simon Butcher5db13622018-06-04 22:11:25 +0100464 * For non-streaming use, the iv should be initialised on each call
465 * to a unique value, and iv_off set to 0 on each call.
Simon Butcher968646c2018-06-02 18:27:04 +0100466 *
Simon Butcher5db13622018-06-04 22:11:25 +0100467 * If you need to retain the contents of the initialisation vector,
468 * you must either save it manually or use the cipher module
469 * instead.
Simon Butcher968646c2018-06-02 18:27:04 +0100470 *
Jaeden Amerocb2c9352018-06-08 10:34:08 +0100471 * \warning For the OFB mode, the initialisation vector must be unique
472 * every encryption operation. Reuse of an initialisation vector
473 * will compromise security.
Simon Butcher76a5b222018-04-22 22:57:27 +0100474 *
475 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500476 * It must be initialized and bound to a key.
Simon Butcher76a5b222018-04-22 22:57:27 +0100477 * \param length The length of the input data.
478 * \param iv_off The offset in IV (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500479 * It must point to a valid \c size_t.
Simon Butcher76a5b222018-04-22 22:57:27 +0100480 * \param iv The initialization vector (updated after use).
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500481 * It must be a readable and writeable buffer of \c 16 Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100482 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500483 * It must be readable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100484 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500485 * It must be writeable and of size \p length Bytes.
Simon Butcher76a5b222018-04-22 22:57:27 +0100486 *
487 * \return \c 0 on success.
488 */
489int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
490 size_t length,
491 size_t *iv_off,
492 unsigned char iv[16],
493 const unsigned char *input,
494 unsigned char *output );
495
496#endif /* MBEDTLS_CIPHER_MODE_OFB */
497
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200498#if defined(MBEDTLS_CIPHER_MODE_CTR)
Paul Bakker556efba2014-01-24 15:38:12 +0100499/**
Rose Zadik7f441272018-01-22 11:48:23 +0000500 * \brief This function performs an AES-CTR encryption or decryption
501 * operation.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000502 *
Rose Zadik7f441272018-01-22 11:48:23 +0000503 * This function performs the operation defined in the \p mode
504 * parameter (encrypt/decrypt), on the input data buffer
505 * defined in the \p input parameter.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000506 *
Rose Zadik7f441272018-01-22 11:48:23 +0000507 * Due to the nature of CTR, you must use the same key schedule
508 * for both encryption and decryption operations. Therefore, you
509 * must use the context initialized with mbedtls_aes_setkey_enc()
510 * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
Paul Bakkerca6f3e22011-10-06 13:11:08 +0000511 *
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100512 * \warning You must never reuse a nonce value with the same key. Doing so
513 * would void the encryption for the two messages encrypted with
514 * the same nonce and key.
515 *
516 * There are two common strategies for managing nonces with CTR:
517 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200518 * 1. You can handle everything as a single message processed over
519 * successive calls to this function. In that case, you want to
520 * set \p nonce_counter and \p nc_off to 0 for the first call, and
521 * then preserve the values of \p nonce_counter, \p nc_off and \p
522 * stream_block across calls to this function as they will be
523 * updated by this function.
Manuel Pégourié-Gonnard22997b72018-02-28 12:29:41 +0100524 *
Manuel Pégourié-Gonnard4f24e952018-05-24 11:59:30 +0200525 * With this strategy, you must not encrypt more than 2**128
526 * blocks of data with the same key.
527 *
528 * 2. You can encrypt separate messages by dividing the \p
529 * nonce_counter buffer in two areas: the first one used for a
530 * per-message nonce, handled by yourself, and the second one
531 * updated by this function internally.
532 *
533 * For example, you might reserve the first 12 bytes for the
534 * per-message nonce, and the last 4 bytes for internal use. In that
535 * case, before calling this function on a new message you need to
536 * set the first 12 bytes of \p nonce_counter to your chosen nonce
537 * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
538 * stream_block to be ignored). That way, you can encrypt at most
539 * 2**96 messages of up to 2**32 blocks each with the same key.
540 *
541 * The per-message nonce (or information sufficient to reconstruct
542 * it) needs to be communicated with the ciphertext and must be unique.
543 * The recommended way to ensure uniqueness is to use a message
544 * counter. An alternative is to generate random nonces, but this
545 * limits the number of messages that can be securely encrypted:
546 * for example, with 96-bit random nonces, you should not encrypt
547 * more than 2**32 messages with the same key.
548 *
549 * Note that for both stategies, sizes are measured in blocks and
550 * that an AES block is 16 bytes.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000551 *
Manuel Pégourié-Gonnardfa0c47d2018-05-24 19:02:06 +0200552 * \warning Upon return, \p stream_block contains sensitive data. Its
553 * content must not be written to insecure storage and should be
554 * securely discarded as soon as it's no longer needed.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000555 *
Rose Zadik7f441272018-01-22 11:48:23 +0000556 * \param ctx The AES context to use for encryption or decryption.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500557 * It must be initialized and bound to a key.
Rose Zadik7f441272018-01-22 11:48:23 +0000558 * \param length The length of the input data.
559 * \param nc_off The offset in the current \p stream_block, for
560 * resuming within the current cipher stream. The
561 * offset pointer should be 0 at the start of a stream.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500562 * It must point to a valid \c size_t.
Rose Zadik7f441272018-01-22 11:48:23 +0000563 * \param nonce_counter The 128-bit nonce and counter.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500564 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000565 * \param stream_block The saved stream block for resuming. This is
566 * overwritten by the function.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500567 * It must be a readable-writeable buffer of \c 16 Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000568 * \param input The buffer holding the input data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500569 * It must be readable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000570 * \param output The buffer holding the output data.
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500571 * It must be writeable and of size \p length Bytes.
Rose Zadik7f441272018-01-22 11:48:23 +0000572 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100573 * \return \c 0 on success.
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000574 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200575int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
Paul Bakker1ef71df2011-06-09 14:14:58 +0000576 size_t length,
577 size_t *nc_off,
Paul Bakkerb6ecaf52011-04-19 14:29:23 +0000578 unsigned char nonce_counter[16],
579 unsigned char stream_block[16],
580 const unsigned char *input,
581 unsigned char *output );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200582#endif /* MBEDTLS_CIPHER_MODE_CTR */
Paul Bakker90995b52013-06-24 19:20:35 +0200583
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200584/**
Rose Zadik7f441272018-01-22 11:48:23 +0000585 * \brief Internal AES block encryption function. This is only
586 * exposed to allow overriding it using
587 * \c MBEDTLS_AES_ENCRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200588 *
Rose Zadik7f441272018-01-22 11:48:23 +0000589 * \param ctx The AES context to use for encryption.
590 * \param input The plaintext block.
591 * \param output The output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000592 *
Rose Zadik7f441272018-01-22 11:48:23 +0000593 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200594 */
Andres AGf5bf7182017-03-03 14:09:56 +0000595int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
596 const unsigned char input[16],
597 unsigned char output[16] );
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200598
599/**
Rose Zadik7f441272018-01-22 11:48:23 +0000600 * \brief Internal AES block decryption function. This is only
601 * exposed to allow overriding it using see
602 * \c MBEDTLS_AES_DECRYPT_ALT.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200603 *
Rose Zadik7f441272018-01-22 11:48:23 +0000604 * \param ctx The AES context to use for decryption.
605 * \param input The ciphertext block.
606 * \param output The output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000607 *
Rose Zadik7f441272018-01-22 11:48:23 +0000608 * \return \c 0 on success.
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200609 */
Andres AGf5bf7182017-03-03 14:09:56 +0000610int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
611 const unsigned char input[16],
612 unsigned char output[16] );
613
614#if !defined(MBEDTLS_DEPRECATED_REMOVED)
615#if defined(MBEDTLS_DEPRECATED_WARNING)
616#define MBEDTLS_DEPRECATED __attribute__((deprecated))
617#else
618#define MBEDTLS_DEPRECATED
619#endif
620/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100621 * \brief Deprecated internal AES block encryption function
622 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000623 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500624 * \deprecated Superseded by mbedtls_internal_aes_encrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000625 *
Rose Zadik7f441272018-01-22 11:48:23 +0000626 * \param ctx The AES context to use for encryption.
627 * \param input Plaintext block.
628 * \param output Output (ciphertext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000629 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100630MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
631 const unsigned char input[16],
632 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000633
634/**
Hanno Beckerca1cdb22017-07-20 09:50:59 +0100635 * \brief Deprecated internal AES block decryption function
636 * without return value.
Andres AGf5bf7182017-03-03 14:09:56 +0000637 *
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500638 * \deprecated Superseded by mbedtls_internal_aes_decrypt()
Andres AGf5bf7182017-03-03 14:09:56 +0000639 *
Rose Zadik7f441272018-01-22 11:48:23 +0000640 * \param ctx The AES context to use for decryption.
641 * \param input Ciphertext block.
642 * \param output Output (plaintext) block.
Andres AGf5bf7182017-03-03 14:09:56 +0000643 */
Hanno Beckerbedc2052017-06-26 12:46:56 +0100644MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
645 const unsigned char input[16],
646 unsigned char output[16] );
Andres AGf5bf7182017-03-03 14:09:56 +0000647
648#undef MBEDTLS_DEPRECATED
649#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Manuel Pégourié-Gonnard31993f22015-05-12 15:41:08 +0200650
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500651
652#if defined(MBEDTLS_SELF_TEST)
Paul Bakker5121ce52009-01-03 21:22:43 +0000653/**
Rose Zadik7f441272018-01-22 11:48:23 +0000654 * \brief Checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000655 *
Rose Zadik5ad7aea2018-03-26 12:00:09 +0100656 * \return \c 0 on success.
657 * \return \c 1 on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000658 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200659int mbedtls_aes_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000660
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500661#endif /* MBEDTLS_SELF_TEST */
662
Paul Bakker5121ce52009-01-03 21:22:43 +0000663#ifdef __cplusplus
664}
665#endif
666
667#endif /* aes.h */