Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TPMS_ID_OBJECT structure #311

Open
wants to merge 1 commit into
base: tpmdirect
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tpm2/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,21 @@ type TPMSCreationData struct {
OutsideInfo TPM2BData
}

// TPMSIDObject represents a TPMS_ID_OBJECT.
// See definition in Part 2: Structures, section 12.4.2.
type TPMSIDObject struct {
// HMAC using the nameAlg of the storage key on the target TPM
IntegrityHMAC TPM2BDigest
// credential protector information returned if name matches the referenced object
// All of the encIdentity is encrypted, including the size field.
EncIdentity []byte
Copy link
Member

Choose a reason for hiding this comment

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

This is a strange structure, so it is one of the exceptional cases that can't just get reflection applied to it, I don't think :)

This "encrypted sized" structure makes this not possible to unmarshal (since we don't know the encrypted size of EncIdentity). That's why TPMS_ID_OBJECT in the spec says:

This structure is used for sizing the TPM2B_ID_OBJECT.

It also says that TPM2B_ID_OBJECT contains a buffer that happens to be limited to the size of a TPMS_ID_OBJECT:

credential[size]{:sizeof{TPMS_ID_OBJECT}}

So I would recommend making TPM2BIDObject be a boring TPM2BData, and adding a factory function that makes it easier to assemble a TPM2BIDObject.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chrisfenner

I'm sorry to reply so late; I had written my graduation thesis.

I agree with your opinion, and I will implement it.

To implement it, I have a question.
Which files should I implement it...?
Do you have an idea?

}

// TPM2BIDObject represents a TPM2B_ID_OBJECT.
// See definition in Part 2: Structures, section 12.4.3.
type TPM2BIDObject TPM2BData
type TPM2BIDObject struct {
Credential TPMSIDObject `gotpm:"sized"`
}

// TPMNT represents a TPM_NT.
// See definition in Part 2: Structures, section 13.4.
Expand Down