-
Notifications
You must be signed in to change notification settings - Fork 74
Add STM33TPM Firmware Update Support for LMS/non-LMS #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aidangarske
wants to merge
8
commits into
wolfSSL:master
Choose a base branch
from
aidangarske:stm33KTPM-support-clean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,380
−43
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add wolfTPM2_FirmwareUpgradeWithLMS() for LMS signature path - Implement three-state LMS detection (UNSUPPORTED/CAPABLE/REQUIRED) - Send full manifest (blob0) in FieldUpgradeStart instead of hash - Parse and send firmware as blobs per ST reference implementation - Add --lms flag to st33_fw_update example for V2 firmware files - Handle TPM_RC_UPGRADE state for recovery/continuation - Remove unnecessary finalize command (ST33 doesn't use it) - Increase blob buffer size to handle 1075+ byte blobs - Add test script for ST33 firmware update verification Tested with ST33KTPM2X firmware 9.512 using LMS V2 format.
Corrected the firmware version threshold for LMS signature requirement from 915 to 512 (0x0200) to match ST's actual firmware policy. Version 9.512 is the first modern firmware (Generation 2) that requires LMS signatures, while firmware < 512 (e.g., 9.257) uses legacy non-LMS format (Generation 1). Changes: - Updated ST33_FW_VERSION_LMS_REQUIRED constant from 915 to 512 - Simplified two-state model: < 512 (legacy/non-LMS) vs >= 512 (modern/LMS) - Updated version detection logic throughout codebase - Updated help text and error messages to reflect 512 threshold - Updated documentation to clarify Generation 1 vs Generation 2 firmware - Enhanced test script with --lms and --no-lms flags for selective testing - Fixed error messages in test script to use correct flag names The cutoff at 512 matches ST's reference implementation which uses separate tools for Generation 1 (< 512) vs Generation 2 (>= 512) firmware. Tested on hardware with firmware 9.512, confirming LMS format is required and correctly enforced for modern firmware versions.
4827185 to
018e15f
Compare
- Gate wolfTPM2_FirmwareUpgrade and wolfTPM2_FirmwareUpgradeWithLMS
declarations with WOLFTPM2_NO_WOLFCRYPT (they use wc_Sha384Hash)
- Fix unit tests to only call wolfcrypt-dependent firmware functions
when wolfcrypt is enabled
- Add unused parameter suppressions in FirmwareUpgradeHashWithLMS
when ST33 is not enabled (fixes -Werror for SLB9672/SLB9673 builds)
018e15f to
1a7c490
Compare
3f6d189 to
be306c4
Compare
be306c4 to
7964756
Compare
dgarske
requested changes
Jan 26, 2026
| \sa wolfTPM2_FirmwareUpgradeHash | ||
| \sa wolfTPM2_FirmwareUpgradeWithLMS | ||
| */ | ||
| WOLFTPM_API int wolfTPM2_FirmwareUpgradeHashWithLMS(WOLFTPM2_DEV* dev, |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if you can do this using the existing API and detect at runtime. Unless the API's are not compatible.
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will do
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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