Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed flag comparison selecting most recent flags #470

Merged
merged 12 commits into from
Jul 18, 2024
Prev Previous commit
Next Next commit
Implicitly add trailer when setting enc key
  • Loading branch information
danielinux committed Jul 17, 2024
commit d3795c81cdfef2c6839cfdcbcf803b46d357a66f
4 changes: 3 additions & 1 deletion src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 1381,12 @@ static int RAMFUNCTION hal_set_key(const uint8_t *k, const uint8_t *nonce)
if (ret != 0)
return ret;
#endif

XMEMCPY(ENCRYPT_CACHE addr_off, k, ENCRYPT_KEY_SIZE);
XMEMCPY(ENCRYPT_CACHE addr_off ENCRYPT_KEY_SIZE, nonce,
ENCRYPT_NONCE_SIZE);
XMEMCPY(ENCRYPT_CACHE addr_off - 4,
&wolfboot_magic_trail, 4);
ret = hal_flash_write(addr_align, ENCRYPT_CACHE, WOLFBOOT_SECTOR_SIZE);
#ifdef NVM_FLASH_WRITEONCE
/* now erase the old populated sector */
Expand Down Expand Up @@ -1412,7 1415,6 @@ static int RAMFUNCTION hal_set_key(const uint8_t *k, const uint8_t *nonce)
int RAMFUNCTION wolfBoot_set_encrypt_key(const uint8_t *key,
const uint8_t *nonce)
{
set_partition_magic(PART_BOOT);
hal_set_key(key, nonce);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 821,7 @@ void RAMFUNCTION wolfBoot_start(void)
updateRet = wolfBoot_get_partition_state(PART_UPDATE, &updateState);


#if !defined(DISABLE_BACKUP) && !defined(EXT_ENCRYPTED)
#if !defined(DISABLE_BACKUP)
/* resume the final erase in case the power failed before it finished */
resumedFinalErase = wolfBoot_swap_and_final_erase(1);
if (resumedFinalErase != 0)
Expand Down
Loading