Add STM33TPM Firmware Update Support for LMS/non-LMS #446
+1,783
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds comprehensive firmware update support for STMicroelectronics ST33KTPM2X TPM modules, including both legacy non-LMS and modern LMS (Leighton-Micali Signature) signature formats.
Overview
The implementation supports firmware updates for ST33 TPMs across two firmware generations:
Main Functions Created
Core API Functions
wolfTPM2_FirmwareUpgradeHash()- Main firmware upgrade functionwolfTPM2_FirmwareUpgradeWithLMS()- LMS signature pathwolfTPM2_FirmwareUpgradeCancel()- Cancel/abandon firmware updateHelper Functions
tpm2_st33_firmware_start()- Non-LMS firmware upgrade starttpm2_st33_firmware_start_lms()- LMS firmware upgrade starttpm2_st33_firmware_upgrade_hash()- Version detection and routing logictpm2_st33_firmware_send_blob()- Send firmware blob chunks to TPMKey Implementation Details
Firmware Version Detection
The implementation uses a simplified two-state model matching ST's reference tools:
Version threshold is
512 (0x0200), matching ST's policy where 9.512 is the first firmware version that mandates LMS signatures.Testing
All functionality was tested on real ST33KTPM2X hardware:
Tested firmware update and all examples with LMS and non-LMS and confirmed update to LMS version
Added test script (
examples/firmware/test_st33_firmware.sh) with selective testing via--lmsand--no-lmsflags..github/workflows/cmake-build.ymlwith--enable-firmware.github/workflows/make-test-swtpm.ymlwith--enable-firmware