📄 tpm.h
字号:
/*++
*
* TPM structures extracted from the TPM specification 1.2,
* Part 2 (Structures), rev 85.
*
* Errata:
*
* *) The individual bits of TPM_STARTUP_EFFECTS were not given names in
* the TPM spec so they are not defined in tpm.h.
*
* *) A few typedefs not present in the TPM 1.2 specification have been
* added. This was generally done when the TPM 1.2 spec defined a set of
* related values (either bitmasks or enumeration values) but did not
* define an associated type to hold these values. The typedefs have been
* added and structure fields that were to hold those values have been
* switched from generic UINT* types to the more specific types. This was
* done to highlight exactly where those #defined values were to be used.
* The types that have been added are:
* TPM_NV_PER_ATTRIBUTES
* TPM_DELEGATE_TYPE
*
* *) The layout of bitfields within a structure are compiler-dependent
* and the use of structure bitfields has been avoided where possible. In
* cases where a value is a collection of independent bits the type is
* given a name (typedeffed to UINT16 or UINT32 as appropriate) and masks
* are #defined to access the individual bits. This is not possible for
* TPM_VERSION_BYTE because the fields are 4-bit values. A best attempt
* has been made to make this compiler independent but it has only been
* checked on GCC and Visual C++ on little-endian machines.
*
* *) The TPM_DELEGATIONS per1 and per2 fields field are a bitmask but
* are defined as a UINT32 because the bitfields have different meaning
* based on the type of delegation blob.
*
* *) The definitions of TPM_PERMANENT_DATA, TPM_STCLEAR_DATA,
* TPM_STANY_DATA, and TPM_DELEGATE_TABLE_ROW are commented out. These
* structures are internal to the TPM and are not directly accessible by
* external software so this should not be a problem.
*
* *) The definitions of TPM_FAMILY_TABLE and TPM_DELEGATE_TABLE are
* commented out because they are variable length arrays internal to the
* TPM. As above they are not directly accessible by external software
* so this should not be a problem.
*/
#ifndef __TPM_H__
#define __TPM_H__
#ifdef __midl
#define SIZEIS(x) [size_is(x)]
#else
#define SIZEIS(x)
#endif
#include <tss/platform.h>
//-------------------------------------------------------------------
// Part 2, section 2.1: Basic data types
typedef BYTE TPM_BOOL;
#ifndef FALSE
#define FALSE 0x00
#define TRUE 0x01
#endif /* ifndef FALSE */
//-------------------------------------------------------------------
// Part 2, section 2.3: Helper Redefinitions
// Many of the helper redefinitions appear later in this file
// so that they are declared next to the list of valid values
// they may hold.
typedef BYTE TPM_LOCALITY_MODIFIER;
typedef UINT32 TPM_COMMAND_CODE; /* 1.1b */
typedef UINT32 TPM_COUNT_ID;
typedef UINT32 TPM_REDIT_COMMAND;
typedef UINT32 TPM_HANDLE;
typedef UINT32 TPM_AUTHHANDLE;
typedef UINT32 TPM_TRANSHANDLE;
typedef UINT32 TPM_KEYHANDLE;
typedef UINT32 TPM_DIRINDEX;
typedef UINT32 TPM_PCRINDEX;
typedef UINT32 TPM_RESULT;
typedef UINT32 TPM_MODIFIER_INDICATOR;
//-------------------------------------------------------------------
// Part 2, section 2.2.4: Vendor Specific
#define TPM_Vendor_Specific32 0x00000400
#define TPM_Vendor_Specific8 0x80
//-------------------------------------------------------------------
// Part 2, section 3: Structure Tags
typedef UINT16 TPM_STRUCTURE_TAG;
#define TPM_TAG_CONTEXTBLOB ((UINT16)0x0001)
#define TPM_TAG_CONTEXT_SENSITIVE ((UINT16)0x0002)
#define TPM_TAG_CONTEXTPOINTER ((UINT16)0x0003)
#define TPM_TAG_CONTEXTLIST ((UINT16)0x0004)
#define TPM_TAG_SIGNINFO ((UINT16)0x0005)
#define TPM_TAG_PCR_INFO_LONG ((UINT16)0x0006)
#define TPM_TAG_PERSISTENT_FLAGS ((UINT16)0x0007)
#define TPM_TAG_VOLATILE_FLAGS ((UINT16)0x0008)
#define TPM_TAG_PERSISTENT_DATA ((UINT16)0x0009)
#define TPM_TAG_VOLATILE_DATA ((UINT16)0x000a)
#define TPM_TAG_SV_DATA ((UINT16)0x000b)
#define TPM_TAG_EK_BLOB ((UINT16)0x000c)
#define TPM_TAG_EK_BLOB_AUTH ((UINT16)0x000d)
#define TPM_TAG_COUNTER_VALUE ((UINT16)0x000e)
#define TPM_TAG_TRANSPORT_INTERNAL ((UINT16)0x000f)
#define TPM_TAG_TRANSPORT_LOG_IN ((UINT16)0x0010)
#define TPM_TAG_TRANSPORT_LOG_OUT ((UINT16)0x0011)
#define TPM_TAG_AUDIT_EVENT_IN ((UINT16)0x0012)
#define TPM_TAG_AUDIT_EVENT_OUT ((UINT16)0x0013)
#define TPM_TAG_CURRENT_TICKS ((UINT16)0x0014)
#define TPM_TAG_KEY ((UINT16)0x0015)
#define TPM_TAG_STORED_DATA12 ((UINT16)0x0016)
#define TPM_TAG_NV_ATTRIBUTES ((UINT16)0x0017)
#define TPM_TAG_NV_DATA_PUBLIC ((UINT16)0x0018)
#define TPM_TAG_NV_DATA_SENSITIVE ((UINT16)0x0019)
#define TPM_TAG_DELEGATIONS ((UINT16)0x001a)
#define TPM_TAG_DELEGATE_PUBLIC ((UINT16)0x001b)
#define TPM_TAG_DELEGATE_TABLE_ROW ((UINT16)0x001c)
#define TPM_TAG_TRANSPORT_AUTH ((UINT16)0x001d)
#define TPM_TAG_TRANSPORT_PUBLIC ((UINT16)0x001e)
#define TPM_TAG_PERMANENT_FLAGS ((UINT16)0x001f)
#define TPM_TAG_STCLEAR_FLAGS ((UINT16)0x0020)
#define TPM_TAG_STANY_FLAGS ((UINT16)0x0021)
#define TPM_TAG_PERMANENT_DATA ((UINT16)0x0022)
#define TPM_TAG_STCLEAR_DATA ((UINT16)0x0023)
#define TPM_TAG_STANY_DATA ((UINT16)0x0024)
#define TPM_TAG_FAMILY_TABLE_ENTRY ((UINT16)0x0025)
#define TPM_TAG_DELEGATE_SENSITIVE ((UINT16)0x0026)
#define TPM_TAG_DELG_KEY_BLOB ((UINT16)0x0027)
#define TPM_TAG_KEY12 ((UINT16)0x0028)
#define TPM_TAG_CERTIFY_INFO2 ((UINT16)0x0029)
#define TPM_TAG_DELEGATE_OWNER_BLOB ((UINT16)0x002a)
#define TPM_TAG_EK_BLOB_ACTIVATE ((UINT16)0x002b)
#define TPM_TAG_DAA_BLOB ((UINT16)0x002c)
#define TPM_TAG_DAA_CONTEXT ((UINT16)0x002d)
#define TPM_TAG_DAA_ENFORCE ((UINT16)0x002e)
#define TPM_TAG_DAA_ISSUER ((UINT16)0x002f)
#define TPM_TAG_CAP_VERSION_INFO ((UINT16)0x0030)
#define TPM_TAG_DAA_SENSITIVE ((UINT16)0x0031)
#define TPM_TAG_DAA_TPM ((UINT16)0x0032)
#define TPM_TAG_CMK_MIGAUTH ((UINT16)0x0033)
#define TPM_TAG_CMK_SIGTICKET ((UINT16)0x0034)
#define TPM_TAG_CMK_MA_APPROVAL ((UINT16)0x0035)
#define TPM_TAG_QUOTE_INFO2 ((UINT16)0x0036)
#define TPM_TAG_DA_INFO ((UINT16)0x0037)
#define TPM_TAG_DA_INFO_LIMITED ((UINT16)0x0038)
#define TPM_TAG_DA_ACTION_TYPE ((UINT16)0x0039)
//-------------------------------------------------------------------
// Part 2, section 4: Types
typedef UINT32 TPM_RESOURCE_TYPE;
#define TPM_RT_KEY ((UINT32)0x00000001)
#define TPM_RT_AUTH ((UINT32)0x00000002)
#define TPM_RT_HASH ((UINT32)0x00000003)
#define TPM_RT_TRANS ((UINT32)0x00000004)
#define TPM_RT_CONTEXT ((UINT32)0x00000005)
#define TPM_RT_COUNTER ((UINT32)0x00000006)
#define TPM_RT_DELEGATE ((UINT32)0x00000007)
#define TPM_RT_DAA_TPM ((UINT32)0x00000008)
#define TPM_RT_DAA_V0 ((UINT32)0x00000009)
#define TPM_RT_DAA_V1 ((UINT32)0x0000000a)
typedef BYTE TPM_PAYLOAD_TYPE; /* 1.1b */
#define TPM_PT_ASYM ((BYTE)0x01) /* 1.1b */
#define TPM_PT_BIND ((BYTE)0x02) /* 1.1b */
#define TPM_PT_MIGRATE ((BYTE)0x03) /* 1.1b */
#define TPM_PT_MAINT ((BYTE)0x04) /* 1.1b */
#define TPM_PT_SEAL ((BYTE)0x05) /* 1.1b */
#define TPM_PT_MIGRATE_RESTRICTED ((BYTE)0x06)
#define TPM_PT_MIGRATE_EXTERNAL ((BYTE)0x07)
#define TPM_PT_CMK_MIGRATE ((BYTE)0x08)
typedef UINT16 TPM_ENTITY_TYPE; /* 1.1b */
#define TPM_ET_KEYHANDLE ((UINT16)0x0001) /* 1.1b */
#define TPM_ET_OWNER ((UINT16)0x0002) /* 1.1b */
#define TPM_ET_DATA ((UINT16)0x0003) /* 1.1b */
#define TPM_ET_SRK ((UINT16)0x0004) /* 1.1b */
#define TPM_ET_KEY ((UINT16)0x0005) /* 1.1b */
#define TPM_ET_REVOKE ((UINT16)0x0006)
#define TPM_ET_DEL_OWNER_BLOB ((UINT16)0x0007)
#define TPM_ET_DEL_ROW ((UINT16)0x0008)
#define TPM_ET_DEL_KEY_BLOB ((UINT16)0x0009)
#define TPM_ET_COUNTER ((UINT16)0x000a)
#define TPM_ET_NV ((UINT16)0x000b)
#define TPM_ET_OPERATOR ((UINT16)0x000c)
#define TPM_ET_RESERVED_HANDLE ((UINT16)0x0040)
/* The following values may be ORed into the MSB of the TPM_ENTITY_TYPE
* to indicate particular encryption scheme
*/
#define TPM_ET_XOR ((BYTE)0x00)
#define TPM_ET_AES ((BYTE)0x06)
typedef UINT32 TPM_KEY_HANDLE; /* 1.1b */
#define TPM_KH_SRK ((UINT32)0x40000000)
#define TPM_KH_OWNER ((UINT32)0x40000001)
#define TPM_KH_REVOKE ((UINT32)0x40000002)
#define TPM_KH_TRANSPORT ((UINT32)0x40000003)
#define TPM_KH_OPERATOR ((UINT32)0x40000004)
#define TPM_KH_ADMIN ((UINT32)0x40000005)
#define TPM_KH_EK ((UINT32)0x40000006)
/* 1.1b used different names, but the same values */
#define TPM_KEYHND_SRK (TPM_KH_SRK) /* 1.1b */
#define TPM_KEYHND_OWNER (TPM_KH_OWNER) /* 1.1b */
typedef UINT16 TPM_STARTUP_TYPE; /* 1.1b */
#define TPM_ST_CLEAR ((UINT16)0x0001) /* 1.1b */
#define TPM_ST_STATE ((UINT16)0x0002) /* 1.1b */
#define TPM_ST_DEACTIVATED ((UINT16)0x0003) /* 1.1b */
//typedef UINT32 TPM_STARTUP_EFFECTS;
// 32-bit mask, see spec for meaning. Names not currently defined.
// bits 0-8 have meaning
typedef UINT16 TPM_PROTOCOL_ID; /* 1.1b */
#define TPM_PID_OIAP ((UINT16)0x0001) /* 1.1b */
#define TPM_PID_OSAP ((UINT16)0x0002) /* 1.1b */
#define TPM_PID_ADIP ((UINT16)0x0003) /* 1.1b */
#define TPM_PID_ADCP ((UINT16)0x0004) /* 1.1b */
#define TPM_PID_OWNER ((UINT16)0x0005) /* 1.1b */
#define TPM_PID_DSAP ((UINT16)0x0006)
#define TPM_PID_TRANSPORT ((UINT16)0x0007)
// Note in 1.2 rev 104, DES and 3DES are eliminated
typedef UINT32 TPM_ALGORITHM_ID; /* 1.1b */
#define TPM_ALG_RSA ((UINT32)0x00000001) /* 1.1b */
#define TPM_ALG_DES ((UINT32)0x00000002) /* 1.1b */
#define TPM_ALG_3DES ((UINT32)0x00000003) /* 1.1b */
#define TPM_ALG_SHA ((UINT32)0x00000004) /* 1.1b */
#define TPM_ALG_HMAC ((UINT32)0x00000005) /* 1.1b */
#define TPM_ALG_AES ((UINT32)0x00000006) /* 1.1b */
#define TPM_ALG_AES128 (TPM_ALG_AES)
#define TPM_ALG_MGF1 ((UINT32)0x00000007)
#define TPM_ALG_AES192 ((UINT32)0x00000008)
#define TPM_ALG_AES256 ((UINT32)0x00000009)
#define TPM_ALG_XOR ((UINT32)0x0000000a)
typedef UINT16 TPM_PHYSICAL_PRESENCE; /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_LOCK ((UINT16)0x0004) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_PRESENT ((UINT16)0x0008) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((UINT16)0x0010) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((UINT16)0x0020) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((UINT16)0x0040) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((UINT16)0x0080) /* 1.1b */
#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((UINT16)0x0100)
#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((UINT16)0x0200)
typedef UINT16 TPM_MIGRATE_SCHEME; /* 1.1b */
#define TPM_MS_MIGRATE ((UINT16)0x0001) /* 1.1b */
#define TPM_MS_REWRAP ((UINT16)0x0002) /* 1.1b */
#define TPM_MS_MAINT ((UINT16)0x0003) /* 1.1b */
#define TPM_MS_RESTRICT_MIGRATE ((UINT16)0x0004)
#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((UINT16)0x0005)
typedef UINT16 TPM_EK_TYPE;
#define TPM_EK_TYPE_ACTIVATE ((UINT16)0x0001)
#define TPM_EK_TYPE_AUTH ((UINT16)0x0002)
typedef UINT16 TPM_PLATFORM_SPECIFIC;
#define TPM_PS_PC_11 ((UINT16)0x0001)
#define TPM_PS_PC_12 ((UINT16)0x0002)
#define TPM_PS_PDA_12 ((UINT16)0x0003)
#define TPM_PS_Server_12 ((UINT16)0x0004)
#define TPM_PS_Mobile_12 ((UINT16)0x0005)
//-------------------------------------------------------------------
// Part 2, section 5: Basic Structures
typedef struct tdTPM_STRUCT_VER
{
BYTE major;
BYTE minor;
BYTE revMajor;
BYTE revMinor;
} TPM_STRUCT_VER;
typedef struct tdTPM_VERSION_BYTE
{
// This needs to be made compiler-independent.
int leastSigVer : 4; // least significant 4 bits
int mostSigVer : 4; // most significant 4 bits
} TPM_VERSION_BYTE;
typedef struct tdTPM_VERSION
{
BYTE major; // Should really be a TPM_VERSION_BYTE
BYTE minor; // Should really be a TPM_VERSION_BYTE
BYTE revMajor;
BYTE revMinor;
} TPM_VERSION;
// Put this in the right place:
// byte size definition for 160 bit SHA1 hash value
#define TPM_SHA1_160_HASH_LEN 0x14
#define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN
typedef struct tdTPM_DIGEST
{
BYTE digest[TPM_SHA1_160_HASH_LEN];
} TPM_DIGEST;
typedef TPM_DIGEST TPM_CHOSENID_HASH;
typedef TPM_DIGEST TPM_COMPOSITE_HASH;
typedef TPM_DIGEST TPM_DIRVALUE;
typedef TPM_DIGEST TPM_HMAC;
typedef TPM_DIGEST TPM_PCRVALUE;
typedef TPM_DIGEST TPM_AUDITDIGEST;
typedef struct tdTPM_NONCE /* 1.1b */
{
BYTE nonce[TPM_SHA1BASED_NONCE_LEN];
} TPM_NONCE;
typedef TPM_NONCE TPM_DAA_TPM_SEED;
typedef TPM_NONCE TPM_DAA_CONTEXT_SEED;
typedef struct tdTPM_AUTHDATA /* 1.1b */
{
BYTE authdata[TPM_SHA1_160_HASH_LEN];
} TPM_AUTHDATA;
typedef TPM_AUTHDATA TPM_SECRET;
typedef TPM_AUTHDATA TPM_ENCAUTH;
typedef struct tdTPM_KEY_HANDLE_LIST /* 1.1b */
{
UINT16 loaded;
SIZEIS(loaded)
TPM_KEY_HANDLE *handle;
} TPM_KEY_HANDLE_LIST;
//-------------------------------------------------------------------
// Part 2, section 5.8: Key usage values
typedef UINT16 TPM_KEY_USAGE; /* 1.1b */
#define TPM_KEY_SIGNING ((UINT16)0x0010) /* 1.1b */
#define TPM_KEY_STORAGE ((UINT16)0x0011) /* 1.1b */
#define TPM_KEY_IDENTITY ((UINT16)0x0012) /* 1.1b */
#define TPM_KEY_AUTHCHANGE ((UINT16)0x0013) /* 1.1b */
#define TPM_KEY_BIND ((UINT16)0x0014) /* 1.1b */
#define TPM_KEY_LEGACY ((UINT16)0x0015) /* 1.1b */
#define TPM_KEY_MIGRATE ((UINT16)0x0016)
typedef UINT16 TPM_SIG_SCHEME; /* 1.1b */
#define TPM_SS_NONE ((UINT16)0x0001) /* 1.1b */
#define TPM_SS_RSASSAPKCS1v15_SHA1 ((UINT16)0x0002) /* 1.1b */
#define TPM_SS_RSASSAPKCS1v15_DER ((UINT16)0x0003) /* 1.1b */
#define TPM_SS_RSASSAPKCS1v15_INFO ((UINT16)0x0004)
typedef UINT16 TPM_ENC_SCHEME; /* 1.1b */
#define TPM_ES_NONE ((UINT16)0x0001) /* 1.1b */
#define TPM_ES_RSAESPKCSv15 ((UINT16)0x0002) /* 1.1b */
#define TPM_ES_RSAESOAEP_SHA1_MGF1 ((UINT16)0x0003) /* 1.1b */
#define TPM_ES_SYM_CNT ((UINT16)0x0004)
#define TPM_ES_SYM_CTR TPM_ES_SYM_CNT
#define TPM_ES_SYM_OFB ((UINT16)0x0005)
#define TPM_ES_SYM_CBC_PKCS5PAD ((UINT16)0x00ff)
//-------------------------------------------------------------------
// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
typedef BYTE TPM_AUTH_DATA_USAGE; /* 1.1b */
#define TPM_AUTH_NEVER ((BYTE)0x00) /* 1.1b */
#define TPM_AUTH_ALWAYS ((BYTE)0x01) /* 1.1b */
#define TPM_AUTH_PRIV_USE_ONLY ((BYTE)0x11)
//-------------------------------------------------------------------
// Part 2, section 5.10: TPM_KEY_FLAGS flags
typedef UINT32 TPM_KEY_FLAGS; /* 1.1b */
#define TPM_REDIRECTION ((UINT32)0x00000001) /* 1.1b */
#define TPM_MIGRATABLE ((UINT32)0x00000002) /* 1.1b */
#define TPM_VOLATILE ((UINT32)0x00000004) /* 1.1b */
#define TPM_PCRIGNOREDONREAD ((UINT32)0x00000008)
#define TPM_MIGRATEAUTHORITY ((UINT32)0x00000010)
//-------------------------------------------------------------------
// 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
// declared after section 10 to catch declaration of TPM_PUBKEY
//-------------------------------------------------------------------
// Part 2, section 5.13: TPM_COUNTER_VALUE;
typedef UINT32 TPM_ACTUAL_COUNT;
typedef struct tdTPM_COUNTER_VALUE
{
TPM_STRUCTURE_TAG tag;
BYTE label[4];
TPM_ACTUAL_COUNT counter;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -