X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FInclude%2FIndustryStandard%2FTpm12.h;h=5bcc16ca7e3cef3b28d008860104a17346ceb8af;hb=e2a5ae07669c0863c58b51939fe48540fe597b29;hp=1d489815ca7a16e195d871dfc7f79ca714df3547;hpb=65a8ca8c1767e4b6d9106c3ef2809a2ef4a9567a;p=mirror_edk2.git diff --git a/MdePkg/Include/IndustryStandard/Tpm12.h b/MdePkg/Include/IndustryStandard/Tpm12.h index 1d489815ca..5bcc16ca7e 100644 --- a/MdePkg/Include/IndustryStandard/Tpm12.h +++ b/MdePkg/Include/IndustryStandard/Tpm12.h @@ -1,85 +1,208 @@ -/*++ - -Copyright (c) 2005 - 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Tpm12.h - -Abstract: +/** @file + TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103) + See http://trustedcomputinggroup.org for latest specification updates - TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 94) + Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php - See http://trustedcomputinggroup.org for latest specification updates + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ ---*/ #ifndef _TPM12_H_ #define _TPM12_H_ -// -// The start of TPM return codes -// -#define TPM_BASE (EFI_MAX_BIT + (EFI_MAX_BIT >> 1)) +/// +/// The start of TPM return codes +/// +#define TPM_BASE 0 // -// Structures are all packed on 1-byte alignment +// All structures MUST be packed on a byte boundary. // -#pragma pack (push) #pragma pack (1) // -// Part 2, section 2.2: Basic types & Helper redefinitions +// Part 2, section 2.2.3: Helper redefinitions // +/// +/// Indicates the conditions where it is required that authorization be presented +/// typedef UINT8 TPM_AUTH_DATA_USAGE; +/// +/// The information as to what the payload is in an encrypted structure +/// typedef UINT8 TPM_PAYLOAD_TYPE; +/// +/// The version info breakdown +/// typedef UINT8 TPM_VERSION_BYTE; +/// +/// The state of the dictionary attack mitigation logic +/// +typedef UINT8 TPM_DA_STATE; +/// +/// The request or response authorization type +/// typedef UINT16 TPM_TAG; +/// +/// The protocol in use +/// typedef UINT16 TPM_PROTOCOL_ID; +/// +/// Indicates the start state +/// typedef UINT16 TPM_STARTUP_TYPE; +/// +/// The definition of the encryption scheme +/// typedef UINT16 TPM_ENC_SCHEME; +/// +/// The definition of the signature scheme +/// typedef UINT16 TPM_SIG_SCHEME; +/// +/// The definition of the migration scheme +/// typedef UINT16 TPM_MIGRATE_SCHEME; +/// +/// Sets the state of the physical presence mechanism +/// typedef UINT16 TPM_PHYSICAL_PRESENCE; +/// +/// Indicates the types of entity that are supported by the TPM +/// typedef UINT16 TPM_ENTITY_TYPE; +/// +/// Indicates the permitted usage of the key +/// typedef UINT16 TPM_KEY_USAGE; +/// +/// The type of asymmetric encrypted structure in use by the endorsement key +/// typedef UINT16 TPM_EK_TYPE; +/// +/// The tag for the structure +/// typedef UINT16 TPM_STRUCTURE_TAG; +/// +/// The platform specific spec to which the information relates to +/// typedef UINT16 TPM_PLATFORM_SPECIFIC; +/// +/// The command ordinal +/// typedef UINT32 TPM_COMMAND_CODE; +/// +/// Identifies a TPM capability area +/// typedef UINT32 TPM_CAPABILITY_AREA; +/// +/// Indicates information regarding a key +/// typedef UINT32 TPM_KEY_FLAGS; +/// +/// Indicates the type of algorithm +/// typedef UINT32 TPM_ALGORITHM_ID; +/// +/// The locality modifier +/// typedef UINT32 TPM_MODIFIER_INDICATOR; +/// +/// The actual number of a counter +/// typedef UINT32 TPM_ACTUAL_COUNT; +/// +/// Attributes that define what options are in use for a transport session +/// typedef UINT32 TPM_TRANSPORT_ATTRIBUTES; +/// +/// Handle to an authorization session +/// typedef UINT32 TPM_AUTHHANDLE; +/// +/// Index to a DIR register +/// typedef UINT32 TPM_DIRINDEX; +/// +/// The area where a key is held assigned by the TPM +/// typedef UINT32 TPM_KEY_HANDLE; +/// +/// Index to a PCR register +/// typedef UINT32 TPM_PCRINDEX; +/// +/// The return code from a function +/// typedef UINT32 TPM_RESULT; +/// +/// The types of resources that a TPM may have using internal resources +/// typedef UINT32 TPM_RESOURCE_TYPE; +/// +/// Allows for controlling of the key when loaded and how to handle TPM_Startup issues +/// typedef UINT32 TPM_KEY_CONTROL; +/// +/// The index into the NV storage area +/// typedef UINT32 TPM_NV_INDEX; +/// +/// The family ID. Family IDs are automatically assigned a sequence number by the TPM. +/// A trusted process can set the FamilyID value in an individual row to NULL, which +/// invalidates that row. The family ID resets to NULL on each change of TPM Owner. +/// typedef UINT32 TPM_FAMILY_ID; +/// +/// IA value used as a label for the most recent verification of this family. Set to zero when not in use. +/// typedef UINT32 TPM_FAMILY_VERIFICATION; +/// +/// How the TPM handles var +/// typedef UINT32 TPM_STARTUP_EFFECTS; +/// +/// The mode of a symmetric encryption +/// typedef UINT32 TPM_SYM_MODE; +/// +/// The family flags +/// typedef UINT32 TPM_FAMILY_FLAGS; +/// +/// The index value for the delegate NV table +/// typedef UINT32 TPM_DELEGATE_INDEX; +/// +/// The restrictions placed on delegation of CMK commands +/// typedef UINT32 TPM_CMK_DELEGATE; +/// +/// The ID value of a monotonic counter +/// typedef UINT32 TPM_COUNT_ID; +/// +/// A command to execute +/// typedef UINT32 TPM_REDIT_COMMAND; +/// +/// A transport session handle +/// typedef UINT32 TPM_TRANSHANDLE; +/// +/// A generic handle could be key, transport etc +/// typedef UINT32 TPM_HANDLE; +/// +/// What operation is happening +/// typedef UINT32 TPM_FAMILY_OPERATION; // @@ -91,7 +214,7 @@ typedef UINT32 TPM_FAMILY_OPERATION; #define TPM_Vendor_Specific8 ((UINT8) 0x80) // -// Part 2, section 3.1: Structure TAGs +// Part 2, section 3.1: TPM_STRUCTURE_TAG // #define TPM_TAG_CONTEXTBLOB ((TPM_STRUCTURE_TAG) 0x0001) #define TPM_TAG_CONTEXT_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0002) @@ -147,6 +270,9 @@ typedef UINT32 TPM_FAMILY_OPERATION; #define TPM_TAG_CMK_SIGTICKET ((TPM_STRUCTURE_TAG) 0x0034) #define TPM_TAG_CMK_MA_APPROVAL ((TPM_STRUCTURE_TAG) 0x0035) #define TPM_TAG_QUOTE_INFO2 ((TPM_STRUCTURE_TAG) 0x0036) +#define TPM_TAG_DA_INFO ((TPM_STRUCTURE_TAG) 0x0037) +#define TPM_TAG_DA_LIMITED ((TPM_STRUCTURE_TAG) 0x0038) +#define TPM_TAG_DA_ACTION_TYPE ((TPM_STRUCTURE_TAG) 0x0039) // // Part 2, section 4: TPM Types @@ -155,68 +281,69 @@ typedef UINT32 TPM_FAMILY_OPERATION; // // Part 2, section 4.1: TPM_RESOURCE_TYPE // -#define TPM_RT_KEY ((TPM_RESOURCE_TYPE) 0x00000001) // The handle is a key handle and is the result of a LoadKey type operation -#define TPM_RT_AUTH ((TPM_RESOURCE_TYPE) 0x00000002) // The handle is an authorization handle. Auth handles come from TPM_OIAP, TPM_OSAP and TPM_DSAP -#define TPM_RT_HASH ((TPM_RESOURCE_TYPE) 0x00000003) // Reserved for hashes -#define TPM_RT_TRANS ((TPM_RESOURCE_TYPE) 0x00000004) // The handle is for a transport session. Transport handles come from TPM_EstablishTransport -#define TPM_RT_CONTEXT ((TPM_RESOURCE_TYPE) 0x00000005) // Resource wrapped and held outside the TPM using the context save/restore commands -#define TPM_RT_COUNTER ((TPM_RESOURCE_TYPE) 0x00000006) // Reserved for counters -#define TPM_RT_DELEGATE ((TPM_RESOURCE_TYPE) 0x00000007) // The handle is for a delegate row. These are the internal rows held in NV storage by the TPM -#define TPM_RT_DAA_TPM ((TPM_RESOURCE_TYPE) 0x00000008) // The value is a DAA TPM specific blob -#define TPM_RT_DAA_V0 ((TPM_RESOURCE_TYPE) 0x00000009) // The value is a DAA V0 parameter -#define TPM_RT_DAA_V1 ((TPM_RESOURCE_TYPE) 0x0000000A) // The value is a DAA V1 parameter +#define TPM_RT_KEY ((TPM_RESOURCE_TYPE) 0x00000001) ///< The handle is a key handle and is the result of a LoadKey type operation +#define TPM_RT_AUTH ((TPM_RESOURCE_TYPE) 0x00000002) ///< The handle is an authorization handle. Auth handles come from TPM_OIAP, TPM_OSAP and TPM_DSAP +#define TPM_RT_HASH ((TPM_RESOURCE_TYPE) 0x00000003) ///< Reserved for hashes +#define TPM_RT_TRANS ((TPM_RESOURCE_TYPE) 0x00000004) ///< The handle is for a transport session. Transport handles come from TPM_EstablishTransport +#define TPM_RT_CONTEXT ((TPM_RESOURCE_TYPE) 0x00000005) ///< Resource wrapped and held outside the TPM using the context save/restore commands +#define TPM_RT_COUNTER ((TPM_RESOURCE_TYPE) 0x00000006) ///< Reserved for counters +#define TPM_RT_DELEGATE ((TPM_RESOURCE_TYPE) 0x00000007) ///< The handle is for a delegate row. These are the internal rows held in NV storage by the TPM +#define TPM_RT_DAA_TPM ((TPM_RESOURCE_TYPE) 0x00000008) ///< The value is a DAA TPM specific blob +#define TPM_RT_DAA_V0 ((TPM_RESOURCE_TYPE) 0x00000009) ///< The value is a DAA V0 parameter +#define TPM_RT_DAA_V1 ((TPM_RESOURCE_TYPE) 0x0000000A) ///< The value is a DAA V1 parameter // // Part 2, section 4.2: TPM_PAYLOAD_TYPE // -#define TPM_PT_ASYM ((TPM_PAYLOAD_TYPE) 0x01) // The entity is an asymmetric key -#define TPM_PT_BIND ((TPM_PAYLOAD_TYPE) 0x02) // The entity is bound data -#define TPM_PT_MIGRATE ((TPM_PAYLOAD_TYPE) 0x03) // The entity is a migration blob -#define TPM_PT_MAINT ((TPM_PAYLOAD_TYPE) 0x04) // The entity is a maintenance blob -#define TPM_PT_SEAL ((TPM_PAYLOAD_TYPE) 0x05) // The entity is sealed data -#define TPM_PT_MIGRATE_RESTRICTED ((TPM_PAYLOAD_TYPE) 0x06) // The entity is a restricted-migration asymmetric key -#define TPM_PT_MIGRATE_EXTERNAL ((TPM_PAYLOAD_TYPE) 0x07) // The entity is a external migratable key -#define TPM_PT_CMK_MIGRATE ((TPM_PAYLOAD_TYPE) 0x08) // The entity is a CMK migratable blob -#define TPM_PT_VENDOR_SPECIFIC ((TPM_PAYLOAD_TYPE) 0x80) // 0x80 - 0xFF Vendor specific payloads - -// -// Part 2, section 4.3: TPM_ENTIRY_TYPE -// -#define TPM_ET_KEYHANDLE ((UINT16) 0x0001) // The entity is a keyHandle or key -#define TPM_ET_OWNER ((UINT16) 0x0002) // The entity is the TPM Owner -#define TPM_ET_DATA ((UINT16) 0x0003) // The entity is some data -#define TPM_ET_SRK ((UINT16) 0x0004) // The entity is the SRK -#define TPM_ET_KEY ((UINT16) 0x0005) // The entity is a key or keyHandle -#define TPM_ET_REVOKE ((UINT16) 0x0006) // The entity is the RevokeTrust value -#define TPM_ET_DEL_OWNER_BLOB ((UINT16) 0x0007) // The entity is a delegate owner blob -#define TPM_ET_DEL_ROW ((UINT16) 0x0008) // The entity is a delegate row -#define TPM_ET_DEL_KEY_BLOB ((UINT16) 0x0009) // The entity is a delegate key blob -#define TPM_ET_COUNTER ((UINT16) 0x000A) // The entity is a counter -#define TPM_ET_NV ((UINT16) 0x000B) // The entity is a NV index -#define TPM_ET_RESERVED_HANDLE ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting. +#define TPM_PT_ASYM ((TPM_PAYLOAD_TYPE) 0x01) ///< The entity is an asymmetric key +#define TPM_PT_BIND ((TPM_PAYLOAD_TYPE) 0x02) ///< The entity is bound data +#define TPM_PT_MIGRATE ((TPM_PAYLOAD_TYPE) 0x03) ///< The entity is a migration blob +#define TPM_PT_MAINT ((TPM_PAYLOAD_TYPE) 0x04) ///< The entity is a maintenance blob +#define TPM_PT_SEAL ((TPM_PAYLOAD_TYPE) 0x05) ///< The entity is sealed data +#define TPM_PT_MIGRATE_RESTRICTED ((TPM_PAYLOAD_TYPE) 0x06) ///< The entity is a restricted-migration asymmetric key +#define TPM_PT_MIGRATE_EXTERNAL ((TPM_PAYLOAD_TYPE) 0x07) ///< The entity is a external migratable key +#define TPM_PT_CMK_MIGRATE ((TPM_PAYLOAD_TYPE) 0x08) ///< The entity is a CMK migratable blob +#define TPM_PT_VENDOR_SPECIFIC ((TPM_PAYLOAD_TYPE) 0x80) ///< 0x80 - 0xFF Vendor specific payloads + +// +// Part 2, section 4.3: TPM_ENTITY_TYPE +// +#define TPM_ET_KEYHANDLE ((UINT16) 0x0001) ///< The entity is a keyHandle or key +#define TPM_ET_OWNER ((UINT16) 0x0002) ///< The entity is the TPM Owner +#define TPM_ET_DATA ((UINT16) 0x0003) ///< The entity is some data +#define TPM_ET_SRK ((UINT16) 0x0004) ///< The entity is the SRK +#define TPM_ET_KEY ((UINT16) 0x0005) ///< The entity is a key or keyHandle +#define TPM_ET_REVOKE ((UINT16) 0x0006) ///< The entity is the RevokeTrust value +#define TPM_ET_DEL_OWNER_BLOB ((UINT16) 0x0007) ///< The entity is a delegate owner blob +#define TPM_ET_DEL_ROW ((UINT16) 0x0008) ///< The entity is a delegate row +#define TPM_ET_DEL_KEY_BLOB ((UINT16) 0x0009) ///< The entity is a delegate key blob +#define TPM_ET_COUNTER ((UINT16) 0x000A) ///< The entity is a counter +#define TPM_ET_NV ((UINT16) 0x000B) ///< The entity is a NV index +#define TPM_ET_OPERATOR ((UINT16) 0x000C) ///< The entity is the operator +#define TPM_ET_RESERVED_HANDLE ((UINT16) 0x0040) ///< Reserved. This value avoids collisions with the handle MSB setting. // // TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable // -#define TPM_ET_XOR ((UINT16) 0x0000) // ADIP encryption scheme: XOR -#define TPM_ET_AES128 ((UINT16) 0x0006) // ADIP encryption scheme: AES 128 bits +#define TPM_ET_XOR ((UINT16) 0x0000) ///< ADIP encryption scheme: XOR +#define TPM_ET_AES128 ((UINT16) 0x0006) ///< ADIP encryption scheme: AES 128 bits // // Part 2, section 4.4.1: Reserved Key Handles // -#define TPM_KH_SRK ((TPM_KEY_HANDLE) 0x40000000) // The handle points to the SRK -#define TPM_KH_OWNER ((TPM_KEY_HANDLE) 0x40000001) // The handle points to the TPM Owner -#define TPM_KH_REVOKE ((TPM_KEY_HANDLE) 0x40000002) // The handle points to the RevokeTrust value -#define TPM_KH_TRANSPORT ((TPM_KEY_HANDLE) 0x40000003) // The handle points to the EstablishTransport static authorization -#define TPM_KH_OPERATOR ((TPM_KEY_HANDLE) 0x40000004) // The handle points to the Operator auth -#define TPM_KH_ADMIN ((TPM_KEY_HANDLE) 0x40000005) // The handle points to the delegation administration auth -#define TPM_KH_EK ((TPM_KEY_HANDLE) 0x40000006) // The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub +#define TPM_KH_SRK ((TPM_KEY_HANDLE) 0x40000000) ///< The handle points to the SRK +#define TPM_KH_OWNER ((TPM_KEY_HANDLE) 0x40000001) ///< The handle points to the TPM Owner +#define TPM_KH_REVOKE ((TPM_KEY_HANDLE) 0x40000002) ///< The handle points to the RevokeTrust value +#define TPM_KH_TRANSPORT ((TPM_KEY_HANDLE) 0x40000003) ///< The handle points to the EstablishTransport static authorization +#define TPM_KH_OPERATOR ((TPM_KEY_HANDLE) 0x40000004) ///< The handle points to the Operator auth +#define TPM_KH_ADMIN ((TPM_KEY_HANDLE) 0x40000005) ///< The handle points to the delegation administration auth +#define TPM_KH_EK ((TPM_KEY_HANDLE) 0x40000006) ///< The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub // // Part 2, section 4.5: TPM_STARTUP_TYPE // -#define TPM_ST_CLEAR ((TPM_STARTUP_TYPE) 0x0001) // The TPM is starting up from a clean state -#define TPM_ST_STATE ((TPM_STARTUP_TYPE) 0x0002) // The TPM is starting up from a saved state -#define TPM_ST_DEACTIVATED ((TPM_STARTUP_TYPE) 0x0003) // The TPM is to startup and set the deactivated flag to TRUE +#define TPM_ST_CLEAR ((TPM_STARTUP_TYPE) 0x0001) ///< The TPM is starting up from a clean state +#define TPM_ST_STATE ((TPM_STARTUP_TYPE) 0x0002) ///< The TPM is starting up from a saved state +#define TPM_ST_DEACTIVATED ((TPM_STARTUP_TYPE) 0x0003) ///< The TPM is to startup and set the deactivated flag to TRUE // // Part 2, section 4.6: TPM_STATUP_EFFECTS @@ -226,73 +353,73 @@ typedef UINT32 TPM_FAMILY_OPERATION; // // Part 2, section 4.7: TPM_PROTOCOL_ID // -#define TPM_PID_OIAP ((TPM_PROTOCOL_ID) 0x0001) // The OIAP protocol. -#define TPM_PID_OSAP ((TPM_PROTOCOL_ID) 0x0002) // The OSAP protocol. -#define TPM_PID_ADIP ((TPM_PROTOCOL_ID) 0x0003) // The ADIP protocol. -#define TPM_PID_ADCP ((TPM_PROTOCOL_ID) 0x0004) // The ADCP protocol. -#define TPM_PID_OWNER ((TPM_PROTOCOL_ID) 0x0005) // The protocol for taking ownership of a TPM. -#define TPM_PID_DSAP ((TPM_PROTOCOL_ID) 0x0006) // The DSAP protocol -#define TPM_PID_TRANSPORT ((TPM_PROTOCOL_ID) 0x0007) // The transport protocol +#define TPM_PID_OIAP ((TPM_PROTOCOL_ID) 0x0001) ///< The OIAP protocol. +#define TPM_PID_OSAP ((TPM_PROTOCOL_ID) 0x0002) ///< The OSAP protocol. +#define TPM_PID_ADIP ((TPM_PROTOCOL_ID) 0x0003) ///< The ADIP protocol. +#define TPM_PID_ADCP ((TPM_PROTOCOL_ID) 0x0004) ///< The ADCP protocol. +#define TPM_PID_OWNER ((TPM_PROTOCOL_ID) 0x0005) ///< The protocol for taking ownership of a TPM. +#define TPM_PID_DSAP ((TPM_PROTOCOL_ID) 0x0006) ///< The DSAP protocol +#define TPM_PID_TRANSPORT ((TPM_PROTOCOL_ID) 0x0007) ///< The transport protocol // // Part 2, section 4.8: TPM_ALGORITHM_ID // The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC, // TPM_ALG_MGF1 // -#define TPM_ALG_RSA ((TPM_ALGORITHM_ID) 0x00000001) // The RSA algorithm. -#define TPM_ALG_DES ((TPM_ALGORITHM_ID) 0x00000002) // The DES algorithm -#define TPM_ALG_3DES ((TPM_ALGORITHM_ID) 0x00000003) // The 3DES algorithm in EDE mode -#define TPM_ALG_SHA ((TPM_ALGORITHM_ID) 0x00000004) // The SHA1 algorithm -#define TPM_ALG_HMAC ((TPM_ALGORITHM_ID) 0x00000005) // The RFC 2104 HMAC algorithm -#define TPM_ALG_AES128 ((TPM_ALGORITHM_ID) 0x00000006) // The AES algorithm, key size 128 -#define TPM_ALG_MGF1 ((TPM_ALGORITHM_ID) 0x00000007) // The XOR algorithm using MGF1 to create a string the size of the encrypted block -#define TPM_ALG_AES192 ((TPM_ALGORITHM_ID) 0x00000008) // AES, key size 192 -#define TPM_ALG_AES256 ((TPM_ALGORITHM_ID) 0x00000009) // AES, key size 256 -#define TPM_ALG_XOR ((TPM_ALGORITHM_ID) 0x0000000A) // XOR using the rolling nonces +#define TPM_ALG_RSA ((TPM_ALGORITHM_ID) 0x00000001) ///< The RSA algorithm. +#define TPM_ALG_DES ((TPM_ALGORITHM_ID) 0x00000002) ///< The DES algorithm +#define TPM_ALG_3DES ((TPM_ALGORITHM_ID) 0x00000003) ///< The 3DES algorithm in EDE mode +#define TPM_ALG_SHA ((TPM_ALGORITHM_ID) 0x00000004) ///< The SHA1 algorithm +#define TPM_ALG_HMAC ((TPM_ALGORITHM_ID) 0x00000005) ///< The RFC 2104 HMAC algorithm +#define TPM_ALG_AES128 ((TPM_ALGORITHM_ID) 0x00000006) ///< The AES algorithm, key size 128 +#define TPM_ALG_MGF1 ((TPM_ALGORITHM_ID) 0x00000007) ///< The XOR algorithm using MGF1 to create a string the size of the encrypted block +#define TPM_ALG_AES192 ((TPM_ALGORITHM_ID) 0x00000008) ///< AES, key size 192 +#define TPM_ALG_AES256 ((TPM_ALGORITHM_ID) 0x00000009) ///< AES, key size 256 +#define TPM_ALG_XOR ((TPM_ALGORITHM_ID) 0x0000000A) ///< XOR using the rolling nonces // // Part 2, section 4.9: TPM_PHYSICAL_PRESENCE // -#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0200) // Sets the physicalPresenceHWEnable to FALSE -#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0100) // Sets the physicalPresenceCMDEnable to FALSE -#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) // Sets the physicalPresenceLifetimeLock to TRUE -#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0040) // Sets the physicalPresenceHWEnable to TRUE -#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0020) // Sets the physicalPresenceCMDEnable to TRUE -#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((TPM_PHYSICAL_PRESENCE) 0x0010) // Sets PhysicalPresence = FALSE -#define TPM_PHYSICAL_PRESENCE_PRESENT ((TPM_PHYSICAL_PRESENCE) 0x0008) // Sets PhysicalPresence = TRUE -#define TPM_PHYSICAL_PRESENCE_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0004) // Sets PhysicalPresenceLock = TRUE +#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0200) ///< Sets the physicalPresenceHWEnable to FALSE +#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0100) ///< Sets the physicalPresenceCMDEnable to FALSE +#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) ///< Sets the physicalPresenceLifetimeLock to TRUE +#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0040) ///< Sets the physicalPresenceHWEnable to TRUE +#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0020) ///< Sets the physicalPresenceCMDEnable to TRUE +#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((TPM_PHYSICAL_PRESENCE) 0x0010) ///< Sets PhysicalPresence = FALSE +#define TPM_PHYSICAL_PRESENCE_PRESENT ((TPM_PHYSICAL_PRESENCE) 0x0008) ///< Sets PhysicalPresence = TRUE +#define TPM_PHYSICAL_PRESENCE_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0004) ///< Sets PhysicalPresenceLock = TRUE // // Part 2, section 4.10: TPM_MIGRATE_SCHEME // -#define TPM_MS_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0001) // A public key that can be used with all TPM migration commands other than 'ReWrap' mode. -#define TPM_MS_REWRAP ((TPM_MIGRATE_SCHEME) 0x0002) // A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob. -#define TPM_MS_MAINT ((TPM_MIGRATE_SCHEME) 0x0003) // A public key that can be used for the Maintenance commands -#define TPM_MS_RESTRICT_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0004) // The key is to be migrated to a Migration Authority. -#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((TPM_MIGRATE_SCHEME) 0x0005) // The key is to be migrated to an entity approved by a Migration Authority using double wrapping +#define TPM_MS_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0001) ///< A public key that can be used with all TPM migration commands other than 'ReWrap' mode. +#define TPM_MS_REWRAP ((TPM_MIGRATE_SCHEME) 0x0002) ///< A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob. +#define TPM_MS_MAINT ((TPM_MIGRATE_SCHEME) 0x0003) ///< A public key that can be used for the Maintenance commands +#define TPM_MS_RESTRICT_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0004) ///< The key is to be migrated to a Migration Authority. +#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((TPM_MIGRATE_SCHEME) 0x0005) ///< The key is to be migrated to an entity approved by a Migration Authority using double wrapping // // Part 2, section 4.11: TPM_EK_TYPE // -#define TPM_EK_TYPE_ACTIVATE ((TPM_EK_TYPE) 0x0001) // The blob MUST be TPM_EK_BLOB_ACTIVATE -#define TPM_EK_TYPE_AUTH ((TPM_EK_TYPE) 0x0002) // The blob MUST be TPM_EK_BLOB_AUTH +#define TPM_EK_TYPE_ACTIVATE ((TPM_EK_TYPE) 0x0001) ///< The blob MUST be TPM_EK_BLOB_ACTIVATE +#define TPM_EK_TYPE_AUTH ((TPM_EK_TYPE) 0x0002) ///< The blob MUST be TPM_EK_BLOB_AUTH // // Part 2, section 4.12: TPM_PLATFORM_SPECIFIC // -#define TPM_PS_PC_11 ((TPM_PLATFORM_SPECIFIC) 0x0001) // PC Specific version 1.1 -#define TPM_PS_PC_12 ((TPM_PLATFORM_SPECIFIC) 0x0002) // PC Specific version 1.2 -#define TPM_PS_PDA_12 ((TPM_PLATFORM_SPECIFIC) 0x0003) // PDA Specific version 1.2 -#define TPM_PS_Server_12 ((TPM_PLATFORM_SPECIFIC) 0x0004) // Server Specific version 1.2 -#define TPM_PS_Mobile_12 ((TPM_PLATFORM_SPECIFIC) 0x0005) // Mobil Specific version 1.2 +#define TPM_PS_PC_11 ((TPM_PLATFORM_SPECIFIC) 0x0001) ///< PC Specific version 1.1 +#define TPM_PS_PC_12 ((TPM_PLATFORM_SPECIFIC) 0x0002) ///< PC Specific version 1.2 +#define TPM_PS_PDA_12 ((TPM_PLATFORM_SPECIFIC) 0x0003) ///< PDA Specific version 1.2 +#define TPM_PS_Server_12 ((TPM_PLATFORM_SPECIFIC) 0x0004) ///< Server Specific version 1.2 +#define TPM_PS_Mobile_12 ((TPM_PLATFORM_SPECIFIC) 0x0005) ///< Mobil Specific version 1.2 // // Part 2, section 5: Basic Structures // -// -// Part 2, section 5.1: TPM_STRUCT_VER -// +/// +/// Part 2, section 5.1: TPM_STRUCT_VER +/// typedef struct tdTPM_STRUCT_VER { UINT8 major; UINT8 minor; @@ -300,9 +427,9 @@ typedef struct tdTPM_STRUCT_VER { UINT8 revMinor; } TPM_STRUCT_VER; -// -// Part 2, section 5.3: TPM_VERSION -// +/// +/// Part 2, section 5.3: TPM_VERSION +/// typedef struct tdTPM_VERSION { TPM_VERSION_BYTE major; TPM_VERSION_BYTE minor; @@ -310,44 +437,80 @@ typedef struct tdTPM_VERSION { UINT8 revMinor; } TPM_VERSION; -// -// Part 2, section 5.4: TPM_DIGEST -// + #define TPM_SHA1_160_HASH_LEN 0x14 #define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN +/// +/// Part 2, section 5.4: TPM_DIGEST +/// typedef struct tdTPM_DIGEST{ UINT8 digest[TPM_SHA1_160_HASH_LEN]; } TPM_DIGEST; -typedef TPM_DIGEST TPM_CHOSENID_HASH; // This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity. -typedef TPM_DIGEST TPM_COMPOSITE_HASH; // This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to. -typedef TPM_DIGEST TPM_DIRVALUE; // This SHALL be the value of a DIR register -typedef TPM_DIGEST TPM_HMAC; -typedef TPM_DIGEST TPM_PCRVALUE; // The value inside of the PCR -typedef TPM_DIGEST TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state -typedef TPM_DIGEST TPM_DAA_TPM_SEED; // This SHALL be a random value generated by a TPM immediately after the EK is installed in that TPM, whenever an EK is installed in that TPM -typedef TPM_DIGEST TPM_DAA_CONTEXT_SEED; // This SHALL be a random value +/// +/// This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity +/// +typedef TPM_DIGEST TPM_CHOSENID_HASH; +/// +/// This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to +/// +typedef TPM_DIGEST TPM_COMPOSITE_HASH; +/// +/// This SHALL be the value of a DIR register +/// +typedef TPM_DIGEST TPM_DIRVALUE; -// -// Part 2, section 5.5: TPM_NONCE -// +typedef TPM_DIGEST TPM_HMAC; +/// +/// The value inside of the PCR +/// +typedef TPM_DIGEST TPM_PCRVALUE; +/// +/// This SHALL be the value of the current internal audit state +/// +typedef TPM_DIGEST TPM_AUDITDIGEST; + +/// +/// Part 2, section 5.5: TPM_NONCE +/// typedef struct tdTPM_NONCE{ UINT8 nonce[20]; } TPM_NONCE; +/// +/// This SHALL be a random value generated by a TPM immediately after the EK is installed +/// in that TPM, whenever an EK is installed in that TPM +/// +typedef TPM_NONCE TPM_DAA_TPM_SEED; +/// +/// This SHALL be a random value +/// +typedef TPM_NONCE TPM_DAA_CONTEXT_SEED; + // // Part 2, section 5.6: TPM_AUTHDATA // +/// +/// The AuthData data is the information that is saved or passed to provide proof of ownership +/// 296 of an entity +/// typedef UINT8 tdTPM_AUTHDATA[20]; + typedef tdTPM_AUTHDATA TPM_AUTHDATA; +/// +/// A secret plaintext value used in the authorization process +/// typedef TPM_AUTHDATA TPM_SECRET; +/// +/// A ciphertext (encrypted) version of AuthData data. The encryption mechanism depends on the context +/// typedef TPM_AUTHDATA TPM_ENCAUTH; -// -// Part 2, section 5.7: TPM_KEY_HANDLE_LIST -// Size of handle is loaded * sizeof(TPM_KEY_HANDLE) -// +/// +/// Part 2, section 5.7: TPM_KEY_HANDLE_LIST +/// Size of handle is loaded * sizeof(TPM_KEY_HANDLE) +/// typedef struct tdTPM_KEY_HANDLE_LIST { UINT16 loaded; TPM_KEY_HANDLE handle[1]; @@ -356,47 +519,55 @@ typedef struct tdTPM_KEY_HANDLE_LIST { // // Part 2, section 5.8: TPM_KEY_USAGE values // - +/// +/// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be +/// used for signing operations, only. This means that it MUST be a leaf of the +/// Protected Storage key hierarchy. +/// #define TPM_KEY_SIGNING ((UINT16) 0x0010) -// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be -// used for signing operations, only. This means that it MUST be a leaf of the -// Protected Storage key hierarchy. - +/// +/// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap +/// and unwrap other keys in the Protected Storage hierarchy +/// #define TPM_KEY_STORAGE ((UINT16) 0x0011) -// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap -// and unwrap other keys in the Protected Storage hierarchy - +/// +/// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for +/// operations that require a TPM identity, only. +/// #define TPM_KEY_IDENTITY ((UINT16) 0x0012) -// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for -// operations that require a TPM identity, only. - +/// +/// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during +/// the ChangeAuthAsym process, only. +/// #define TPM_KEY_AUTHCHANGE ((UINT16) 0x0013) -// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during -// the ChangeAuthAsym process, only. - +/// +/// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and +/// TPM_Unbind operations only. +/// #define TPM_KEY_BIND ((UINT16) 0x0014) -// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and -// TPM_Unbind operations only. - +/// +/// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding +/// operations. The key MAY be used for both signing and binding operations. +/// The TPM_KEY_LEGACY key type is to allow for use by applications where both +/// signing and encryption operations occur with the same key. The use of this +/// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a +/// key in use for TPM_MigrateKey +/// #define TPM_KEY_LEGACY ((UINT16) 0x0015) -// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding -// operations. The key MAY be used for both signing and binding operations. -// The TPM_KEY_LEGACY key type is to allow for use by applications where both -// signing and encryption operations occur with the same key. The use of this -// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a -// key in use for TPM_MigrateKey - +/// +/// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey +/// #define TPM_KEY_MIGRATE ((UINT16) 0x0016) -// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey // -// Part 2, section 5.8.1: Encryption/Signature schemes +// Part 2, section 5.8.1: Mandatory Key Usage Schemes // #define TPM_ES_NONE ((TPM_ENC_SCHEME) 0x0001) #define TPM_ES_RSAESPKCSv15 ((TPM_ENC_SCHEME) 0x0002) #define TPM_ES_RSAESOAEP_SHA1_MGF1 ((TPM_ENC_SCHEME) 0x0003) -#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004) +#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004) ///< rev94 defined +#define TPM_ES_SYM_CTR ((TPM_ENC_SCHEME) 0x0004) #define TPM_ES_SYM_OFB ((TPM_ENC_SCHEME) 0x0005) #define TPM_SS_NONE ((TPM_SIG_SCHEME) 0x0001) @@ -411,32 +582,32 @@ typedef struct tdTPM_KEY_HANDLE_LIST { #define TPM_AUTH_ALWAYS ((TPM_AUTH_DATA_USAGE) 0x01) #define TPM_AUTH_PRIV_USE_ONLY ((TPM_AUTH_DATA_USAGE) 0x03) -// -// Part 2, section 5.10: TPM_KEY_FLAGS -// -enum tdTPM_KEY_FLAGS { +/// +/// Part 2, section 5.10: TPM_KEY_FLAGS +/// +typedef enum tdTPM_KEY_FLAGS { redirection = 0x00000001, migratable = 0x00000002, isVolatile = 0x00000004, pcrIgnoredOnRead = 0x00000008, migrateAuthority = 0x00000010 -}; +} TPM_KEY_FLAGS_BITS; -// -// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE -// +/// +/// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE +/// typedef struct tdTPM_CHANGEAUTH_VALIDATE { TPM_SECRET newAuthSecret; TPM_NONCE n1; } TPM_CHANGEAUTH_VALIDATE; -// -// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH -// decalared after section 10 to catch declaration of TPM_PUBKEY -// -// Part 2 section 10.1: TPM_KEY_PARMS -// [size_is(parmSize)] BYTE* parms; -// +/// +/// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH +/// decalared after section 10 to catch declaration of TPM_PUBKEY +/// +/// Part 2 section 10.1: TPM_KEY_PARMS +/// [size_is(parmSize)] BYTE* parms; +/// typedef struct tdTPM_KEY_PARMS { TPM_ALGORITHM_ID algorithmID; TPM_ENC_SCHEME encScheme; @@ -445,44 +616,44 @@ typedef struct tdTPM_KEY_PARMS { UINT8 *parms; } TPM_KEY_PARMS; -// -// Part 2, section 10.4: TPM_STORE_PUBKEY -// +/// +/// Part 2, section 10.4: TPM_STORE_PUBKEY +/// typedef struct tdTPM_STORE_PUBKEY { UINT32 keyLength; UINT8 key[1]; } TPM_STORE_PUBKEY; -// -// Part 2, section 10.5: TPM_PUBKEY -// +/// +/// Part 2, section 10.5: TPM_PUBKEY +/// typedef struct tdTPM_PUBKEY{ TPM_KEY_PARMS algorithmParms; TPM_STORE_PUBKEY pubKey; } TPM_PUBKEY; -// -// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH -// +/// +/// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH +/// typedef struct tdTPM_MIGRATIONKEYAUTH{ TPM_PUBKEY migrationKey; TPM_MIGRATE_SCHEME migrationScheme; TPM_DIGEST digest; } TPM_MIGRATIONKEYAUTH; -// -// Part 2, section 5.13: TPM_COUNTER_VALUE -// +/// +/// Part 2, section 5.13: TPM_COUNTER_VALUE +/// typedef struct tdTPM_COUNTER_VALUE{ TPM_STRUCTURE_TAG tag; UINT8 label[4]; TPM_ACTUAL_COUNT counter; } TPM_COUNTER_VALUE; -// -// Part 2, section 5.14: TPM_SIGN_INFO -// Size of data indicated by dataLen -// +/// +/// Part 2, section 5.14: TPM_SIGN_INFO +/// Size of data indicated by dataLen +/// typedef struct tdTPM_SIGN_INFO { TPM_STRUCTURE_TAG tag; UINT8 fixed[4]; @@ -491,18 +662,18 @@ typedef struct tdTPM_SIGN_INFO { UINT8 *data; } TPM_SIGN_INFO; -// -// Part 2, section 5.15: TPM_MSA_COMPOSITE -// Number of migAuthDigest indicated by MSAlist -// +/// +/// Part 2, section 5.15: TPM_MSA_COMPOSITE +/// Number of migAuthDigest indicated by MSAlist +/// typedef struct tdTPM_MSA_COMPOSITE { UINT32 MSAlist; TPM_DIGEST migAuthDigest[1]; } TPM_MSA_COMPOSITE; -// -// Part 2, section 5.16: TPM_CMK_AUTH -// +/// +/// Part 2, section 5.16: TPM_CMK_AUTH +/// typedef struct tdTPM_CMK_AUTH{ TPM_DIGEST migrationAuthorityDigest; TPM_DIGEST destinationKeyDigest; @@ -512,42 +683,42 @@ typedef struct tdTPM_CMK_AUTH{ // // Part 2, section 5.17: TPM_CMK_DELEGATE // -#define TPM_CMK_DELEGATE_SIGNING (((TPM_CMK_DELEGATE)1) << 31) -#define TPM_CMK_DELEGATE_STORAGE (((TPM_CMK_DELEGATE)1) << 30) -#define TPM_CMK_DELEGATE_BIND (((TPM_CMK_DELEGATE)1) << 29) -#define TPM_CMK_DELEGATE_LEGACY (((TPM_CMK_DELEGATE)1) << 28) -#define TPM_CMK_DELEGATE_MIGRATE (((TPM_CMK_DELEGATE)1) << 27) +#define TPM_CMK_DELEGATE_SIGNING ((TPM_CMK_DELEGATE) BIT31) +#define TPM_CMK_DELEGATE_STORAGE ((TPM_CMK_DELEGATE) BIT30) +#define TPM_CMK_DELEGATE_BIND ((TPM_CMK_DELEGATE) BIT29) +#define TPM_CMK_DELEGATE_LEGACY ((TPM_CMK_DELEGATE) BIT28) +#define TPM_CMK_DELEGATE_MIGRATE ((TPM_CMK_DELEGATE) BIT27) -// -// Part 2, section 5.18: TPM_SELECT_SIZE -// +/// +/// Part 2, section 5.18: TPM_SELECT_SIZE +/// typedef struct tdTPM_SELECT_SIZE { UINT8 major; UINT8 minor; UINT16 reqSize; } TPM_SELECT_SIZE; -// -// Part 2, section 5,19: TPM_CMK_MIGAUTH -// +/// +/// Part 2, section 5,19: TPM_CMK_MIGAUTH +/// typedef struct tdTPM_CMK_MIGAUTH{ TPM_STRUCTURE_TAG tag; TPM_DIGEST msaDigest; TPM_DIGEST pubKeyDigest; } TPM_CMK_MIGAUTH; -// -// Part 2, section 5.20: TPM_CMK_SIGTICKET -// +/// +/// Part 2, section 5.20: TPM_CMK_SIGTICKET +/// typedef struct tdTPM_CMK_SIGTICKET{ TPM_STRUCTURE_TAG tag; TPM_DIGEST verKeyDigest; TPM_DIGEST signedData; } TPM_CMK_SIGTICKET; -// -// Part 2, section 5.21: TPM_CMK_MA_APPROVAL -// +/// +/// Part 2, section 5.21: TPM_CMK_MA_APPROVAL +/// typedef struct tdTPM_CMK_MA_APPROVAL{ TPM_STRUCTURE_TAG tag; TPM_DIGEST migrationAuthorityDigest; @@ -563,9 +734,9 @@ typedef struct tdTPM_CMK_MA_APPROVAL{ #define TPM_TAG_RSP_AUTH1_COMMAND ((TPM_STRUCTURE_TAG) 0x00C5) #define TPM_TAG_RSP_AUTH2_COMMAND ((TPM_STRUCTURE_TAG) 0x00C6) -// -// Part 2, section 7.1: TPM_PERMANENT_FLAGS -// +/// +/// Part 2, section 7.1: TPM_PERMANENT_FLAGS +/// typedef struct tdTPM_PERMANENT_FLAGS{ TPM_STRUCTURE_TAG tag; BOOLEAN disable; @@ -587,10 +758,11 @@ typedef struct tdTPM_PERMANENT_FLAGS{ BOOLEAN readSRKPub; BOOLEAN tpmEstablished; BOOLEAN maintenanceDone; + BOOLEAN disableFullDALogicInfo; } TPM_PERMANENT_FLAGS; // -// Part 2, section 7.1.1: PERMANENT_FLAGS Subcap for SetCapability +// Part 2, section 7.1.1: Flag Restrictions (of TPM_PERMANENT_FLAGS) // #define TPM_PF_DISABLE ((TPM_CAPABILITY_AREA) 1) #define TPM_PF_OWNERSHIP ((TPM_CAPABILITY_AREA) 2) @@ -611,10 +783,11 @@ typedef struct tdTPM_PERMANENT_FLAGS{ #define TPM_PF_READSRKPUB ((TPM_CAPABILITY_AREA) 17) #define TPM_PF_TPMESTABLISHED ((TPM_CAPABILITY_AREA) 18) #define TPM_PF_MAINTENANCEDONE ((TPM_CAPABILITY_AREA) 19) +#define TPM_PF_DISABLEFULLDALOGICINFO ((TPM_CAPABILITY_AREA) 20) -// -// Part 2, section 7.2: TPM_STCLEAR_FLAGS -// +/// +/// Part 2, section 7.2: TPM_STCLEAR_FLAGS +/// typedef struct tdTPM_STCLEAR_FLAGS{ TPM_STRUCTURE_TAG tag; BOOLEAN deactivated; @@ -625,7 +798,7 @@ typedef struct tdTPM_STCLEAR_FLAGS{ } TPM_STCLEAR_FLAGS; // -// Part 2, section 7.2.1: STCLEAR_FLAGS Subcap for SetCapability +// Part 2, section 7.2.1: Flag Restrictions (of TPM_STCLEAR_FLAGS) // #define TPM_SF_DEACTIVATED ((TPM_CAPABILITY_AREA) 1) #define TPM_SF_DISABLEFORCECLEAR ((TPM_CAPABILITY_AREA) 2) @@ -633,9 +806,9 @@ typedef struct tdTPM_STCLEAR_FLAGS{ #define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4) #define TPM_SF_BGLOBALLOCK ((TPM_CAPABILITY_AREA) 5) -// -// Part 2, section 7.3: TPM_STANY_FLAGS -// +/// +/// Part 2, section 7.3: TPM_STANY_FLAGS +/// typedef struct tdTPM_STANY_FLAGS{ TPM_STRUCTURE_TAG tag; BOOLEAN postInitialise; @@ -645,7 +818,7 @@ typedef struct tdTPM_STANY_FLAGS{ } TPM_STANY_FLAGS; // -// Part 2, section 7.3.1: STANY_FLAGS Subcap for SetCapability +// Part 2, section 7.3.1: Flag Restrictions (of TPM_STANY_FLAGS) // #define TPM_AF_POSTINITIALISE ((TPM_CAPABILITY_AREA) 1) #define TPM_AF_LOCALITYMODIFIER ((TPM_CAPABILITY_AREA) 2) @@ -653,107 +826,114 @@ typedef struct tdTPM_STANY_FLAGS{ #define TPM_AF_TOSPRESENT ((TPM_CAPABILITY_AREA) 4) // -// All those structures (section 7.4, 7.5, 7.6) are not normative and +// All those structures defined in section 7.4, 7.5, 7.6 are not normative and // thus no definitions here // // Part 2, section 7.4: TPM_PERMANENT_DATA // -//#define TPM_MIN_COUNTERS 4 // the minimum number of counters is 4 -//#define TPM_DELEGATE_KEY TPM_KEY -//#define TPM_NUM_PCR 16 -//#define TPM_MAX_NV_WRITE_NOOWNER 64 -//typedef struct tdTPM_PERMANENT_DATA -//{ -// TPM_STRUCTURE_TAG tag; -// UINT8 revMajor; -// UINT8 revMinor; -// TPM_NONCE tpmProof; -// TPM_NONCE ekReset; -// TPM_SECRET ownerAuth; -// TPM_SECRET operatorAuth; -// TPM_DIRVALUE authDIR[1]; -// TPM_PUBKEY manuMaintPub; -// TPM_KEY endorsementKey; -// TPM_KEY srk; -// TPM_KEY contextKey; -// TPM_KEY delegateKey; -// TPM_COUNTER_VALUE auditMonotonicCounter; -// TPM_COUNTER_VALUE monitonicCounter[TPM_MIN_COUNTERS]; -// TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR]; -// UINT8 ordinalAuditStatus[]; -// UINT8 *rngState; -// TPM_FAMILY_TABLE familyTable; -// TPM_DELEGATE_TABLE delegateTable; -// UINT32 maxNVBufSize; -// UINT32 lastFamilyID; -// UINT32 noOwnerNVWrite; -// TPM_CMK_DELEGATE restrictDelegate; -// TPM_DAA_TPM_SEED tpmDAASeed; -//} TPM_PERMANENT_DATA; - -// -// Part 2, section 7.5: TPM_STCLEAR_DATA -// available inside TPM only -// -//typedef struct tdTPM_STCLEAR_DATA -//{ -// TPM_STRUCTURE_TAG tag; -// TPM_NONCE contextNonceKey; -// TPM_COUNT_ID countID; -// UINT32 ownerReference; -// BOOLEAN disableResetLock; -//} TPM_STCLEAR_DATA; - -// -// Part 2, section 7.6: TPM_STANY_DATA -// available inside TPM only -// -//typedef struct tdTPM_STANY_DATA -//{ -// TPM_STRUCTURE_TAG tag; -// TPM_NONCE contextNonceSession; -// TPM_DIGEST auditDigest; -// TPM_CURRENT_TICKS currentTicks; -// UINT32 contextCount; -// UINT32 contextList[TPM_MIN_SESSION_LIST]; -// TPM_SESSION_DATA sessions[TPM_MIN_SESSIONS]; -//} TPM_STANY_DATA; +#define TPM_MIN_COUNTERS 4 ///< the minimum number of counters is 4 +#define TPM_DELEGATE_KEY TPM_KEY +#define TPM_NUM_PCR 16 +#define TPM_MAX_NV_WRITE_NOOWNER 64 + +// +// Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability +// +#define TPM_PD_REVMAJOR ((TPM_CAPABILITY_AREA) 1) +#define TPM_PD_REVMINOR ((TPM_CAPABILITY_AREA) 2) +#define TPM_PD_TPMPROOF ((TPM_CAPABILITY_AREA) 3) +#define TPM_PD_OWNERAUTH ((TPM_CAPABILITY_AREA) 4) +#define TPM_PD_OPERATORAUTH ((TPM_CAPABILITY_AREA) 5) +#define TPM_PD_MANUMAINTPUB ((TPM_CAPABILITY_AREA) 6) +#define TPM_PD_ENDORSEMENTKEY ((TPM_CAPABILITY_AREA) 7) +#define TPM_PD_SRK ((TPM_CAPABILITY_AREA) 8) +#define TPM_PD_DELEGATEKEY ((TPM_CAPABILITY_AREA) 9) +#define TPM_PD_CONTEXTKEY ((TPM_CAPABILITY_AREA) 10) +#define TPM_PD_AUDITMONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 11) +#define TPM_PD_MONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 12) +#define TPM_PD_PCRATTRIB ((TPM_CAPABILITY_AREA) 13) +#define TPM_PD_ORDINALAUDITSTATUS ((TPM_CAPABILITY_AREA) 14) +#define TPM_PD_AUTHDIR ((TPM_CAPABILITY_AREA) 15) +#define TPM_PD_RNGSTATE ((TPM_CAPABILITY_AREA) 16) +#define TPM_PD_FAMILYTABLE ((TPM_CAPABILITY_AREA) 17) +#define TPM_DELEGATETABLE ((TPM_CAPABILITY_AREA) 18) +#define TPM_PD_EKRESET ((TPM_CAPABILITY_AREA) 19) +#define TPM_PD_MAXNVBUFSIZE ((TPM_CAPABILITY_AREA) 20) +#define TPM_PD_LASTFAMILYID ((TPM_CAPABILITY_AREA) 21) +#define TPM_PD_NOOWNERNVWRITE ((TPM_CAPABILITY_AREA) 22) +#define TPM_PD_RESTRICTDELEGATE ((TPM_CAPABILITY_AREA) 23) +#define TPM_PD_TPMDAASEED ((TPM_CAPABILITY_AREA) 24) +#define TPM_PD_DAAPROOF ((TPM_CAPABILITY_AREA) 25) + +/// +/// Part 2, section 7.5: TPM_STCLEAR_DATA +/// available inside TPM only +/// + typedef struct tdTPM_STCLEAR_DATA{ + TPM_STRUCTURE_TAG tag; + TPM_NONCE contextNonceKey; + TPM_COUNT_ID countID; + UINT32 ownerReference; + BOOLEAN disableResetLock; + TPM_PCRVALUE PCR[TPM_NUM_PCR]; + UINT32 deferredPhysicalPresence; + }TPM_STCLEAR_DATA; + +// +// Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability +// +#define TPM_SD_CONTEXTNONCEKEY ((TPM_CAPABILITY_AREA)0x00000001) +#define TPM_SD_COUNTID ((TPM_CAPABILITY_AREA)0x00000002) +#define TPM_SD_OWNERREFERENCE ((TPM_CAPABILITY_AREA)0x00000003) +#define TPM_SD_DISABLERESETLOCK ((TPM_CAPABILITY_AREA)0x00000004) +#define TPM_SD_PCR ((TPM_CAPABILITY_AREA)0x00000005) +#define TPM_SD_DEFERREDPHYSICALPRESENCE ((TPM_CAPABILITY_AREA)0x00000006) + +// +// Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability +// +#define TPM_AD_CONTEXTNONCESESSION ((TPM_CAPABILITY_AREA) 1) +#define TPM_AD_AUDITDIGEST ((TPM_CAPABILITY_AREA) 2) +#define TPM_AD_CURRENTTICKS ((TPM_CAPABILITY_AREA) 3) +#define TPM_AD_CONTEXTCOUNT ((TPM_CAPABILITY_AREA) 4) +#define TPM_AD_CONTEXTLIST ((TPM_CAPABILITY_AREA) 5) +#define TPM_AD_SESSIONS ((TPM_CAPABILITY_AREA) 6) // // Part 2, section 8: PCR Structures // -// -// Part 2, section 8.1: TPM_PCR_SELECTION -// Size of pcrSelect[] indicated by sizeOfSelect -// +/// +/// Part 2, section 8.1: TPM_PCR_SELECTION +/// Size of pcrSelect[] indicated by sizeOfSelect +/// typedef struct tdTPM_PCR_SELECTION { UINT16 sizeOfSelect; UINT8 pcrSelect[1]; } TPM_PCR_SELECTION; -// -// Part 2, section 8.2: TPM_PCR_COMPOSITE -// Size of pcrValue[] indicated by valueSize -// +/// +/// Part 2, section 8.2: TPM_PCR_COMPOSITE +/// Size of pcrValue[] indicated by valueSize +/// typedef struct tdTPM_PCR_COMPOSITE { TPM_PCR_SELECTION select; UINT32 valueSize; TPM_PCRVALUE pcrValue[1]; } TPM_PCR_COMPOSITE; -// -// Part 2, section 8.3: TPM_PCR_INFO -// +/// +/// Part 2, section 8.3: TPM_PCR_INFO +/// typedef struct tdTPM_PCR_INFO { TPM_PCR_SELECTION pcrSelection; TPM_COMPOSITE_HASH digestAtRelease; TPM_COMPOSITE_HASH digestAtCreation; } TPM_PCR_INFO; -// -// Part 2, section 8.6: TPM_LOCALITY_SELECTION -// +/// +/// Part 2, section 8.6: TPM_LOCALITY_SELECTION +/// typedef UINT8 TPM_LOCALITY_SELECTION; #define TPM_LOC_FOUR ((UINT8) 0x10) @@ -762,9 +942,9 @@ typedef UINT8 TPM_LOCALITY_SELECTION; #define TPM_LOC_ONE ((UINT8) 0x02) #define TPM_LOC_ZERO ((UINT8) 0x01) -// -// Part 2, section 8.4: TPM_PCR_INFO_LONG -// +/// +/// Part 2, section 8.4: TPM_PCR_INFO_LONG +/// typedef struct tdTPM_PCR_INFO_LONG { TPM_STRUCTURE_TAG tag; TPM_LOCALITY_SELECTION localityAtCreation; @@ -775,18 +955,18 @@ typedef struct tdTPM_PCR_INFO_LONG { TPM_COMPOSITE_HASH digestAtRelease; } TPM_PCR_INFO_LONG; -// -// Part 2, section 8.5: TPM_PCR_INFO_SHORT -// +/// +/// Part 2, section 8.5: TPM_PCR_INFO_SHORT +/// typedef struct tdTPM_PCR_INFO_SHORT{ TPM_PCR_SELECTION pcrSelection; TPM_LOCALITY_SELECTION localityAtRelease; TPM_COMPOSITE_HASH digestAtRelease; } TPM_PCR_INFO_SHORT; -// -// Part 2, section 8.8: TPM_PCR_ATTRIBUTES -// +/// +/// Part 2, section 8.8: TPM_PCR_ATTRIBUTES +/// typedef struct tdTPM_PCR_ATTRIBUTES{ BOOLEAN pcrReset; TPM_LOCALITY_SELECTION pcrExtendLocal; @@ -797,11 +977,11 @@ typedef struct tdTPM_PCR_ATTRIBUTES{ // Part 2, section 9: Storage Structures // -// -// Part 2, section 9.1: TPM_STORED_DATA -// [size_is(sealInfoSize)] BYTE* sealInfo; -// [size_is(encDataSize)] BYTE* encData; -// +/// +/// Part 2, section 9.1: TPM_STORED_DATA +/// [size_is(sealInfoSize)] BYTE* sealInfo; +/// [size_is(encDataSize)] BYTE* encData; +/// typedef struct tdTPM_STORED_DATA { TPM_STRUCT_VER ver; UINT32 sealInfoSize; @@ -810,11 +990,11 @@ typedef struct tdTPM_STORED_DATA { UINT8 *encData; } TPM_STORED_DATA; -// -// Part 2, section 9.2: TPM_STORED_DATA12 -// [size_is(sealInfoSize)] BYTE* sealInfo; -// [size_is(encDataSize)] BYTE* encData; -// +/// +/// Part 2, section 9.2: TPM_STORED_DATA12 +/// [size_is(sealInfoSize)] BYTE* sealInfo; +/// [size_is(encDataSize)] BYTE* encData; +/// typedef struct tdTPM_STORED_DATA12 { TPM_STRUCTURE_TAG tag; TPM_ENTITY_TYPE et; @@ -824,10 +1004,10 @@ typedef struct tdTPM_STORED_DATA12 { UINT8 *encData; } TPM_STORED_DATA12; -// -// Part 2, section 9.3: TPM_SEALED_DATA -// [size_is(dataSize)] BYTE* data; -// +/// +/// Part 2, section 9.3: TPM_SEALED_DATA +/// [size_is(dataSize)] BYTE* data; +/// typedef struct tdTPM_SEALED_DATA { TPM_PAYLOAD_TYPE payload; TPM_SECRET authData; @@ -837,10 +1017,10 @@ typedef struct tdTPM_SEALED_DATA { UINT8 *data; } TPM_SEALED_DATA; -// -// Part 2, section 9.4: TPM_SYMMETRIC_KEY -// [size_is(size)] BYTE* data; -// +/// +/// Part 2, section 9.4: TPM_SYMMETRIC_KEY +/// [size_is(size)] BYTE* data; +/// typedef struct tdTPM_SYMMETRIC_KEY { TPM_ALGORITHM_ID algId; TPM_ENC_SCHEME encScheme; @@ -848,9 +1028,9 @@ typedef struct tdTPM_SYMMETRIC_KEY { UINT8 *data; } TPM_SYMMETRIC_KEY; -// -// Part 2, section 9.5: TPM_BOUND_DATA -// +/// +/// Part 2, section 9.5: TPM_BOUND_DATA +/// typedef struct tdTPM_BOUND_DATA { TPM_STRUCT_VER ver; TPM_PAYLOAD_TYPE payload; @@ -862,9 +1042,13 @@ typedef struct tdTPM_BOUND_DATA { // // -// Part 2, section 10.2: TPM_KEY -// [size_is(encDataSize)] BYTE* encData; +// Section 10.1, 10.4, and 10.5 have been defined previously // + +/// +/// Part 2, section 10.2: TPM_KEY +/// [size_is(encDataSize)] BYTE* encData; +/// typedef struct tdTPM_KEY{ TPM_STRUCT_VER ver; TPM_KEY_USAGE keyUsage; @@ -878,10 +1062,10 @@ typedef struct tdTPM_KEY{ UINT8 *encData; } TPM_KEY; -// -// Part 2, section 10.3: TPM_KEY12 -// [size_is(encDataSize)] BYTE* encData; -// +/// +/// Part 2, section 10.3: TPM_KEY12 +/// [size_is(encDataSize)] BYTE* encData; +/// typedef struct tdTPM_KEY12{ TPM_STRUCTURE_TAG tag; UINT16 fill; @@ -896,18 +1080,18 @@ typedef struct tdTPM_KEY12{ UINT8 *encData; } TPM_KEY12; -// -// Part 2, section 10.7: TPM_STORE_PRIVKEY -// [size_is(keyLength)] BYTE* key; -// +/// +/// Part 2, section 10.7: TPM_STORE_PRIVKEY +/// [size_is(keyLength)] BYTE* key; +/// typedef struct tdTPM_STORE_PRIVKEY { UINT32 keyLength; UINT8 *key; } TPM_STORE_PRIVKEY; -// -// Part 2, section 10.6: TPM_STORE_ASYMKEY -// +/// +/// Part 2, section 10.6: TPM_STORE_ASYMKEY +/// typedef struct tdTPM_STORE_ASYMKEY { // pos len total TPM_PAYLOAD_TYPE payload; // 0 1 1 TPM_SECRET usageAuth; // 1 20 21 @@ -916,10 +1100,10 @@ typedef struct tdTPM_STORE_ASYMKEY { // pos len total TPM_STORE_PRIVKEY privKey; // 61 132-151 193-214 } TPM_STORE_ASYMKEY; -// -// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY -// [size_is(partPrivKeyLen)] BYTE* partPrivKey; -// +/// +/// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY +/// [size_is(partPrivKeyLen)] BYTE* partPrivKey; +/// typedef struct tdTPM_MIGRATE_ASYMKEY { // pos len total TPM_PAYLOAD_TYPE payload; // 0 1 1 TPM_SECRET usageAuth; // 1 20 21 @@ -928,141 +1112,165 @@ typedef struct tdTPM_MIGRATE_ASYMKEY { // pos len total UINT8 *partPrivKey; // 45 112-127 157-172 } TPM_MIGRATE_ASYMKEY; -// -// Part 2, section 10.9: TPM_KEY_CONTROL -// +/// +/// Part 2, section 10.9: TPM_KEY_CONTROL +/// #define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001) // // Part 2, section 11: Signed Structures // -typedef struct tdTPM_CERTIFY_INFO -{ - TPM_STRUCT_VER version; - TPM_KEY_USAGE keyUsage; - TPM_KEY_FLAGS keyFlags; - TPM_AUTH_DATA_USAGE authDataUsage; - TPM_KEY_PARMS algorithmParms; - TPM_DIGEST pubkeyDigest; - TPM_NONCE data; - BOOLEAN parentPCRStatus; - UINT32 PCRInfoSize; - UINT8 *PCRInfo; +/// +/// Part 2, section 11.1: TPM_CERTIFY_INFO Structure +/// +typedef struct tdTPM_CERTIFY_INFO { + TPM_STRUCT_VER version; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + BOOLEAN parentPCRStatus; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; } TPM_CERTIFY_INFO; -typedef struct tdTPM_CERTIFY_INFO2 -{ - TPM_STRUCTURE_TAG tag; - UINT8 fill; - TPM_PAYLOAD_TYPE payloadType; - TPM_KEY_USAGE keyUsage; - TPM_KEY_FLAGS keyFlags; - TPM_AUTH_DATA_USAGE authDataUsage; - TPM_KEY_PARMS algorithmParms; - TPM_DIGEST pubkeyDigest; - TPM_NONCE data; - BOOLEAN parentPCRStatus; - UINT32 PCRInfoSize; - UINT8 *PCRInfo; - UINT32 migrationAuthoritySize; - UINT8 *migrationAuthority; +/// +/// Part 2, section 11.2: TPM_CERTIFY_INFO2 Structure +/// +typedef struct tdTPM_CERTIFY_INFO2 { + TPM_STRUCTURE_TAG tag; + UINT8 fill; + TPM_PAYLOAD_TYPE payloadType; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + BOOLEAN parentPCRStatus; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; + UINT32 migrationAuthoritySize; + UINT8 *migrationAuthority; } TPM_CERTIFY_INFO2; -typedef struct tdTPM_QUOTE_INFO -{ - TPM_STRUCT_VER version; - UINT8 fixed[4]; - TPM_COMPOSITE_HASH digestValue; - TPM_NONCE externalData; +/// +/// Part 2, section 11.3 TPM_QUOTE_INFO Structure +/// +typedef struct tdTPM_QUOTE_INFO { + TPM_STRUCT_VER version; + UINT8 fixed[4]; + TPM_COMPOSITE_HASH digestValue; + TPM_NONCE externalData; } TPM_QUOTE_INFO; -typedef struct tdTPM_QUOTE_INFO2 -{ - TPM_STRUCTURE_TAG tag; - UINT8 fixed[4]; - TPM_NONCE externalData; - TPM_PCR_INFO_SHORT infoShort; +/// +/// Part 2, section 11.4 TPM_QUOTE_INFO2 Structure +/// +typedef struct tdTPM_QUOTE_INFO2 { + TPM_STRUCTURE_TAG tag; + UINT8 fixed[4]; + TPM_NONCE externalData; + TPM_PCR_INFO_SHORT infoShort; } TPM_QUOTE_INFO2; // // Part 2, section 12: Identity Structures // -typedef struct tdTPM_EK_BLOB -{ - TPM_STRUCTURE_TAG tag; - TPM_EK_TYPE ekType; - UINT32 blobSize; - UINT8 *blob; +/// +/// Part 2, section 12.1 TPM_EK_BLOB +/// +typedef struct tdTPM_EK_BLOB { + TPM_STRUCTURE_TAG tag; + TPM_EK_TYPE ekType; + UINT32 blobSize; + UINT8 *blob; } TPM_EK_BLOB; -typedef struct tdTPM_EK_BLOB_ACTIVATE -{ - TPM_STRUCTURE_TAG tag; - TPM_SYMMETRIC_KEY sessionKey; - TPM_DIGEST idDigest; - TPM_PCR_INFO_SHORT pcrInfo; +/// +/// Part 2, section 12.2 TPM_EK_BLOB_ACTIVATE +/// +typedef struct tdTPM_EK_BLOB_ACTIVATE { + TPM_STRUCTURE_TAG tag; + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; + TPM_PCR_INFO_SHORT pcrInfo; } TPM_EK_BLOB_ACTIVATE; -typedef struct tdTPM_EK_BLOB_AUTH -{ - TPM_STRUCTURE_TAG tag; - TPM_SECRET authValue; +/// +/// Part 2, section 12.3 TPM_EK_BLOB_AUTH +/// +typedef struct tdTPM_EK_BLOB_AUTH { + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; } TPM_EK_BLOB_AUTH; -typedef struct tdTPM_IDENTITY_CONTENTS -{ - TPM_STRUCT_VER ver; - UINT32 ordinal; - TPM_CHOSENID_HASH labelPrivCADigest; - TPM_PUBKEY identityPubKey; +/// +/// Part 2, section 12.5 TPM_IDENTITY_CONTENTS +/// +typedef struct tdTPM_IDENTITY_CONTENTS { + TPM_STRUCT_VER ver; + UINT32 ordinal; + TPM_CHOSENID_HASH labelPrivCADigest; + TPM_PUBKEY identityPubKey; } TPM_IDENTITY_CONTENTS; -typedef struct tdTPM_IDENTITY_REQ -{ - UINT32 asymSize; - UINT32 symSize; - TPM_KEY_PARMS asymAlgorithm; - TPM_KEY_PARMS symAlgorithm; - UINT8 *asymBlob; - UINT8 *symBlob; +/// +/// Part 2, section 12.6 TPM_IDENTITY_REQ +/// +typedef struct tdTPM_IDENTITY_REQ { + UINT32 asymSize; + UINT32 symSize; + TPM_KEY_PARMS asymAlgorithm; + TPM_KEY_PARMS symAlgorithm; + UINT8 *asymBlob; + UINT8 *symBlob; } TPM_IDENTITY_REQ; -typedef struct tdTPM_IDENTITY_PROOF -{ - TPM_STRUCT_VER ver; - UINT32 labelSize; - UINT32 identityBindingSize; - UINT32 endorsementSize; - UINT32 platformSize; - UINT32 conformanceSize; - TPM_PUBKEY identityKey; - UINT8 *labelArea; - UINT8 *identityBinding; - UINT8 *endorsementCredential; - UINT8 *platformCredential; - UINT8 *conformanceCredential; +/// +/// Part 2, section 12.7 TPM_IDENTITY_PROOF +/// +typedef struct tdTPM_IDENTITY_PROOF { + TPM_STRUCT_VER ver; + UINT32 labelSize; + UINT32 identityBindingSize; + UINT32 endorsementSize; + UINT32 platformSize; + UINT32 conformanceSize; + TPM_PUBKEY identityKey; + UINT8 *labelArea; + UINT8 *identityBinding; + UINT8 *endorsementCredential; + UINT8 *platformCredential; + UINT8 *conformanceCredential; } TPM_IDENTITY_PROOF; -typedef struct tdTPM_ASYM_CA_CONTENTS -{ - TPM_SYMMETRIC_KEY sessionKey; - TPM_DIGEST idDigest; +/// +/// Part 2, section 12.8 TPM_ASYM_CA_CONTENTS +/// +typedef struct tdTPM_ASYM_CA_CONTENTS { + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; } TPM_ASYM_CA_CONTENTS; -typedef struct tdTPM_SYM_CA_ATTESTATION -{ - UINT32 credSize; - TPM_KEY_PARMS algorithm; - UINT8 *credential; +/// +/// Part 2, section 12.9 TPM_SYM_CA_ATTESTATION +/// +typedef struct tdTPM_SYM_CA_ATTESTATION { + UINT32 credSize; + TPM_KEY_PARMS algorithm; + UINT8 *credential; } TPM_SYM_CA_ATTESTATION; -// -// Part 2, section 15: TPM_CURRENT_TICKS -// Placed here out of order because definitions are used in section 13. -// +/// +/// Part 2, section 15: Tick Structures +/// Placed here out of order because definitions are used in section 13. +/// typedef struct tdTPM_CURRENT_TICKS { TPM_STRUCTURE_TAG tag; UINT64 currentTicks; @@ -1070,79 +1278,93 @@ typedef struct tdTPM_CURRENT_TICKS { TPM_NONCE tickNonce; } TPM_CURRENT_TICKS; +/// +/// Part 2, section 13: Transport structures +/// + +/// +/// Part 2, section 13.1: TPM _TRANSPORT_PUBLIC +/// +typedef struct tdTPM_TRANSPORT_PUBLIC { + TPM_STRUCTURE_TAG tag; + TPM_TRANSPORT_ATTRIBUTES transAttributes; + TPM_ALGORITHM_ID algId; + TPM_ENC_SCHEME encScheme; +} TPM_TRANSPORT_PUBLIC; + // -// Part 2, section 13: Transport structures +// Part 2, section 13.1.1 TPM_TRANSPORT_ATTRIBUTES Definitions // +#define TPM_TRANSPORT_ENCRYPT ((UINT32)BIT0) +#define TPM_TRANSPORT_LOG ((UINT32)BIT1) +#define TPM_TRANSPORT_EXCLUSIVE ((UINT32)BIT2) -#define TPM_TRANSPORT_ENCRYPT ((UINT32)0x00000001) -#define TPM_TRANSPORT_LOG ((UINT32)0x00000002) -#define TPM_TRANSPORT_EXCLUSIVE ((UINT32)0x00000004) - -typedef struct tdTPM_TRANSPORT_PUBLIC -{ - TPM_STRUCTURE_TAG tag; - TPM_TRANSPORT_ATTRIBUTES transAttributes; - TPM_ALGORITHM_ID algId; - TPM_ENC_SCHEME encScheme; -} TPM_TRANSPORT_PUBLIC; - -typedef struct tdTPM_TRANSPORT_INTERNAL -{ - TPM_STRUCTURE_TAG tag; - TPM_AUTHDATA authData; - TPM_TRANSPORT_PUBLIC transPublic; - TPM_TRANSHANDLE transHandle; - TPM_NONCE transNonceEven; - TPM_DIGEST transDigest; +/// +/// Part 2, section 13.2 TPM_TRANSPORT_INTERNAL +/// +typedef struct tdTPM_TRANSPORT_INTERNAL { + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; + TPM_TRANSPORT_PUBLIC transPublic; + TPM_TRANSHANDLE transHandle; + TPM_NONCE transNonceEven; + TPM_DIGEST transDigest; } TPM_TRANSPORT_INTERNAL; -typedef struct tdTPM_TRANSPORT_LOG_IN -{ - TPM_STRUCTURE_TAG tag; - TPM_DIGEST parameters; - TPM_DIGEST pubKeyHash; +/// +/// Part 2, section 13.3 TPM_TRANSPORT_LOG_IN structure +/// +typedef struct tdTPM_TRANSPORT_LOG_IN { + TPM_STRUCTURE_TAG tag; + TPM_DIGEST parameters; + TPM_DIGEST pubKeyHash; } TPM_TRANSPORT_LOG_IN; -typedef struct tdTPM_TRANSPORT_LOG_OUT -{ - TPM_STRUCTURE_TAG tag; - TPM_CURRENT_TICKS currentTicks; - TPM_DIGEST parameters; - TPM_MODIFIER_INDICATOR locality; +/// +/// Part 2, section 13.4 TPM_TRANSPORT_LOG_OUT structure +/// +typedef struct tdTPM_TRANSPORT_LOG_OUT { + TPM_STRUCTURE_TAG tag; + TPM_CURRENT_TICKS currentTicks; + TPM_DIGEST parameters; + TPM_MODIFIER_INDICATOR locality; } TPM_TRANSPORT_LOG_OUT; -typedef struct tdTPM_TRANSPORT_AUTH -{ - TPM_STRUCTURE_TAG tag; - TPM_AUTHDATA authData; +/// +/// Part 2, section 13.5 TPM_TRANSPORT_AUTH structure +/// +typedef struct tdTPM_TRANSPORT_AUTH { + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; } TPM_TRANSPORT_AUTH; // // Part 2, section 14: Audit Structures // -typedef struct tdTPM_AUDIT_EVENT_IN -{ - TPM_STRUCTURE_TAG tag; - TPM_DIGEST inputParms; - TPM_COUNTER_VALUE auditCount; +/// +/// Part 2, section 14.1 TPM_AUDIT_EVENT_IN structure +/// +typedef struct tdTPM_AUDIT_EVENT_IN { + TPM_STRUCTURE_TAG tag; + TPM_DIGEST inputParms; + TPM_COUNTER_VALUE auditCount; } TPM_AUDIT_EVENT_IN; -typedef struct tdTPM_AUDIT_EVENT_OUT -{ - TPM_STRUCTURE_TAG tag; - TPM_COMMAND_CODE ordinal; - TPM_DIGEST outputParms; - TPM_COUNTER_VALUE auditCount; - TPM_RESULT returnCode; +/// +/// Part 2, section 14.2 TPM_AUDIT_EVENT_OUT structure +/// +typedef struct tdTPM_AUDIT_EVENT_OUT { + TPM_STRUCTURE_TAG tag; + TPM_COMMAND_CODE ordinal; + TPM_DIGEST outputParms; + TPM_COUNTER_VALUE auditCount; + TPM_RESULT returnCode; } TPM_AUDIT_EVENT_OUT; // // Part 2, section 16: Return Codes // -#ifndef TPM_BASE -#error "TPM Error Codes require definition of TPM_BASE" -#endif #define TPM_VENDOR_ERROR TPM_Vendor_Specific32 #define TPM_NON_FATAL 0x00000800 @@ -1410,32 +1632,39 @@ typedef struct tdTPM_AUDIT_EVENT_OUT // Part 2, section 18: Context structures // -typedef struct tdTPM_CONTEXT_BLOB -{ - TPM_STRUCTURE_TAG tag; - TPM_RESOURCE_TYPE resourceType; - TPM_HANDLE handle; - UINT8 label[16]; - UINT32 contextCount; - TPM_DIGEST integrityDigest; - UINT32 additionalSize; - UINT8 *additionalData; - UINT32 sensitiveSize; - UINT8 *sensitiveData; +/// +/// Part 2, section 18.1: TPM_CONTEXT_BLOB +/// +typedef struct tdTPM_CONTEXT_BLOB { + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + TPM_HANDLE handle; + UINT8 label[16]; + UINT32 contextCount; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + UINT8 *additionalData; + UINT32 sensitiveSize; + UINT8 *sensitiveData; } TPM_CONTEXT_BLOB; -typedef struct tdTPM_CONTEXT_SENSITIVE -{ - TPM_STRUCTURE_TAG tag; - TPM_NONCE contextNonce; - UINT32 internalSize; - UINT8 *internalData; +/// +/// Part 2, section 18.2 TPM_CONTEXT_SENSITIVE +/// +typedef struct tdTPM_CONTEXT_SENSITIVE { + TPM_STRUCTURE_TAG tag; + TPM_NONCE contextNonce; + UINT32 internalSize; + UINT8 *internalData; } TPM_CONTEXT_SENSITIVE; // // Part 2, section 19: NV Structures // +// +// Part 2, section 19.1.1: Required TPM_NV_INDEX values +// #define TPM_NV_INDEX_LOCK ((UINT32)0xffffffff) #define TPM_NV_INDEX0 ((UINT32)0x00000000) #define TPM_NV_INDEX_DIR ((UINT32)0x10000001) @@ -1443,7 +1672,9 @@ typedef struct tdTPM_CONTEXT_SENSITIVE #define TPM_NV_INDEX_TPM_CC ((UINT32)0x0000f001) #define TPM_NV_INDEX_PlatformCert ((UINT32)0x0000f002) #define TPM_NV_INDEX_Platform_CC ((UINT32)0x0000f003) -// The following define ranges of reserved indices. +// +// Part 2, section 19.1.2: Reserved Index values +// #define TPM_NV_INDEX_TSS_BASE ((UINT32)0x00011100) #define TPM_NV_INDEX_PC_BASE ((UINT32)0x00011200) #define TPM_NV_INDEX_SERVER_BASE ((UINT32)0x00011300) @@ -1451,222 +1682,238 @@ typedef struct tdTPM_CONTEXT_SENSITIVE #define TPM_NV_INDEX_PERIPHERAL_BASE ((UINT32)0x00011500) #define TPM_NV_INDEX_GROUP_RESV_BASE ((UINT32)0x00010000) -typedef UINT32 TPM_NV_PER_ATTRIBUTES; -// The typedefs TPM_NV_PER_ATTRIBUTES (not present in TPM 1.2 Spec. have been added -// and structure fields that were to hold the following values -#define TPM_NV_PER_READ_STCLEAR (((UINT32)1)<<31) -#define TPM_NV_PER_AUTHREAD (((UINT32)1)<<18) -#define TPM_NV_PER_OWNERREAD (((UINT32)1)<<17) -#define TPM_NV_PER_PPREAD (((UINT32)1)<<16) -#define TPM_NV_PER_GLOBALLOCK (((UINT32)1)<<15) -#define TPM_NV_PER_WRITE_STCLEAR (((UINT32)1)<<14) -#define TPM_NV_PER_WRITEDEFINE (((UINT32)1)<<13) -#define TPM_NV_PER_WRITEALL (((UINT32)1)<<12) -#define TPM_NV_PER_AUTHWRITE (((UINT32)1)<<2) -#define TPM_NV_PER_OWNERWRITE (((UINT32)1)<<1) -#define TPM_NV_PER_PPWRITE (((UINT32)1)<<0) - -typedef struct tdTPM_NV_ATTRIBUTES -{ - TPM_STRUCTURE_TAG tag; - TPM_NV_PER_ATTRIBUTES attributes; +/// +/// Part 2, section 19.2: TPM_NV_ATTRIBUTES +/// +typedef struct tdTPM_NV_ATTRIBUTES { + TPM_STRUCTURE_TAG tag; + UINT32 attributes; } TPM_NV_ATTRIBUTES; - -typedef struct tdTPM_NV_DATA_PUBLIC -{ - TPM_STRUCTURE_TAG tag; - TPM_NV_INDEX nvIndex; - TPM_PCR_INFO_SHORT pcrInfoRead; - TPM_PCR_INFO_SHORT pcrInfoWrite; - TPM_NV_ATTRIBUTES permission; - BOOLEAN bReadSTClear; - BOOLEAN bWriteSTClear; - BOOLEAN bWriteDefine; - UINT32 dataSize; +#define TPM_NV_PER_READ_STCLEAR (BIT31) +#define TPM_NV_PER_AUTHREAD (BIT18) +#define TPM_NV_PER_OWNERREAD (BIT17) +#define TPM_NV_PER_PPREAD (BIT16) +#define TPM_NV_PER_GLOBALLOCK (BIT15) +#define TPM_NV_PER_WRITE_STCLEAR (BIT14) +#define TPM_NV_PER_WRITEDEFINE (BIT13) +#define TPM_NV_PER_WRITEALL (BIT12) +#define TPM_NV_PER_AUTHWRITE (BIT2) +#define TPM_NV_PER_OWNERWRITE (BIT1) +#define TPM_NV_PER_PPWRITE (BIT0) + +/// +/// Part 2, section 19.3: TPM_NV_DATA_PUBLIC +/// +typedef struct tdTPM_NV_DATA_PUBLIC { + TPM_STRUCTURE_TAG tag; + TPM_NV_INDEX nvIndex; + TPM_PCR_INFO_SHORT pcrInfoRead; + TPM_PCR_INFO_SHORT pcrInfoWrite; + TPM_NV_ATTRIBUTES permission; + BOOLEAN bReadSTClear; + BOOLEAN bWriteSTClear; + BOOLEAN bWriteDefine; + UINT32 dataSize; } TPM_NV_DATA_PUBLIC; +// +// Part 2, section 20: Delegate Structures +// +#define TPM_DEL_OWNER_BITS ((UINT32)0x00000001) +#define TPM_DEL_KEY_BITS ((UINT32)0x00000002) +/// +/// Part 2, section 20.2: Delegate Definitions +/// +typedef struct tdTPM_DELEGATIONS { + TPM_STRUCTURE_TAG tag; + UINT32 delegateType; + UINT32 per1; + UINT32 per2; +} TPM_DELEGATIONS; -// Internal to TPM: -//typedef struct tdTPM_NV_DATA_SENSITIVE -//{ -// TPM_STRUCTURE_TAG tag; -// TPM_NV_DATA_PUBLIC pubInfo; -// TPM_AUTHDATA authValue; -// UINT8 *data; -//} TPM_NV_DATA_SENSITIVE; - - -// -// Part 2, section 20: Delegation -// - -// -// Part 2, section 20.3: Owner Permissions Settings for per1 bits -// -#define TPM_DELEGATE_SetOrdinalAuditStatus (((UINT32)1)<<30) -#define TPM_DELEGATE_DirWriteAuth (((UINT32)1)<<29) -#define TPM_DELEGATE_CMK_ApproveMA (((UINT32)1)<<28) -#define TPM_DELEGATE_CMK_CreateTicket (((UINT32)1)<<26) -#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (((UINT32)1)<<24) -#define TPM_DELEGATE_DAA_Join (((UINT32)1)<<23) -#define TPM_DELEGATE_AuthorizeMigrationKey (((UINT32)1)<<22) -#define TPM_DELEGATE_CreateMaintenanceArchive (((UINT32)1)<<21) -#define TPM_DELEGATE_LoadMaintenanceArchive (((UINT32)1)<<20) -#define TPM_DELEGATE_KillMaintenanceFeature (((UINT32)1)<<19) -#define TPM_DELEGATE_OwnerReadInteralPub (((UINT32)1)<<18) -#define TPM_DELEGATE_ResetLockValue (((UINT32)1)<<17) -#define TPM_DELEGATE_OwnerClear (((UINT32)1)<<16) -#define TPM_DELEGATE_DisableOwnerClear (((UINT32)1)<<15) -#define TPM_DELEGATE_OwnerSetDisable (((UINT32)1)<<13) -#define TPM_DELEGATE_SetCapability (((UINT32)1)<<12) -#define TPM_DELEGATE_MakeIdentity (((UINT32)1)<<11) -#define TPM_DELEGATE_ActivateIdentity (((UINT32)1)<<10) -#define TPM_DELEGATE_OwnerReadPubek (((UINT32)1)<<9) -#define TPM_DELEGATE_DisablePubekRead (((UINT32)1)<<8) -#define TPM_DELEGATE_SetRedirection (((UINT32)1)<<7) -#define TPM_DELEGATE_FieldUpgrade (((UINT32)1)<<6) -#define TPM_DELEGATE_Delegate_UpdateVerification (((UINT32)1)<<5) -#define TPM_DELEGATE_CreateCounter (((UINT32)1)<<4) -#define TPM_DELEGATE_ReleaseCounterOwner (((UINT32)1)<<3) -#define TPM_DELEGATE_DelegateManage (((UINT32)1)<<2) -#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1) -#define TPM_DELEGATE_DAA_Sign (((UINT32)1)<<0) - -// -// Part 2, section 20.3: Key Permissions Settings for per1 bits -// -#define TPM_KEY_DELEGATE_CMK_ConvertMigration (((UINT32)1)<<28) -#define TPM_KEY_DELEGATE_TickStampBlob (((UINT32)1)<<27) -#define TPM_KEY_DELEGATE_ChangeAuthAsymStart (((UINT32)1)<<26) -#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish (((UINT32)1)<<25) -#define TPM_KEY_DELEGATE_CMK_CreateKey (((UINT32)1)<<24) -#define TPM_KEY_DELEGATE_MigrateKey (((UINT32)1)<<23) -#define TPM_KEY_DELEGATE_LoadKey2 (((UINT32)1)<<22) -#define TPM_KEY_DELEGATE_EstablishTransport (((UINT32)1)<<21) -#define TPM_KEY_DELEGATE_ReleaseTransportSigned (((UINT32)1)<<20) -#define TPM_KEY_DELEGATE_Quote2 (((UINT32)1)<<19) -#define TPM_KEY_DELEGATE_Sealx (((UINT32)1)<<18) -#define TPM_KEY_DELEGATE_MakeIdentity (((UINT32)1)<<17) -#define TPM_KEY_DELEGATE_ActivateIdentity (((UINT32)1)<<16) -#define TPM_KEY_DELEGATE_GetAuditDigestSigned (((UINT32)1)<<15) -#define TPM_KEY_DELEGATE_Sign (((UINT32)1)<<14) -#define TPM_KEY_DELEGATE_CertifyKey2 (((UINT32)1)<<13) -#define TPM_KEY_DELEGATE_CertifyKey (((UINT32)1)<<12) -#define TPM_KEY_DELEGATE_CreateWrapKey (((UINT32)1)<<11) -#define TPM_KEY_DELEGATE_CMK_CreateBlob (((UINT32)1)<<10) -#define TPM_KEY_DELEGATE_CreateMigrationBlob (((UINT32)1)<<9) -#define TPM_KEY_DELEGATE_ConvertMigrationBlob (((UINT32)1)<<8) -#define TPM_KEY_DELEGATE_CreateKeyDelegation (((UINT32)1)<<7) -#define TPM_KEY_DELEGATE_ChangeAuth (((UINT32)1)<<6) -#define TPM_KEY_DELEGATE_GetPubKey (((UINT32)1)<<5) -#define TPM_KEY_DELEGATE_UnBind (((UINT32)1)<<4) -#define TPM_KEY_DELEGATE_Quote (((UINT32)1)<<3) -#define TPM_KEY_DELEGATE_Unseal (((UINT32)1)<<2) -#define TPM_KEY_DELEGATE_Seal (((UINT32)1)<<1) -#define TPM_KEY_DELEGATE_LoadKey (((UINT32)1)<<0) - -#define TPM_FAMILY_CREATE ((UINT32)0x00000001) -#define TPM_FAMILY_ENABLE ((UINT32)0x00000002) -#define TPM_FAMILY_ADMIN ((UINT32)0x00000003) -#define TPM_FAMILY_INVALIDATE ((UINT32)0x00000004) - -#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK (((UINT32)1)<<1) -#define TPM_FAMFLAG_ENABLE (((UINT32)1)<<0) - -typedef struct tdTPM_FAMILY_LABEL -{ - UINT8 label; +// +// Part 2, section 20.2.1: Owner Permission Settings +// +#define TPM_DELEGATE_SetOrdinalAuditStatus (BIT30) +#define TPM_DELEGATE_DirWriteAuth (BIT29) +#define TPM_DELEGATE_CMK_ApproveMA (BIT28) +#define TPM_DELEGATE_NV_WriteValue (BIT27) +#define TPM_DELEGATE_CMK_CreateTicket (BIT26) +#define TPM_DELEGATE_NV_ReadValue (BIT25) +#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (BIT24) +#define TPM_DELEGATE_DAA_Join (BIT23) +#define TPM_DELEGATE_AuthorizeMigrationKey (BIT22) +#define TPM_DELEGATE_CreateMaintenanceArchive (BIT21) +#define TPM_DELEGATE_LoadMaintenanceArchive (BIT20) +#define TPM_DELEGATE_KillMaintenanceFeature (BIT19) +#define TPM_DELEGATE_OwnerReadInteralPub (BIT18) +#define TPM_DELEGATE_ResetLockValue (BIT17) +#define TPM_DELEGATE_OwnerClear (BIT16) +#define TPM_DELEGATE_DisableOwnerClear (BIT15) +#define TPM_DELEGATE_NV_DefineSpace (BIT14) +#define TPM_DELEGATE_OwnerSetDisable (BIT13) +#define TPM_DELEGATE_SetCapability (BIT12) +#define TPM_DELEGATE_MakeIdentity (BIT11) +#define TPM_DELEGATE_ActivateIdentity (BIT10) +#define TPM_DELEGATE_OwnerReadPubek (BIT9) +#define TPM_DELEGATE_DisablePubekRead (BIT8) +#define TPM_DELEGATE_SetRedirection (BIT7) +#define TPM_DELEGATE_FieldUpgrade (BIT6) +#define TPM_DELEGATE_Delegate_UpdateVerification (BIT5) +#define TPM_DELEGATE_CreateCounter (BIT4) +#define TPM_DELEGATE_ReleaseCounterOwner (BIT3) +#define TPM_DELEGATE_DelegateManage (BIT2) +#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (BIT1) +#define TPM_DELEGATE_DAA_Sign (BIT0) + +// +// Part 2, section 20.2.3: Key Permission settings +// +#define TPM_KEY_DELEGATE_CMK_ConvertMigration (BIT28) +#define TPM_KEY_DELEGATE_TickStampBlob (BIT27) +#define TPM_KEY_DELEGATE_ChangeAuthAsymStart (BIT26) +#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish (BIT25) +#define TPM_KEY_DELEGATE_CMK_CreateKey (BIT24) +#define TPM_KEY_DELEGATE_MigrateKey (BIT23) +#define TPM_KEY_DELEGATE_LoadKey2 (BIT22) +#define TPM_KEY_DELEGATE_EstablishTransport (BIT21) +#define TPM_KEY_DELEGATE_ReleaseTransportSigned (BIT20) +#define TPM_KEY_DELEGATE_Quote2 (BIT19) +#define TPM_KEY_DELEGATE_Sealx (BIT18) +#define TPM_KEY_DELEGATE_MakeIdentity (BIT17) +#define TPM_KEY_DELEGATE_ActivateIdentity (BIT16) +#define TPM_KEY_DELEGATE_GetAuditDigestSigned (BIT15) +#define TPM_KEY_DELEGATE_Sign (BIT14) +#define TPM_KEY_DELEGATE_CertifyKey2 (BIT13) +#define TPM_KEY_DELEGATE_CertifyKey (BIT12) +#define TPM_KEY_DELEGATE_CreateWrapKey (BIT11) +#define TPM_KEY_DELEGATE_CMK_CreateBlob (BIT10) +#define TPM_KEY_DELEGATE_CreateMigrationBlob (BIT9) +#define TPM_KEY_DELEGATE_ConvertMigrationBlob (BIT8) +#define TPM_KEY_DELEGATE_CreateKeyDelegation (BIT7) +#define TPM_KEY_DELEGATE_ChangeAuth (BIT6) +#define TPM_KEY_DELEGATE_GetPubKey (BIT5) +#define TPM_KEY_DELEGATE_UnBind (BIT4) +#define TPM_KEY_DELEGATE_Quote (BIT3) +#define TPM_KEY_DELEGATE_Unseal (BIT2) +#define TPM_KEY_DELEGATE_Seal (BIT1) +#define TPM_KEY_DELEGATE_LoadKey (BIT0) + +// +// Part 2, section 20.3: TPM_FAMILY_FLAGS +// +#define TPM_DELEGATE_ADMIN_LOCK (BIT1) +#define TPM_FAMFLAG_ENABLE (BIT0) + +/// +/// Part 2, section 20.4: TPM_FAMILY_LABEL +/// +typedef struct tdTPM_FAMILY_LABEL { + UINT8 label; } TPM_FAMILY_LABEL; -typedef struct tdTPM_FAMILY_TABLE_ENTRY -{ - TPM_STRUCTURE_TAG tag; - TPM_FAMILY_LABEL label; - TPM_FAMILY_ID familyID; - TPM_FAMILY_VERIFICATION verificationCount; - TPM_FAMILY_FLAGS flags; +/// +/// Part 2, section 20.5: TPM_FAMILY_TABLE_ENTRY +/// +typedef struct tdTPM_FAMILY_TABLE_ENTRY { + TPM_STRUCTURE_TAG tag; + TPM_FAMILY_LABEL label; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; + TPM_FAMILY_FLAGS flags; } TPM_FAMILY_TABLE_ENTRY; -#define TPM_FAMILY_TABLE_ENTRY_MIN 8 -//typedef struct tdTPM_FAMILY_TABLE -//{ -// TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN]; -//} TPM_FAMILY_TABLE; +// +// Part 2, section 20.6: TPM_FAMILY_TABLE +// +#define TPM_NUM_FAMILY_TABLE_ENTRY_MIN 8 +typedef struct tdTPM_FAMILY_TABLE{ + TPM_FAMILY_TABLE_ENTRY famTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN]; +} TPM_FAMILY_TABLE; -typedef struct tdTPM_DELEGATE_LABEL -{ - UINT8 label; +/// +/// Part 2, section 20.7: TPM_DELEGATE_LABEL +/// +typedef struct tdTPM_DELEGATE_LABEL { + UINT8 label; } TPM_DELEGATE_LABEL; - -typedef UINT32 TPM_DELEGATE_TYPE; -#define TPM_DEL_OWNER_BITS ((UINT32)0x00000001) -#define TPM_DEL_KEY_BITS ((UINT32)0x00000002) - -typedef struct tdTPM_DELEGATIONS -{ - TPM_STRUCTURE_TAG tag; - TPM_DELEGATE_TYPE delegateType; - UINT32 per1; - UINT32 per2; -} TPM_DELEGATIONS; - -typedef struct tdTPM_DELEGATE_PUBLIC -{ - TPM_STRUCTURE_TAG tag; - TPM_DELEGATE_LABEL label; - TPM_PCR_INFO_SHORT pcrInfo; - TPM_DELEGATIONS permissions; - TPM_FAMILY_ID familyID; - TPM_FAMILY_VERIFICATION verificationCount; +/// +/// Part 2, section 20.8: TPM_DELEGATE_PUBLIC +/// +typedef struct tdTPM_DELEGATE_PUBLIC { + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_LABEL label; + TPM_PCR_INFO_SHORT pcrInfo; + TPM_DELEGATIONS permissions; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; } TPM_DELEGATE_PUBLIC; -typedef struct tdTPM_DELEGATE_TABLE_ROW -{ - TPM_STRUCTURE_TAG tag; - TPM_DELEGATE_PUBLIC pub; - TPM_SECRET authValue; +/// +/// Part 2, section 20.9: TPM_DELEGATE_TABLE_ROW +/// +typedef struct tdTPM_DELEGATE_TABLE_ROW { + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_SECRET authValue; } TPM_DELEGATE_TABLE_ROW; - +// +// Part 2, section 20.10: TPM_DELEGATE_TABLE +// #define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2 -//typedef struct tdTPM_DELEGATE_TABLE -//{ -// TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN]; -//} TPM_DELEGATE_TABLE; - -typedef struct tdTPM_DELEGATE_SENSITIVE -{ - TPM_STRUCTURE_TAG tag; - TPM_SECRET authValue; + +typedef struct tdTPM_DELEGATE_TABLE{ + TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN]; +} TPM_DELEGATE_TABLE; + +/// +/// Part 2, section 20.11: TPM_DELEGATE_SENSITIVE +/// +typedef struct tdTPM_DELEGATE_SENSITIVE { + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; } TPM_DELEGATE_SENSITIVE; -typedef struct tdTPM_DELEGATE_OWNER_BLOB -{ - TPM_STRUCTURE_TAG tag; - TPM_DELEGATE_PUBLIC pub; - TPM_DIGEST integrityDigest; - UINT32 additionalSize; - UINT8 *additionalArea; - UINT32 sensitiveSize; - UINT8 *sensitiveArea; +/// +/// Part 2, section 20.12: TPM_DELEGATE_OWNER_BLOB +/// +typedef struct tdTPM_DELEGATE_OWNER_BLOB { + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + UINT8 *additionalArea; + UINT32 sensitiveSize; + UINT8 *sensitiveArea; } TPM_DELEGATE_OWNER_BLOB; -typedef struct tdTPM_DELEGATE_KEY_BLOB -{ - TPM_STRUCTURE_TAG tag; - TPM_DELEGATE_PUBLIC pub; - TPM_DIGEST integrityDigest; - TPM_DIGEST pubKeyDigest; - UINT32 additionalSize; - UINT8 *additionalArea; - UINT32 sensitiveSize; - UINT8 *sensitiveArea; +/// +/// Part 2, section 20.13: TTPM_DELEGATE_KEY_BLOB +/// +typedef struct tdTPM_DELEGATE_KEY_BLOB { + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + TPM_DIGEST pubKeyDigest; + UINT32 additionalSize; + UINT8 *additionalArea; + UINT32 sensitiveSize; + UINT8 *sensitiveArea; } TPM_DELEGATE_KEY_BLOB; +// +// Part 2, section 20.14: TPM_FAMILY_OPERATION Values +// +#define TPM_FAMILY_CREATE ((UINT32)0x00000001) +#define TPM_FAMILY_ENABLE ((UINT32)0x00000002) +#define TPM_FAMILY_ADMIN ((UINT32)0x00000003) +#define TPM_FAMILY_INVALIDATE ((UINT32)0x00000004) + // // Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability // @@ -1728,9 +1975,19 @@ typedef struct tdTPM_DELEGATE_KEY_BLOB #define TPM_CAP_PROP_INPUT_BUFFER ((TPM_CAPABILITY_AREA) 0x00000124) // -// Part 2, section 21.6: TPM_CAP_VERSION_INFO -// [size_is(vendorSpecificSize)] BYTE* vendorSpecific; +// Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability // +#define TPM_SET_PERM_FLAGS ((TPM_CAPABILITY_AREA) 0x00000001) +#define TPM_SET_PERM_DATA ((TPM_CAPABILITY_AREA) 0x00000002) +#define TPM_SET_STCLEAR_FLAGS ((TPM_CAPABILITY_AREA) 0x00000003) +#define TPM_SET_STCLEAR_DATA ((TPM_CAPABILITY_AREA) 0x00000004) +#define TPM_SET_STANY_FLAGS ((TPM_CAPABILITY_AREA) 0x00000005) +#define TPM_SET_STANY_DATA ((TPM_CAPABILITY_AREA) 0x00000006) + +/// +/// Part 2, section 21.6: TPM_CAP_VERSION_INFO +/// [size_is(vendorSpecificSize)] BYTE* vendorSpecific; +/// typedef struct tdTPM_CAP_VERSION_INFO { TPM_STRUCTURE_TAG tag; TPM_VERSION version; @@ -1741,10 +1998,57 @@ typedef struct tdTPM_CAP_VERSION_INFO { UINT8 *vendorSpecific; } TPM_CAP_VERSION_INFO; +/// +/// Part 2, section 21.10: TPM_DA_ACTION_TYPE +/// +typedef struct tdTPM_DA_ACTION_TYPE { + TPM_STRUCTURE_TAG tag; + UINT32 actions; +} TPM_DA_ACTION_TYPE; + +#define TPM_DA_ACTION_FAILURE_MODE (((UINT32)1)<<3) +#define TPM_DA_ACTION_DEACTIVATE (((UINT32)1)<<2) +#define TPM_DA_ACTION_DISABLE (((UINT32)1)<<1) +#define TPM_DA_ACTION_TIMEOUT (((UINT32)1)<<0) + +/// +/// Part 2, section 21.7: TPM_DA_INFO +/// +typedef struct tdTPM_DA_INFO { + TPM_STRUCTURE_TAG tag; + TPM_DA_STATE state; + UINT16 currentCount; + UINT16 thresholdCount; + TPM_DA_ACTION_TYPE actionAtThreshold; + UINT32 actionDependValue; + UINT32 vendorDataSize; + UINT8 *vendorData; +} TPM_DA_INFO; + +/// +/// Part 2, section 21.8: TPM_DA_INFO_LIMITED +/// +typedef struct tdTPM_DA_INFO_LIMITED { + TPM_STRUCTURE_TAG tag; + TPM_DA_STATE state; + TPM_DA_ACTION_TYPE actionAtThreshold; + UINT32 vendorDataSize; + UINT8 *vendorData; +} TPM_DA_INFO_LIMITED; + +// +// Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability +// +#define TPM_DA_STATE_INACTIVE ((UINT8)0x00) +#define TPM_DA_STATE_ACTIVE ((UINT8)0x01) + // // Part 2, section 22: DAA Structures // +// +// Part 2, section 22.1: Size definitions +// #define TPM_DAA_SIZE_r0 (43) #define TPM_DAA_SIZE_r1 (43) #define TPM_DAA_SIZE_r2 (128) @@ -1756,66 +2060,80 @@ typedef struct tdTPM_CAP_VERSION_INFO { #define TPM_DAA_SIZE_NE (256) #define TPM_DAA_SIZE_w (256) #define TPM_DAA_SIZE_issuerModulus (256) +// +// Part 2, section 22.2: Constant definitions +// #define TPM_DAA_power0 (104) #define TPM_DAA_power1 (1024) -typedef struct tdTPM_DAA_ISSUER -{ - TPM_STRUCTURE_TAG tag; - TPM_DIGEST DAA_digest_R0; - TPM_DIGEST DAA_digest_R1; - TPM_DIGEST DAA_digest_S0; - TPM_DIGEST DAA_digest_S1; - TPM_DIGEST DAA_digest_n; - TPM_DIGEST DAA_digest_gamma; - UINT8 DAA_generic_q[26]; +/// +/// Part 2, section 22.3: TPM_DAA_ISSUER +/// +typedef struct tdTPM_DAA_ISSUER { + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digest_R0; + TPM_DIGEST DAA_digest_R1; + TPM_DIGEST DAA_digest_S0; + TPM_DIGEST DAA_digest_S1; + TPM_DIGEST DAA_digest_n; + TPM_DIGEST DAA_digest_gamma; + UINT8 DAA_generic_q[26]; } TPM_DAA_ISSUER; - -typedef struct tdTPM_DAA_TPM -{ - TPM_STRUCTURE_TAG tag; - TPM_DIGEST DAA_digestIssuer; - TPM_DIGEST DAA_digest_v0; - TPM_DIGEST DAA_digest_v1; - TPM_DIGEST DAA_rekey; - UINT32 DAA_count; +/// +/// Part 2, section 22.4: TPM_DAA_TPM +/// +typedef struct tdTPM_DAA_TPM { + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestIssuer; + TPM_DIGEST DAA_digest_v0; + TPM_DIGEST DAA_digest_v1; + TPM_DIGEST DAA_rekey; + UINT32 DAA_count; } TPM_DAA_TPM; -typedef struct tdTPM_DAA_CONTEXT -{ - TPM_STRUCTURE_TAG tag; - TPM_DIGEST DAA_digestContext; - TPM_DIGEST DAA_digest; - TPM_DAA_CONTEXT_SEED DAA_contextSeed; - UINT8 DAA_scratch[256]; - UINT8 DAA_stage; +/// +/// Part 2, section 22.5: TPM_DAA_CONTEXT +/// +typedef struct tdTPM_DAA_CONTEXT { + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestContext; + TPM_DIGEST DAA_digest; + TPM_DAA_CONTEXT_SEED DAA_contextSeed; + UINT8 DAA_scratch[256]; + UINT8 DAA_stage; } TPM_DAA_CONTEXT; -typedef struct tdTPM_DAA_JOINDATA -{ - UINT8 DAA_join_u0[128]; - UINT8 DAA_join_u1[138]; - TPM_DIGEST DAA_digest_n0; +/// +/// Part 2, section 22.6: TPM_DAA_JOINDATA +/// +typedef struct tdTPM_DAA_JOINDATA { + UINT8 DAA_join_u0[128]; + UINT8 DAA_join_u1[138]; + TPM_DIGEST DAA_digest_n0; } TPM_DAA_JOINDATA; -typedef struct tdTPM_DAA_BLOB -{ - TPM_STRUCTURE_TAG tag; - TPM_RESOURCE_TYPE resourceType; - UINT8 label[16]; - TPM_DIGEST blobIntegrity; - UINT32 additionalSize; - UINT8 *additionalData; - UINT32 sensitiveSize; - UINT8 *sensitiveData; +/// +/// Part 2, section 22.8: TPM_DAA_BLOB +/// +typedef struct tdTPM_DAA_BLOB { + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + UINT8 label[16]; + TPM_DIGEST blobIntegrity; + UINT32 additionalSize; + UINT8 *additionalData; + UINT32 sensitiveSize; + UINT8 *sensitiveData; } TPM_DAA_BLOB; -typedef struct tdTPM_DAA_SENSITIVE -{ - TPM_STRUCTURE_TAG tag; - UINT32 internalSize; - UINT8 *internalData; +/// +/// Part 2, section 22.9: TPM_DAA_SENSITIVE +/// +typedef struct tdTPM_DAA_SENSITIVE { + TPM_STRUCTURE_TAG tag; + UINT32 internalSize; + UINT8 *internalData; } TPM_DAA_SENSITIVE; @@ -1823,27 +2141,33 @@ typedef struct tdTPM_DAA_SENSITIVE // Part 2, section 23: Redirection // -// This section of the TPM spec defines exactly one value but does not -// give it a name. The definition of TPM_SetRedirection in Part3 -// refers to exactly one name but does not give its value. We join -// them here. +/// +/// Part 2 section 23.1: TPM_REDIR_COMMAND +/// This section defines exactly one value but does not +/// give it a name. The definition of TPM_SetRedirection in Part3 +/// refers to exactly one name but does not give its value. We join +/// them here. +/// #define TPM_REDIR_GPIO (0x00000001) -// -// TPM Command & Response Headers -// +/// +/// TPM Command Headers defined in Part 3 +/// typedef struct tdTPM_RQU_COMMAND_HDR { TPM_STRUCTURE_TAG tag; UINT32 paramSize; TPM_COMMAND_CODE ordinal; } TPM_RQU_COMMAND_HDR; +/// +/// TPM Response Headers defined in Part 3 +/// typedef struct tdTPM_RSP_COMMAND_HDR { TPM_STRUCTURE_TAG tag; UINT32 paramSize; TPM_RESULT returnCode; } TPM_RSP_COMMAND_HDR; -#pragma pack (pop) +#pragma pack () -#endif // _TPM12_H_ +#endif