STMicroelectronics / stm32h7xx-hal-driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32H7 series.
BSD 3-Clause "New" or "Revised" License
97 stars 41 forks source link

CRYP api upgrade #36

Open fermentedfly opened 1 year ago

fermentedfly commented 1 year ago

As far as I can tell the current HAL_CRYP_Encrypt (decrypt as well) provides an all-in-one solution for encryption. This is fine but my use case requires an API that can be initialized and then fed with multiple blocks of data, i.e. something like Init -> Encrypt Block 1 -> Encrypt Block 2 -> ... -> Finalize

Some other HAL implementations, e.g. STM32L4, provide functionality to do this. I've had a look in stm32h7xx_hal_cryp.c and it seems all the required functions are already present but have internal linkage. Please consider making those functions public.

Regards, Manuel

TOUNSTM commented 1 year ago

Hello @fermentedfly,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

HBOSTM commented 1 year ago

Hello @fermentedfly,

Thank you for this contribution. Could you please give me more details about this issue, I need to know what internally linked functions you are talking about?

Best Regards,

fermentedfly commented 1 year ago

Hello @HBOSTM ,

I had a deeper look in stm32h7xx_hal_cryp.c and my initial estimate was a bit optimistic. I use AES CBC & GCM. For CBC, making static void CRYP_AES_ProcessData(CRYP_HandleTypeDef *hcryp, uint32_t Timeout) public is enough although a separate Init() would be very convenient.

For GCM, static HAL_StatusTypeDef CRYP_AESGCM_Process(CRYP_HandleTypeDef *hcryp, uint32_t Timeout) needs refactoring, i.e. the function needs to be split in it's three phases (header, data, finalize) in order to feed data multiple times.

For reference, please have a look in stm32l4xx_hal_cryp.c & stm32l4xx_hal_cryp_ex.c. It got my use case (both CBC & GCM) to work while using

It would be superb if you can provide a similar API for STM32H7.

Regards, Manuel

ALABSTM commented 1 month ago

ST Internal Reference: 191062

ALABSTM commented 1 month ago

Hi @fermentedfly,

Your proposal has been forwarded to our development teams. I will get back to you once I have their feedback.

With regards,