Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e6655e6
F-7989: clamp unaligned head size in ext_flash_decrypt_read()
danielinux Aug 11, 2026
7608e33
F-7988: clamp unaligned head size in ext_flash_encrypt_write()
danielinux Aug 11, 2026
e200579
F-7969: validate boot-side digest before delta base hash compare
danielinux Aug 11, 2026
748fa8a
F-8006: return errors from delta base-hash validation in sign tool
danielinux Aug 11, 2026
f9957da
F-8003: separate decoded key objects for hybrid signers
danielinux Aug 11, 2026
5dfdec3
F-7992: bound staged ciphertext in ext_flash_encrypt_write()
danielinux Aug 11, 2026
93edc29
F-7985: enter legacy uImage at ih_ep when it differs from ih_load
danielinux Aug 11, 2026
f446a4a
F-8007: wipe TPM advanced-IO staging buffers in TPM2_IoCb()
danielinux Aug 11, 2026
bc743ad
F-7987: abort the swap when a sector copy fails
danielinux Aug 11, 2026
ab7b79c
F-7383: use one consistent sector size in mcxw hal_flash_erase
danielinux Aug 11, 2026
a799a98
F-7382: clip QSPI page program transfers at the device page boundary
danielinux Aug 11, 2026
40021b8
F-7069: clear the EH authValue from the stack in wolfBoot_tpm2_get_ti…
danielinux Aug 11, 2026
f755125
F-6757: fix partial-word hal_flash_write on nrf52, nrf5340 and stm32l0
danielinux Aug 11, 2026
f9fe138
F-6130: clear disk_encrypt_key/nonce on the FIT DTS load failure path
danielinux Aug 11, 2026
4726dce
update_disk: use wc_ForceZero() in the DISK_ENCRYPT helpers
danielinux Aug 11, 2026
db8e768
aarch64: link the ARM ChaCha port when ChaCha is selected
danielinux Aug 11, 2026
e24fff0
libwolfboot: declare ForceZero() in the test-app build
danielinux Aug 11, 2026
31a9adc
test: bump footprint limits
danielinux Aug 11, 2026
fca6bf0
Address PR review on the encrypted write and sector copy paths
danielinux Aug 11, 2026
cfaf145
libwolfboot: propagate the head-block write failure
danielinux Aug 12, 2026
a69b338
nrf52/nrf5340/stm32l0: fix the 32-bit fast path in hal_flash_write
danielinux Aug 12, 2026
a2706b9
mcxw: extend the erase length when rounding the start down
danielinux Aug 12, 2026
acf0779
update_ram: track the uImage entry override explicitly
danielinux Aug 12, 2026
6201ba4
sign: scrub the primary key when the key load fails
danielinux Aug 12, 2026
e4fd913
gitignore: add two missing unit-test binaries
danielinux Aug 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,21 @@ jobs:
arch: aarch64
config-file: ./config/examples/zynqmp_sdcard.config

# Only build that compiles the DISK_ENCRYPT paths of src/update_disk.c.
zynqmp_sdcard_encrypt_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/zynqmp_sdcard.config
make-args: ENCRYPT=1 ENCRYPT_WITH_AES256=1

zynqmp_sdcard_encrypt_chacha_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/zynqmp_sdcard.config
make-args: ENCRYPT=1 ENCRYPT_WITH_CHACHA=1

zynqmp_fsbl_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,29 @@ tools/unit-tests/unit-otp-keystore
tools/unit-tests/unit-otp-keystore-gen-zeroize
tools/unit-tests/unit-tpm-api-names
tools/unit-tests/unit-tpm-nsc-cert
tools/unit-tests/unit-tpm-advio-zeroize
Comment thread
danielinux marked this conversation as resolved.
tools/unit-tests/unit-tpm-mfgid-eh-zeroize
tools/unit-tests/unit-elf-bss-guard
tools/unit-tests/unit-fit-fpga
tools/unit-tests/unit-flash-erase-c0
tools/unit-tests/unit-flash-erase-g0
tools/unit-tests/unit-flash-erase-l0
tools/unit-tests/unit-flash-erase-u3
tools/unit-tests/unit-flash-erase-wb
tools/unit-tests/unit-flash-erase-mcxw
tools/unit-tests/unit-fwtpm-nv-oob
tools/unit-tests/unit-x86-paging-oob
tools/unit-tests/unit-ahci-unlock-panic
tools/unit-tests/unit-ata-security-passphrase-zeroize
tools/unit-tests/unit-arm-tee-psa-ipc
tools/unit-tests/unit-flash-write-mcxa
tools/unit-tests/unit-flash-write-nrf52
tools/unit-tests/unit-flash-write-same51
tools/unit-tests/unit-flash-write-samr21
tools/unit-tests/unit-image-elf-scatter
tools/unit-tests/unit-image-hybrid
tools/unit-tests/unit-imx-rt-cache-align
tools/unit-tests/unit-update-disk-fit
tools/unit-tests/unit-update-disk-oob
tools/unit-tests/unit-update-ram-enc
tools/unit-tests/unit-update-ram-enc-nopart
Expand Down
23 changes: 19 additions & 4 deletions hal/mcxw.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

