Skip to content

PolarFire SoC: keep the golden image encrypted across a zeroize - #970

Draft
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:disk_golden_enckey
Draft

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

Conversation

@dgarske

@dgarske dgarske commented Nov 4, 2026

Copy link
Copy Markdown
Member

Description

A zeroize destroys the image encryption key, so until now the golden recovery image had to be stored in plaintext to stay bootable. That does not suit deployments whose data-at-rest requirement covers the recovery image too.

DISK_GOLDEN_ENCRYPT_KEY=1 gives the golden slot a key of its own, in a second sNVM module (default 202) that the failover never erases. The zeroize still destroys the operational key in module 201, so the operational images become undecryptable while the golden image stays encrypted at rest and bootable. Both keys are wrapped by the same device PUF KEK - the separation is only which module gets erased, so wolfBoot_erase_encrypt_key() is unchanged and the zeroize itself needs no new code.

The platform selects a slot's key with wolfBoot_select_golden_encrypt_key(). There is deliberately no default implementation: a target that cannot select a key fails to link rather than reading the golden image under the operational one. The option is off by default, and with it off the generated binary is unchanged.

For integrators: a golden bitstream that carries sNVM clients should carry module 202 only. Carrying module 201 as well restores the operational key when the bitstream is reapplied, which partially undoes the zeroize.

Testing

Host unit tests in tools/unit-tests/unit-update-disk-golden-enckey.c cover the golden image booting after the operational key is zeroized, the operational key being the only one erased, and two fail-closed cases: the golden key missing, and a golden image encrypted under the operational key. The existing disk-boot and failover suites are unchanged, and the PolarFire config matrix gains a row for the new option.

@dgarske dgarske self-assigned this Nov 4, 2026
Copilot AI balanced review requested due to automatic review settings November 4, 2026 00:08

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

Conflicting zeroize and provisioning guards make the documented golden-key provisioning build impossible.

4 open issues
What changed in this PR

This PR adds an optional, separate encryption key for the PolarFire SoC golden recovery image, allowing it to remain encrypted and bootable after the operational key is zeroized.

Changes:

  • Adds per-slot key selection and a separate sNVM module for the golden key.
  • Adds host tests for encrypted recovery and fail-closed behavior.
  • Documents configuration, provisioning, and bitstream requirements.
File Description
tools/​unit-tests/​unit-update-disk-golden-enckey.c Adds encrypted golden-slot boot and failure tests.
tools/​unit-tests/​Makefile Registers and builds the new test suite.
src/​update_disk.c Rekeys the disk cipher for the selected slot.
options.mk Adds the option and prerequisite checks.
include/​wolfboot/​wolfboot.h Declares the platform key-selection API.
hal/​mpfs250_snvm.h Defines and validates the golden-key module.
hal/​mpfs250_snvm.c Implements key selection and two-key provisioning.
docs/​PolarFire.md Documents encrypted recovery and provisioning constraints.
docs/​encrypted_partitions.md Links to the encrypted golden-image guidance.
config/​examples/​polarfire_mpfs250_m.config Adds a commented configuration example.

Review effort: Balanced

Comment thread options.mk
Comment on lines +204 to +207
ifneq ($(DISK_GOLDEN_SLOT)$(SNVM_KEK)$(DISK_FAILOVER_ZEROIZE),111)
$(error DISK_GOLDEN_ENCRYPT_KEY=1 requires DISK_GOLDEN_SLOT=1, SNVM_KEK=1 \
and DISK_FAILOVER_ZEROIZE=1: a second key exists so the zeroize can \
destroy one and leave the other)
Comment thread hal/mpfs250_snvm.c
Comment on lines +431 to +432
snvm_enckey_module = golden ? SNVM_GOLDEN_ENCKEY_MODULE :
SNVM_ENCKEY_MODULE;
Comment thread options.mk
and DISK_FAILOVER_ZEROIZE=1: a second key exists so the zeroize can \
destroy one and leave the other)
endif
CFLAGS+=-D"DISK_GOLDEN_ENCRYPT_KEY"
Comment on lines +212 to +213
mock_cur_key = mock_pending_key;
memset(key, mock_cur_key, ENCRYPT_KEY_SIZE);
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.

2 participants