tpm2-software / tpm2-tss

OSS implementation of the TCG TPM2 Software Stack (TSS2)
https://tpm2-software.github.io
BSD 2-Clause "Simplified" License
715 stars 352 forks source link

[Specification question] Wrong type in TPMS_CONTEXT? #2710

Open Superhepper opened 7 months ago

Superhepper commented 7 months ago

I am having difficulties understanding what type that should actually be used in the TPMS_CONTEXT structure.

The Errata: TPM 2.0 Library Specification 1.38 Errata 1.13, Section 2.19

. To fix this, the handle type for savedHandle in the TPMS_CONTEXT structure should be changed from TPMI_DH_CONTEXT to TPMI_DH_SAVE. . . The commands affected by this change are TPM2_ContextLoad(), and TPM2_ContextSave()

The structures specification: TCG TPM2 r1p59 Part2 Structures, Section 14.5 The type is now specified with the field 'savedHandle' having the type TPMI_DH_SAVED.

The commands specification: TCG TPM2 r1p59 Part 3 Commands, Section 28.2.2, Table 194 — TPM2_ContextSave Command The 'saveHandle' field is specified as TPMI_DH_CONTEXT.

TCG TPM2 r1p59 Part 3 Commands, Section 28.3.2, Table 197 — TPM2_ContextLoad Response The 'loadedHandle' in the response is specified as a TPMI_DH_CONTEXT.

The code:

TPMS_CONTEXT: https://github.com/tpm2-software/tpm2-tss/blob/ede63dd1ac1f0a46029d457304edcac2162bfab8/include/tss2/tss2_tpm2_types.h#L1991

ContextSave: https://github.com/tpm2-software/tpm2-tss/blob/ede63dd1ac1f0a46029d457304edcac2162bfab8/include/tss2/tss2_sys.h#L1803

ContextLoad: https://github.com/tpm2-software/tpm2-tss/blob/ede63dd1ac1f0a46029d457304edcac2162bfab8/include/tss2/tss2_sys.h#L1825

The code seem to still specify all the fields as TPMI_DH_CONTEXT is there a reason for this?

And it seems to me as if the TPMI_DH_CONTEXT is no longer needed should it not be removed from the specification?

AndreasFuchsTPM commented 2 months ago

Sounds good; even though it's a minor thing. PRs welcome.

Superhepper commented 2 months ago

The code is simple enough to change. It might be harder to update the specification.