Harden crypto callback, ASN.1 parsing, param-enc and marshalling; add negative tests#551
Merged
Merged
Conversation
aidangarske
commented
Jul 13, 2026
Member
There was a problem hiding this comment.
Pull request overview
This PR hardens several security-sensitive paths in wolfTPM around parameter encryption hashing, TPM public-area marshalling, ASN.1 parsing, and the wolfCrypt crypto callback, and adds unit tests intended to lock in the new boundary/error handling.
Changes:
- Add new unit tests for param-encryption boundary conditions, response HMAC verification, ASN.1 error handling, crypto callback edge cases, and public marshal/parse round-trips.
- Scrub hash context stack state after cpHash/rpHash computation.
- Clamp several
TPM2B_*size fields during public-area marshalling and add an ECC verify guard against oversized DER R/S causing offset underflow.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit_tests.c | Adds new negative/boundary tests across param-enc, ResponseProcess HMAC, public marshalling, CryptoDevCb, and ASN.1 parsing. |
| src/tpm2_param_enc.c | Adds explicit stack zeroization of hash contexts after cpHash/rpHash calculation. |
| src/tpm2_packet.c | Clamps public-area authPolicy and several unique.* sizes before appending to packet. |
| src/tpm2_cryptocb.c | Rejects ECDSA verify signatures with R/S larger than key size to prevent pad-offset underflow. |
| src/tpm2_asn.c | Normalizes ASN header decode success return to 0 and updates callers accordingly. |
| src/fwtpm/fwtpm_crypto.c | Adds clarifying comments about ML-KEM secret length per FIPS 203 errata. |
embhorn
reviewed
Jul 13, 2026
embhorn
approved these changes
Jul 13, 2026
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.