Compare commits

...

3 Commits

Author SHA1 Message Date
Stefan Berger
11117d396a tpm2: Define TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL and use it
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-06 15:45:45 -04:00
Stefan Berger
c4bd7dfe9c tpm2: Add missing ADD_FLAG to X509Certificate definition
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-06 15:41:05 -04:00
Stefan Berger
e596e87ebd tpm2: Rename PlatformPCR.c to PlatformPcr.c and sync
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-08-06 13:47:45 -04:00
3 changed files with 42 additions and 39 deletions

View File

@ -247,7 +247,7 @@ libtpms_tpm2_la_SOURCES = \
tpm2/PCR.c \
tpm2/PlatformACT.c \
tpm2/PlatformData.c \
tpm2/PlatformPCR.c \
tpm2/PlatformPcr.c \
tpm2/Policy_spt.c \
tpm2/Power.c \
tpm2/PowerPlat.c \

View File

@ -111,7 +111,9 @@ const _UNMARSHAL_T_ unmarshalArray[] = {
UNMARSHAL_DISPATCH(TPMI_RH_LOCKOUT),
#define TPMI_RH_NV_AUTH_H_UNMARSHAL (TPMI_RH_LOCKOUT_H_UNMARSHAL + 1)
UNMARSHAL_DISPATCH(TPMI_RH_NV_AUTH),
#define TPMI_RH_NV_INDEX_H_UNMARSHAL (TPMI_RH_NV_AUTH_H_UNMARSHAL + 1)
#define TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL (TPMI_RH_NV_AUTH_H_UNMARSHAL + 1)
UNMARSHAL_DISPATCH(TPMI_RH_NV_DEFINED_INDEX),
#define TPMI_RH_NV_INDEX_H_UNMARSHAL (TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL + 1)
UNMARSHAL_DISPATCH(TPMI_RH_NV_INDEX),
#define TPMI_RH_PLATFORM_H_UNMARSHAL (TPMI_RH_NV_INDEX_H_UNMARSHAL + 1)
UNMARSHAL_DISPATCH(TPMI_RH_PLATFORM),
@ -2251,7 +2253,7 @@ CertifyX509_COMMAND_DESCRIPTOR_t _CertifyX509Data = {
(UINT16)(offsetof(CertifyX509_Out, tbsDigest)),
(UINT16)(offsetof(CertifyX509_Out, signature))},
/* types */ {TPMI_DH_OBJECT_H_UNMARSHAL,
TPMI_DH_OBJECT_H_UNMARSHAL,
TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,
TPM2B_DATA_P_UNMARSHAL,
TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,
TPM2B_MAX_BUFFER_P_UNMARSHAL,
@ -4493,7 +4495,7 @@ NV_UndefineSpace_COMMAND_DESCRIPTOR_t _NV_UndefineSpaceData = {
/* offsetOfTypes */ offsetof(NV_UndefineSpace_COMMAND_DESCRIPTOR_t, types),
/* offsets */ {(UINT16)(offsetof(NV_UndefineSpace_In, nvIndex))},
/* types */ {TPMI_RH_PROVISION_H_UNMARSHAL,
TPMI_RH_NV_INDEX_H_UNMARSHAL,
TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL,
END_OF_LIST,
END_OF_LIST}
};
@ -4527,7 +4529,7 @@ NV_UndefineSpaceSpecial_COMMAND_DESCRIPTOR_t _NV_UndefineSpaceSpecialData = {
/* outSize */ 0,
/* offsetOfTypes */ offsetof(NV_UndefineSpaceSpecial_COMMAND_DESCRIPTOR_t, types),
/* offsets */ {(UINT16)(offsetof(NV_UndefineSpaceSpecial_In, platform))},
/* types */ {TPMI_RH_NV_INDEX_H_UNMARSHAL,
/* types */ {TPMI_RH_NV_DEFINED_INDEX_H_UNMARSHAL,
TPMI_RH_PLATFORM_H_UNMARSHAL,
END_OF_LIST,
END_OF_LIST}

View File

@ -58,13 +58,14 @@
/* */
/********************************************************************************/
// PCR platform interface functions
#include "Platform.h"
#include "TpmAlgorithmDefines.h"
// use this as a convenient lookup for hash size for PCRs.
UINT16 CryptHashGetDigestSize(TPM_ALG_ID hashAlg // IN: hash algorithm to look up
);
);
void MemorySet(void* dest, int value, size_t size);
// The initial value of PCR attributes. The value of these fields should be
@ -100,17 +101,17 @@ static const PCR_Attributes s_initAttributes[] = {
{1, 0, 0, 0, 0, 0x1F},
// these PCRs are never saved
{0, 1, 0, 0, 0x0F, 0x1F}, // PCR 16, Debug, reset allowed, extend all
{0, 1, 0, 0, 0x0F, 0x1F}, // PCR 16, Debug, reset allowed, extend all // libtpms changed
{0, 0, 0, 0, 0x10, 0x1C}, // PCR 17, Locality 4, extend loc 2+
{0, 0, 0, 0, 0x10, 0x1C}, // PCR 18, Locality 3, extend loc 2+
{0, 0, 0, 0, 0x10, 0x0C}, // PCR 19, Locality 2, extend loc 2, 3
// these three support doNotIncrement, PolicyAuth, and AuthValue.
// this is consistent with the existing behavior of the TPM Reference code
// but differs from the behavior of the PC client spec.
{0, 0, 0, 0, 0x1C, 0x0E}, // PCR 20, Locality 1, extend loc 1, 2, 3
{0, 0, 0, 0, 0x1C, 0x0E}, // PCR 20, Locality 1, extend loc 1, 2, 3 // libtpms changed begin
{0, 1, 0, 0, 0x1C, 0x04}, // PCR 21, Dynamic OS, extend loc 2
{0, 1, 0, 0, 0x1C, 0x04}, // PCR 22, Dynamic OS, extend loc 2
{0, 1, 0, 0, 0x0F, 0x1F}, // PCR 23, reset allowed, App specific, extend all
{0, 1, 0, 0, 0x0F, 0x1F}, // PCR 23, reset allowed, App specific, extend all // libtpms changed end
};
#ifndef ARRAYSIZE
@ -168,7 +169,7 @@ PCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber)
BOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg)
{
// brute force search is fast enough for a small array.
for(size_t i = 0; i < ARRAYSIZE(DefaultActivePcrBanks); i++)
for(size_t i = 0; i < ARRAYSIZE(DefaultActivePcrBanks); i++) // libtpms changed
{
if(DefaultActivePcrBanks[i] == pcrAlg)
{
@ -192,7 +193,7 @@ TPM_RC _platPcr__GetInitialValueForPcr(
BYTE* pcrData, // OUT: buffer to put PCR initialization value into
uint16_t bufferSize, // IN: maximum size of value buffer can hold
uint16_t* pcrLength // OUT: size of initialization value returned in pcrBuffer
)
)
{
// If the reset locality contains locality 4, then this
// indicates a DRTM PCR where the reset value is all ones,