Skip to content

Add key revocation, a security version floor and FIPS image encryption on AArch64 - #1011

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:secure_boot_upstream
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:secure_boot_upstream

Conversation

@dgarske

@dgarske dgarske commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Description

This PR adds signing-key revocation and an anti-rollback security version, and makes FIPS builds work with AES image encryption on AArch64:

  • Signing-key revocation through a signed HDR_KEY_REVOKE mask, applied only once the revoking image is confirmed (KEY_REVOCATION=1).
  • A security version floor, independent of the image version, enforced on flash, RAM and disk boot paths (SECURITY_VERSION=1).
  • ZynqMP storage of both in user eFuses, report-only unless ZYNQMP_EFUSE_BURN=1.
  • WOLFBOOT_PRODUCTION=1 build guard that refuses options which weaken verification, including ALLOW_DOWNGRADE and DUALBOOT_ROLLBACK_UNCONFIRMED.

FIPS on AArch64:

  • The module's ARMv8 assembly (AES, SHA-2, SHA-3, SP ECC) linked inside the module boundary; 32-bit ARM keeps the portable-C module.
  • P-256 kept in FIPS builds because the module's ECDHE self-test is fixed to it.
  • FIPS=1 with ENCRYPT_WITH_AES128/256 allowed; ZynqMP seeds the DRBG from the module's jitter entropy source and bounds the newlib heap.
  • ECC384 stack limit raised for AArch64 SP math (GCC 13 needs 11232 bytes).

ZynqMP boot policy (wolfBoot as BL33):

  • The eFuse security state (SEC_CTRL, PUF, PPK0 hash) read through the PMU firmware, and a required SEC_CTRL mask (ZYNQMP_SEC_POLICY) that stops the boot under WOLFBOOT_PRODUCTION=1 and warns otherwise; the state goes to /chosen as wolfboot,sec-ctrl and wolfboot,sec-policy.

