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 #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32l4_aes) 12 #define crypt_config_t CRYP_InitTypeDef 13 #else 14 #define crypt_config_t CRYP_ConfigTypeDef 15 #endif 16 17 /* Maximum supported key length is 256 bits */ 18 #define CRYPTO_STM32_AES_MAX_KEY_LEN (256 / 8) 19 20 struct crypto_stm32_config { 21 const struct reset_dt_spec reset; 22 struct stm32_pclken pclken; 23 }; 24 25 struct crypto_stm32_data { 26 CRYP_HandleTypeDef hcryp; 27 struct k_sem device_sem; 28 struct k_sem session_sem; 29 }; 30 31 struct crypto_stm32_session { 32 crypt_config_t config; 33 uint32_t key[CRYPTO_STM32_AES_MAX_KEY_LEN / sizeof(uint32_t)]; 34 bool in_use; 35 }; 36 37 #define CRYPTO_STM32_CFG(dev) \ 38 ((const struct crypto_stm32_config *const)(dev)->config) 39 40 #define CRYPTO_STM32_DATA(dev) \ 41 ((struct crypto_stm32_data *const)(dev)->data) 42 43 #define CRYPTO_STM32_SESSN(ctx) \ 44 ((struct crypto_stm32_session *const)(ctx)->drv_sessn_state) 45 46 #endif /* ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_ */ 47