drivers: crypto: stm32: h7: add AES CCM and GCM support#93189
drivers: crypto: stm32: h7: add AES CCM and GCM support#93189GeorgeCGV wants to merge 11 commits intozephyrproject-rtos:mainfrom
Conversation
55c625f to
6aa8470
Compare
6aa8470 to
167348a
Compare
9c47b93 to
e494b35
Compare
mathieuchopstm
left a comment
There was a problem hiding this comment.
I'm wondering if, instead of hardcoded SoCs in Kconfig, we shouldn't create a new compatible for the IP embedded in H7, as it is also used on other series so the code can probably shared (e.g., STM32F72xx/F73xx).
This can always be integrated later, so OK for me in current state..
e494b35 to
420a6b9
Compare
Ideally, as more boards are tested and the necessary adjustments are made, this condition will no longer be needed. It is mainly here because testing is performed on the STM32H730XX, which shares the same RM with STM32H723XX, STM32H725XX, STM32H730XXQ, and STM32H735XX. |
erwango
left a comment
There was a problem hiding this comment.
I'm wondering if, instead of hardcoded SoCs in Kconfig, we shouldn't create a new compatible for the IP embedded in H7, as it is also used on other series so the code can probably shared (e.g., STM32F72xx/F73xx).
It will be harder to impose to the next ones if this is done this way today. Let's do it now.
420a6b9 to
3407044
Compare
|
@erwango @mathieuchopstm reworked the memory comparison approach. I guess depending on mbedtls is ok for ct memcmp. |
It still does actually. Did you push the right branch ? |
Do you mean? (.c, not Kconfig) #if defined(CONFIG_SOC_STM32H723XX) || defined(CONFIG_SOC_STM32H725XX) || \
defined(CONFIG_SOC_STM32H730XX) || defined(CONFIG_SOC_STM32H730XXQ) || \
defined(CONFIG_SOC_STM32H735XX)
#define STM32_CRYPTO_GCM_CCM_SUPPORT 1
#endifThe most recent push to Kconfig includes a new option that relies on the mbedtls. |
etienne-lms
left a comment
There was a problem hiding this comment.
Sorry for the late feedback. Looks all good to me.
|
@GeorgeCGV Can you confirm this is still blocked at HAL level ? (Hence the |
|
@erwango yes, unfortunately. No updates from ST regarding the HAL issue - STMicroelectronics/stm32h7xx-hal-driver#88. |
1545157
2d11890 to
1545157
Compare
|
Rebased |
|
|
For info, the issue in the HAL has been addressed internally. Hopefully to be available in the next HAL release. In the meantime, @GeorgeCGV, do you want to have at least CCM functional and introduce a For info, I've been through the STM32 SoCs series and those that have a CRYP instance actually support GCM and CCM. The issue for extending your changes to all SoCs is that some SOCs have specific HAL APIs that do not match the H7 ones you used in your implementation here. Once crypto_stm32.c driver adapted done, we would be able to fully remove the Saying that, I realize that maybe your patch could enable |
|
@etienne-lms, there is no rush to upstream this.
This is how it used to be at the beginning of the PR. The discussions then led to the creation of the DT property. |
Device semaphore handling is being moved out of the do_aes function. This is necessary to support upcoming GCM and CCM modes, which require the semaphore to be held during tag generation. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Marks default case for cipher mode as unreachable. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Adds a gcm-ccm-supported property to the crypto driver. This allows to enable or disable support for AES GCM and CCM, providing flexibility to remove the functionality if it's not needed. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Enables AES GCM and CCM support for the crypto driver. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Adds AES GCM and CCM support for: * H723XX * H725XX * H730XX, H730XXQ * H735XX Note: To use CCM with additional authenticated data (AD), the heap memory pool size must be large enough to accommodate the AD length, rounded up to the nearest multiple of 16 bytes. For an AD length of 8 bytes, the heap size must be at least 16 bytes. For an AD length of 17 bytes, you'll need at least 32 bytes. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
* Use if, endif to scope the configuration options. * Add an option to use mbedtls_ct_memcmp instead of memcmp. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Adds constant time comparison to replace memcmp. Co-Authored-By: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Enables crypto peripheral for the board. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Enables AES GCM and CCM support for the crypto driver. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
Enables AES GCM and CCM support for the crypto driver. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
The AES CCM AD (Additional Authenticated Data) relies on dynamic memory allocation, the heap memory pool size must be greater than zero. This commit sets the heap memory one block size when you enable crypto with CCM support. This ensures that the crypto sample can be built and run. Signed-off-by: Georgij Černyšiov <geo.cgv@gmail.com>
1545157 to
f247a32
Compare
|
|
Rebased, and a minor ccm fix: |
|
A new issue STMicroelectronics/stm32h7xx-hal-driver#104 has been discovered in the CubeH7 HAL related to the AES CCM. Fixing this inside the driver is not practical, because it would require allocating an aligned copy of the payload, which adds unnecessary overhead. |



Adds support for AES-CCM and AES-GCM cipher modes.
The support is limited to the following STM32 H7 SoCs:
STM32H723XX,STM32H725XX,STM32H730XX,STM32H730XXQ, andSTM32H735XX, as they share the same reference manual.Note: testing was performed on the
STM32H730XX.Crypto sample output:
The pull request is open for review but not yet ready to be merged (therefore, labeled
DNM) due to an issue in the STM32 H7 HAL related to GCM tag generation during decryption: STMicroelectronics/stm32h7xx-hal-driver#88.