STMCryptoLib failures on STM32U599
The Issue
- When my bootloader jumps to the application all `AES_ECB_Encrypt_XXX` incorrectly encrypt/decrypt the data. Once the application fails to initialize too many times it will reboot due to watchdog and the ncrypt/decrypt will continue to fail in the bootloader although it was working before it jumped to the application.
Background
- I am using the STMCryptoLib_V4.1.0 in my bootloader and application.
- I am using the legacy_v3 APIs. As our code was originally written with the V3 library.
- The module in question is `AES_ECB_Encrypt_xxx`.
- The bootloader uses the modules successfully but after it jumps to the application it fails to encrypt/decrypt.
- The CRC clock is not disable prior to the bootloader jumping to the application.
- The CRC clock is enable on board bring up for each applications as follows..
__HAL_RCC_CRC_FORCE_RESET();
__HAL_RCC_CRC_RELEASE_RESET();
__HAL_RCC_CRC_CLK_ENABLE();
- The library is not failing it's just not encrypt/decrypt correctly after jumping from the application.
- The code that I am using has worked for years using STMCryptoLib_V3 on stm32L4. So our code isn't the issue. If I turn off encryption feature on our code everything works.
- If I built the application without bootloader support. That is it's the first thing to run after POR everything works. So the issue is related to jumping to the application from the bootloader after using the cyrpotLibrary.
- If I use a CRC in software and dedicate the CRC HW to crypto library everything works fine. As we use the CRC module for software purposes too. On the STML4 using cryptoLibV3 we has to snapshot and reset the register as follow to make sure it played nicely but this doesn't help on the STMU5 and crytpoLibv4
ctx.handle.Instance->CR = ctx.regs.CR;
ctx.handle.Instance->POL = ctx.regs.POL;
__HAL_CRC_INITIALCRCVALUE_CONFIG(&ctx.handle, value);
__HAL_CRC_DR_RESET(&ctx.handle);
value = ~HAL_CRC_Accumulate(&ctx.handle, (uint32_t *)data, (uint32_t)size);
__HAL_CRC_INITIALCRCVALUE_CONFIG(&ctx.handle, ~0);I would like to know how to correctly reinit the CRC after jumping from my bootloader to application as everything I have tried has failed?
