Skip to content

Commit cffa75d

Browse files
committed
Proper interface renaming + documentation
1 parent b26d38e commit cffa75d

19 files changed

Lines changed: 529 additions & 427 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ tools/unit-tests/unit-loader-tpm-init
186186
tools/unit-tests/unit-update-ram-nofixed
187187
tools/unit-tests/unit-max-space
188188
tools/unit-tests/unit-sdhci-disk-unaligned
189+
tools/unit-tests/unit-fwtpm-stub
189190

190191

191192

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x0C1A0000
3030
FLAGS_HOME=0
3131
DISABLE_BACKUP=0
3232
WOLFCRYPT_TZ=1
33-
WOLFCRYPT_TZ_FTPM=1
33+
WOLFCRYPT_TZ_FWTPM=1
3434
IMAGE_HEADER_SIZE?=1024
3535
ARMORED=1

docs/fwTPM.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# wolfBoot fwTPM on STM32H5
2+
3+
wolfBoot can host wolfTPM's firmware TPM 2.0 implementation in the secure
4+
TrustZone image and expose it to the non-secure application through the wolfBoot
5+
callable service interface. This lets the non-secure application use the normal
6+
wolfTPM client API while TPM commands are processed inside the secure world.
7+
8+
The feature is intended for STM32H5 TrustZone builds. The secure image contains
9+
the fwTPM command processor and the non-secure test application uses a small TIS
10+
shim that forwards commands through the NSC entry point.
11+
12+
## Configuration
13+
14+
Use these wolfBoot configuration options:
15+
16+
| Option | Effect |
17+
| ------ | ------ |
18+
| `TZEN=1` | Builds wolfBoot for TrustZone-enabled STM32H5 parts. |
19+
| `WOLFCRYPT_TZ=1` | Enables the wolfCrypt secure callable service layer. |
20+
| `WOLFCRYPT_TZ_FWTPM=1` | Enables the secure fwTPM service and non-secure fwTPM test support. |
21+
22+
`WOLFCRYPT_TZ_FWTPM=1` defines `WOLFBOOT_TZ_FWTPM` for the secure and
23+
non-secure builds. It also enables wolfTPM fwTPM sources, `WOLFTPM_FWTPM`,
24+
`FWTPM_NO_NV`, and the callable fwTPM object.
25+
26+
The ready-to-use STM32H5 configuration is:
27+
28+
```sh
29+
cp config/examples/stm32h5-tz-fwtpm.config .config
30+
```
31+
32+
## Build
33+
34+
Build wolfBoot and the signed STM32H5 test application from the repository root:
35+
36+
```sh
37+
cp config/examples/stm32h5-tz-fwtpm.config .config
38+
make clean
39+
make
40+
make test-app/image_v1_signed.bin
41+
```
42+
43+
The main outputs are:
44+
45+
| Output | Description |
46+
| ------ | ----------- |
47+
| `wolfboot.bin` | Secure wolfBoot image with the fwTPM service. |
48+
| `test-app/image_v1_signed.bin` | Signed non-secure STM32H5 test application. |
49+
| `test-app/image.elf` | Non-secure test application ELF for debugging. |
50+
51+
## Flash on STM32H5
52+
53+
Enable TrustZone and program the secure and non-secure images with
54+
STM32CubeProgrammer:
55+
56+
```sh
57+
STM32_Programmer_CLI -c port=swd mode=hotplug -ob TZEN=0xB4
58+
STM32_Programmer_CLI -c port=swd -d wolfboot.bin 0x0C000000
59+
STM32_Programmer_CLI -c port=swd -d test-app/image_v1_signed.bin 0x08060000
60+
```
61+
62+
The addresses above match `config/examples/stm32h5-tz-fwtpm.config`:
63+
64+
| Region | Address |
65+
| ------ | ------- |
66+
| Secure wolfBoot image | `0x0C000000` |
67+
| Non-secure boot partition | `0x08060000` |
68+
| Non-secure update partition | `0x0C100000` |
69+
| Swap partition | `0x0C1A0000` |
70+
| NSC veneer region | `0x0C05C000` |
71+
72+
## Test
73+
74+
Open the board serial console and run the fwTPM test command:
75+
76+
```text
77+
fwtpm
78+
```
79+
80+
The test application initializes wolfTPM using the non-secure TIS callback,
81+
queries capabilities, requests random bytes, extends PCR 0, verifies the PCR
82+
value, and seals/unseals a PCR-bound secret. A successful run ends with:
83+
84+
```text
85+
fwTPM NSC tests passed
86+
```
87+
88+
The STM32H5 test app also runs the same fwTPM test automatically during startup
89+
when built with `WOLFBOOT_TZ_FWTPM`.
90+
91+
## Notes
92+
93+
The current wolfBoot integration builds the secure fwTPM service with
94+
`FWTPM_NO_NV`, so TPM NV state is not persistent across resets. To add persistent
95+
NV storage, provide a flash-backed `FWTPM_NV_HAL` implementation and remove
96+
`FWTPM_NO_NV` from the fwTPM build flags.
97+
98+
`WOLFCRYPT_TZ_FWTPM` is mutually exclusive with `WOLFCRYPT_TZ_PKCS11` and
99+
`WOLFCRYPT_TZ_PSA` because each option selects a different TrustZone secure
100+
service surface for the test application.

