stm32f7xx_hal_driver icon indicating copy to clipboard operation
stm32f7xx_hal_driver copied to clipboard

[Request] [AES] Change default AES input size from uint16_t to uint32_t or enable chunking data.

Open printfKrzysztof opened this issue 8 months ago • 3 comments

Currently HAL doesn't enable you to encrypt more than 65KB in one go nor doest it enable you to upload data by chunks. Its smol :c I changed my stm32f7xx_hal_cryp.h and .c to uint32_t input size in initializers and interrupts and it works just fine. If there is any particular reason for keeping uint16_t please let me know. Have a good day!

printfKrzysztof avatar Mar 24 '25 08:03 printfKrzysztof

Hello @printfKrzysztof,

Thank you for the report.

Just to be sure, you are talking about the parameter size in the structure CRYP_HandleTypeDef which is defined as uint16_t, and when you changed it to uint32_t it worked just fine. If so, I will check with our team and keep you posted.

With regards,

KRASTM avatar Mar 28 '25 09:03 KRASTM

Hi @KRASTM, It requied to change more than just a size in CRYP_HandleTypeDef. In CRYP_HandleTypeDef i changed

__IO uint32_t                     CrypHeaderCount;   /*!< Counter of header data */
__IO uint32_t                     CrypInCount;      /*!< Counter of input data */
__IO uint32_t                     CrypOutCount;     /*!< Counter of output data */
      uint32_t                          Size;           /*!< length of input data in word */

In interrupt callbacks there were also:

uint16_t incount; /* Temporary CrypInCount Value */
uint16_t outcount;  /* Temporary CrypOutCount Value */

needs to be changed.

After those i tested it with 300KB file and it encrypted properly using AES CTR. I decrypted it using openssl without any problem. For clarity i am using 2021 version of HAL in my project, but i checked and on current release and there wasn't any fix to this problem.

Rgrds

printfKrzysztof avatar Mar 28 '25 13:03 printfKrzysztof

ST Internal Reference: 206903

KRASTM avatar Apr 07 '25 08:04 KRASTM