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

This commit is contained in:
Cao Sen Miao
2023-10-24 11:31:33 +08:00
parent c5ae121bac
commit 420ac840ff
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
@@ -93,7 +94,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);
}