mirror of https://github.com/wolfSSL/wolfBoot.git
Fixed bug in encrypted update, removed swap_counter.
parent
d31bfc2032
commit
b2beb49370
|
@ -587,8 +587,6 @@ static inline uint8_t part_address(uintptr_t a)
|
|||
return PART_NONE;
|
||||
}
|
||||
|
||||
static uint32_t swap_counter = 0;
|
||||
|
||||
int ext_flash_encrypt_write(uintptr_t address, const uint8_t *data, int len)
|
||||
{
|
||||
uint32_t iv_counter;
|
||||
|
@ -622,7 +620,7 @@ int ext_flash_encrypt_write(uintptr_t address, const uint8_t *data, int len)
|
|||
{
|
||||
uint32_t row_number;
|
||||
row_number = (address - WOLFBOOT_PARTITION_SWAP_ADDRESS) / ENCRYPT_BLOCK_SIZE;
|
||||
iv_counter = ((swap_counter++) << 8) + row_number;
|
||||
iv_counter = row_number;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -682,8 +680,8 @@ int ext_flash_decrypt_read(uintptr_t address, uint8_t *data, int len)
|
|||
case PART_SWAP:
|
||||
{
|
||||
uint32_t row_number;
|
||||
row_number = (address - WOLFBOOT_PARTITION_UPDATE_ADDRESS) / ENCRYPT_BLOCK_SIZE;
|
||||
iv_counter = (swap_counter << 8) + row_number;
|
||||
row_number = (address - WOLFBOOT_PARTITION_SWAP_ADDRESS) / ENCRYPT_BLOCK_SIZE;
|
||||
iv_counter = row_number;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -188,7 +188,7 @@ uint8_t *mmap_firmware(const char *fname)
|
|||
perror("open");
|
||||
return (void *)-1;
|
||||
}
|
||||
if (st.st_size < FIRMWARE_PARTITION_SIZE) {
|
||||
if (st.st_size <= FIRMWARE_PARTITION_SIZE) {
|
||||
uint8_t pad = 0xFF;
|
||||
int i;
|
||||
const char update_flags[] = "pBOOT";
|
||||
|
|
Loading…
Reference in New Issue