2021-05-20 09:09 AM
Hi,
I am migrating some code from an STM32F745 to an STM32H743.
I came into some trouble while using the crypto library and the hardware CRC at the same time.
The STM32H743 crypto library resets the CRC DR register every time AES_CBC_Decrypt_Append is called.
This was not the case when using the STM32F745.
The workaround is to save restore the CRC.DR register as shown below:
// Save CRC_DR register
uint32_t CRC_DR = hcrc.Instance->DR;
// Call crypto function
// Restore CRC_DR register
__HAL_CRC_INITIALCRCVALUE_CONFIG(&hcrc, CRC_DR);
__HAL_CRC_DR_RESET(&hcrc);
Crypto library used:
AES256CBC.h
STM32F745: STM32CryptographicV3.1.2_CM7_GCC_FPU.a
STM32H743: libSTM32CryptographicV3.1.1_STM32H7_GCC.a
I hope it can help others.
2021-05-20 09:48 AM
This has been noted before, ST really needs to remove these "Am I an STM32" checks from these libraries
I think some of the windowing and graphic libraries also do this.
Used also to be problems with earlier crypto libraries where they would fail or provide bad results if the CRC unit clock was not enabled.
2021-05-20 01:53 PM
IIRC the ST crypto library readme says that the CRC device is not available when the crypto library is used.
-- pa