Skip to content

Conversation

@FRASTM
Copy link
Contributor

@FRASTM FRASTM commented Aug 20, 2025

Following the #93923
this PR adds the support of crypto hash hardware to the stm32h7RS

Note that -T crypto.hash will use the SW hash

The testcase only tests the SHA256, more SHA are available on the stm32 hash hw processors and main could be extended

@FRASTM
Copy link
Contributor Author

FRASTM commented Aug 20, 2025

west build -p -b nucleo_h7s3l8 tests/crypto/crypto_hash/ with LOG

*** Booting Zephyr OS build v4.2.0-2020-g7ef0acdb1ed5 ***
Running TESTSUITE crypto_hash
===================================================================
START - test_hash
D: begin_session (algo=2)
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: HASH compute SHA256
D: Hash computation successful
D: Session freed
 PASS - test_hash in 0.038 seconds
===================================================================
TESTSUITE crypto_hash succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [crypto_hash]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.038 seconds
 - PASS - [crypto_hash.test_hash] duration = 0.038 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL


@FRASTM FRASTM force-pushed the stm32h7rs_hash branch 5 times, most recently from 635d0b2 to 67b6ed6 Compare September 2, 2025 07:30
Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside some indentation issues to be addressed or not.

@FRASTM
Copy link
Contributor Author

FRASTM commented Sep 4, 2025

Requires one commit to fix regression after #94869 --> fix the CI error on build

west build -p -b nucleo_h7s3l8 samples/drivers/i2s/output -T sample.drivers.i2s.output
with something like ./include/zephyr/drivers/dma/dma_stm32.h
#define __LL_DMA_GET_CHANNEL_INSTANCE LL_DMA_GET_CHANNEL_INSTANCE
(put in another PR)

@zephyrbot zephyrbot added the area: DMA Direct Memory Access label Sep 4, 2025
@zephyrbot zephyrbot requested a review from teburd September 4, 2025 09:55
@FRASTM
Copy link
Contributor Author

FRASTM commented Sep 4, 2025

Requires #95470

Adapt the stm32 crypto hash driver for the stm32h7rs HAL modules
Create hal_func_hash_SHAxxx_start to abstract the algorithm
The crypto algo is set by the HAL_HASH_SetConfig function

Signed-off-by: Francois Ramu <[email protected]>
Add the HASH processor "st,stm32-hash" of the stm32H7RS series.

Signed-off-by: Francois Ramu <[email protected]>
Enables the crypto HASH processor on the nucleo_h7s3l8.

Signed-off-by: Francois Ramu <[email protected]>
Enable crypto.hash test on nucleo_h7s3l8 board disco kit

Signed-off-by: Francois Ramu <[email protected]>
@FRASTM
Copy link
Contributor Author

FRASTM commented Sep 5, 2025

rebase on f878a55

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 5, 2025

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Some coding style minor issues worth to address but not blocking.

{
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
hhash->Init.Algorithm = HASH_ALGOSELECTION_SHA256;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking consistency: remove this empty line, as in hal_func_hash_SHA224_start().

Comment on lines +53 to +56
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 hal_func_hash_SHA256_start().

pkt->out_buf, HAL_MAX_DELAY);
LOG_DBG("HASH compute SHA256");
status = hal_func_hash_SHA256_start(&data->hhash, pkt->in_buf, pkt->in_len,
pkt->out_buf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

		status = hal_func_hash_SHA256_start(&data->hhash, pkt->in_buf, pkt->in_len,
						    pkt->out_buf);

uint32_t in_size_byte,
void *p_out_buffer)
{
#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, this implementation (calling HAL_HASH_SetConfig()/HAL_HASH_Start() instead of HAL_HASHEx_SHA224_Start() is also common with other all recent STM32 series (H5,MP2,N6,U3,WBA).

In order to avoid updating driver code with || defined(CONFIG_SOC_SERIES_STM32FOO) for each new series, let's define a new Kconfig (CRYPTO_STM32_HASH_HAL_CFG_START for instance) that would be selected by these series when driver support is added. That would minimize effort to add new series and be better for code readability.
(I'm not proposing a new compatible, as I think this is not an issue of HW, but pure HAL implementation, but I could be wrong)

@FRASTM
Copy link
Contributor Author

FRASTM commented Sep 29, 2025

to be reconsidered later "on-demand"

@FRASTM FRASTM closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Crypto / RNG area: DMA Direct Memory Access platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants