]> git.proxmox.com Git - libtpms.git/commit - CHANGES
tpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap
authorStefan Berger <stefanb@linux.ibm.com>
Fri, 30 Apr 2021 20:44:03 +0000 (16:44 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Thu, 13 May 2021 12:53:26 +0000 (08:53 -0400)
commitdb1fd5948bcad810344ea1b2bda1eaefacba3547
tree95fa3813679ad7565b476a1cd3288987bf1b183a
parent31925c8e333bcdec0ee52b21445f8c89d1fcf599
tpm2: Switch to UINT16 for CONTEXT_SLOT and 64k context gap

This patch addresses issue #209.

The context gap for libtpms is currently only 0xff due to the CONTEXT_SLOT
being a UINT8. To extend this to 0xffff, we need to define the CONTEXT_SLOT
as UINT16 and introduce a global variable s_ContextArrayMask that takes on
two valid values, 0xff for simulating the CONTEXT_SLOT when it was UINT8
and 0xffff for usage with the new CONTEXT_SLOT of type UINT16. All
occurrences of casts to CONTEXT_SLOT are replaced with a macro
CONTEXT_SLOT_MASKED that applies this mask to a value instead of using the
cast. We also use it for some calculations to avoid spilling over from
1 byte into 2 bytes for example. The cast with the new code is the same as
applying the mask 0xffff, and using the 0xff mask we can simulate the old
CONTEXT_SLOT (1 byte), which we need for seamlessly resuming old state. We
switch from the 0xff mask to the 0xffff mask when the TPM is reset.

There's one place where the s_ContextArrayMask is initialized to 0xff, and
this is when we resume 'old' STATE_RESET_DATA. The places where it is
intialized to 0xffff are in TPM_Manufacture() and
TPM_SessionStartup(SU_CLEAR), both of which are not called after resuming
state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
CHANGES
src/tpm2/Global.h
src/tpm2/Manufacture.c
src/tpm2/NVMarshal.c
src/tpm2/PropertyCap.c
src/tpm2/Session.c
src/tpm2/TpmProfile.h