include/user_settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ extern int tolower(int c);
434434
# define NO_CODING
435435
#endif
436436

437-
#if defined(WOLFBOOT_TPM) && !defined(WOLFBOOT_TZ_FTPM)
437+
#if defined(WOLFBOOT_TPM) && !defined(WOLFBOOT_TZ_FWTPM)
438438
/* Do not use heap */
439439
#define WOLFTPM2_NO_HEAP
440440
/* small stack options */
@@ -632,7 +632,7 @@ extern int tolower(int c);
632632
#undef NO_KDF
633633
#endif
634634

635-
#if defined(WOLFBOOT_TZ_FTPM)
635+
#if defined(WOLFBOOT_TZ_FWTPM)
636636
#undef NO_CMAC
637637
#undef NO_KDF
638638
#define WOLFSSL_AES_CFB

include/wolfboot/wcs_ftpm.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

include/wolfboot/wcs_fwtpm.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* wcs_fwtpm.h
2+
*
3+
* Copyright (C) 2026 wolfSSL Inc.
4+
*
5+
* This file is part of wolfBoot.
6+
*/
7+
8+
#ifndef WOLFBOOT_WCS_FWTPM_H
9+
#define WOLFBOOT_WCS_FWTPM_H
10+
11+
#include <stdint.h>
12+
#include "wolfboot/wc_secure.h"
13+
14+
#ifdef WOLFBOOT_TZ_FWTPM
15+
16+
#ifndef WCS_FWTPM_MAX_COMMAND_SIZE
17+
#define WCS_FWTPM_MAX_COMMAND_SIZE 4096U
18+
#endif
19+
20+
int CSME_NSE_API wcs_fwtpm_transmit(const uint8_t *cmd, uint32_t cmdSz,
21+
uint8_t *rsp, uint32_t *rspSz);
22+
23+
void wcs_fwtpm_init(void);
24+
25+
#endif /* WOLFBOOT_TZ_FWTPM */
26+
27+
#endif /* WOLFBOOT_WCS_FWTPM_H */

options.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -810,14 +810,14 @@ ifeq ($(WOLFCRYPT_TZ_PKCS11),1)
810810
ifeq ($(WOLFCRYPT_TZ_PSA),1)
811811
$(error WOLFCRYPT_TZ_PKCS11 and WOLFCRYPT_TZ_PSA are mutually exclusive)
812812
endif
813-
ifeq ($(WOLFCRYPT_TZ_FTPM),1)
814-
$(error WOLFCRYPT_TZ_PKCS11 and WOLFCRYPT_TZ_FTPM are mutually exclusive)
813+
ifeq ($(WOLFCRYPT_TZ_FWTPM),1)
814+
$(error WOLFCRYPT_TZ_PKCS11 and WOLFCRYPT_TZ_FWTPM are mutually exclusive)
815815
endif
816816
endif
817817

818818
ifeq ($(WOLFCRYPT_TZ_PSA),1)
819-
ifeq ($(WOLFCRYPT_TZ_FTPM),1)
820-
$(error WOLFCRYPT_TZ_PSA and WOLFCRYPT_TZ_FTPM are mutually exclusive)
819+
ifeq ($(WOLFCRYPT_TZ_FWTPM),1)
820+
$(error WOLFCRYPT_TZ_PSA and WOLFCRYPT_TZ_FWTPM are mutually exclusive)
821821
endif
822822
endif
823823

@@ -928,8 +928,8 @@ ifeq ($(WOLFCRYPT_TZ_PSA),1)
928928
endif
929929
endif
930930

931-
ifeq ($(WOLFCRYPT_TZ_FTPM),1)
932-
CFLAGS+=-DWOLFBOOT_TZ_FTPM
931+
ifeq ($(WOLFCRYPT_TZ_FWTPM),1)
932+
CFLAGS+=-DWOLFBOOT_TZ_FWTPM
933933
CFLAGS+=-DWOLFCRYPT_SECURE_MODE
934934
CFLAGS+=-DWOLFTPM_FWTPM
935935
CFLAGS+=-DFWTPM_NO_NV
@@ -945,7 +945,7 @@ ifeq ($(WOLFCRYPT_TZ_FTPM),1)
945945
LDFLAGS+=--specs=nano.specs
946946
endif
947947
WOLFCRYPT_OBJS+=src/store_sbrk.o
948-
WOLFCRYPT_OBJS+=src/ftpm_callable.o
948+
WOLFCRYPT_OBJS+=src/fwtpm_callable.o
949949
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFTPM)/src/fwtpm/fwtpm.o
950950
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFTPM)/src/fwtpm/fwtpm_command.o
951951
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFTPM)/src/fwtpm/fwtpm_crypto.o

0 commit comments

Comments
 (0)