wolfBoot/src
Daniele Lacamera 5caac27eb9 F-9750: decrypt the stored block before the encrypted RMW patch
Both partial-block read-modify-write paths in ext_flash_encrypt_write
read the stored block (ciphertext), spliced the new plaintext in, and
re-encrypted the whole block. The untouched bytes were therefore
XOR'd with the keystream a second time: stored ciphertext came back
as plaintext in flash, and the next read of those bytes returned raw
ciphertext instead of the original data. Any encrypted update whose
first or last block partially overlaps a block with previous content
- e.g. a retry over a previously written update image - silently
corrupted the neighbouring bytes.

Decrypt the stored block before splicing (into the scratch buffer, so
no backend has to handle in-place decrypt) and re-encrypt the merged
plaintext. Erased (0xFF) bytes round-trip unchanged because the
decrypt/encrypt pair is the identity on the stored value.

The re-encryption re-syncs the stream to the block index first: the
decrypt step consumes keystream, and on the ChaCha/PKCS#11 backends
encrypt and decrypt share a single stream state, while on the AES
backends the decrypt context had not advanced with the full-block
writes. The tail path also syncs the decrypt context, which on the
AES backends sits at the first block's index after the aligned
writes. Fallback-IV offset handling mirrors ext_flash_decrypt_read.

New unit-extflash tests (run under the plain, AES-128, AES-256 and
ChaCha20 variants): a mid-block patch must leave the untouched bytes
of a previously written block intact, a trailing partial block must
leave the rest of a previously written block intact, and a stream
written in small unaligned chunks must round-trip byte for byte. All
three fail on the pre-fix code with every cipher.
2026-08-21 08:52:59 +02:00
..
dice Add wolfCOSE DICE attestation 2026-08-06 09:44:52 +02:00
x86
arm_tee_psa_ipc.c F-7389: arm_tee: reject Secure .base in zero-length PSA iovecs 2026-08-04 07:02:53 +02:00
arm_tee_psa_veneer.c
boot_aarch64.c PolarFire SoC: address PR review 2026-08-03 12:27:22 +02:00
boot_aarch64_efi.c Add aarch64_efi target: wolfBoot as an AArch64 UEFI application 2026-08-10 21:03:50 +02:00
boot_aarch64_start.S tegra234: bare-metal BL33 target with verified EL2->EL1 + device-tree boot 2026-08-18 11:01:45 +02:00
boot_arm.c
boot_arm32.c PolarFire SoC: address PR review 2026-08-03 12:27:22 +02:00
boot_arm32_start.S
boot_ppc.c PolarFire SoC: address PR review 2026-08-03 12:27:22 +02:00
boot_ppc_mp.S
boot_ppc_start.S
boot_renesas.c
boot_renesas_start.S
boot_riscv.c RISC-V: minimal SBI runtime; PolarFire SoC boots 4-CPU SMP Yocto Linux 2026-08-03 12:27:22 +02:00
boot_riscv_start.S RISC-V: minimal SBI runtime; PolarFire SoC boots 4-CPU SMP Yocto Linux 2026-08-03 12:27:22 +02:00
boot_x86_64.c PolarFire SoC: address PR review 2026-08-03 12:27:22 +02:00
boot_x86_fsp.c
boot_x86_fsp_payload.c
boot_x86_fsp_start.S
clang_sections.S
ddr_cadence.c PolarFire SoC: LPDDR4 DDR init for MPFS250T Video Kit (M-Mode) 2026-08-03 12:27:22 +02:00
delta.c
disk.c
elf.c update_ram: track the uImage entry override explicitly 2026-08-12 13:21:08 +02:00
fdt.c F-9757: length-bound the FIT name/compression string properties 2026-08-21 08:52:59 +02:00
flash_otp_keystore.c
fwtpm_callable.c
gpt.c
gzip.c
image.c F-9756: validate PT_LOAD segments before the scatter flash hash walk 2026-08-21 08:52:59 +02:00
libwolfboot.c F-9750: decrypt the stored block before the encrypted RMW patch 2026-08-21 08:52:59 +02:00
loader.c
multiboot.c
pci.c
pkcs11_callable.c F-6875: pkcs11: zeroize NSC bounce buffers before freeing them 2026-08-04 08:26:17 +02:00
pkcs11_store.c
psa_store.c
qspi_flash.c F-7382: clip QSPI page program transfers at the device page boundary 2026-08-11 12:54:36 +02:00
riscv_sbi.c RISC-V: minimal SBI runtime; PolarFire SoC boots 4-CPU SMP Yocto Linux 2026-08-03 12:27:22 +02:00
sdhci.c Merge pull request #862 from danielinux/fenrir-fixes-2026-08-18 2026-08-18 12:12:50 -07:00
spi_flash.c
stage2_params.c
store_sbrk.c
store_sbrk.h
string.c Clean up build flag usage, use trng healthtest in test-app 2026-07-31 14:33:56 +02:00
tpm.c F-7069: clear the EH authValue from the stack in wolfBoot_tpm2_get_timestamp 2026-08-11 12:59:01 +02:00
uart_flash.c
update_disk.c F-7066: bound the FIT DTS relocation copy to the staging size 2026-08-21 08:52:59 +02:00
update_flash.c F-7071: scrub the staging buffer on the swap resume early-return 2026-08-21 08:52:59 +02:00
update_flash_hwswap.c
update_ram.c F-7066: bound the FIT DTS relocation copy to the staging size 2026-08-21 08:52:59 +02:00
vector_riscv.S RISC-V: minimal SBI runtime; PolarFire SoC boots 4-CPU SMP Yocto Linux 2026-08-03 12:27:22 +02:00
wc_callable.c
wolfhsm_callable.c
wolfhsm_flash_hal.c
xmalloc.c