Skip to content

Add new TPM2_ASN_GetNameAttr API and capture X.509 issuer and subject in TPM2_ASN_DecodeX509Cert - #646

Merged
aidangarske merged 1 commit into
wolfSSL:masterfrom
dgarske:asn_subject
Oct 23, 2026
Merged

aidangarske merged 1 commit into
wolfSSL:masterfrom
dgarske:asn_subject

Conversation

@dgarske

@dgarske dgarske commented Oct 22, 2026

Copy link
Copy Markdown
Member

Description

Lets callers read identity fields from an X.509 certificate stored in NV without wolfCrypt. Used by the U-Boot integration, which builds with WOLFTPM2_NO_WOLFCRYPT.

  • DecodedX509 gains issuer/issuerSz and subject/subjectSz, appended so existing members keep their offsets.
  • New TPM2_ASN_GetNameAttr() returns the first attribute with a given OID (for example commonName or serialNumber) from a Name, with every length bounds-checked.

Testing

New test_TPM2_ASN_GetNameAttr unit test. unit.test passes against fwTPM and ibmswtpm2, and the API is used by U-Boot tpm2 nv_read_cert on QEMU with swtpm. Not tested on hardware.

@dgarske dgarske self-assigned this Oct 22, 2026
@dgarske
dgarske force-pushed the asn_subject branch 2 times, most recently from b32d902 to b4fe014 Compare October 22, 2026 14:20

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Code Review

Scan type: review

Overall recommendation: REQUEST_CHANGES
Findings: 4 total — 4 posted, 0 skipped
4 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [High] Existing binaries pass a smaller DecodedX509 buffer — src/tpm2_asn.c:247-275
  • [High] Malformed AttributeTypeAndValue sequences can return success — src/tpm2_asn.c:409-425
  • [Medium] Truncated headers violate the documented error contract — wolftpm/tpm2_asn.h:164-165
  • [Medium] Boundary and bad-argument paths are not covered — tests/unit_tests.c:9020-9026

Review generated by Skoll

Comment thread src/tpm2_asn.c
Comment thread src/tpm2_asn.c
Comment thread wolftpm/tpm2_asn.h Outdated
Comment thread tests/unit_tests.c
@aidangarske
aidangarske merged commit 3737723 into wolfSSL:master Oct 23, 2026
244 of 245 checks passed
@aidangarske
aidangarske deleted the asn_subject branch October 23, 2026 17:50
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.

3 participants