-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: crypto: hash driver for the STM32H7RS series #94749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
976343a
8ee2c29
35abe4e
d6cb04f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,24 @@ | |
| #ifndef ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_HASH_PRIV_H_ | ||
| #define ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_HASH_PRIV_H_ | ||
|
|
||
| #define hash_config_t HASH_InitTypeDef | ||
|
|
||
| /* Max digest length: SHA256 = 32 bytes */ | ||
| #define STM32_HASH_MAX_DIGEST_SIZE (32) | ||
|
|
||
| #if defined(CONFIG_SOC_SERIES_STM32H7RSX) | ||
|
|
||
| #define hash_config_t HASH_ConfigTypeDef | ||
| #define HASH_DATATYPE_8B HASH_BYTE_SWAP | ||
| #define STM32_HASH_SHA224_START HAL_HASH_Start | ||
| #define STM32_HASH_SHA256_START HAL_HASH_Start | ||
|
|
||
| #else /* CONFIG_SOC_SERIES_STM32H7RSX */ | ||
|
|
||
| #define hash_config_t HASH_InitTypeDef | ||
| #define STM32_HASH_SHA224_START HAL_HASHEx_SHA224_Start | ||
| #define STM32_HASH_SHA256_START HAL_HASHEx_SHA256_Start | ||
|
|
||
| #endif /* CONFIG_SOC_SERIES_STM32H7RSX */ | ||
|
|
||
| struct crypto_stm32_hash_config { | ||
| const struct reset_dt_spec reset; | ||
| struct stm32_pclken pclken; | ||
|
|
@@ -37,4 +50,35 @@ struct crypto_stm32_hash_session { | |
| #define CRYPTO_STM32_HASH_SESSN(ctx) \ | ||
| ((struct crypto_stm32_hash_session *const)(ctx)->drv_sessn_state) | ||
|
|
||
| static inline HAL_StatusTypeDef hal_func_hash_SHA224_start(HASH_HandleTypeDef *hhash, | ||
| void *p_in_buffer, | ||
| uint32_t in_size_byte, | ||
| void *p_out_buffer) | ||
|
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indenattion static inline HAL_StatusTypeDef hal_func_hash_SHA224_start(HASH_HandleTypeDef *hhash,
void *p_in_buffer,
uint32_t in_size_byte,
void *p_out_buffer)Ditto for |
||
| { | ||
| #if defined(CONFIG_SOC_SERIES_STM32H7RSX) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I can see, this implementation (calling In order to avoid updating driver code with |
||
| hhash->Init.Algorithm = HASH_ALGOSELECTION_SHA224; | ||
| if (HAL_HASH_SetConfig(hhash, &hhash->Init) != HAL_OK) { | ||
| return HAL_ERROR; | ||
| } | ||
| #endif /* CONFIG_SOC_SERIES_STM32H7RSX */ | ||
| return STM32_HASH_SHA224_START(hhash, p_in_buffer, in_size_byte, p_out_buffer, | ||
| HAL_MAX_DELAY); | ||
| } | ||
|
|
||
| static inline HAL_StatusTypeDef hal_func_hash_SHA256_start(HASH_HandleTypeDef *hhash, | ||
| void *p_in_buffer, | ||
| uint32_t in_size_byte, | ||
| void *p_out_buffer) | ||
| { | ||
| #if defined(CONFIG_SOC_SERIES_STM32H7RSX) | ||
| hhash->Init.Algorithm = HASH_ALGOSELECTION_SHA256; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicking consistency: remove this empty line, as in |
||
| if (HAL_HASH_SetConfig(hhash, &hhash->Init) != HAL_OK) { | ||
| return HAL_ERROR; | ||
| } | ||
| #endif /* CONFIG_SOC_SERIES_STM32H7RSX */ | ||
| return STM32_HASH_SHA256_START(hhash, p_in_buffer, in_size_byte, p_out_buffer, | ||
| HAL_MAX_DELAY); | ||
| } | ||
|
|
||
| #endif /* ZEPHYR_DRIVERS_CRYPTO_CRYPTO_STM32_HASH_PRIV_H_ */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation