2020-01-14 01:05:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Markus Fuchs <markus.fuchs@de.sauter-bc.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_
|
|
|
|
#define ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_
|
|
|
|
|
2024-09-25 04:40:56 +08:00
|
|
|
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32l4_aes)
|
|
|
|
#define crypt_config_t CRYP_InitTypeDef
|
|
|
|
#else
|
|
|
|
#define crypt_config_t CRYP_ConfigTypeDef
|
|
|
|
#endif
|
|
|
|
|
2020-01-14 01:05:14 +08:00
|
|
|
/* Maximum supported key length is 256 bits */
|
|
|
|
#define CRYPTO_STM32_AES_MAX_KEY_LEN (256 / 8)
|
|
|
|
|
|
|
|
struct crypto_stm32_config {
|
2024-06-21 21:59:59 +08:00
|
|
|
const struct reset_dt_spec reset;
|
2020-01-14 01:05:14 +08:00
|
|
|
struct stm32_pclken pclken;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct crypto_stm32_data {
|
|
|
|
CRYP_HandleTypeDef hcryp;
|
|
|
|
struct k_sem device_sem;
|
|
|
|
struct k_sem session_sem;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct crypto_stm32_session {
|
2024-09-25 04:40:56 +08:00
|
|
|
crypt_config_t config;
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t key[CRYPTO_STM32_AES_MAX_KEY_LEN / sizeof(uint32_t)];
|
2020-01-14 01:05:14 +08:00
|
|
|
bool in_use;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CRYPTO_STM32_CFG(dev) \
|
2020-05-29 02:44:16 +08:00
|
|
|
((const struct crypto_stm32_config *const)(dev)->config)
|
2020-01-14 01:05:14 +08:00
|
|
|
|
|
|
|
#define CRYPTO_STM32_DATA(dev) \
|
2020-05-29 03:23:02 +08:00
|
|
|
((struct crypto_stm32_data *const)(dev)->data)
|
2020-01-14 01:05:14 +08:00
|
|
|
|
|
|
|
#define CRYPTO_STM32_SESSN(ctx) \
|
|
|
|
((struct crypto_stm32_session *const)(ctx)->drv_sessn_state)
|
|
|
|
|
|
|
|
#endif /* ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_PRIV_H_ */
|