1 /*
2  * Copyright (c) 2020 Markus Fuchs <markus.fuchs@de.sauter-bc.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  */
7 
8 #ifndef ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_
9 #define ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_
10 
11 /* Maximum supported key length is 256 bits */
12 #define CRYPTO_STM32_AES_MAX_KEY_LEN (256 / 8)
13 
14 struct crypto_stm32_config {
15 	const struct reset_dt_spec reset;
16 	struct stm32_pclken pclken;
17 };
18 
19 struct crypto_stm32_data {
20 	CRYP_HandleTypeDef hcryp;
21 	struct k_sem device_sem;
22 	struct k_sem session_sem;
23 };
24 
25 struct crypto_stm32_session {
26 	CRYP_ConfigTypeDef config;
27 	uint32_t key[CRYPTO_STM32_AES_MAX_KEY_LEN / sizeof(uint32_t)];
28 	bool in_use;
29 };
30 
31 #define CRYPTO_STM32_CFG(dev) \
32 	((const struct crypto_stm32_config *const)(dev)->config)
33 
34 #define CRYPTO_STM32_DATA(dev) \
35 	((struct crypto_stm32_data *const)(dev)->data)
36 
37 #define CRYPTO_STM32_SESSN(ctx) \
38 	((struct crypto_stm32_session *const)(ctx)->drv_sessn_state)
39 
40 #endif /* ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_ */
41