Skip to content

Add certificate parser to parse x509 Certificate to EK Certificate.#471

Merged
liamjm merged 5 commits intogoogle:masterfrom
neha-gunta:master
Jan 23, 2026
Merged

Add certificate parser to parse x509 Certificate to EK Certificate.#471
liamjm merged 5 commits intogoogle:masterfrom
neha-gunta:master

Conversation

@neha-gunta
Copy link
Collaborator

Add certificate parser to parse x509 Certificate to EK Certificate.
The standard fields are validated by referencing the TCG EK Credential Profile.

Copy link
Collaborator

@liamjm liamjm left a comment

Choose a reason for hiding this comment

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

I didn't see any handling of TPM Security Assertions (Section 3.1.1 from the EK Credential profile spec). Shall we add a TODO to add these.

The code also doesn't validate some things, eg the format of the TPM Manufacturer. I think this is OK, as that can be in a separate method to verify these attributes, if anyone cares. However, the code does verify some aspects (eg critical vs optional extensions), so there is some potential for confusion. Perhaps the method documentation should state something around the face that the presence of extensions are check, but not all values are checked. WDYT?

Copy link
Collaborator Author

@neha-gunta neha-gunta left a comment

Choose a reason for hiding this comment

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

I didn't see any handling of TPM Security Assertions (Section 3.1.1 from the EK Credential profile spec). Shall we add a TODO to add these.

The code also doesn't validate some things, eg the format of the TPM Manufacturer. I think this is OK, as that can be in a separate method to verify these attributes, if anyone cares. However, the code does verify some aspects (eg critical vs optional extensions), so there is some potential for confusion. Perhaps the method documentation should state something around the face that the presence of extensions are check, but not all values are checked. WDYT?

Agreed! I shall add an elaborate comment stating the limitations of our function.

@liamjm
Copy link
Collaborator

liamjm commented Jan 16, 2026

Please fix lint errors, otherwise LGTM.

Copy link
Collaborator

@liamjm liamjm left a comment

Choose a reason for hiding this comment

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

Thanks, great stuff.

@liamjm liamjm merged commit 5514d09 into google:master Jan 23, 2026
8 checks passed
}

// Iterate through unknown/custom ExtKeyUsage OIDs
for _, eku := range cert.UnknownExtKeyUsage {
Copy link

Choose a reason for hiding this comment

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

This could theoretically break if Go x509 ever adds this ExtKeyUsage

golang/go#75325 is solved in Go 1.26 which would allow this to be written in a forward-compatible manner by iterating both over ExtKeyUsage and call OID() on that, and iterate over UnknownExtKeyUsage.

However it's a bit of a nit as I don't expect it to be likely that this ExtKeyUsage is ever added to x509 due to not being web pki related

if spec, err = parseTPMSpecification(subjectDirectoryAttributes); err != nil {
return nil, err
}
case ext.Id.Equal(oidBasicConstraints):
Copy link

Choose a reason for hiding this comment

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

There is no need to manually check for Critical bit on all these oids. This is already handled by the x509 library. Either the x509 library parses the fields; or it puts them in UnhandledCriticalExtensions. a non-empty UnhandlesCriticalExtensions throws an error on Verify()

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the critical bit is off? The x509 library will not complaint, but it violate the TCG spec, right?

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.

4 participants