Skip to content

Commit 0b50f63

Browse files
committed
Add stm33ktpm support LMS and non-LMS
1 parent 6898e84 commit 0b50f63

File tree

14 files changed

+1180
-47
lines changed

14 files changed

+1180
-47
lines changed

.github/workflows/cmake-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
options: "-DWOLFTPM_INTERFACE=SPI -DWOLFTPM_MODULE=st33"
2323
- name: "Module ST33 I2C"
2424
options: "-DWOLFTPM_INTERFACE=I2C -DWOLFTPM_MODULE=st33"
25+
# ST33 Firmware
26+
- name: "Module ST33 Firmware"
27+
options: "-DWOLFTPM_MODULE=st33 -DWOLFTPM_FIRMWARE=yes"
2528
# Other modules use SPI
2629
- name: "Module Microchip"
2730
options: "-DWOLFTPM_INTERFACE=SPI -DWOLFTPM_MODULE=microchip"

.github/workflows/make-test-swtpm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
# STMicro ST33KTPM2
6767
- name: st33ktpm2
6868
wolftpm_config: --enable-st33
69+
# STMicro ST33KTPM2
70+
- name: st33ktpm2 firmware
71+
wolftpm_config: --enable-st33 --enable-firmware
6972
# Microchip
7073
- name: microchip
7174
wolftpm_config: --enable-microchip

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ examples/boot/secret_seal
8484
examples/boot/secret_unseal
8585
examples/firmware/ifx_fw_extract
8686
examples/firmware/ifx_fw_update
87+
examples/firmware/st33_fw_update
8788
examples/endorsement/get_ek_certs
8889
examples/endorsement/verify_ek_cert
8990

@@ -151,6 +152,10 @@ UpgradeLog.htm
151152
*.VC.db
152153
*.filters
153154