Split out: TPM NV storage (#1027, stacked on this PR), disk-path failure records and boot times (#1026), and the disk decrypt return-code checks (#1025).

Testing

  • Simulator scripts for key revocation and the security version, run by a new workflow (development and production builds).
  • Unit tests for the BL33 eFuse read and the user-eFuse counter.
  • A ZynqMP FIPS + AES build job.

Validated on a ZCU102 (SD boot, BL33): encrypted FIT boot with the FIPS module operational, plus wrong-key and modified-ciphertext rejection. The eFuse path ran report-only; no eFuse was burned. The policy gate: a development build warns and boots, a production build stops, and the policy state reads from Linux. The bench PMU firmware does not return SEC_CTRL, so only the not-met path ran.

@dgarske dgarske self-assigned this Dec 1, 2026
Copilot AI balanced review requested due to automatic review settings December 1, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical flaws allow unauthenticated security-policy changes, key-revocation bypasses, and irreversible fuse writes outside the permitted range.

8 open issues
What changed in this PR

This PR adds signing-key revocation and an independent security-version floor to wolfBoot’s image-verification flow, alongside AArch64 FIPS support for AES-encrypted images.

Changes:

  • Adds confirmation-triggered security policies, simulator and ZynqMP storage, and production build guards.
  • Enables AArch64 FIPS assembly and AES encryption, checks cipher errors, and clears cipher state before handoff.
  • Adds simulator and unit coverage, a ZynqMP FIPS build job, documentation, and cached FIPS-ready downloads.
File Description
tools/​unit-tests/​unit-zynqmp-efuse-counter.c Tests monotonic eFuse counter encoding and capacity.
tools/​unit-tests/​unit-update-disk-decrypt-fail.c Tests decrypt failures, failover, and cipher-state clearing.
tools/​unit-tests/​Makefile Registers new tests and counter extraction rules.
tools/​scripts/​sim-security-version.sh Exercises security-version enforcement and confirmation.
tools/​scripts/​sim-key-revocation.sh Exercises key revocation, fallback, and self-revocation protection.
tools/​scripts/​sim-common.sh Shares image-signing, assembly, and boot-check helpers.
src/​update_ram.c Adds confirmed-image policy handling to RAM boot.
src/​update_flash.c Adds confirmed-image policy handling to flash boot.
src/​update_disk.c Adds policy handling, cipher error checks, and cleanup.
src/​libwolfboot.c Checks AES initialization and key-setup results.
src/​image.c Enforces revocation and security versions and applies confirmed policies.
options.mk Adds security options, production guards, and FIPS build support.
include/​wolfboot/​wolfboot.h Defines revocation and security-version header fields.
include/​user_settings.h Enables FIPS ARM64 ECC and retains P-256 self-test support.
include/​image.h Declares the confirmed-image policy interface and feature guards.
include/​hal.h Declares persistent security-policy storage interfaces.
hal/​zynq.c Adds user-eFuse policy storage, FIPS entropy, and bounded heap allocation.
hal/​sim.c Adds file-backed security-policy storage.
docs/​Targets.md Documents ZynqMP policy-storage allocation and programming controls.
docs/​keystore.md Documents signing-key revocation and rotation.
docs/​firmware_update.md Explains the independent security-version floor.
docs/​FIPS.md Documents AArch64 assembly, AES encryption, entropy, and runtime requirements.
docs/​compile.md Documents the production build guard.
arch.mk Passes ZynqMP eFuse allocation and programming options.
.gitignore Ignores generated counter-test artifacts.
.github/​workflows/​test-key-revocation-simulator.yml Adds separate and combined simulator policy jobs.
.github/​workflows/​test-configs.yml Adds a ZynqMP FIPS/AES-256 build configuration.
.github/​workflows/​test-build.yml Caches the FIPS-ready archive while retaining checksum checks.
.github/​workflows/​test-build-aarch64.yml Adds equivalent FIPS-ready caching for AArch64 builds.

Review effort: Balanced

Comment thread hal/zynq.c Resolved
Comment thread include/image.h Resolved
Comment thread options.mk Resolved
Comment thread src/image.c Resolved
Comment thread src/image.c Resolved
Comment thread src/image.c Resolved
Comment thread src/update_flash.c Resolved
Comment thread hal/zynq.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .gitignore, arch.mk, docs/FIPS.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, options.mk, tools/scripts/sim-common.sh, tools/scripts/sim-key-revocation.sh, tools/scripts/sim-security-version.sh, tools/unit-tests/Makefile
Coverage: 9 of 13 in-scope changed file(s) opened by the reviewer; not opened: hal/sim.c, include/hal.h, tools/unit-tests/unit-update-disk-decrypt-fail.c, tools/unit-tests/unit-zynqmp-efuse-counter.c

Findings: 6
6 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

@dgarske
dgarske force-pushed the secure_boot_upstream branch 2 times, most recently from cd1700f to a0a24f4 Compare December 1, 2026 15:42

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .github/workflows/test-units.yml, .gitignore, arch.mk, config/examples/nai_68int6.config, docs/FIPS.md, docs/TPM.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, options.mk, stage1/Makefile, tools/config.mk, tools/scripts/sim-common.sh, tools/scripts/sim-key-revocation.sh, tools/scripts/sim-security-version.sh and 2 more
Coverage: 6 of 14 in-scope changed file(s) opened by the reviewer; not opened: hal/sim.c, include/hal.h, include/image.h, include/tpm.h, src/tpm_policy_nv.c, tools/tpm/policy_nv.c, tools/unit-tests/unit-update-disk-confirm.c, tools/unit-tests/unit-update-ram.c

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/tpm.c Resolved
Comment thread src/update_disk.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .github/workflows/test-units.yml, .gitignore, arch.mk, config/examples/nai_68int6.config, docs/FIPS.md, docs/TPM.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, options.mk, stage1/Makefile, tools/config.mk, tools/scripts/sim-common.sh, tools/scripts/sim-key-revocation.sh, tools/scripts/sim-security-version.sh and 2 more
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself December 1, 2026 21:48

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@dgarske
dgarske force-pushed the secure_boot_upstream branch from d5830da to bf9a5a4 Compare December 2, 2026 21:47
@dgarske
dgarske requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot December 2, 2026 21:54

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .github/workflows/test-units.yml, .gitignore, arch.mk, config/examples/nai_68int6.config, docs/API.md, docs/FIPS.md, docs/TPM.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, hal/zynq.h, options.mk, stage1/Makefile, tools/config.mk, tools/scripts/sim-common.sh and 4 more
Coverage: 5 of 10 in-scope changed file(s) opened by the reviewer; not opened: include/hal.h, include/wolfboot/wolfboot.h, src/loader.c, tools/unit-tests/unit-diagnostics-disk.c, tools/unit-tests/unit-update-disk.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/update_disk.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread options.mk Resolved
Comment thread src/image.c Resolved
Comment thread src/tpm.c Resolved
Comment thread src/tpm_policy_nv.c Resolved
Comment thread src/update_disk.c Resolved
Comment thread src/update_disk.c Resolved
Comment thread src/update_disk.c Resolved
Comment thread tools/config.mk Resolved
Comment thread src/update_disk.c Resolved
@dgarske
dgarske requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot December 2, 2026 23:03

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .github/workflows/test-units.yml, .gitignore, arch.mk, config/examples/nai_68int6.config, docs/API.md, docs/FIPS.md, docs/TPM.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, hal/zynq.h, options.mk, stage1/Makefile, tools/config.mk, tools/scripts/sim-common.sh and 4 more
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tools/unit-tests/unit-update-disk-confirm.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/update_disk.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved critical flaws can bypass revocation and rollback protections or allow diagnostic writes to corrupt boot partitions and confirmation state.

8 open issues
4 previously missed issues

In code that hasn't changed since last review

High severity Defer updates until confirmed policy storage succeeds

src/​image.c:3482

Policy application only prints backend write errors, so this returns success even when the confirmed image's mask/floor was not persisted. With an update already staged, the boot paths then verify it against the old policy and can replace the last carrier of the confirmed policy permanently. Propagate storage failures and defer the pending update until the policy is durable, rather than treating a failed commit as complete.

High severity Route rollback records through diagnostics bounds checks

src/​update_disk.c:613

This direct store call bypasses disk_diag_off, so reaping a TESTING slot still writes even when logging was disabled because its region overlaps a boot-state trailer. Initializing or rotating the log can then overwrite boot-confirmation state. Route this event through disk_record_failure() so rollback records respect the same bounds check as other failures.

High severity Commit confirmed-image policy before checking self-updates

src/​update_flash.c:2307

With RAM_CODE enabled, wolfBoot_check_self_update() can install a bootloader before this confirmed-image policy commit runs. A bootloader update signed by a newly revoked key, or below the newly confirmed security version, is therefore checked against the old policy. Commit the verified confirmed image's policy before checking self-updates as well as ordinary firmware updates.

High severity Preserve ZYNQMP security policy and prerequisite in CONFIG_VARS

tools/​config.mk:150

Please preserve ZYNQMP_SEC_POLICY and its ZYNQMP_SEC prerequisite in CONFIG_VARS too. config/Makefile deletes .config and rewrites only this list, so running make config drops the required eFuse mask while retaining the newly listed WOLFBOOT_PRODUCTION=1. The next production build merely warns and no longer enforces the device security policy.

2 resolved since last review

Review effort: Balanced

@dgarske
dgarske requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot December 3, 2026 00:02

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1011

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-aarch64.yml, .github/workflows/test-build.yml, .github/workflows/test-configs.yml, .github/workflows/test-key-revocation-simulator.yml, .github/workflows/test-units.yml, .gitignore, arch.mk, config/examples/nai_68int6.config, docs/API.md, docs/FIPS.md, docs/TPM.md, docs/Targets.md, docs/compile.md, docs/firmware_update.md, docs/keystore.md, hal/zynq.h, options.mk, stage1/Makefile, tools/config.mk, tools/scripts/sim-common.sh and 4 more
Coverage: 3 of 5 in-scope changed file(s) opened by the reviewer; not opened: src/tpm_policy_nv.c, tools/unit-tests/unit-update-disk.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review December 3, 2026 00:05

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Monolithic self-updates can replace the confirmed application before pending security policy is committed and inherit BOOT’s SUCCESS trailer, applying replacement policy before confirmation.

1 open issue
4 resolved since last review

Review effort: Balanced

Comment thread include/image.h Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical flaws allow unconfirmed images with missing trailers to boot before pending revocations or security-version floors are applied, while revocation-store read failures can silently bypass pending revocations.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/image.c Resolved
Comment thread src/update_disk.c Resolved
Comment thread src/update_ram.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical issues cause duplicate-definition errors in FIPS self-header builds and allow production compiler flags to disable boot verification or permit downgrades.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread options.mk Resolved
Comment thread options.mk Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

BL33 burn-path regression coverage is missing, leaving irreversible PMU writes, row and bit selection, zero-bit no-ops, and both error-status words untested.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread hal/zynq.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical issue under EXT_FLASH=1 NO_XIP=1 misinterprets the disk loader’s RAM-resident header as an external-flash offset, rejecting valid disk slots and requiring a fix with regression coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/image.c Resolved
@dgarske
dgarske force-pushed the secure_boot_upstream branch from d108c25 to 21efd36 Compare December 4, 2026 15:47
Comment thread docs/compile.md Outdated

### Production build guard

`WOLFBOOT_PRODUCTION=1` makes these options build errors, whether set as make variables or passed as `-D` flags: `SIGN=NONE`, `WOLFBOOT_SKIP_BOOT_VERIFY=1`, `ALLOW_DOWNGRADE=1`, `DUALBOOT_ROLLBACK_UNCONFIRMED=1`, `WOLFBOOT_UDS_UID_FALLBACK_FORTEST=1` and `DEBUG_CSU` (JTAG on ZynqMP).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should list both the Makefile variables as well as the corresponding wolfBoot defines here, since I'm pretty sure they aren't all the same (e.g. SIGN).

Also, this is a pretty important list for users to grok, so recommend bulleted list, one per line. I think "these options" reads weird, I'd prefer "the following options". Something like the following, but with both env variables and macros highlighted

Suggested change
`WOLFBOOT_PRODUCTION=1` makes these options build errors, whether set as make variables or passed as `-D` flags: `SIGN=NONE`, `WOLFBOOT_SKIP_BOOT_VERIFY=1`, `ALLOW_DOWNGRADE=1`, `DUALBOOT_ROLLBACK_UNCONFIRMED=1`, `WOLFBOOT_UDS_UID_FALLBACK_FORTEST=1` and `DEBUG_CSU` (JTAG on ZynqMP).
`WOLFBOOT_PRODUCTION=1` makes the following options build errors, whether set as make variables or passed as `-D` flags:
- `SIGN=NONE`
- `WOLFBOOT_SKIP_BOOT_VERIFY=1`
- `ALLOW_DOWNGRADE=1`
- `DUALBOOT_ROLLBACK_UNCONFIRMED=1`
- `WOLFBOOT_UDS_UID_FALLBACK_FORTEST=1`
- `DEBUG_CSU` (JTAG on ZynqMP).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8984102 with "the following options", one per line. I used a two-column table (make variable, define) rather than bullets so both names sit side by side. DEBUG_CSU is define-only.

Comment thread docs/FIPS.md Outdated
- **POST entry.** The module registers its POST via a C constructor (`.init_array`), which a hosted runtime runs before `main()`. wolfBoot's bare-metal startup does not run `.init_array`, so build with `NO_ATTRIBUTE_CONSTRUCTOR` and call `fipsEntry()` explicitly (`src/loader.c`).
- **Normal (cacheable) memory.** wolfBoot's simple startup runs with the MMU off, where all memory is Device-nGnRnE and unaligned / 128-bit SIMD accesses fault (the FIPS module and newlib `printf`/`snprintf` do both). The CM4 HAL enables a minimal identity MMU with DDR mapped Normal cacheable before the POST (`cm4_mmu_enable`), and tears it down (clean D-cache, disable MMU/caches) before the boot handoff (`cm4_mmu_disable`) so the loaded image is coherent and the application starts MMU-off.
- **libc.** The module uses malloc/printf; stub the newlib syscalls (`--specs=nosys.specs`) and provide a bounded `_sbrk` so the heap cannot grow into the unverified image (the CM4 HAL allocates from a fixed static buffer in `hal/rpi_common.c`).
- **libc.** The module uses malloc/printf; stub the newlib syscalls (`--specs=nosys.specs`, the default on cm4, cm5 and zynq via `FIPS_NOSYS_SPECS`) and provide a bounded `_sbrk` so the heap cannot grow into the unverified image (`hal/rpi_common.c`, `hal/zynq.c`). Use a bare-metal toolchain (`aarch64-none-elf-`); with a glibc cross compiler the module's `printf` does not link to anything at run time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we internally provide _sbrk in our various port/startup code for the various platforms?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for cm4/cm5 (hal/rpi_common.c) and zynq (hal/zynq.c). Reworded in 8984102: wolfBoot provides it on those targets, and a new bare-metal FIPS target needs its own.

Comment thread docs/firmware_update.md Outdated

```c
int hal_get_security_version(uint32_t *svn); /* non-zero: unreadable, reject */
int hal_set_security_version(uint32_t svn); /* may only raise */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

micro nit: consider raise_security_version() or increase_security_version() so the "may only raise" clause is made obnoxiously clear in the name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8984102: hal_raise_security_version(). Since the revocation setter also only adds bits, it's now hal_revoke_keys().

Comment thread include/image.h Outdated
#ifdef DUALBANK_SWAP
#error "KEY_REVOCATION and SECURITY_VERSION are not supported with DUALBANK_SWAP"
#endif
#define WOLFBOOT_CONFIRMED_IMAGE_HOOKS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend changing the name, as wolfBoot already has a "hooks" feature, and this will cause confusion since it has nothing to do with that. Maybe something like WOLFBOOT_CONFIRMED_IMAGE_POLICY or WOLFBOOT_COMMIT_CONFIRMED (which matches the other macros you build off of it)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to WOLFBOOT_CONFIRMED_IMAGE_POLICY in 8984102, along with the unit-update-*-confirm-policy test targets.

Comment thread docs/firmware_update.md Outdated
The security version is separate from the firmware version and is carried in the signed `HDR_SECURITY_VERSION` (0x37) TLV:

```
./tools/keytools/sign --ecc384 --sha384 --custom-tlv 0x37 4 3 image.bin key.der 12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels janky for a "first class feature". IMO custom TLVs should be for users to implement their own custom extensions, but I think official features should not need to take advantage of them. Thoughts on just adding support to the sign tool?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Added --security-version <n> and --revoke-keys <mask> to the sign tool in 8984102. They write the 4-byte signed TLVs, take a value up to 32 bits, and refuse a second TLV with the same tag (option given twice, or alongside --custom-tlv). Documented in Signing.md; unit-sign-policy-tlv.py checks the bytes and the refusals, and the simulator scripts use the options (only the malformed-length cases still use --custom-tlv).

Comment thread docs/keystore.md Outdated
An image signed by a valid key revokes others with the signed `HDR_KEY_REVOKE` (0x36) TLV:

```
./tools/keytools/sign --ecc384 --sha384 --custom-tlv 0x36 4 0x1 image.bin key1.der 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as with the security version. IMO should not use custom TLVs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done in 8984102: sign --revoke-keys <mask> (see the security version thread for details). The docs use it now.

Comment thread src/update_flash.c
Comment on lines +43 to +48
/* A monolithic self-update replaces the application without committing its
* pending policy, and keeps BOOT's SUCCESS state for the new one */
#if defined(WOLFBOOT_SELF_UPDATE_MONOLITHIC) && \
defined(WOLFBOOT_CONFIRMED_IMAGE_HOOKS)
#error "KEY_REVOCATION and SECURITY_VERSION are not supported with SELF_UPDATE_MONOLITHIC"
#endif

@bigbrett bigbrett Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong in this file, but elsewhere I think we need the same check for disk boot without DISK_BOOT_CONFIRM and for RAM boot without partition trailers? In those cases, images never get marked confirmed so I think that means the floor and the revocation mask would never be written but also never print anything or warn the user? Maybe theres some way we could make this a runtime error too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Made it a build error in 8984102 rather than a runtime one, since the build already knows: update_disk.c refuses KEY_REVOCATION/SECURITY_VERSION without DISK_BOOT_CONFIRM, and update_ram.c refuses them without partition trailers (WOLFBOOT_FIXED_PARTITIONS or CUSTOM_PARTITION_TRAILER). Documented in firmware_update.md and keystore.md.

Comment thread docs/Targets.md
Comment on lines +3920 to +3924
SECURITY_VERSION=1
ZYNQMP_EFUSE_SVN_ROW=0 # first counter row
ZYNQMP_EFUSE_SVN_NROWS=6 # 6 rows = up to 192 security versions
KEY_REVOCATION=1
ZYNQMP_EFUSE_REVOKE_ROW=6 # one bit per keystore slot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also mention that SD-card boot would need DISK_BOOT_CONFIRM=1 too, for this snippet to work?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Added DISK_BOOT_CONFIRM=1 to the snippet in 8984102, and the build now refuses the combination without it (next thread).

@dgarske
dgarske force-pushed the secure_boot_upstream branch from 21efd36 to 8984102 Compare December 4, 2026 22:45
@dgarske
dgarske requested review from bigbrett and a balanced review from Copilot December 4, 2026 22:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A permitted partition configuration skips the pre-commit pass, allowing a newer unconfirmed image to boot without enforcing pending security floors or revocations.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/update_ram.c Resolved
Comment thread tools/keytools/sign.c Resolved
@dgarske
dgarske force-pushed the secure_boot_upstream branch from 8984102 to 9a4e75f Compare December 4, 2026 23:45
@dgarske
dgarske requested a balanced review from Copilot December 4, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Irreversible ZynqMP eFuse writes and FIPS boundary changes require specialist validation because fuse testing was report-only, a policy-met device was not exercised, and the exact FIPS bundle was unavailable for inspection.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants