Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,15 @@ jobs:
config-file: ./config/examples/sim-fips.config
fips: true

# ARMv8 asm inside the FIPS boundary, with AES-256 image encryption.
zynqmp_fips_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/zynqmp_sdcard.config
make-args: wolfboot.bin FIPS=1 SIGN=ECC384 HASH=SHA384 ENCRYPT=1 ENCRYPT_WITH_AES256=1 WOLFBOOT_LIB_WOLFSSL=../wolfssl-5.9.2-gplv3-fips-ready
fips: true

tegra234_sdcard_fs_test:
uses: ./.github/workflows/test-build.yml
with:
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/test-key-revocation-simulator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Key revocation and security version - test with simulator target

on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

jobs:
revocation_svn_simulator_tests:
strategy:
fail-fast: false
matrix:
include:
- name: key-revocation
options: KEY_REVOCATION=1
scripts: sim-key-revocation.sh
- name: security-version
options: SECURITY_VERSION=1
scripts: sim-security-version.sh
- name: both
options: KEY_REVOCATION=1 SECURITY_VERSION=1
scripts: sim-security-version.sh sim-key-revocation.sh
- name: both-production
options: KEY_REVOCATION=1 SECURITY_VERSION=1 WOLFBOOT_PRODUCTION=1
scripts: sim-security-version.sh sim-key-revocation.sh
name: ${{ matrix.name }}
runs-on: ubuntu-latest
container:
image: ghcr.io/wolfssl/wolfboot-ci-sim:v1.0
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Trust workspace
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Select config
run: |
make distclean
cp config/examples/sim.config .config
for opt in ${{ matrix.options }}; do echo "$opt" >> .config; done

- name: Build tools
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Build wolfboot.elf and test-app/image.elf
run: |
make test-sim-internal-flash-with-update

- name: Run simulator tests
run: |
for s in ${{ matrix.scripts }}; do tools/scripts/$s || exit 1; done

revocation_svn_tpm_nv_tests:
name: tpm-nv
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
with:
repository: kgoldman/ibmswtpm2
ref: ad169862f25060f6d83ef3018be7dbdc9bf4e266
path: ibmswtpm2
- name: ibmswtpm2 make
working-directory: ./ibmswtpm2/src
run: |
make
./tpm_server &

- uses: actions/checkout@v4
with:
submodules: true

- name: Select config
run: |
make distclean
cp config/examples/sim-tpm.config .config
for opt in KEY_REVOCATION=1 SECURITY_VERSION=1 WOLFBOOT_TPM_POLICY_NV=1; do echo "$opt" >> .config; done
Comment thread
dgarske marked this conversation as resolved.
Resolved

- name: Build tools
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Build wolfboot.elf and test-app/image.elf
run: |
make test-sim-internal-flash-with-update

- name: Build TPM tools
run: |
make tpmtools

- name: Run simulator tests
run: |
for s in sim-security-version.sh sim-key-revocation.sh; do tools/scripts/$s || exit 1; done
2 changes: 1 addition & 1 deletion .github/workflows/test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/wolfssl/wolfboot-ci-sim:v1.0
timeout-minutes: 15
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ tools/tpm/pcr_reset
tools/tpm/pcr_extend
tools/tpm/policy_create
tools/tpm/policy_sign
tools/tpm/policy_nv
config/*.ld
config/*.sct
test-lib
Expand Down Expand Up @@ -649,6 +650,7 @@ tools/unit-tests/imx8qm_flexspi_extract.h
tools/unit-tests/unit-ct-compare
tools/unit-tests/unit-zynqmp-bbram-crc
tools/unit-tests/unit-zynqmp-efuse-guards
tools/unit-tests/unit-zynqmp-efuse-counter
tools/unit-tests/unit-zynqmp-efuse-burn
tools/unit-tests/unit-fit-gzip-small
tools/unit-tests/unit-gzip-bits32
Expand Down Expand Up @@ -710,12 +712,17 @@ tools/unit-tests/unit-ti-hercules-erase
tools/unit-tests/unit-update-disk-fsp
tools/unit-tests/unit-update-ram-custom-trailer
tools/unit-tests/unit-update-ram-rollback-unconfirmed
tools/unit-tests/unit-update-ram-confirm-policy
tools/unit-tests/unit-update-disk-confirm-policy
tools/unit-tests/unit-update-ram-nofixed-noramboot
tools/unit-tests/unit-update-trigger-scrub
tools/unit-tests/unit-x86-uart
# sources generated by the unit-test extraction rules
tools/unit-tests/bbram_crc_extract.h
tools/unit-tests/efuse_guards_extract.h
tools/unit-tests/efuse_counter_extract.h
tools/unit-tests/sec_bl33_extract.h
tools/unit-tests/sec_bl33_burn_extract.h
tools/unit-tests/stm32g0_write_extract.h
tools/unit-tests/ct_compare_extract.h
tools/unit-tests/puf_extract.h
Expand Down
42 changes: 42 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ ifeq ($(ARCH),AARCH64)
ifeq ($(TARGET),zynq)
ARCH_FLAGS=-march=armv8-a+crypto
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A53
# User eFuse rows (USER_0..USER_7 index) for the security version counter
# and the key revocation mask. No default: the allocation is a
# provisioning decision.
ifeq ($(SECURITY_VERSION),1)
ifeq ($(ZYNQMP_EFUSE_SVN_ROW),)
$(error SECURITY_VERSION=1 on zynq needs ZYNQMP_EFUSE_SVN_ROW)
endif
ifeq ($(ZYNQMP_EFUSE_SVN_NROWS),)
$(error SECURITY_VERSION=1 on zynq needs ZYNQMP_EFUSE_SVN_NROWS)
endif
CFLAGS+=-DZYNQMP_EFUSE_SVN_ROW=$(ZYNQMP_EFUSE_SVN_ROW)
CFLAGS+=-DZYNQMP_EFUSE_SVN_NROWS=$(ZYNQMP_EFUSE_SVN_NROWS)
endif
ifeq ($(KEY_REVOCATION),1)
ifeq ($(ZYNQMP_EFUSE_REVOKE_ROW),)
$(error KEY_REVOCATION=1 on zynq needs ZYNQMP_EFUSE_REVOKE_ROW)
endif
CFLAGS+=-DZYNQMP_EFUSE_REVOKE_ROW=$(ZYNQMP_EFUSE_REVOKE_ROW)
endif
CFLAGS+=-DNO_QNX
# Support detection and skip of U-Boot legacy header */
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
Expand Down Expand Up @@ -182,6 +201,29 @@ ifeq ($(ARCH),AARCH64)
endif
endif
endif
# As BL33 the user eFuse writes go through the PMU firmware; the same
# opt-in arms them, otherwise they are report-only.
ifneq ($(ZYNQMP_FSBL),1)
ifeq ($(ZYNQMP_EFUSE_BURN),1)
CFLAGS+=-DZYNQMP_EFUSE_BURN
endif
endif
# eFuse security state (SEC_CTRL, PUF, PPK0 hash): read directly as the
# FSBL, through the PMU firmware as BL33.
ifeq ($(ZYNQMP_SEC),1)
CFLAGS+=-DWOLFBOOT_ZYNQMP_SEC_STATE
endif
# SEC_CTRL bits a deployed part must have. A WOLFBOOT_PRODUCTION build
# refuses a part without them; any other build boots it and reports it.
ifneq ($(ZYNQMP_SEC_POLICY),)
ifneq ($(ZYNQMP_SEC),1)
$(error ZYNQMP_SEC_POLICY needs ZYNQMP_SEC=1)
endif
ifneq ($(filter 0 0x0 0x00 0x00000000,$(ZYNQMP_SEC_POLICY)),)
$(error ZYNQMP_SEC_POLICY=0 would refuse every part; leave it unset for no policy)
endif
CFLAGS+=-DZYNQMP_SEC_POLICY=$(ZYNQMP_SEC_POLICY)
endif

endif

Expand Down
8 changes: 8 additions & 0 deletions config/examples/nai_68int6.config
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ DISK_ERASE=0
# Anti-rollback: persistent version floor + audit counters in TPM NV
# (trust-on-first-use; provision before first boot where that matters).
ANTI_ROLLBACK=1

# Signing key revocation and a security version floor in TPM NV bit-field
# indices. They are committed only for a confirmed image, so the OS must
# confirm each boot (DISK_BOOT_CONFIRM). Not yet run on this board.
#DISK_BOOT_CONFIRM=1
#KEY_REVOCATION=1
#SECURITY_VERSION=1
#WOLFBOOT_TPM_POLICY_NV=1
3 changes: 2 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ For verification failures, the cause distinguishes a bad header
(`WOLFBOOT_FAILURE_CAUSE_HEADER`), a failed integrity/hash check
(`WOLFBOOT_FAILURE_CAUSE_HASH`) and a failed signature/authenticity check
(`WOLFBOOT_FAILURE_CAUSE_SIGNATURE`). A rollback uses
`WOLFBOOT_FAILURE_CAUSE_NOT_CONFIRMED`.
`WOLFBOOT_FAILURE_CAUSE_NOT_CONFIRMED`. The ZynqMP `ZYNQMP_SEC_POLICY` check
uses `WOLFBOOT_FAILURE_CAUSE_POLICY`.

The application can read the records, ordered newest-first, through this API:

Expand Down
14 changes: 11 additions & 3 deletions docs/FIPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,22 @@ Production use requires the licensed, validated FIPS bundle. Unpack it and point
The `FIPS=1` build option (`options.mk`) rebuilds the wolfcrypt object list as the validated module boundary in link order (`wolfcrypt_first.o` first, `wolfcrypt_last.o` last, with `fips.o`/`fips_test.o` and the boundary crypto between them - the in-core integrity hash on GCC/ELF is enforced by this link order). Point the build at the FIPS tree and select an approved algorithm pair:

```
cp config/examples/sim-fips.config .config # or cm4.config / cm5.config
cp config/examples/sim-fips.config .config # or cm4.config / cm5.config / zynqmp_sdcard.config
make FIPS=1 WOLFBOOT_LIB_WOLFSSL=/path/to/wolfssl-5.9.2-gplv3-fips-ready \
SIGN=ECC384 HASH=SHA384 SPMATH=1
```

On AArch64 the module's ARMv8 assembly (`cpuid.o`, `port/arm/armv8-*-asm_c.o`, `sp_arm64.o`) is linked inside the boundary unless `NO_ARM_ASM=1`. Its SP ECC tables add about 570 KB, so the CM4 builds the portable-C module. 32-bit ARM always does.

`ENCRYPT=1` works with `ENCRYPT_WITH_AES128` or `ENCRYPT_WITH_AES256`, using the module's AES. ChaCha20 and `ENCRYPT_PKCS11` are refused.

FIPS builds keep P-256 compiled in for the module's ECDH self-test, whatever curve signs the images.

`-DHAVE_FIPS` is added by the `FIPS=1` block. `FIPS=1` also defaults `FIPS_READY=1`, which defines `WOLFSSL_FIPS_READY` (`include/user_settings.h`); that macro forces the evaluation bundle's `HAVE_FIPS_VERSION` to 7 and selects the FIPS-186-4 gating in `settings.h`. `FIPS_READY=1` (the default) builds the evaluation FIPS-ready bundle. A production build with the licensed **validated** bundle (not a FIPS-ready drop) must pass both `FIPS_READY=0` and `FIPS_VERSION=<n>` (for example `FIPS_VERSION=7` for a 140-3 module), which `options.mk` turns into `-DHAVE_FIPS_VERSION=<n>` to pin the module version. This is required because under wolfBoot's `-DWOLFSSL_USER_SETTINGS` build `settings.h` includes only `user_settings.h` and never the configure-generated `wolfssl/options.h`, so the validated bundle does not self-declare `HAVE_FIPS_VERSION`; without it the module would silently build as FIPS v1 (140-2). `options.mk` therefore errors if `FIPS_READY=0` is passed without `FIPS_VERSION`. The `HAVE_FIPS` block in `include/user_settings.h` also enables the module's algorithm set, keeps the RNG/DRBG enabled, and wires the entropy seed (below).

## Entropy source (required)

The FIPS DRBG needs a seed. wolfBoot's lean configuration compiles out the OS seed paths, so a seed is provided via `CUSTOM_RAND_GENERATE_SEED` (the `HAVE_FIPS` block in `include/user_settings.h` keeps the RNG enabled by undoing wolfBoot's `WC_NO_RNG`/`WC_NO_HASHDRBG`). The example wiring points it at `wolfBoot_fips_seed()`, implemented per target: `/dev/urandom` on the simulator (`hal/sim.c`) and the BCM2711 RNG200 hardware TRNG on the CM4 (`hal/rpi_common.c`). Without a working seed, the ECDSA power-on self-test (which performs a sign) fails with `ECDSA_KAT_FIPS_E` because `wc_GenerateSeed()` returns `NOT_COMPILED_IN`.
The FIPS DRBG needs a seed. wolfBoot's lean configuration compiles out the OS seed paths, so a seed is provided via `CUSTOM_RAND_GENERATE_SEED` (the `HAVE_FIPS` block in `include/user_settings.h` keeps the RNG enabled by undoing wolfBoot's `WC_NO_RNG`/`WC_NO_HASHDRBG`). The example wiring points it at `wolfBoot_fips_seed()`, implemented per target: `/dev/urandom` on the simulator (`hal/sim.c`), the BCM2711 RNG200 hardware TRNG on the CM4 (`hal/rpi_common.c`), and the module's CPU-jitter entropy source on ZynqMP, which has no TRNG (`hal/zynq.c`, `FIPS_ENTROPY_MEMUSE=1` by default for `TARGET=zynq`). A jitter seed takes a few hundred milliseconds on a Cortex-A53, paid in the first signature verification. Without a working seed, the ECDSA power-on self-test (which performs a sign) fails with `ECDSA_KAT_FIPS_E` because `wc_GenerateSeed()` returns `NOT_COMPILED_IN`.

## Sealing the in-core integrity hash

Expand All @@ -74,7 +80,9 @@ The FIPS module targets a hosted environment; a few things must be provided on b

- **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 give the module a bounded `_sbrk` so the heap cannot grow into the unverified image. wolfBoot provides one on cm4/cm5 (`hal/rpi_common.c`) and zynq (`hal/zynq.c`); a new bare-metal FIPS target needs its own. 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.

`WOLFBOOT_SELF_HEADER=1` is not supported with `FIPS=1` on AArch64.

Bring the module up on the simulator (`config/examples/sim-fips.config`) first - it exercises the whole flow (module boundary, POST, in-core seal, verify, A/B update) with no hardware.

Expand Down
10 changes: 10 additions & 0 deletions docs/Signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,16 @@ Provides a value to be set with a custom tag
altered without breaking the image signature. Example:
`--cmdline "root=/dev/mmcblk0p2 rw rootwait console=ttyTCU0,115200"`.

* `--security-version n`: Sets the image security version, the 4-byte signed TLV
`HDR_SECURITY_VERSION` (0x37) checked against the floor with `SECURITY_VERSION=1`
(see [firmware_update.md](firmware_update.md#security-version-floor)).

* `--revoke-keys mask`: Sets the key revocation mask, the 4-byte signed TLV
`HDR_KEY_REVOKE` (0x36), one bit per keystore slot, applied with `KEY_REVOCATION=1`
(see [keystore.md](keystore.md#key-revocation)).

Both take a decimal or `0x` hex value up to 32 bits and may each be given once per image.

* `--dts filename`: Binds a raw (non-FIT) device tree blob to the firmware image. The sign
tool hashes exactly the first `totalsize` bytes of the `.dtb`, per that header field (validating the FDT magic
and version the same way the bootloader does) with the image hash algorithm and stores the
Expand Down
1 change: 1 addition & 0 deletions docs/TPM.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ In wolfBoot we support TPM based root of trust, sealing/unsealing, cryptographic
| `WOLFBOOT_TPM_SEAL=1` | `WOLFBOOT_TPM_SEAL` | Enables support for sealing/unsealing based on PCR policy signed externally. |
| `WOLFBOOT_TPM_SEAL_NV_BASE=0x01400300` | `WOLFBOOT_TPM_SEAL_NV_BASE` | To override the default sealed blob storage location in the platform hierarchy. |
| `WOLFBOOT_TPM_SEAL_AUTH=secret` | `WOLFBOOT_TPM_SEAL_AUTH` | Password for sealing/unsealing secrets, if omitted the PCR policy will be used |
| `WOLFBOOT_TPM_POLICY_NV=1` | `WOLFBOOT_TPM_POLICY_NV` | Keeps the `KEY_REVOCATION` mask and the `SECURITY_VERSION` floor in TPM NV bit-field indices (`WOLFBOOT_TPM_REVOKE_NV_INDEX`, default 0x01400401, and `WOLFBOOT_TPM_SVN_NV_INDEX`, default 0x01400402). See [docs/keystore.md](/docs/keystore.md#key-revocation). |
| `WOLFBOOT_TPM_MFG_AUTH_DERIVE=1` | `WOLFBOOT_TPM_MFG_AUTH_DERIVE` | MFG identity: opt into on-device derive-from-master. The default is a precomputed per-device authValue (no master secret on device). Requires `WOLFTPM_MFG_IDENTITY`. |
| (header macro) | `WOLFBOOT_TPM_MFG_AIK_AUTH` / `WOLFBOOT_TPM_MFG_EH_AUTH` | Default (precomputed) mode: the 16-byte per-device AIK / EH authValues (placeholder `0xFF` default). |
| (header macro) | `WOLFBOOT_TPM_MFG_EH_MASTER` | Derive mode: override the endorsement-hierarchy master value (16-byte initializer list, sample default). |
Expand Down
Loading
Loading