#ifndef WOLFBOOT_UNIT_TEST_FLASH_ERASE
#include <stdint.h>
#include <target.h>
#include "image.h"
Expand All @@ -44,8 +45,11 @@
/*!< Core clock frequency: 48000000Hz */
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 48000000U
static flash_config_t pflash;
#endif /* !WOLFBOOT_UNIT_TEST_FLASH_ERASE */

static uint32_t pflash_sector_size = WOLFBOOT_SECTOR_SIZE;

#ifndef WOLFBOOT_UNIT_TEST_FLASH_ERASE
uint32_t SystemCoreClock;

#ifdef TZEN
Expand Down Expand Up @@ -223,15 +227,26 @@ static void erase_flash_sector(uint32_t *dst) {
/* Wait for completion */
while (!(FMU0->FSTAT & 0x00000080)) {}
}
#endif /* !WOLFBOOT_UNIT_TEST_FLASH_ERASE */

int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
Comment thread
danielinux marked this conversation as resolved.
{
if (address % pflash_sector_size)
address -= address % pflash_sector_size;
uint32_t sector_size = pflash_sector_size;

if (sector_size == 0U)
sector_size = WOLFBOOT_SECTOR_SIZE;

/* Rounding the start down extends the range, so the length must grow by
* the same amount or the last sector of the request is left unerased. */
if (address % sector_size) {
uint32_t offset = address % sector_size;
address -= offset;
len += (int)offset;
}
while (len > 0) {
erase_flash_sector((uint32_t *)address);
address += WOLFBOOT_SECTOR_SIZE;
len -= WOLFBOOT_SECTOR_SIZE;
address += sector_size;
len -= (int)sector_size;
}
return 0;
}
Expand Down
26 changes: 17 additions & 9 deletions hal/nrf52.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,33 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)

while (i < len) {
if ((len - i > 3) && ((((address + i) & 0x03) == 0) && ((((uint32_t)data) + i) & 0x03) == 0)) {
src = (uint32_t *)data;
dst = (uint32_t *)address;
/* Index by "i" directly: the condition above only guarantees
* that "address + i" and "data + i" are word aligned, so
* dst[i >> 2] off the unaligned base would address the wrong
* word (and fault on a strict-alignment core). */
src = (uint32_t *)(data + i);
dst = (uint32_t *)(address + i);
NVMC_CONFIG = NVMC_CONFIG_WEN;
flash_wait_complete();
dst[i >> 2] = src[i >> 2];
*dst = *src;
flash_wait_complete();
i+=4;
} else {
Comment thread
danielinux marked this conversation as resolved.
uint32_t val;
uint8_t *vbytes = (uint8_t *)(&val);
int off = (address + i) - (((address + i) >> 2) << 2);
dst = (uint32_t *)(address - off);
val = dst[i >> 2];
vbytes[off] = data[i];
uint32_t off = ((address + i) % 4);
dst = (uint32_t *)(address + i - off);
val = *dst;
while (off < 4) {
if (i < len)
vbytes[off++] = data[i++];
else
off++;
}
NVMC_CONFIG = NVMC_CONFIG_WEN;
flash_wait_complete();
dst[i >> 2] = val;
*dst = val;
flash_wait_complete();
i++;
}
}
return 0;
Expand Down
26 changes: 17 additions & 9 deletions hal/nrf5340.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,31 +317,39 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
while (i < len) {
if ((len - i > 3) && ((((address + i) & 0x03) == 0) &&
((((uint32_t)data) + i) & 0x03) == 0)) {
src = (uint32_t *)data;
dst = (uint32_t *)address;
/* Index by "i" directly: the condition above only guarantees
* that "address + i" and "data + i" are word aligned, so
* dst[i >> 2] off the unaligned base would address the wrong
* word (and fault on a strict-alignment core). */
src = (uint32_t *)(data + i);
dst = (uint32_t *)(address + i);
#if TZ_SECURE() || defined(TARGET_nrf5340_net)
NVMC_CONFIG = NVMC_CONFIG_WEN;
#endif
NVMC_CONFIGNS = NVMC_CONFIG_WEN;
while (NVMC_READY == 0);
dst[i >> 2] = src[i >> 2];
*dst = *src;
while (NVMC_READY == 0);
i+=4;
} else {
uint32_t val;
uint8_t *vbytes = (uint8_t *)(&val);
int off = (address + i) - (((address + i) >> 2) << 2);
dst = (uint32_t *)(address - off);
val = dst[i >> 2];
vbytes[off] = data[i];
uint32_t off = ((address + i) % 4);
dst = (uint32_t *)(address + i - off);
val = *dst;
while (off < 4) {
if (i < len)
vbytes[off++] = data[i++];
else
off++;
}
#if TZ_SECURE() || defined(TARGET_nrf5340_net)
NVMC_CONFIG = NVMC_CONFIG_WEN;
#endif
NVMC_CONFIGNS = NVMC_CONFIG_WEN;
while (NVMC_READY == 0);
dst[i >> 2] = val;
*dst = val;
while (NVMC_READY == 0);
i++;
}
}
return 0;
Expand Down
26 changes: 17 additions & 9 deletions hal/stm32l0.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,31 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)

