mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-09 23:38:23 +00:00
rev180: Add TPM2_DefineSpace2 and dependencies
TPM2_DefineSpace2 defines NV areas in the same format as the old TPM2_DefineSpace function did, so there should not be any compatibility issues with the NV areas' format. However, it may not currently make much sense to enable this command since its improvement over the existing TPM2_DefineSpace is only support for exernal memory, which we don't have. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
12d8418c41
commit
843fbe0762
@ -426,6 +426,7 @@ noinst_HEADERS += \
|
||||
tpm2/NV_Certify_fp.h \
|
||||
tpm2/NV_ChangeAuth_fp.h \
|
||||
tpm2/NV_DefineSpace_fp.h \
|
||||
tpm2/NV_DefineSpace2_fp.h \
|
||||
tpm2/NVDynamic_fp.h \
|
||||
tpm2/NV_Extend_fp.h \
|
||||
tpm2/NV_GlobalWriteLock_fp.h \
|
||||
|
||||
@ -451,6 +451,9 @@ const TPMA_CC s_ccAttr [] = {
|
||||
#if (PAD_LIST || CC_PolicyParameters)
|
||||
TPMA_CC_INITIALIZER(0x019C, 0, 0, 0, 0, 1, 0, 0, 0),
|
||||
#endif
|
||||
#if (PAD_LIST || CC_NV_DefineSpace2)
|
||||
TPMA_CC_INITIALIZER(0x019D, 0, 1, 0, 0, 1, 0, 0, 0),
|
||||
#endif
|
||||
#if (PAD_LIST || CC_Vendor_TCG_Test)
|
||||
TPMA_CC_INITIALIZER(0x0000, 0, 0, 0, 0, 0, 0, 1, 0),
|
||||
#endif
|
||||
@ -960,6 +963,10 @@ const COMMAND_ATTRIBUTES s_commandAttributes [] = {
|
||||
(COMMAND_ATTRIBUTES)(CC_PolicyParameters * // 0x019C
|
||||
(IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),
|
||||
#endif
|
||||
#if (PAD_LIST || CC_NV_DefineSpace2)
|
||||
(COMMAND_ATTRIBUTES)(CC_NV_DefineSpace2 * // 0x019D
|
||||
(IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),
|
||||
#endif
|
||||
#if (PAD_LIST || CC_Vendor_TCG_Test)
|
||||
(COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test * // 0x0000
|
||||
(IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),
|
||||
|
||||
@ -153,7 +153,9 @@ const _UNMARSHAL_T_ unmarshalArray[] = {
|
||||
UNMARSHAL_DISPATCH(TPM2B_NAME),
|
||||
#define TPM2B_NV_PUBLIC_P_UNMARSHAL (TPM2B_NAME_P_UNMARSHAL + 1)
|
||||
UNMARSHAL_DISPATCH(TPM2B_NV_PUBLIC),
|
||||
#define TPM2B_PRIVATE_P_UNMARSHAL (TPM2B_NV_PUBLIC_P_UNMARSHAL + 1)
|
||||
#define TPM2B_NV_PUBLIC_2_P_UNMARSHAL (TPM2B_NV_PUBLIC_P_UNMARSHAL + 1)
|
||||
UNMARSHAL_DISPATCH(TPM2B_NV_PUBLIC_2),
|
||||
#define TPM2B_PRIVATE_P_UNMARSHAL (TPM2B_NV_PUBLIC_2_P_UNMARSHAL + 1)
|
||||
UNMARSHAL_DISPATCH(TPM2B_PRIVATE),
|
||||
#define TPM2B_PUBLIC_KEY_RSA_P_UNMARSHAL (TPM2B_PRIVATE_P_UNMARSHAL + 1)
|
||||
UNMARSHAL_DISPATCH(TPM2B_PUBLIC_KEY_RSA),
|
||||
@ -292,7 +294,9 @@ const _MARSHAL_T_ marshalArray[] = {
|
||||
MARSHAL_DISPATCH(TPM2B_NAME),
|
||||
#define TPM2B_NV_PUBLIC_P_MARSHAL (TPM2B_NAME_P_MARSHAL + 1)
|
||||
MARSHAL_DISPATCH(TPM2B_NV_PUBLIC),
|
||||
#define TPM2B_PRIVATE_P_MARSHAL (TPM2B_NV_PUBLIC_P_MARSHAL + 1)
|
||||
#define TPM2B_NV_PUBLIC_2_P_MARSHAL (TPM2B_NV_PUBLIC_P_MARSHAL + 1)
|
||||
MARSHAL_DISPATCH(TPM2B_NV_PUBLIC_2),
|
||||
#define TPM2B_PRIVATE_P_MARSHAL (TPM2B_NV_PUBLIC_2_P_MARSHAL + 1)
|
||||
MARSHAL_DISPATCH(TPM2B_PRIVATE),
|
||||
#define TPM2B_PUBLIC_P_MARSHAL (TPM2B_PRIVATE_P_MARSHAL + 1)
|
||||
MARSHAL_DISPATCH(TPM2B_PUBLIC),
|
||||
@ -4139,6 +4143,43 @@ NV_Certify_COMMAND_DESCRIPTOR_t _NV_CertifyData = {
|
||||
#define _NV_CertifyDataAddress 0
|
||||
#endif
|
||||
|
||||
#if CC_NV_DefineSpace2
|
||||
#include "NV_DefineSpace2_fp.h"
|
||||
|
||||
typedef TPM_RC (NV_DefineSpace2_Entry)(
|
||||
NV_DefineSpace2_In* in
|
||||
);
|
||||
|
||||
typedef const struct
|
||||
{
|
||||
NV_DefineSpace2_Entry *entry;
|
||||
UINT16 inSize;
|
||||
UINT16 outSize;
|
||||
UINT16 offsetOfTypes;
|
||||
UINT16 paramOffsets[2];
|
||||
BYTE types[5];
|
||||
} NV_DefineSpace2_COMMAND_DESCRIPTOR_t;
|
||||
|
||||
NV_DefineSpace2_COMMAND_DESCRIPTOR_t _NV_DefineSpace2Data = {
|
||||
/* entry */ &TPM2_NV_DefineSpace2,
|
||||
/* inSize */ (UINT16)(sizeof(NV_DefineSpace2_In)),
|
||||
/* outSize */ 0,
|
||||
/* offsetOfTypes */ offsetof(NV_DefineSpace2_COMMAND_DESCRIPTOR_t, types),
|
||||
/* offsets */ {(UINT16)(offsetof(NV_DefineSpace2_In, auth)),
|
||||
(UINT16)(offsetof(NV_DefineSpace2_In, publicInfo))},
|
||||
/* types */ {TPMI_RH_PROVISION_H_UNMARSHAL,
|
||||
TPM2B_AUTH_P_UNMARSHAL,
|
||||
TPM2B_NV_PUBLIC_2_P_UNMARSHAL,
|
||||
END_OF_LIST,
|
||||
END_OF_LIST}
|
||||
};
|
||||
|
||||
#define _NV_DefineSpace2DataAddress (&_NV_DefineSpace2Data)
|
||||
#else
|
||||
#define _NV_DefineSpace2DataAddress 0
|
||||
#endif // CC_NV_DefineSpace2
|
||||
|
||||
|
||||
#if CC_AC_GetCapability
|
||||
#include "AC_GetCapability_fp.h"
|
||||
typedef TPM_RC (AC_GetCapability_Entry)(
|
||||
@ -4697,6 +4738,9 @@ COMMAND_DESCRIPTOR_t *s_CommandDataArray[] = {
|
||||
#if (PAD_LIST || CC_PolicyParameters)
|
||||
(COMMAND_DESCRIPTOR_t*)_PolicyParametersDataAddress,
|
||||
#endif // CC_PolicyParameters
|
||||
#if (PAD_LIST || CC_NV_DefineSpace2)
|
||||
(COMMAND_DESCRIPTOR_t*)_NV_DefineSpace2DataAddress,
|
||||
#endif // CC_NV_DefineSpace2
|
||||
#if (PAD_LIST || CC_Vendor_TCG_Test)
|
||||
(COMMAND_DESCRIPTOR_t *)_Vendor_TCG_TestDataAddress,
|
||||
#endif
|
||||
|
||||
@ -186,6 +186,11 @@ EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure
|
||||
result = AcIsAccessible(handle);
|
||||
break;
|
||||
#endif
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
case TPM_HT_PERMANENT_NV:
|
||||
// Not yet supported.
|
||||
result = TPM_RC_VALUE;
|
||||
break;
|
||||
default:
|
||||
// Any other handle type is a defect in the unmarshaling code.
|
||||
FAIL(FATAL_ERROR_INTERNAL);
|
||||
|
||||
@ -396,6 +396,16 @@ TPMI_RH_NV_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size)
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 69 - Definition of (TPM_HANDLE) TPMI_RH_NV_ EXP_INDEX Type <IN/OUT> */
|
||||
|
||||
UINT16
|
||||
TPMI_RH_NV_EXP_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
written += TPM_HANDLE_Marshal(source, buffer, size);
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 2:60 - Definition of TPMI_ALG_HASH Type (InterfaceTable()) */
|
||||
|
||||
UINT16
|
||||
@ -2181,6 +2191,15 @@ TPMA_NV_Marshal(TPMA_NV *source, BYTE **buffer, INT32 *size)
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 226 - Definition of (UINT64) TPMA_NV_EXP Bits */
|
||||
UINT16
|
||||
TPMA_NV_EXP_Marshal(TPMA_NV_EXP *source, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
written += UINT64_Marshal(source, buffer, size);
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 2:206 - Definition of TPMS_NV_PUBLIC Structure (StructuresTable()) */
|
||||
|
||||
UINT16
|
||||
@ -2218,6 +2237,78 @@ TPM2B_NV_PUBLIC_Marshal(TPM2B_NV_PUBLIC *source, BYTE **buffer, INT32 *size)
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 229 - Definition of TPMS_NV_PUBLIC_EXP_ATTR Structure */
|
||||
UINT16
|
||||
TPMS_NV_PUBLIC_EXP_ATTR_Marshal(TPMS_NV_PUBLIC_EXP_ATTR *source, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
|
||||
written += TPMI_RH_NV_EXP_INDEX_Marshal(&source->nvIndex, buffer, size);
|
||||
written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);
|
||||
written += TPMA_NV_EXP_Marshal(&source->attributes, buffer, size);
|
||||
written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);
|
||||
written += UINT16_Marshal(&source->dataSize, buffer, size);
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 230 - Definition of TPMU_NV_PUBLIC_2 Union */
|
||||
|
||||
UINT16
|
||||
TPMU_NV_PUBLIC_2_Marshal(TPMU_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size, UINT8 selector)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
|
||||
switch (selector) {
|
||||
|
||||
case TPM_HT_NV_INDEX:
|
||||
written += TPMS_NV_PUBLIC_Marshal(&source->nvIndex, buffer, size);
|
||||
break;
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
written += TPMS_NV_PUBLIC_EXP_ATTR_Marshal(&source->externalNV, buffer, size);
|
||||
break;
|
||||
case TPM_HT_PERMANENT_NV:
|
||||
written += TPMS_NV_PUBLIC_Marshal(&source->permanentNV, buffer, size);
|
||||
break;
|
||||
default:
|
||||
pAssert(FALSE);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 231 - Definition of TPMT_NV_PUBLIC_2 Structure */
|
||||
|
||||
UINT16
|
||||
TPMT_NV_PUBLIC_2_Marshal(TPMT_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
|
||||
written += UINT8_Marshal(&source->handleType, buffer, size);
|
||||
written += TPMU_NV_PUBLIC_2_Marshal(&source->nvPublic2, buffer, size, source->handleType);
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 232 - Definition of TPM2B_NV_PUBLIC_2 Structure */
|
||||
|
||||
UINT16
|
||||
TPM2B_NV_PUBLIC_2_Marshal(TPM2B_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
UINT16 written = 0;
|
||||
BYTE *sizePtr;
|
||||
|
||||
if (buffer != NULL) {
|
||||
sizePtr = *buffer;
|
||||
*buffer += sizeof(UINT16);
|
||||
}
|
||||
written += TPMT_NV_PUBLIC_2_Marshal(&source->nvPublic2, buffer, size);
|
||||
if (buffer != NULL) {
|
||||
written += UINT16_Marshal(&written, &sizePtr, size);
|
||||
}
|
||||
else {
|
||||
written += sizeof(UINT16);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
/* Table 2:210 - Definition of TPM2B_CONTEXT_DATA Structure (StructuresTable()) */
|
||||
|
||||
UINT16
|
||||
|
||||
@ -122,6 +122,8 @@ extern "C" {
|
||||
UINT16
|
||||
TPMI_RH_NV_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMI_RH_NV_EXP_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMI_ALG_HASH_Marshal(TPMI_ALG_HASH *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMI_ALG_SYM_OBJECT_Marshal(TPMI_ALG_SYM_OBJECT *source, BYTE **buffer, INT32 *size);
|
||||
@ -378,10 +380,20 @@ extern "C" {
|
||||
UINT16
|
||||
TPMA_NV_Marshal(TPMA_NV *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMA_NV_EXP_Marshal(TPMA_NV_EXP *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMS_NV_PUBLIC_Marshal(TPMS_NV_PUBLIC *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPM2B_NV_PUBLIC_Marshal(TPM2B_NV_PUBLIC *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMS_NV_PUBLIC_EXP_ATTR_Marshal(TPMS_NV_PUBLIC_EXP_ATTR *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMU_NV_PUBLIC_2_Marshal(TPMU_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size, UINT8 selector);
|
||||
UINT16
|
||||
TPMT_NV_PUBLIC_2_Marshal(TPMT_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPM2B_NV_PUBLIC_2_Marshal(TPM2B_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPM2B_CONTEXT_DATA_Marshal(TPM2B_CONTEXT_DATA *source, BYTE **buffer, INT32 *size);
|
||||
UINT16
|
||||
TPMS_CONTEXT_Marshal(TPMS_CONTEXT *source, BYTE **buffer, INT32 *size);
|
||||
|
||||
@ -704,3 +704,73 @@ TPM2_NV_Certify(
|
||||
&in->qualifyingData, &out->certifyInfo, &out->signature);
|
||||
}
|
||||
#endif // CC_NV_Certify
|
||||
|
||||
#include "Tpm.h"
|
||||
#include "NV_DefineSpace2_fp.h"
|
||||
|
||||
#if CC_NV_DefineSpace2 // Conditional expansion of this file
|
||||
|
||||
/*(See part 3 specification)
|
||||
// Define a NV index space
|
||||
*/
|
||||
// Return Type: TPM_RC
|
||||
// TPM_RC_HIERARCHY for authorizations using TPM_RH_PLATFORM
|
||||
// phEnable_NV is clear preventing access to NV
|
||||
// data in the platform hierarchy.
|
||||
// TPM_RC_ATTRIBUTES attributes of the index are not consistent
|
||||
// TPM_RC_NV_DEFINED index already exists
|
||||
// TPM_RC_NV_SPACE insufficient space for the index
|
||||
// TPM_RC_SIZE 'auth->size' or 'publicInfo->authPolicy.size' is
|
||||
// larger than the digest size of
|
||||
// 'publicInfo->nameAlg'; or 'publicInfo->dataSize'
|
||||
// is not consistent with 'publicInfo->attributes'
|
||||
// (this includes the case when the index is
|
||||
// larger than a MAX_NV_BUFFER_SIZE but the
|
||||
// TPMA_NV_WRITEALL attribute is SET)
|
||||
TPM_RC
|
||||
TPM2_NV_DefineSpace2(NV_DefineSpace2_In* in // IN: input parameter list
|
||||
)
|
||||
{
|
||||
TPM_RC result;
|
||||
TPMS_NV_PUBLIC legacyPublic;
|
||||
|
||||
// Input Validation
|
||||
|
||||
// Validate the handle type and the (handle-type-specific) attributes.
|
||||
switch(in->publicInfo.nvPublic2.handleType)
|
||||
{
|
||||
case TPM_HT_NV_INDEX:
|
||||
break;
|
||||
# if EXTERNAL_NV
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
// The reference implementation may let you define an "external" NV
|
||||
// index, but it doesn't currently support setting any of the extended
|
||||
// bits for customizing the behavior of external NV.
|
||||
if((TPMA_NV_EXP_TO_UINT64(
|
||||
in->publicInfo.nvPublic2.nvPublic2.externalNV.attributes)
|
||||
& 0xffffffff00000000)
|
||||
!= 0)
|
||||
{
|
||||
return TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace2_publicInfo;
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
return TPM_RCS_HANDLE + RC_NV_DefineSpace2_publicInfo;
|
||||
}
|
||||
|
||||
result = NvPublicFromNvPublic2(&in->publicInfo.nvPublic2, &legacyPublic);
|
||||
if(result != TPM_RC_SUCCESS)
|
||||
{
|
||||
return RcSafeAddToResult(result, RC_NV_DefineSpace2_publicInfo);
|
||||
}
|
||||
|
||||
return NvDefineSpace(in->authHandle,
|
||||
&in->auth,
|
||||
&legacyPublic,
|
||||
RC_NV_DefineSpace2_authHandle,
|
||||
RC_NV_DefineSpace2_auth,
|
||||
RC_NV_DefineSpace2_publicInfo);
|
||||
}
|
||||
|
||||
#endif // CC_NV_DefineSpace
|
||||
|
||||
@ -4741,6 +4741,9 @@ USER_NVRAM_Display(const char *msg)
|
||||
NvReadObject(entryRef + offset, &obj);
|
||||
fprintf(stderr, " sizeof(obj): %zu entrysize: %u\n", sizeof(obj), entrysize);
|
||||
break;
|
||||
#if CC_NV_DefineSpace2
|
||||
# error Missing support for TPM_HT_PERMANENT_NV
|
||||
#endif
|
||||
default:
|
||||
TPMLIB_LogTPM2Error("USER_NVRAM: Corrupted handle: %08x\n", handle);
|
||||
}
|
||||
@ -4814,6 +4817,9 @@ USER_NVRAM_Marshal(BYTE **buffer, INT32 *size)
|
||||
NvReadObject(entryRef + offset, &obj);
|
||||
written += ANY_OBJECT_Marshal(&obj, buffer, size);
|
||||
break;
|
||||
#if CC_NV_DefineSpace2
|
||||
# error Missing support for TPM_HT_PERMANENT_NV
|
||||
#endif
|
||||
default:
|
||||
TPMLIB_LogTPM2Error("USER_NVRAM: Corrupted handle: %08x\n", handle);
|
||||
}
|
||||
|
||||
81
src/tpm2/NV_DefineSpace2_fp.h
Normal file
81
src/tpm2/NV_DefineSpace2_fp.h
Normal file
@ -0,0 +1,81 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
/* 1. Copyright Licenses: */
|
||||
/* */
|
||||
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
|
||||
/* this specification (the "Source Code") a worldwide, irrevocable, */
|
||||
/* nonexclusive, royalty free, copyright license to reproduce, create */
|
||||
/* derivative works, distribute, display and perform the Source Code and */
|
||||
/* derivative works thereof, and to grant others the rights granted herein. */
|
||||
/* */
|
||||
/* - The TCG grants to the user of the other parts of the specification */
|
||||
/* (other than the Source Code) the rights to reproduce, distribute, */
|
||||
/* display, and perform the specification solely for the purpose of */
|
||||
/* developing products based on such documents. */
|
||||
/* */
|
||||
/* 2. Source Code Distribution Conditions: */
|
||||
/* */
|
||||
/* - Redistributions of Source Code must retain the above copyright licenses, */
|
||||
/* this list of conditions and the following disclaimers. */
|
||||
/* */
|
||||
/* - Redistributions in binary form must reproduce the above copyright */
|
||||
/* licenses, this list of conditions and the following disclaimers in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
/* */
|
||||
/* 3. Disclaimers: */
|
||||
/* */
|
||||
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
|
||||
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
|
||||
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
|
||||
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
|
||||
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
|
||||
/* information on specification licensing rights available through TCG */
|
||||
/* membership agreements. */
|
||||
/* */
|
||||
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
|
||||
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
|
||||
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
|
||||
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
|
||||
/* */
|
||||
/* - Without limitation, TCG and its members and licensors disclaim all */
|
||||
/* liability, including liability for infringement of any proprietary */
|
||||
/* rights, relating to use of information in this specification and to the */
|
||||
/* implementation of this specification, and TCG disclaims all liability for */
|
||||
/* cost of procurement of substitute goods or services, lost profits, loss */
|
||||
/* of use, loss of data or any incidental, consequential, direct, indirect, */
|
||||
/* or special damages, whether under contract, tort, warranty or otherwise, */
|
||||
/* arising in any way out of use or reliance upon this specification or any */
|
||||
/* information herein. */
|
||||
/* */
|
||||
/* (c) Copyright IBM Corp. and others, 2023 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
|
||||
#if CC_NV_DefineSpace2 // Command must be enabled
|
||||
|
||||
#ifndef NV_DEFINESPACE2_FP_H
|
||||
#define NV_DEFINESPACE2_FP_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TPMI_RH_PROVISION authHandle;
|
||||
TPM2B_AUTH auth;
|
||||
TPM2B_NV_PUBLIC_2 publicInfo;
|
||||
} NV_DefineSpace2_In;
|
||||
|
||||
#define RC_NV_DefineSpace2_authHandle (TPM_RC_H + TPM_RC_1)
|
||||
#define RC_NV_DefineSpace2_auth (TPM_RC_P + TPM_RC_1)
|
||||
#define RC_NV_DefineSpace2_publicInfo (TPM_RC_P + TPM_RC_2)
|
||||
|
||||
TPM_RC
|
||||
TPM2_NV_DefineSpace2(NV_DefineSpace2_In* in);
|
||||
|
||||
#endif // NV_DEFINESPACE2_FP_H
|
||||
#endif // CC_NV_DefineSpace2
|
||||
@ -196,13 +196,28 @@ TPM2B_NAME* NvGetIndexName(
|
||||
)
|
||||
{
|
||||
UINT16 dataSize, digestSize;
|
||||
BYTE marshalBuffer[sizeof(TPMS_NV_PUBLIC)];
|
||||
BYTE marshalBuffer[sizeof(TPMU_NV_PUBLIC_2)];
|
||||
BYTE* buffer;
|
||||
INT32 bufferSize = sizeof(marshalBuffer);
|
||||
HASH_STATE hashState;
|
||||
TPMT_NV_PUBLIC_2 public2;
|
||||
|
||||
// Marshal public area
|
||||
// Convert the legacy representation into the tagged-union representation.
|
||||
NvPublic2FromNvPublic(&nvIndex->publicArea, &public2);
|
||||
|
||||
// Marshal the whole public area, but not the TPM_HT selector:
|
||||
// This is safe, because the TPM_HT is the first byte of the handle value,
|
||||
// which is already in every element of TPMT_NV_PUBLIC_2.
|
||||
// This allows the Name of an NV index calculated based on the
|
||||
// TPMT_NV_PUBLIC_2 to be consistent with the Name of the same index if it
|
||||
// has a TPMS_NV_PUBLIC representation.
|
||||
buffer = marshalBuffer;
|
||||
dataSize = TPMS_NV_PUBLIC_Marshal(&nvIndex->publicArea, &buffer, NULL);
|
||||
dataSize =
|
||||
TPMU_NV_PUBLIC_2_Marshal(&public2.nvPublic2,
|
||||
&buffer,
|
||||
&bufferSize,
|
||||
(UINT32)HandleGetType(nvIndex->publicArea.nvIndex));
|
||||
|
||||
// hash public area
|
||||
digestSize = CryptHashStart(&hashState, nvIndex->publicArea.nameAlg);
|
||||
CryptDigestUpdate(&hashState, dataSize, marshalBuffer);
|
||||
@ -216,3 +231,251 @@ TPM2B_NAME* NvGetIndexName(
|
||||
return name;
|
||||
}
|
||||
|
||||
//*** NvPublic2FromNvPublic()
|
||||
// This function converts a legacy-form NV public (TPMS_NV_PUBLIC) into the
|
||||
// generalized TPMT_NV_PUBLIC_2 tagged-union representation.
|
||||
TPM_RC NvPublic2FromNvPublic(
|
||||
TPMS_NV_PUBLIC* nvPublic, // IN: the source S-form NV public area
|
||||
TPMT_NV_PUBLIC_2* nvPublic2 // OUT: the T-form NV public area to populate
|
||||
)
|
||||
{
|
||||
TPM_HT handleType = HandleGetType(nvPublic->nvIndex);
|
||||
|
||||
switch(handleType)
|
||||
{
|
||||
case TPM_HT_NV_INDEX:
|
||||
nvPublic2->nvPublic2.nvIndex = *nvPublic;
|
||||
break;
|
||||
case TPM_HT_PERMANENT_NV:
|
||||
nvPublic2->nvPublic2.permanentNV = *nvPublic;
|
||||
break;
|
||||
#if EXTERNAL_NV
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
{
|
||||
TPMS_NV_PUBLIC_EXP_ATTR* pub = &nvPublic2->nvPublic2.externalNV;
|
||||
|
||||
pub->attributes = ExpandedAttributesFromLegacy(nvPublic->attributes);
|
||||
pub->authPolicy = nvPublic->authPolicy;
|
||||
pub->dataSize = nvPublic->dataSize;
|
||||
pub->nameAlg = nvPublic->nameAlg;
|
||||
pub->nvIndex = nvPublic->nvIndex;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
return TPM_RCS_HANDLE;
|
||||
}
|
||||
|
||||
nvPublic2->handleType = handleType;
|
||||
return TPM_RC_SUCCESS;
|
||||
}
|
||||
|
||||
//*** NvPublicFromNvPublic2()
|
||||
// This function converts a tagged-union NV public (TPMT_NV_PUBLIC_2) into the
|
||||
// legacy TPMS_NV_PUBLIC representation. This is a lossy conversion: any
|
||||
// bits in the extended area of the attributes are lost, and the Name cannot be
|
||||
// computed based on it.
|
||||
TPM_RC NvPublicFromNvPublic2(
|
||||
TPMT_NV_PUBLIC_2* nvPublic2, // IN: the source T-form NV public area
|
||||
TPMS_NV_PUBLIC* nvPublic // OUT: the S-form NV public area to populate
|
||||
)
|
||||
{
|
||||
switch(nvPublic2->handleType)
|
||||
{
|
||||
case TPM_HT_NV_INDEX:
|
||||
*nvPublic = nvPublic2->nvPublic2.nvIndex;
|
||||
break;
|
||||
case TPM_HT_PERMANENT_NV:
|
||||
*nvPublic = nvPublic2->nvPublic2.permanentNV;
|
||||
break;
|
||||
#if EXTERNAL_NV
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
{
|
||||
TPMS_NV_PUBLIC_EXP_ATTR* pub = &nvPublic2->nvPublic2.externalNV;
|
||||
|
||||
nvPublic->attributes = LegacyAttributesFromExpanded(pub->attributes);
|
||||
nvPublic->authPolicy = pub->authPolicy;
|
||||
nvPublic->dataSize = pub->dataSize;
|
||||
nvPublic->nameAlg = pub->nameAlg;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
return TPM_RCS_HANDLE;
|
||||
}
|
||||
|
||||
return TPM_RC_SUCCESS;
|
||||
}
|
||||
|
||||
//*** NvDefineSpace()
|
||||
// This function combines the common functionality of TPM2_NV_DefineSpace and
|
||||
// TPM2_NV_DefineSpace2.
|
||||
TPM_RC NvDefineSpace(TPMI_RH_PROVISION authHandle,
|
||||
TPM2B_AUTH* auth,
|
||||
TPMS_NV_PUBLIC* publicInfo,
|
||||
TPM_RC blameAuthHandle,
|
||||
TPM_RC blameAuth,
|
||||
TPM_RC blamePublic)
|
||||
{
|
||||
TPMA_NV attributes = publicInfo->attributes;
|
||||
UINT16 nameSize;
|
||||
|
||||
nameSize = CryptHashGetDigestSize(publicInfo->nameAlg);
|
||||
|
||||
// Input Validation
|
||||
|
||||
// Checks not specific to type
|
||||
|
||||
// If the UndefineSpaceSpecial command is not implemented, then can't have
|
||||
// an index that can only be deleted with policy
|
||||
#if CC_NV_UndefineSpaceSpecial == NO
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
#endif
|
||||
|
||||
// check that the authPolicy consistent with hash algorithm
|
||||
|
||||
if(publicInfo->authPolicy.t.size != 0
|
||||
&& publicInfo->authPolicy.t.size != nameSize)
|
||||
return TPM_RCS_SIZE + blamePublic;
|
||||
|
||||
// make sure that the authValue is not too large
|
||||
if(MemoryRemoveTrailingZeros(auth) > CryptHashGetDigestSize(publicInfo->nameAlg))
|
||||
return TPM_RCS_SIZE + blameAuth;
|
||||
|
||||
// If an index is being created by the owner and shEnable is
|
||||
// clear, then we would not reach this point because ownerAuth
|
||||
// can't be given when shEnable is CLEAR. However, if phEnable
|
||||
// is SET but phEnableNV is CLEAR, we have to check here
|
||||
if(authHandle == TPM_RH_PLATFORM && gc.phEnableNV == CLEAR)
|
||||
return TPM_RCS_HIERARCHY + blameAuthHandle;
|
||||
|
||||
// Attribute checks
|
||||
// Eliminate the unsupported types
|
||||
switch(GET_TPM_NT(attributes))
|
||||
{
|
||||
#if CC_NV_Increment == YES
|
||||
case TPM_NT_COUNTER:
|
||||
#endif
|
||||
#if CC_NV_SetBits == YES
|
||||
case TPM_NT_BITS:
|
||||
#endif
|
||||
#if CC_NV_Extend == YES
|
||||
case TPM_NT_EXTEND:
|
||||
#endif
|
||||
#if CC_PolicySecret == YES && defined TPM_NT_PIN_PASS
|
||||
case TPM_NT_PIN_PASS:
|
||||
case TPM_NT_PIN_FAIL:
|
||||
#endif
|
||||
case TPM_NT_ORDINARY:
|
||||
break;
|
||||
default:
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
break;
|
||||
}
|
||||
// Check that the sizes are OK based on the type
|
||||
switch(GET_TPM_NT(attributes))
|
||||
{
|
||||
case TPM_NT_ORDINARY:
|
||||
// Can't exceed the allowed size for the implementation
|
||||
if(publicInfo->dataSize > MAX_NV_INDEX_SIZE)
|
||||
return TPM_RCS_SIZE + blamePublic;
|
||||
break;
|
||||
case TPM_NT_EXTEND:
|
||||
if(publicInfo->dataSize != nameSize)
|
||||
return TPM_RCS_SIZE + blamePublic;
|
||||
break;
|
||||
default:
|
||||
// Everything else needs a size of 8
|
||||
if(publicInfo->dataSize != 8)
|
||||
return TPM_RCS_SIZE + blamePublic;
|
||||
break;
|
||||
}
|
||||
// Handle other specifics
|
||||
switch(GET_TPM_NT(attributes))
|
||||
{
|
||||
case TPM_NT_COUNTER:
|
||||
// Counter can't have TPMA_NV_CLEAR_STCLEAR SET (don't clear counters)
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
break;
|
||||
#ifdef TPM_NT_PIN_FAIL
|
||||
case TPM_NT_PIN_FAIL:
|
||||
// NV_NO_DA must be SET and AUTHWRITE must be CLEAR
|
||||
// NOTE: As with a PIN_PASS index, the authValue of the index is not
|
||||
// available until the index is written. If AUTHWRITE is the only way to
|
||||
// write then index, it could never be written. Rather than go through
|
||||
// all of the other possible ways to write the Index, it is simply
|
||||
// prohibited to write the index with the authValue. Other checks
|
||||
// below will insure that there seems to be a way to write the index
|
||||
// (i.e., with platform authorization , owner authorization,
|
||||
// or with policyAuth.)
|
||||
// It is not allowed to create a PIN Index that can't be modified.
|
||||
if(!IS_ATTRIBUTE(attributes, TPMA_NV, NO_DA))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
#endif
|
||||
#ifdef TPM_NT_PIN_PASS
|
||||
case TPM_NT_PIN_PASS:
|
||||
// AUTHWRITE must be CLEAR (see note above to TPM_NT_PIN_FAIL)
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)
|
||||
|| IS_ATTRIBUTE(attributes, TPMA_NV, GLOBALLOCK)
|
||||
|| IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
#endif // this comes before break because PIN_FAIL falls through
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Locks may not be SET and written cannot be SET
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, WRITTEN)
|
||||
|| IS_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED)
|
||||
|| IS_ATTRIBUTE(attributes, TPMA_NV, READLOCKED))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
|
||||
// There must be a way to read the index.
|
||||
if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERREAD)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, PPREAD)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHREAD)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYREAD))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
|
||||
// There must be a way to write the index
|
||||
if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERWRITE)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, PPWRITE)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)
|
||||
&& !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYWRITE))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
|
||||
// An index with TPMA_NV_CLEAR_STCLEAR can't have TPMA_NV_WRITEDEFINE SET
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)
|
||||
&& IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
|
||||
// Make sure that the creator of the index can delete the index
|
||||
if((IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)
|
||||
&& authHandle == TPM_RH_OWNER)
|
||||
|| (!IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)
|
||||
&& authHandle == TPM_RH_PLATFORM))
|
||||
return TPM_RCS_ATTRIBUTES + blameAuthHandle;
|
||||
|
||||
// If TPMA_NV_POLICY_DELETE is SET, then the index must be defined by
|
||||
// the platform
|
||||
if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE)
|
||||
&& TPM_RH_PLATFORM != authHandle)
|
||||
return TPM_RCS_ATTRIBUTES + blamePublic;
|
||||
|
||||
// Make sure that the TPMA_NV_WRITEALL is not set if the index size is larger
|
||||
// than the allowed NV buffer size.
|
||||
if(publicInfo->dataSize > MAX_NV_BUFFER_SIZE
|
||||
&& IS_ATTRIBUTE(attributes, TPMA_NV, WRITEALL))
|
||||
return TPM_RCS_SIZE + blamePublic;
|
||||
|
||||
// And finally, see if the index is already defined.
|
||||
if(NvIndexIsDefined(publicInfo->nvIndex))
|
||||
return TPM_RC_NV_DEFINED;
|
||||
|
||||
// Internal Data Update
|
||||
// define the space. A TPM_RC_NV_SPACE error may be returned at this point
|
||||
return NvDefineIndex(publicInfo, auth);
|
||||
}
|
||||
|
||||
@ -88,4 +88,18 @@ TPM2B_NAME* NvGetIndexName(
|
||||
// computed
|
||||
TPM2B_NAME* name // OUT: name of the index
|
||||
);
|
||||
TPM_RC NvPublic2FromNvPublic(
|
||||
TPMS_NV_PUBLIC* nvPublic, // IN: the source S-form NV public area
|
||||
TPMT_NV_PUBLIC_2* nvPublic2 // OUT: the T-form NV public area to populate
|
||||
);
|
||||
TPM_RC NvPublicFromNvPublic2(
|
||||
TPMT_NV_PUBLIC_2* nvPublic2, // IN: the source T-form NV public area
|
||||
TPMS_NV_PUBLIC* nvPublic // OUT: the S-form NV public area to populate
|
||||
);
|
||||
TPM_RC NvDefineSpace(TPMI_RH_PROVISION authHandle,
|
||||
TPM2B_AUTH* auth,
|
||||
TPMS_NV_PUBLIC* publicInfo,
|
||||
TPM_RC blameAuthHandle,
|
||||
TPM_RC blameAuth,
|
||||
TPM_RC blamePublic);
|
||||
#endif
|
||||
|
||||
@ -188,10 +188,11 @@ static const struct {
|
||||
COMMAND(ECC_Decrypt, true, 3),
|
||||
COMMAND(PolicyCapability, true, 0), // not supported
|
||||
COMMAND(PolicyParameters, true, 0), // not supported
|
||||
COMMAND(NV_DefineSpace2, true, 0), // not supported
|
||||
/* all new commands added here MUST have CAN_BE_DISABLE = true */
|
||||
#undef COMMAND
|
||||
};
|
||||
MUST_BE(TPM_CC_LAST == TPM_CC_PolicyParameters); /* force update of above list when new commands added */
|
||||
MUST_BE(TPM_CC_LAST == TPM_CC_NV_DefineSpace2); /* force update of above list when new commands added */
|
||||
|
||||
static void
|
||||
RuntimeCommandsEnableAllCommands(struct RuntimeCommands *RuntimeCommands,
|
||||
|
||||
@ -346,6 +346,7 @@
|
||||
+ (ADD_FILL || CC_ECC_Decrypt) /* 0x0000019A */ \
|
||||
+ (ADD_FILL || CC_PolicyCapability) /* 0x0000019B */ \
|
||||
+ (ADD_FILL || CC_PolicyParameters) /* 0x0000019C */ \
|
||||
+ (ADD_FILL || CC_NV_DefineSpace2) /* 0x0000019D */ \
|
||||
)
|
||||
|
||||
#define VENDOR_COMMAND_ARRAY_SIZE (0 + CC_Vendor_TCG_Test)
|
||||
|
||||
@ -325,8 +325,6 @@
|
||||
// "external NV" that is stored in the same place as "internal NV."
|
||||
// NOTE: enabling this doesn't necessarily mean that the expanded
|
||||
// (external-NV-specific) attributes are supported.
|
||||
#if 0 // libtpms: added
|
||||
#define EXTERNAL_NV YES
|
||||
#endif // libtpms: added
|
||||
#define EXTERNAL_NV NO
|
||||
|
||||
#endif // _TPM_PROFILE_COMMON_H_
|
||||
|
||||
@ -304,7 +304,8 @@ typedef UINT32 TPM_CC;
|
||||
#define TPM_CC_ECC_Decrypt (TPM_CC)(0x0000019A)
|
||||
#define TPM_CC_PolicyCapability (TPM_CC)(0x0000019B)
|
||||
#define TPM_CC_PolicyParameters (TPM_CC)(0x0000019C)
|
||||
#define TPM_CC_LAST (TPM_CC)(0x0000019C)
|
||||
#define TPM_CC_NV_DefineSpace2 (TPM_CC)(0x0000019D)
|
||||
#define TPM_CC_LAST (TPM_CC)(0x0000019D)
|
||||
#define CC_VEND 0x20000000
|
||||
#define TPM_CC_Vendor_TCG_Test (TPM_CC)(0x20000000)
|
||||
|
||||
@ -696,6 +697,8 @@ typedef UINT8 TPM_HT;
|
||||
#define TPM_HT_LOADED_SESSION (TPM_HT)(0x02)
|
||||
#define TPM_HT_POLICY_SESSION (TPM_HT)(0x03)
|
||||
#define TPM_HT_SAVED_SESSION (TPM_HT)(0x03)
|
||||
#define TPM_HT_EXTERNAL_NV (TPM_HT)(0x11)
|
||||
#define TPM_HT_PERMANENT_NV (TPM_HT)(0x12)
|
||||
#define TPM_HT_PERMANENT (TPM_HT)(0x40)
|
||||
#define TPM_HT_TRANSIENT (TPM_HT)(0x80)
|
||||
#define TPM_HT_PERSISTENT (TPM_HT)(0x81)
|
||||
@ -734,6 +737,8 @@ typedef TPM_HANDLE TPM_HC;
|
||||
#define HR_TRANSIENT (TPM_HC)((((UINT32)TPM_HT_TRANSIENT) << HR_SHIFT))
|
||||
#define HR_PERSISTENT (TPM_HC)((((UINT32)TPM_HT_PERSISTENT) << HR_SHIFT))
|
||||
#define HR_NV_INDEX (TPM_HC)((TPM_HT_NV_INDEX << HR_SHIFT))
|
||||
#define HR_EXTERNAL_NV (TPM_HC)((TPM_HT_EXTERNAL_NV << HR_SHIFT))
|
||||
#define HR_PERMANENT_NV (TPM_HC)((TPM_HT_PERMANENT_NV << HR_SHIFT))
|
||||
#define HR_PERMANENT (TPM_HC)((TPM_HT_PERMANENT << HR_SHIFT))
|
||||
#define PCR_FIRST (TPM_HC)((HR_PCR+0))
|
||||
#define PCR_LAST (TPM_HC)((PCR_FIRST+IMPLEMENTATION_PCR-1))
|
||||
@ -752,6 +757,10 @@ typedef TPM_HANDLE TPM_HC;
|
||||
#define PLATFORM_PERSISTENT (TPM_HC)((PERSISTENT_FIRST+0x00800000))
|
||||
#define NV_INDEX_FIRST (TPM_HC)((HR_NV_INDEX+0))
|
||||
#define NV_INDEX_LAST (TPM_HC)((NV_INDEX_FIRST+0x00FFFFFF))
|
||||
#define EXTERNAL_NV_FIRST (TPM_HC)((HR_EXTERNAL_NV + 0))
|
||||
#define EXTERNAL_NV_LAST (TPM_HC)((EXTERNAL_NV_FIRST + 0x00FFFFFF))
|
||||
#define PERMANENT_NV_FIRST (TPM_HC)((HR_PERMANENT_NV + 0))
|
||||
#define PERMANENT_NV_LAST (TPM_HC)((PERMANENT_NV_FIRST + 0x00FFFFFF))
|
||||
#define PERMANENT_FIRST (TPM_HC)(TPM_RH_FIRST)
|
||||
#define PERMANENT_LAST (TPM_HC)(TPM_RH_LAST)
|
||||
#define HR_NV_AC (TPM_HC)(((TPM_HT_NV_INDEX<<HR_SHIFT)+0xD00000))
|
||||
@ -1311,6 +1320,11 @@ typedef TPM_HANDLE TPMI_RH_NV_AUTH;
|
||||
typedef TPM_HANDLE TPMI_RH_LOCKOUT;
|
||||
/* Table 2:59 - Definition of TPMI_RH_NV_INDEX Type */
|
||||
typedef TPM_HANDLE TPMI_RH_NV_INDEX;
|
||||
|
||||
typedef TPM_HANDLE TPMI_RH_NV_DEFINED_INDEX;
|
||||
typedef TPM_HANDLE TPMI_RH_NV_LEGACY_INDEX;
|
||||
typedef TPM_HANDLE TPMI_RH_NV_EXP_INDEX;
|
||||
|
||||
/* Table 2:60 - Definition of TPMI_RH_AC Type */
|
||||
typedef TPM_HANDLE TPMI_RH_AC;
|
||||
/* Table 2:65 - Definition of TPMI_RH_ACT Type */
|
||||
@ -2385,6 +2399,168 @@ typedef UINT32 TPMA_NV;
|
||||
(platformcreate << 30) + (read_stclear << 31))
|
||||
#endif // USE_BIT_FIELD_STRUCTURES
|
||||
|
||||
// Table "Definition of TPMA_NV_EXP Bits" (Part 2: Structures)
|
||||
#define TYPE_OF_TPMA_NV_EXP UINT64
|
||||
#define TPMA_NV_EXP_TO_UINT64(a) (*((UINT64*)&(a)))
|
||||
#define UINT64_TO_TPMA_NV_EXP(a) (*((TPMA_NV_EXP*)&(a)))
|
||||
#define TPMA_NV_EXP_TO_BYTE_ARRAY(i, a) \
|
||||
UINT64_TO_BYTE_ARRAY((TPMA_NV_EXP_TO_UINT64(i)), (a))
|
||||
#define BYTE_ARRAY_TO_TPMA_NV_EXP(i, a) \
|
||||
{ \
|
||||
UINT64 x = BYTE_ARRAY_TO_UINT64(a); \
|
||||
i = UINT64_TO_TPMA_NV_EXP(x); \
|
||||
}
|
||||
#if USE_BIT_FIELD_STRUCTURES
|
||||
typedef struct
|
||||
{
|
||||
unsigned TPMA_NV_PPWRITE : 1;
|
||||
unsigned TPMA_NV_OWNERWRITE : 1;
|
||||
unsigned TPMA_NV_AUTHWRITE : 1;
|
||||
unsigned TPMA_NV_POLICYWRITE : 1;
|
||||
unsigned TPM_NT : 4;
|
||||
unsigned Reserved_bits_at_8 : 2;
|
||||
unsigned TPMA_NV_POLICY_DELETE : 1;
|
||||
unsigned TPMA_NV_WRITELOCKED : 1;
|
||||
unsigned TPMA_NV_WRITEALL : 1;
|
||||
unsigned TPMA_NV_WRITEDEFINE : 1;
|
||||
unsigned TPMA_NV_WRITE_STCLEAR : 1;
|
||||
unsigned TPMA_NV_GLOBALLOCK : 1;
|
||||
unsigned TPMA_NV_PPREAD : 1;
|
||||
unsigned TPMA_NV_OWNERREAD : 1;
|
||||
unsigned TPMA_NV_AUTHREAD : 1;
|
||||
unsigned TPMA_NV_POLICYREAD : 1;
|
||||
unsigned Reserved_bits_at_20 : 5;
|
||||
unsigned TPMA_NV_NO_DA : 1;
|
||||
unsigned TPMA_NV_ORDERLY : 1;
|
||||
unsigned TPMA_NV_CLEAR_STCLEAR : 1;
|
||||
unsigned TPMA_NV_READLOCKED : 1;
|
||||
unsigned TPMA_NV_WRITTEN : 1;
|
||||
unsigned TPMA_NV_PLATFORMCREATE : 1;
|
||||
unsigned TPMA_NV_READ_STCLEAR : 1;
|
||||
unsigned TPMA_EXTERNAL_NV_ENCRYPTION : 1;
|
||||
unsigned TPMA_EXTERNAL_NV_INTEGRITY : 1;
|
||||
unsigned TPMA_EXTERNAL_NV_ANTIROLLBACK : 1;
|
||||
unsigned Reserved_bits_at_35 : 29;
|
||||
} TPMA_NV_EXP;
|
||||
|
||||
// Initializer for the bit-field structure
|
||||
# define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite, \
|
||||
tpma_nv_ownerwrite, \
|
||||
tpma_nv_authwrite, \
|
||||
tpma_nv_policywrite, \
|
||||
tpm_nt, \
|
||||
bits_at_8, \
|
||||
tpma_nv_policy_delete, \
|
||||
tpma_nv_writelocked, \
|
||||
tpma_nv_writeall, \
|
||||
tpma_nv_writedefine, \
|
||||
tpma_nv_write_stclear, \
|
||||
tpma_nv_globallock, \
|
||||
tpma_nv_ppread, \
|
||||
tpma_nv_ownerread, \
|
||||
tpma_nv_authread, \
|
||||
tpma_nv_policyread, \
|
||||
bits_at_20, \
|
||||
tpma_nv_no_da, \
|
||||
tpma_nv_orderly, \
|
||||
tpma_nv_clear_stclear, \
|
||||
tpma_nv_readlocked, \
|
||||
tpma_nv_written, \
|
||||
tpma_nv_platformcreate, \
|
||||
tpma_nv_read_stclear, \
|
||||
tpma_external_nv_encryption, \
|
||||
tpma_external_nv_integrity, \
|
||||
tpma_external_nv_antirollback, \
|
||||
bits_at_35) \
|
||||
{ \
|
||||
tpma_nv_ppwrite, tpma_nv_ownerwrite, tpma_nv_authwrite, \
|
||||
tpma_nv_policywrite, tpm_nt, bits_at_8, tpma_nv_policy_delete, \
|
||||
tpma_nv_writelocked, tpma_nv_writeall, tpma_nv_writedefine, \
|
||||
tpma_nv_write_stclear, tpma_nv_globallock, tpma_nv_ppread, \
|
||||
tpma_nv_ownerread, tpma_nv_authread, tpma_nv_policyread, bits_at_20, \
|
||||
tpma_nv_no_da, tpma_nv_orderly, tpma_nv_clear_stclear, \
|
||||
tpma_nv_readlocked, tpma_nv_written, tpma_nv_platformcreate, \
|
||||
tpma_nv_read_stclear, tpma_external_nv_encryption, \
|
||||
tpma_external_nv_integrity, tpma_external_nv_antirollback, bits_at_35 \
|
||||
}
|
||||
#else // USE_BIT_FIELD_STRUCTURES
|
||||
|
||||
// This implements Table "Definition of TPMA_NV_EXP Bits" (Part 2: Structures) using bit masking
|
||||
typedef UINT64 TPMA_NV_EXP;
|
||||
# define TPMA_NV_EXP_TPMA_NV_PPWRITE (TPMA_NV_EXP)(1 << 0)
|
||||
# define TPMA_NV_EXP_TPMA_NV_OWNERWRITE (TPMA_NV_EXP)(1 << 1)
|
||||
# define TPMA_NV_EXP_TPMA_NV_AUTHWRITE (TPMA_NV_EXP)(1 << 2)
|
||||
# define TPMA_NV_EXP_TPMA_NV_POLICYWRITE (TPMA_NV_EXP)(1 << 3)
|
||||
# define TPMA_NV_EXP_TPM_NT (TPMA_NV_EXP)(0xF << 4)
|
||||
# define TPMA_NV_EXP_TPM_NT_SHIFT 4
|
||||
# define TPMA_NV_EXP_TPMA_NV_POLICY_DELETE (TPMA_NV_EXP)(1 << 10)
|
||||
# define TPMA_NV_EXP_TPMA_NV_WRITELOCKED (TPMA_NV_EXP)(1 << 11)
|
||||
# define TPMA_NV_EXP_TPMA_NV_WRITEALL (TPMA_NV_EXP)(1 << 12)
|
||||
# define TPMA_NV_EXP_TPMA_NV_WRITEDEFINE (TPMA_NV_EXP)(1 << 13)
|
||||
# define TPMA_NV_EXP_TPMA_NV_WRITE_STCLEAR (TPMA_NV_EXP)(1 << 14)
|
||||
# define TPMA_NV_EXP_TPMA_NV_GLOBALLOCK (TPMA_NV_EXP)(1 << 15)
|
||||
# define TPMA_NV_EXP_TPMA_NV_PPREAD (TPMA_NV_EXP)(1 << 16)
|
||||
# define TPMA_NV_EXP_TPMA_NV_OWNERREAD (TPMA_NV_EXP)(1 << 17)
|
||||
# define TPMA_NV_EXP_TPMA_NV_AUTHREAD (TPMA_NV_EXP)(1 << 18)
|
||||
# define TPMA_NV_EXP_TPMA_NV_POLICYREAD (TPMA_NV_EXP)(1 << 19)
|
||||
# define TPMA_NV_EXP_TPMA_NV_NO_DA (TPMA_NV_EXP)(1 << 25)
|
||||
# define TPMA_NV_EXP_TPMA_NV_ORDERLY (TPMA_NV_EXP)(1 << 26)
|
||||
# define TPMA_NV_EXP_TPMA_NV_CLEAR_STCLEAR (TPMA_NV_EXP)(1 << 27)
|
||||
# define TPMA_NV_EXP_TPMA_NV_READLOCKED (TPMA_NV_EXP)(1 << 28)
|
||||
# define TPMA_NV_EXP_TPMA_NV_WRITTEN (TPMA_NV_EXP)(1 << 29)
|
||||
# define TPMA_NV_EXP_TPMA_NV_PLATFORMCREATE (TPMA_NV_EXP)(1 << 30)
|
||||
# define TPMA_NV_EXP_TPMA_NV_READ_STCLEAR (TPMA_NV_EXP)(1 << 31)
|
||||
# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ENCRYPTION (TPMA_NV_EXP)(1 << 32)
|
||||
# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_INTEGRITY (TPMA_NV_EXP)(1 << 33)
|
||||
# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ANTIROLLBACK (TPMA_NV_EXP)(1 << 34)
|
||||
# define TPMA_NV_EXP_reserved 0xfffffff800000000L
|
||||
|
||||
// This is the initializer for a TPMA_NV_EXP bit array.
|
||||
# define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite, \
|
||||
tpma_nv_ownerwrite, \
|
||||
tpma_nv_authwrite, \
|
||||
tpma_nv_policywrite, \
|
||||
tpm_nt, \
|
||||
bits_at_8, \
|
||||
tpma_nv_policy_delete, \
|
||||
tpma_nv_writelocked, \
|
||||
tpma_nv_writeall, \
|
||||
tpma_nv_writedefine, \
|
||||
tpma_nv_write_stclear, \
|
||||
tpma_nv_globallock, \
|
||||
tpma_nv_ppread, \
|
||||
tpma_nv_ownerread, \
|
||||
tpma_nv_authread, \
|
||||
tpma_nv_policyread, \
|
||||
bits_at_20, \
|
||||
tpma_nv_no_da, \
|
||||
tpma_nv_orderly, \
|
||||
tpma_nv_clear_stclear, \
|
||||
tpma_nv_readlocked, \
|
||||
tpma_nv_written, \
|
||||
tpma_nv_platformcreate, \
|
||||
tpma_nv_read_stclear, \
|
||||
tpma_external_nv_encryption, \
|
||||
tpma_external_nv_integrity, \
|
||||
tpma_external_nv_antirollback, \
|
||||
bits_at_35) \
|
||||
(TPMA_NV_EXP)((tpma_nv_ppwrite << 0) + (tpma_nv_ownerwrite << 1) \
|
||||
+ (tpma_nv_authwrite << 2) + (tpma_nv_policywrite << 3) \
|
||||
+ (tpm_nt << 4) + (tpma_nv_policy_delete << 10) \
|
||||
+ (tpma_nv_writelocked << 11) + (tpma_nv_writeall << 12) \
|
||||
+ (tpma_nv_writedefine << 13) + (tpma_nv_write_stclear << 14) \
|
||||
+ (tpma_nv_globallock << 15) + (tpma_nv_ppread << 16) \
|
||||
+ (tpma_nv_ownerread << 17) + (tpma_nv_authread << 18) \
|
||||
+ (tpma_nv_policyread << 19) + (tpma_nv_no_da << 25) \
|
||||
+ (tpma_nv_orderly << 26) + (tpma_nv_clear_stclear << 27) \
|
||||
+ (tpma_nv_readlocked << 28) + (tpma_nv_written << 29) \
|
||||
+ (tpma_nv_platformcreate << 30) + (tpma_nv_read_stclear << 31) \
|
||||
+ (tpma_external_nv_encryption << 32) \
|
||||
+ (tpma_external_nv_integrity << 33) \
|
||||
+ (tpma_external_nv_antirollback << 34))
|
||||
|
||||
#endif // USE_BIT_FIELD_STRUCTURES
|
||||
|
||||
/* Table 2:209 - Definition of TPMS_NV_PUBLIC Structure */
|
||||
typedef struct {
|
||||
TPMI_RH_NV_INDEX nvIndex;
|
||||
@ -2398,6 +2574,30 @@ typedef struct {
|
||||
UINT16 size;
|
||||
TPMS_NV_PUBLIC nvPublic;
|
||||
} TPM2B_NV_PUBLIC;
|
||||
typedef struct
|
||||
{
|
||||
TPMI_RH_NV_EXP_INDEX nvIndex;
|
||||
TPMI_ALG_HASH nameAlg;
|
||||
TPMA_NV_EXP attributes;
|
||||
TPM2B_DIGEST authPolicy;
|
||||
UINT16 dataSize;
|
||||
} TPMS_NV_PUBLIC_EXP_ATTR;
|
||||
typedef union
|
||||
{
|
||||
TPMS_NV_PUBLIC nvIndex;
|
||||
TPMS_NV_PUBLIC_EXP_ATTR externalNV;
|
||||
TPMS_NV_PUBLIC permanentNV;
|
||||
} TPMU_NV_PUBLIC_2;
|
||||
typedef struct
|
||||
{
|
||||
TPM_HT handleType;
|
||||
TPMU_NV_PUBLIC_2 nvPublic2;
|
||||
} TPMT_NV_PUBLIC_2;
|
||||
typedef struct
|
||||
{
|
||||
UINT16 size;
|
||||
TPMT_NV_PUBLIC_2 nvPublic2;
|
||||
} TPM2B_NV_PUBLIC_2;
|
||||
/* Table 2:208 - Definition of TPM2B_CONTEXT_SENSITIVE Structure */
|
||||
typedef union {
|
||||
struct {
|
||||
|
||||
@ -1163,6 +1163,56 @@ TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size)
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);
|
||||
BOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);
|
||||
BOOL isNotPermamentNV = (*target < PERMANENT_NV_FIRST) || (*target > PERMANENT_NV_LAST);
|
||||
|
||||
if (isNotNv &&
|
||||
isNotExternalNV &&
|
||||
isNotPermamentNV) {
|
||||
rc = TPM_RC_VALUE;
|
||||
*target = orig_target; // libtpms added
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 67 - Definition of (TPM_HANDLE) TPMI_RH_NV_DEFINED_INDEX Type <IN> */
|
||||
|
||||
TPM_RC
|
||||
TPMI_RH_NV_DEFINED_INDEX_Unmarshal(TPMI_RH_NV_DEFINED_INDEX *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
TPMI_RH_NV_DEFINED_INDEX orig_target = *target; // libtpms added
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPM_HANDLE_Unmarshal(target, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);
|
||||
BOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);
|
||||
|
||||
if (isNotNv &&
|
||||
isNotExternalNV) {
|
||||
rc = TPM_RC_VALUE;
|
||||
*target = orig_target; // libtpms added
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 68 - Definition of (TPM_HANDLE) TPMI_RH_NV_LEGACY_INDEX Type <IN/OUT> */
|
||||
TPM_RC
|
||||
TPMI_RH_NV_LEGACY_INDEX_Unmarshal(TPMI_RH_NV_LEGACY_INDEX *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
TPMI_RH_NV_LEGACY_INDEX orig_target = *target; // libtpms added
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPM_HANDLE_Unmarshal(target, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);
|
||||
|
||||
if (isNotNv) {
|
||||
rc = TPM_RC_VALUE;
|
||||
*target = orig_target; // libtpms added
|
||||
@ -1171,6 +1221,28 @@ TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 69 - Definition of (TPM_HANDLE) TPMI_RH_NV_EXP_INDEX Type <IN/OUT> */
|
||||
|
||||
TPM_RC
|
||||
TPMI_RH_NV_EXP_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
TPMI_RH_NV_EXP_INDEX orig_target = *target; // libtpms added
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPM_HANDLE_Unmarshal(target, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
BOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);
|
||||
|
||||
if (isNotExternalNV) {
|
||||
rc = TPM_RC_VALUE;
|
||||
*target = orig_target; // libtpms added
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 64 - Definition of (TPM_HANDLE) TPMI_RH_AC Type <IN> */
|
||||
|
||||
TPM_RC
|
||||
@ -4626,6 +4698,121 @@ TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 226 - Definition of (UINT64) TPMA_NV_EXP Bits */
|
||||
|
||||
TPM_RC
|
||||
TPMA_NV_EXP_Unmarshal(TPMA_NV_EXP *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = UINT64_Unmarshal(target, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
if (*target & TPMA_NV_EXP_reserved) {
|
||||
rc = TPM_RC_RESERVED_BITS;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 229 - Definition of TPMS_NV_PUBLIC_EXP_ATTR Structure */
|
||||
|
||||
TPM_RC
|
||||
TPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(TPMS_NV_PUBLIC_EXP_ATTR *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPMI_RH_NV_EXP_INDEX_Unmarshal(&target->nvIndex, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPMI_ALG_HASH_Unmarshal(&target->nameAlg, buffer, size, NO);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPMA_NV_EXP_Unmarshal(&target->attributes, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPM2B_DIGEST_Unmarshal(&target->authPolicy, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = UINT16_Unmarshal(&target->dataSize, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
if (target->dataSize > MAX_NV_INDEX_SIZE) {
|
||||
rc = TPM_RC_SIZE;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 230 - Definition of TPMU_NV_PUBLIC_2 Union */
|
||||
|
||||
TPM_RC
|
||||
TPMU_NV_PUBLIC_2_Unmarshal( TPMU_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size, UINT8 selector)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
|
||||
switch (selector) {
|
||||
case TPM_HT_NV_INDEX:
|
||||
rc = TPMS_NV_PUBLIC_Unmarshal(&target->nvIndex, buffer, size);
|
||||
break;
|
||||
case TPM_HT_EXTERNAL_NV:
|
||||
rc = TPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(&target->externalNV, buffer, size);
|
||||
break;
|
||||
case TPM_HT_PERMANENT_NV:
|
||||
rc = TPMS_NV_PUBLIC_Unmarshal(&target->permanentNV, buffer, size);
|
||||
break;
|
||||
default:
|
||||
rc = TPM_RC_SELECTOR;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 231 - Definition of TPMT_NV_PUBLIC_2 Structure */
|
||||
|
||||
TPM_RC
|
||||
TPMT_NV_PUBLIC_2_Unmarshal(TPMT_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = UINT8_Unmarshal(&target->handleType, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPMU_NV_PUBLIC_2_Unmarshal(&target->nvPublic2, buffer, size, target->handleType);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Table 232 - Definition of TPM2B_NV_PUBLIC_2 Structure */
|
||||
TPM_RC
|
||||
TPM2B_NV_PUBLIC_2_Unmarshal(TPM2B_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size)
|
||||
{
|
||||
TPM_RC rc = TPM_RC_SUCCESS;
|
||||
|
||||
INT32 startSize;
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = UINT16_Unmarshal(&target->size, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
if (target->size == 0) {
|
||||
rc = TPM_RC_SIZE;
|
||||
}
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
startSize = *size;
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
rc = TPMT_NV_PUBLIC_2_Unmarshal(&target->nvPublic2, buffer, size);
|
||||
}
|
||||
if (rc == TPM_RC_SUCCESS) {
|
||||
if (target->size != startSize - *size) {
|
||||
rc = TPM_RC_SIZE;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */
|
||||
|
||||
#if 0 // libtpms added
|
||||
|
||||
@ -169,6 +169,14 @@ extern "C" {
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_NV_DEFINED_INDEX_Unmarshal(TPMI_RH_NV_DEFINED_INDEX *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_NV_LEGACY_INDEX_Unmarshal(TPMI_RH_NV_LEGACY_INDEX *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_NV_EXP_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_AC_Unmarshal(TPMI_RH_AC *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMI_RH_ACT_Unmarshal(TPMI_RH_ACT *target, BYTE **buffer, INT32 *size);
|
||||
@ -463,8 +471,18 @@ extern "C" {
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMA_NV_EXP_Unmarshal(TPMA_NV_EXP *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(TPMS_NV_PUBLIC_EXP_ATTR *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMU_NV_PUBLIC_2_Unmarshal( TPMU_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size, UINT8 selector);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPMT_NV_PUBLIC_2_Unmarshal(TPMT_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPM2B_NV_PUBLIC_2_Unmarshal(TPM2B_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size);
|
||||
LIB_EXPORT TPM_RC
|
||||
TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user