Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / third_party / NordicSemiconductor / libraries / nrf_security / include / mbedtls / aes_alt.h
1 /*
2  * Copyright (c) 2019 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
5  */
6
7 /**@file
8  * @addtogroup mbedtls_glue_aes
9  * @{
10  */
11 #ifndef MBEDTLS_AES_ALT_H
12 #define MBEDTLS_AES_ALT_H
13
14 #if !defined(MBEDTLS_CONFIG_FILE)
15 #include "../config.h"
16 #else
17 #include MBEDTLS_CONFIG_FILE
18 #endif
19
20 #define CC310_MBEDTLS_AES_CONTEXT_WORDS         (24)    //!< AES context size in words in nrf_cc310_mbedcrypto library.
21 #define VANILLA_MBEDTLS_AES_CONTEXT_WORDS       (70)    //!< AES context size in words in standard mbed TLS.
22 #define VANILLA_MBEDTLS_AES_XTS_CONTEXT_WORDS   (140)   //!< AES XTS context size in words in standard mbed TLS.
23
24 #if defined(MBEDTLS_AES_ALT)
25
26 #include <stdint.h>
27
28
29 /** @brief Typedef of mbedcrypto AES glue context.
30  */
31 typedef struct mbedtls_aes_context
32 {
33     union
34     {
35 #if defined(CONFIG_CC310_MBEDTLS_AES_C)
36         uint32_t buffer_cc310[CC310_MBEDTLS_AES_CONTEXT_WORDS];                //!< Array the size of an AES context in the nrf_cc310_mbedcrypto library.
37 #endif /* CONFIG_CC310_MBEDTLS_AES_C */
38 #if defined(CONFIG_VANILLA_MBEDTLS_AES_C)
39         uint32_t buffer_vanilla_mbedtls[VANILLA_MBEDTLS_AES_CONTEXT_WORDS];    //!< Array the size of an AES context in vanilla mbed TLS.
40 #endif /* CONFIG_VANILLA_MBEDTLS_AES_C */
41         uint32_t dummy;                                                        //!< Dummy value in case no backend is enabled.
42     } buffer;                                                                  //!< Union with size of the largest enabled backend context.
43     void* handle;   //!< Pointer to the function table in an initialized glue context.
44 } mbedtls_aes_context;
45
46
47 /** @brief Typedef of mbedcrypto glue AES XTS context
48  */
49 typedef struct mbedtls_aes_xts_context
50 {
51     union
52     {
53 #if defined(CONFIG_VANILLA_MBEDTLS_CIPHER_MODE_XTS)
54         uint32_t buffer_vanilla_mbedtls[VANILLA_MBEDTLS_AES_XTS_CONTEXT_WORDS];    //!< Array the size of the memory required for an AES XTS context in vanilla mbed TLS.
55 #endif /* CONFIG_VANILLA_MBEDTLS_CIPHER_MODE_XTS */
56         uint32_t dummy;                                                            //!< Dummy value in case no backend is enabled.
57     } buffer;                                                                      //!< Array with length equal to the size of the largest enabled backend.
58     void* handle;   //!< Pointer to the function table in an initialized glue context.
59 } mbedtls_aes_xts_context;
60
61 #endif /* MBEDTLS_AES_ALT */
62
63 #endif /* MBEDTLS_AES_ALT_H */
64
65 /** @} */