while (i < len) {
if ((len - i > 3) && ((((address + i) & 0x03) == 0) && ((((uint32_t)data) + i) & 0x03) == 0)) {
src = (uint32_t *)data;
dst = (uint32_t *)(address + FLASHMEM_ADDRESS_SPACE);
/* Index by "i" directly: the condition above only guarantees
* that "address + i" and "data + i" are word aligned, so
* dst[i >> 2] off the unaligned base would address the wrong
* word, and the Cortex-M0+ faults on the unaligned access. */
src = (uint32_t *)(data + i);
dst = (uint32_t *)(address + i + FLASHMEM_ADDRESS_SPACE);
flash_wait_complete();
dst[i >> 2] = src[i >> 2];
*dst = *src;
flash_wait_complete();
i+=4;
} else {
uint32_t val;
uint8_t *vbytes = (uint8_t *)(&val);
int off = (address + i) - (((address + i) >> 2) << 2);
dst = (uint32_t *)(address + FLASHMEM_ADDRESS_SPACE - off);
val = dst[i >> 2];
vbytes[off] = data[i];
uint32_t off = ((address + i) % 4);
dst = (uint32_t *)(address + FLASHMEM_ADDRESS_SPACE + i - off);
val = *dst;
while (off < 4) {
if (i < len)
vbytes[off++] = data[i++];
else
off++;
}
flash_wait_complete();
dst[i >> 2] = val;
*dst = val;
flash_wait_complete();
i++;
}
}
return 0;
Expand Down
11 changes: 11 additions & 0 deletions options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1885,3 +1885,14 @@ endif
# includers (test-app), where a self-referencing += would not terminate.
AUX_WOLFCRYPT_OBJS_NEW:=$(filter-out $(WOLFCRYPT_OBJS),$(sort $(AUX_WOLFCRYPT_OBJS)))
WOLFCRYPT_OBJS+=$(AUX_WOLFCRYPT_OBJS_NEW)

# Under WOLFSSL_ARMASM, chacha.c defers the block function to
# wc_chacha_crypt_bytes(), which lives in the port. arch.mk adds the aes/sha
# equivalents unconditionally; ChaCha is only selected here, so add it last.
ifeq ($(ARCH),AARCH64)
ifneq ($(NO_ARM_ASM),1)
ifneq (,$(filter %/wolfcrypt/src/chacha.o,$(WOLFCRYPT_OBJS)))
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-chacha-asm_c.o
endif
endif
endif
8 changes: 5 additions & 3 deletions src/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ int elf_load_image_mmu(uint8_t *image, uint32_t image_sz, uintptr_t *pentry,
is_elf32 ? 32 : 64, is_le ? "little" : "big");
#endif

/* set entry point */
*pentry = GET_H64(entry);

/* programs */
ph_offset = GET_H32(ph_offset);
entry_size = GET_H16(ph_entry_size);
Expand Down Expand Up @@ -222,6 +219,11 @@ int elf_load_image_mmu(uint8_t *image, uint32_t image_sz, uintptr_t *pentry,
#endif /* !ELF_PARSER */
}

/* Publish the entry point only once every check above has passed: callers
* fall back to the raw binary on failure and must not be left with a
* partially validated ELF's declared entry. */
*pentry = GET_H64(entry);

#ifdef DEBUG_ELF
wolfBoot_printf("Entry point %p\r\n", (void*)*pentry);
#endif
Expand Down
Loading
Loading