1 /*
2  * Copyright (c) 2001-2022, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef MBEDTLS_AES_ALT_H
8 #define MBEDTLS_AES_ALT_H
9 
10 #include "mbedtls/build_info.h"
11 
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 /* padlock.c and aesni.c rely on these values! */
16 #define MBEDTLS_AES_ENCRYPT     1 /**< AES encryption. */
17 #define MBEDTLS_AES_DECRYPT     0 /**< AES decryption. */
18 
19 /* Error codes in range 0x0020-0x0022 */
20 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH                -0x0020  /**< Invalid key length. */
21 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH              -0x0022  /**< Invalid data input length. */
22 
23 /* Error codes in range 0x0023-0x0025 */
24 #define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE               -0x0023  /**< Feature not available. For example, an unsupported AES key size. */
25 #define MBEDTLS_ERR_AES_HW_ACCEL_FAILED                   -0x0025  /**< AES hardware accelerator failed. */
26 
27 
28 // hide internal implementation of the struct. Allocate enough space for it.
29 #define MBEDTLS_AES_CONTEXT_SIZE_IN_WORDS 24
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**
37  * \brief          AES context structure
38  *
39  * \note           Max len of key - 256.
40  */
41 typedef struct
42 {
43     uint32_t buf[MBEDTLS_AES_CONTEXT_SIZE_IN_WORDS];
44 } mbedtls_aes_context;
45 
46 
47 #if defined(MBEDTLS_CIPHER_MODE_XTS)
48 /**
49  * \brief The AES XTS context-type definition.
50  */
51 typedef struct mbedtls_aes_xts_context
52 {
53     mbedtls_aes_context crypt; /*!< The AES context to use for AES block
54                                         encryption or decryption. */
55     mbedtls_aes_context tweak; /*!< The AES context used for tweak
56                                         computation. */
57 } mbedtls_aes_xts_context;
58 #endif /* MBEDTLS_CIPHER_MODE_XTS */
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 
65 #endif /* aes_alt.h */
66