Merge branch 'bugfix/flash_enc_plaintext' into 'master'

fix(flash_encryption): Fix the issue that XTS_AES Plain text memory size wrong

See merge request espressif/esp-idf!26640
This commit is contained in:
C.S.M
2023-10-27 18:23:00 +08:00
13 changed files with 27 additions and 13 deletions

View File

@@ -17,6 +17,7 @@
#include "soc/system_reg.h"
#include "soc/hwcrypto_reg.h"
#include "soc/soc.h"
#include "soc/soc_caps.h"
#include "hal/assert.h"
#ifdef __cplusplus
@@ -84,7 +85,8 @@ static inline void spi_flash_encrypt_ll_buffer_length(uint32_t size)
*/
static inline void spi_flash_encrypt_ll_plaintext_save(uint32_t address, const uint32_t* buffer, uint32_t size)
{
uint32_t plaintext_offs = (address % 64);
uint32_t plaintext_offs = (address % SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX);
HAL_ASSERT(plaintext_offs + size <= SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX);
memcpy((void *)(AES_XTS_PLAIN_BASE + plaintext_offs), buffer, size);
}