Fix WOLFTPM_IS_COMMAND_UNAVAILABLE to handle vendor error code variants#553
Open
AmumuI wants to merge 1 commit into
Open
Fix WOLFTPM_IS_COMMAND_UNAVAILABLE to handle vendor error code variants#553AmumuI wants to merge 1 commit into
AmumuI wants to merge 1 commit into
Conversation
Some TPM chips (e.g. Nations NS350) return TPM_RC_COMMAND_CODE with additional bits set (0xb0143 instead of 0x143). The macro previously used exact equality, causing it to miss these variants and treat the error as fatal. Apply a 0x1FF mask to compare only the base VER1 error code, so vendor-extended responses are properly recognized.
Member
|
Hi @AmumuI , Thank you for this report! Can you tell us more about your use of wolfTPM and your project? If you'd like to keep it private you can email support at wolfssl dot com and mention this PR. Are you planning any additional pull requests? If not we may opt to treat this as a bug report and fix ourself since setting up the contributor agreement is not trivial. Thanks, David Garske, wolfSSL |
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
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.
Summary
Some TPM chips (e.g. Nations Technologies NS350) return TPM_RC_COMMAND_CODE

with additional vendor bits set (0xb0143 instead of the standard 0x143).
The
WOLFTPM_IS_COMMAND_UNAVAILABLEmacro previously used exact equality,causing it to fail to recognize these vendor-extended error codes. This
resulted in the bench program treating the error as fatal and aborting
before reaching SHA/RSA/ECC benchmarks.
Fix
Apply a
0x1FFmask to compare only the base VER1 error code bits,stripping any vendor-specific high bits. This matches the approach already
used elsewhere in the codebase (e.g.
(rc & TPM_RC_MODE) == TPM_RC_MODE).Verified
Tested on Nations Technologies NS350 TPM 2.0 module. After this fix, the
bench program correctly skips symmetric encryption tests and continues
to produce SHA, RSA, and ECC benchmark results.