155+
# macOS files
156+
._.DS_Store
157+
.DS_Store
158+
154159
# Backup and old files
155160
/**/*.bak
156161
/**/*.old
@@ -170,3 +175,11 @@ UpgradeLog.htm
170175
# we won't track the actual working sdkconfig files
171176
/IDE/Espressif/**/sdkconfig
172177
/IDE/Espressif/**/sdkconfig.old
178+
179+
# Firmware files
180+
examples/firmware/*.fi
181+
examples/firmware/*.BIN
182+
examples/firmware/*.DATA
183+
examples/firmware/*.MANIFEST
184+
examples/firmware/*.MANIFESTHASH
185+

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ make install
189189
--enable-checkwaitstate Enable TIS / SPI Check Wait State support (default: depends on chip) - WOLFTPM_CHECK_WAIT_STATE
190190
--enable-smallstack Enable options to reduce stack usage
191191
--enable-tislock Enable Linux Named Semaphore for locking access to SPI device for concurrent access between processes - WOLFTPM_TIS_LOCK
192+
--enable-firmware Enable firmware upgrade support for Infineon SLB9672/SLB9673 and ST ST33 (default: disabled) - WOLFTPM_FIRMWARE_UPGRADE
192193
193194
--enable-autodetect Enable Runtime Module Detection (default: enable - when no module specified) - WOLFTPM_AUTODETECT
194195
--enable-infineon Enable Infineon SLB9670/SLB9672/SLB9673 TPM Support (default: disabled) - WOLFTPM_SLB9670 / WOLFTPM_SLB9672
@@ -234,10 +235,12 @@ Build wolfTPM:
234235

235236
```bash
236237
./autogen.sh
237-
./configure --enable-st33 [--enable-i2c]
238+
./configure --enable-st33 [--enable-i2c] [--enable-firmware]
238239
make
239240
```
240241

242+
Note: The `--enable-firmware` option enables firmware upgrade support for ST33 TPMs. This adds the `st33_fw_update` example tool for performing firmware updates.
243+
241244
### Building Microchip ATTPM20
242245

243246
Build wolfTPM:
@@ -903,6 +906,34 @@ Connection: close
903906
</html>
904907
```
905908

909+
### ST33 Firmware Update Example
910+
911+
The firmware update example allows updating firmware on STMicro ST33 TPMs. Build with `--enable-st33 --enable-firmware` to enable this example.
912+
913+
LMS (Leighton-Micali Signature) support is based on firmware version:
914+
- **Firmware < 512**: Legacy firmware - Non-LMS format required
915+
- **Firmware >= 512**: Modern firmware - LMS format required
916+
917+
```bash
918+
# Display firmware information
919+
./examples/firmware/st33_fw_update
920+
921+
# Cancel any in-progress firmware update
922+
./examples/firmware/st33_fw_update --abandon
923+
924+
# Perform firmware update (format auto-detected from TPM firmware version)
925+
./examples/firmware/st33_fw_update <firmware.fi>
926+
```
927+
928+
Example output:
929+
```
930+
ST33 Firmware Update Tool
931+
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.512 (0x0)
932+
Firmware version details: Major=9, Minor=512, Vendor=0x0
933+
Hardware: ST33K (modern firmware, Generation 2)
934+
Firmware update: LMS format required
935+
```
936+
906937
## Device Identity and Attestation Keys
907938

908939
The TCG published a specification for TPM manufacture guidance on setting up keys that can be used for device identiy and attestation.

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_WOLFCRYPT" = "xyes"])
482482
AM_CONDITIONAL([BUILD_I2C], [test "x$ENABLED_I2C" = "xyes"])
483483
AM_CONDITIONAL([BUILD_ADVIO], [test "x$ENABLED_ADVIO" = "xyes"])
484484
AM_CONDITIONAL([BUILD_ST], [test "x$ENABLED_ST" = "xyes"])
485+
AM_CONDITIONAL([BUILD_ST33], [test "x$ENABLED_ST33" = "xyes"])
485486
AM_CONDITIONAL([BUILD_MICROCHIP], [test "x$ENABLED_MICROCHIP" = "xyes"])
486487
AM_CONDITIONAL([BUILD_INFINEON], [test "x$ENABLED_INFINEON" != "xno"])
487488
AM_CONDITIONAL([BUILD_DEVTPM], [test "x$ENABLED_DEVTPM" = "xyes"])

examples/firmware/README.md

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# TPM Firmware Update Support
22

3-
Currently wolfTPM supports firmware update capability for the Infineon SLB9672 (SPI) and SLB9673 (I2C) TPM 2.0 modules. Infineon has open sourced their firmware update.
3+
Currently wolfTPM supports firmware update capability for:
4+
- Infineon SLB9672 (SPI) and SLB9673 (I2C) TPM 2.0 modules. Infineon has open sourced their firmware update.
5+
- STMicroelectronics ST33KTPM TPM 2.0 modules. Support includes both Generation 1 firmware versions (< 512, without LMS signature) and Generation 2 firmware versions (>= 512, with LMS signature requirement).
46

57
## Infineon Firmware
68

@@ -102,3 +104,98 @@ Mfg IFX (1), Vendor SLB9673, Fw 26.13 (0x456a)
102104
Operational mode: Normal TPM operational mode (0x0)
103105
KeyGroupId 0x7, FwCounter 1253 (254 same)
104106
```
107+
108+
## ST33 Firmware Update
109+
110+
### Firmware Format Auto-Detection
111+
112+
ST33KTPM firmware update automatically detects the required format based on TPM firmware version:
113+
114+
- **Legacy firmware (< 512, e.g., 9.257)**: Non-LMS format
115+
- Manifest size: 177 bytes
116+
- Generation 1 firmware (ECC-only)
117+
118+
- **Modern firmware (>= 512, e.g., 9.512)**: LMS format
119+
- Manifest size: 2697 bytes (includes embedded LMS signature)
120+
- Generation 2 firmware (LMS mandatory)
121+
122+
The firmware version is automatically detected from `fwVerMinor` in TPM capabilities. The correct manifest size is determined automatically - no manual format selection is needed.
123+
124+
### Updating the firmware
125+
126+
The `st33_fw_update` tool automatically detects the firmware format.
127+
128+
```sh
129+
# Help
130+
./st33_fw_update --help
131+
ST33 Firmware Update Usage:
132+
./st33_fw_update (get info)
133+
./st33_fw_update --abandon (cancel)
134+
./st33_fw_update <firmware.fi>
135+
136+
Firmware format is auto-detected from TPM firmware version:
137+
- Firmware < 512: Non-LMS format (177 byte manifest)
138+
- Firmware >= 512: LMS format (2697 byte manifest with embedded signature)
139+
140+
# Run without arguments to display the current firmware information
141+
./st33_fw_update
142+
ST33 Firmware Update Tool
143+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
144+
TPM2_Startup pass
145+
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
146+
Firmware version details: Major=9, Minor=257, Vendor=0x0
147+
Hardware: ST33K (legacy firmware, Generation 1)
148+
Firmware update: Non-LMS format required
149+
150+
# Run with firmware file (format auto-detected from TPM version)
151+
./st33_fw_update TPM_ST33KTPM2X_00090200_V1.fi
152+
ST33 Firmware Update Tool
153+
Firmware File: TPM_ST33KTPM2X_00090200_V1.fi
154+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
155+
TPM2_Startup pass
156+
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
157+
Firmware version details: Major=9, Minor=257, Vendor=0x0
158+
Hardware: ST33K (legacy firmware, Generation 1)
159+
Firmware update: Non-LMS format required
160+
Format: Non-LMS (from TPM firmware version)
161+
Firmware Update:
162+
Total file size: 364290 bytes
163+
Manifest (blob0): 177 bytes
164+
Firmware data: 364113 bytes
165+
...
166+
Firmware update completed successfully.
167+
Please reset or power cycle the TPM.
168+
169+
# Example with LMS firmware (Generation 2 TPM, firmware >= 512)
170+
./st33_fw_update ST33KTPM2X_FAC_00090200_V2.fi
171+
ST33 Firmware Update Tool
172+
Firmware File: ST33KTPM2X_FAC_00090200_V2.fi
173+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 3
174+
TPM2_Startup pass
175+
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.512 (0x0)
176+
Firmware version details: Major=9, Minor=512, Vendor=0x0
177+
Hardware: ST33K (modern firmware, Generation 2)
178+
Firmware update: LMS format required
179+
Format: LMS (from TPM firmware version)
180+
Firmware Update:
181+
Total file size: 360092 bytes
182+
Manifest (blob0): 2697 bytes
183+
Firmware data: 357395 bytes
184+
...
185+
Firmware update completed successfully.
186+
Please reset or power cycle the TPM.
187+
188+
# Cancel an ongoing firmware update
189+
./st33_fw_update --abandon
190+
ST33 Firmware Update Tool
191+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
192+
TPM2_Startup pass
193+
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
194+
Firmware version details: Major=9, Minor=257, Vendor=0x0
195+
Hardware: ST33K (legacy firmware, Generation 1)
196+
Firmware update: Non-LMS format required
197+
Firmware Update Abandon:
198+
Success: Please reset or power cycle TPM
199+
```
200+
201+
**Note**: Firmware files cannot be made public and must be obtained separately from STMicroelectronics.

examples/firmware/include.am

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ EXTRA_DIST += examples/firmware/Makefile
88
EXTRA_DIST += examples/firmware/ifx_fw_extract.c
99

1010
if BUILD_EXAMPLES
11+
if BUILD_FIRMWARE
12+
1113
if BUILD_INFINEON
1214
noinst_PROGRAMS += examples/firmware/ifx_fw_update
1315
noinst_HEADERS += examples/firmware/ifx_fw_update.h
@@ -16,9 +18,21 @@ examples_firmware_ifx_fw_update_SOURCES = examples/firmware/ifx_fw_update.c
1618
examples_firmware_ifx_fw_update_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
1719
examples_firmware_ifx_fw_update_DEPENDENCIES = src/libwolftpm.la
1820
endif
21+
22+
if BUILD_ST33
23+
noinst_PROGRAMS += examples/firmware/st33_fw_update
24+
examples_firmware_st33_fw_update_SOURCES = examples/firmware/st33_fw_update.c \
25+
examples/tpm_test_keys.c
26+
examples_firmware_st33_fw_update_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
27+
examples_firmware_st33_fw_update_DEPENDENCIES = src/libwolftpm.la
28+
29+
endif
30+
endif
1931
endif
2032

2133
example_firmwaredir = $(exampledir)/firmware
22-
dist_example_firmware_DATA = examples/firmware/ifx_fw_update.c
34+
dist_example_firmware_DATA = examples/firmware/ifx_fw_update.c \
35+
examples/firmware/st33_fw_update.c
2336

24-
DISTCLEANFILES+= examples/firmware/.libs/ifx_fw_update
37+
DISTCLEANFILES+= examples/firmware/.libs/ifx_fw_update \
38+
examples/firmware/.libs/st33_fw_update

0 commit comments

Comments
 (0)