Skip to content

Fix WOLFTPM_IS_COMMAND_UNAVAILABLE to handle vendor error code variants#553

Open
AmumuI wants to merge 1 commit into
wolfSSL:masterfrom
AmumuI:fix-command-unavailable-macro
Open

Fix WOLFTPM_IS_COMMAND_UNAVAILABLE to handle vendor error code variants#553
AmumuI wants to merge 1 commit into
wolfSSL:masterfrom
AmumuI:fix-command-unavailable-macro

Conversation

@AmumuI

@AmumuI AmumuI commented Jul 16, 2026

Copy link
Copy Markdown

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_UNAVAILABLE macro 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 0x1FF mask 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.

图片

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.
@dgarske dgarske self-assigned this Jul 20, 2026
@dgarske

dgarske commented Jul 20, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants