Jonathan Zhang | 6d27778 | 2020-06-09 17:56:53 -0700 | [diff] [blame] | 1 | /** @file |
| 2 | TPM2.0 Specification data structures |
| 3 | (Trusted Platform Module Library Specification, Family "2.0", Level 00, Revision 00.96, |
| 4 | @http://www.trustedcomputinggroup.org/resources/tpm_library_specification) |
| 5 | |
| 6 | Check http://trustedcomputinggroup.org for latest specification updates. |
| 7 | |
| 8 | Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved. <BR> |
| 9 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 10 | |
| 11 | **/ |
| 12 | |
| 13 | |
| 14 | #ifndef _TPM20_H_ |
| 15 | #define _TPM20_H_ |
| 16 | |
| 17 | #include <IndustryStandard/Tpm12.h> |
| 18 | |
| 19 | #pragma pack (1) |
| 20 | |
| 21 | // Annex A Algorithm Constants |
| 22 | |
| 23 | // Table 205 - Defines for SHA1 Hash Values |
| 24 | #define SHA1_DIGEST_SIZE 20 |
| 25 | #define SHA1_BLOCK_SIZE 64 |
| 26 | |
| 27 | // Table 206 - Defines for SHA256 Hash Values |
| 28 | #define SHA256_DIGEST_SIZE 32 |
| 29 | #define SHA256_BLOCK_SIZE 64 |
| 30 | |
| 31 | // Table 207 - Defines for SHA384 Hash Values |
| 32 | #define SHA384_DIGEST_SIZE 48 |
| 33 | #define SHA384_BLOCK_SIZE 128 |
| 34 | |
| 35 | // Table 208 - Defines for SHA512 Hash Values |
| 36 | #define SHA512_DIGEST_SIZE 64 |
| 37 | #define SHA512_BLOCK_SIZE 128 |
| 38 | |
| 39 | // Table 209 - Defines for SM3_256 Hash Values |
| 40 | #define SM3_256_DIGEST_SIZE 32 |
| 41 | #define SM3_256_BLOCK_SIZE 64 |
| 42 | |
| 43 | // Table 210 - Defines for Architectural Limits Values |
| 44 | #define MAX_SESSION_NUMBER 3 |
| 45 | |
| 46 | // Annex B Implementation Definitions |
| 47 | |
| 48 | // Table 211 - Defines for Logic Values |
| 49 | #define YES 1 |
| 50 | #define NO 0 |
| 51 | #define SET 1 |
| 52 | #define CLEAR 0 |
| 53 | |
| 54 | // Table 215 - Defines for RSA Algorithm Constants |
| 55 | #define MAX_RSA_KEY_BITS 2048 |
| 56 | #define MAX_RSA_KEY_BYTES ((MAX_RSA_KEY_BITS + 7) / 8) |
| 57 | |
| 58 | // Table 216 - Defines for ECC Algorithm Constants |
| 59 | #define MAX_ECC_KEY_BITS 256 |
| 60 | #define MAX_ECC_KEY_BYTES ((MAX_ECC_KEY_BITS + 7) / 8) |
| 61 | |
| 62 | // Table 217 - Defines for AES Algorithm Constants |
| 63 | #define MAX_AES_KEY_BITS 128 |
| 64 | #define MAX_AES_BLOCK_SIZE_BYTES 16 |
| 65 | #define MAX_AES_KEY_BYTES ((MAX_AES_KEY_BITS + 7) / 8) |
| 66 | |
| 67 | // Table 218 - Defines for SM4 Algorithm Constants |
| 68 | #define MAX_SM4_KEY_BITS 128 |
| 69 | #define MAX_SM4_BLOCK_SIZE_BYTES 16 |
| 70 | #define MAX_SM4_KEY_BYTES ((MAX_SM4_KEY_BITS + 7) / 8) |
| 71 | |
| 72 | // Table 219 - Defines for Symmetric Algorithm Constants |
| 73 | #define MAX_SYM_KEY_BITS MAX_AES_KEY_BITS |
| 74 | #define MAX_SYM_KEY_BYTES MAX_AES_KEY_BYTES |
| 75 | #define MAX_SYM_BLOCK_SIZE MAX_AES_BLOCK_SIZE_BYTES |
| 76 | |
| 77 | // Table 220 - Defines for Implementation Values |
| 78 | typedef UINT16 BSIZE; |
| 79 | #define BUFFER_ALIGNMENT 4 |
| 80 | #define IMPLEMENTATION_PCR 24 |
| 81 | #define PLATFORM_PCR 24 |
| 82 | #define DRTM_PCR 17 |
| 83 | #define NUM_LOCALITIES 5 |
| 84 | #define MAX_HANDLE_NUM 3 |
| 85 | #define MAX_ACTIVE_SESSIONS 64 |
| 86 | typedef UINT16 CONTEXT_SLOT; |
| 87 | typedef UINT64 CONTEXT_COUNTER; |
| 88 | #define MAX_LOADED_SESSIONS 3 |
| 89 | #define MAX_SESSION_NUM 3 |
| 90 | #define MAX_LOADED_OBJECTS 3 |
| 91 | #define MIN_EVICT_OBJECTS 2 |
| 92 | #define PCR_SELECT_MIN ((PLATFORM_PCR + 7) / 8) |
| 93 | #define PCR_SELECT_MAX ((IMPLEMENTATION_PCR + 7) / 8) |
| 94 | #define NUM_POLICY_PCR_GROUP 1 |
| 95 | #define NUM_AUTHVALUE_PCR_GROUP 1 |
| 96 | #define MAX_CONTEXT_SIZE 4000 |
| 97 | #define MAX_DIGEST_BUFFER 1024 |
| 98 | #define MAX_NV_INDEX_SIZE 1024 |
| 99 | #define MAX_CAP_BUFFER 1024 |
| 100 | #define NV_MEMORY_SIZE 16384 |
| 101 | #define NUM_STATIC_PCR 16 |
| 102 | #define MAX_ALG_LIST_SIZE 64 |
| 103 | #define TIMER_PRESCALE 100000 |
| 104 | #define PRIMARY_SEED_SIZE 32 |
| 105 | #define CONTEXT_ENCRYPT_ALG TPM_ALG_AES |
| 106 | #define CONTEXT_ENCRYPT_KEY_BITS MAX_SYM_KEY_BITS |
| 107 | #define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS + 7) / 8) |
| 108 | #define CONTEXT_INTEGRITY_HASH_ALG TPM_ALG_SHA256 |
| 109 | #define CONTEXT_INTEGRITY_HASH_SIZE SHA256_DIGEST_SIZE |
| 110 | #define PROOF_SIZE CONTEXT_INTEGRITY_HASH_SIZE |
| 111 | #define NV_CLOCK_UPDATE_INTERVAL 12 |
| 112 | #define NUM_POLICY_PCR 1 |
| 113 | #define MAX_COMMAND_SIZE 4096 |
| 114 | #define MAX_RESPONSE_SIZE 4096 |
| 115 | #define ORDERLY_BITS 8 |
| 116 | #define MAX_ORDERLY_COUNT ((1 << ORDERLY_BITS) - 1) |
| 117 | #define ALG_ID_FIRST TPM_ALG_FIRST |
| 118 | #define ALG_ID_LAST TPM_ALG_LAST |
| 119 | #define MAX_SYM_DATA 128 |
| 120 | #define MAX_RNG_ENTROPY_SIZE 64 |
| 121 | #define RAM_INDEX_SPACE 512 |
| 122 | #define RSA_DEFAULT_PUBLIC_EXPONENT 0x00010001 |
| 123 | #define CRT_FORMAT_RSA YES |
| 124 | #define PRIVATE_VENDOR_SPECIFIC_BYTES ((MAX_RSA_KEY_BYTES / 2) * ( 3 + CRT_FORMAT_RSA * 2)) |
| 125 | |
| 126 | // Capability related MAX_ value |
| 127 | #define MAX_CAP_DATA (MAX_CAP_BUFFER - sizeof(TPM_CAP) - sizeof(UINT32)) |
| 128 | #define MAX_CAP_ALGS (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY)) |
| 129 | #define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE)) |
| 130 | #define MAX_CAP_CC (MAX_CAP_DATA / sizeof(TPM_CC)) |
| 131 | #define MAX_TPM_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY)) |
| 132 | #define MAX_PCR_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT)) |
| 133 | #define MAX_ECC_CURVES (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE)) |
| 134 | |
| 135 | // |
| 136 | // Always set 5 here, because we want to support all hash algo in BIOS. |
| 137 | // |
| 138 | #define HASH_COUNT 5 |
| 139 | |
| 140 | // 5 Base Types |
| 141 | |
| 142 | // Table 3 - Definition of Base Types |
| 143 | typedef UINT8 BYTE; |
| 144 | |
| 145 | // Table 4 - Definition of Types for Documentation Clarity |
| 146 | // |
| 147 | // NOTE: Comment because it has same name as TPM1.2 (value is same, so not runtime issue) |
| 148 | // |
| 149 | //typedef UINT32 TPM_ALGORITHM_ID; |
| 150 | //typedef UINT32 TPM_MODIFIER_INDICATOR; |
| 151 | typedef UINT32 TPM_AUTHORIZATION_SIZE; |
| 152 | typedef UINT32 TPM_PARAMETER_SIZE; |
| 153 | typedef UINT16 TPM_KEY_SIZE; |
| 154 | typedef UINT16 TPM_KEY_BITS; |
| 155 | |
| 156 | // 6 Constants |
| 157 | |
| 158 | // Table 6 - TPM_GENERATED Constants |
| 159 | typedef UINT32 TPM_GENERATED; |
| 160 | #define TPM_GENERATED_VALUE (TPM_GENERATED)(0xff544347) |
| 161 | |
| 162 | // Table 7 - TPM_ALG_ID Constants |
| 163 | typedef UINT16 TPM_ALG_ID; |
| 164 | // |
| 165 | // NOTE: Comment some algo which has same name as TPM1.2 (value is same, so not runtime issue) |
| 166 | // |
| 167 | #define TPM_ALG_ERROR (TPM_ALG_ID)(0x0000) |
| 168 | #define TPM_ALG_FIRST (TPM_ALG_ID)(0x0001) |
| 169 | //#define TPM_ALG_RSA (TPM_ALG_ID)(0x0001) |
| 170 | //#define TPM_ALG_SHA (TPM_ALG_ID)(0x0004) |
| 171 | #define TPM_ALG_SHA1 (TPM_ALG_ID)(0x0004) |
| 172 | //#define TPM_ALG_HMAC (TPM_ALG_ID)(0x0005) |
| 173 | #define TPM_ALG_AES (TPM_ALG_ID)(0x0006) |
| 174 | //#define TPM_ALG_MGF1 (TPM_ALG_ID)(0x0007) |
| 175 | #define TPM_ALG_KEYEDHASH (TPM_ALG_ID)(0x0008) |
| 176 | //#define TPM_ALG_XOR (TPM_ALG_ID)(0x000A) |
| 177 | #define TPM_ALG_SHA256 (TPM_ALG_ID)(0x000B) |
| 178 | #define TPM_ALG_SHA384 (TPM_ALG_ID)(0x000C) |
| 179 | #define TPM_ALG_SHA512 (TPM_ALG_ID)(0x000D) |
| 180 | #define TPM_ALG_NULL (TPM_ALG_ID)(0x0010) |
| 181 | #define TPM_ALG_SM3_256 (TPM_ALG_ID)(0x0012) |
| 182 | #define TPM_ALG_SM4 (TPM_ALG_ID)(0x0013) |
| 183 | #define TPM_ALG_RSASSA (TPM_ALG_ID)(0x0014) |
| 184 | #define TPM_ALG_RSAES (TPM_ALG_ID)(0x0015) |
| 185 | #define TPM_ALG_RSAPSS (TPM_ALG_ID)(0x0016) |
| 186 | #define TPM_ALG_OAEP (TPM_ALG_ID)(0x0017) |
| 187 | #define TPM_ALG_ECDSA (TPM_ALG_ID)(0x0018) |
| 188 | #define TPM_ALG_ECDH (TPM_ALG_ID)(0x0019) |
| 189 | #define TPM_ALG_ECDAA (TPM_ALG_ID)(0x001A) |
| 190 | #define TPM_ALG_SM2 (TPM_ALG_ID)(0x001B) |
| 191 | #define TPM_ALG_ECSCHNORR (TPM_ALG_ID)(0x001C) |
| 192 | #define TPM_ALG_ECMQV (TPM_ALG_ID)(0x001D) |
| 193 | #define TPM_ALG_KDF1_SP800_56a (TPM_ALG_ID)(0x0020) |
| 194 | #define TPM_ALG_KDF2 (TPM_ALG_ID)(0x0021) |
| 195 | #define TPM_ALG_KDF1_SP800_108 (TPM_ALG_ID)(0x0022) |
| 196 | #define TPM_ALG_ECC (TPM_ALG_ID)(0x0023) |
| 197 | #define TPM_ALG_SYMCIPHER (TPM_ALG_ID)(0x0025) |
| 198 | #define TPM_ALG_CTR (TPM_ALG_ID)(0x0040) |
| 199 | #define TPM_ALG_OFB (TPM_ALG_ID)(0x0041) |
| 200 | #define TPM_ALG_CBC (TPM_ALG_ID)(0x0042) |
| 201 | #define TPM_ALG_CFB (TPM_ALG_ID)(0x0043) |
| 202 | #define TPM_ALG_ECB (TPM_ALG_ID)(0x0044) |
| 203 | #define TPM_ALG_LAST (TPM_ALG_ID)(0x0044) |
| 204 | |
| 205 | // Table 8 - TPM_ECC_CURVE Constants |
| 206 | typedef UINT16 TPM_ECC_CURVE; |
| 207 | #define TPM_ECC_NONE (TPM_ECC_CURVE)(0x0000) |
| 208 | #define TPM_ECC_NIST_P192 (TPM_ECC_CURVE)(0x0001) |
| 209 | #define TPM_ECC_NIST_P224 (TPM_ECC_CURVE)(0x0002) |
| 210 | #define TPM_ECC_NIST_P256 (TPM_ECC_CURVE)(0x0003) |
| 211 | #define TPM_ECC_NIST_P384 (TPM_ECC_CURVE)(0x0004) |
| 212 | #define TPM_ECC_NIST_P521 (TPM_ECC_CURVE)(0x0005) |
| 213 | #define TPM_ECC_BN_P256 (TPM_ECC_CURVE)(0x0010) |
| 214 | #define TPM_ECC_BN_P638 (TPM_ECC_CURVE)(0x0011) |
| 215 | #define TPM_ECC_SM2_P256 (TPM_ECC_CURVE)(0x0020) |
| 216 | |
| 217 | // Table 11 - TPM_CC Constants (Numeric Order) |
| 218 | typedef UINT32 TPM_CC; |
| 219 | #define TPM_CC_FIRST (TPM_CC)(0x0000011F) |
| 220 | #define TPM_CC_PP_FIRST (TPM_CC)(0x0000011F) |
| 221 | #define TPM_CC_NV_UndefineSpaceSpecial (TPM_CC)(0x0000011F) |
| 222 | #define TPM_CC_EvictControl (TPM_CC)(0x00000120) |
| 223 | #define TPM_CC_HierarchyControl (TPM_CC)(0x00000121) |
| 224 | #define TPM_CC_NV_UndefineSpace (TPM_CC)(0x00000122) |
| 225 | #define TPM_CC_ChangeEPS (TPM_CC)(0x00000124) |
| 226 | #define TPM_CC_ChangePPS (TPM_CC)(0x00000125) |
| 227 | #define TPM_CC_Clear (TPM_CC)(0x00000126) |
| 228 | #define TPM_CC_ClearControl (TPM_CC)(0x00000127) |
| 229 | #define TPM_CC_ClockSet (TPM_CC)(0x00000128) |
| 230 | #define TPM_CC_HierarchyChangeAuth (TPM_CC)(0x00000129) |
| 231 | #define TPM_CC_NV_DefineSpace (TPM_CC)(0x0000012A) |
| 232 | #define TPM_CC_PCR_Allocate (TPM_CC)(0x0000012B) |
| 233 | #define TPM_CC_PCR_SetAuthPolicy (TPM_CC)(0x0000012C) |
| 234 | #define TPM_CC_PP_Commands (TPM_CC)(0x0000012D) |
| 235 | #define TPM_CC_SetPrimaryPolicy (TPM_CC)(0x0000012E) |
| 236 | #define TPM_CC_FieldUpgradeStart (TPM_CC)(0x0000012F) |
| 237 | #define TPM_CC_ClockRateAdjust (TPM_CC)(0x00000130) |
| 238 | #define TPM_CC_CreatePrimary (TPM_CC)(0x00000131) |
| 239 | #define TPM_CC_NV_GlobalWriteLock (TPM_CC)(0x00000132) |
| 240 | #define TPM_CC_PP_LAST (TPM_CC)(0x00000132) |
| 241 | #define TPM_CC_GetCommandAuditDigest (TPM_CC)(0x00000133) |
| 242 | #define TPM_CC_NV_Increment (TPM_CC)(0x00000134) |
| 243 | #define TPM_CC_NV_SetBits (TPM_CC)(0x00000135) |
| 244 | #define TPM_CC_NV_Extend (TPM_CC)(0x00000136) |
| 245 | #define TPM_CC_NV_Write (TPM_CC)(0x00000137) |
| 246 | #define TPM_CC_NV_WriteLock (TPM_CC)(0x00000138) |
| 247 | #define TPM_CC_DictionaryAttackLockReset (TPM_CC)(0x00000139) |
| 248 | #define TPM_CC_DictionaryAttackParameters (TPM_CC)(0x0000013A) |
| 249 | #define TPM_CC_NV_ChangeAuth (TPM_CC)(0x0000013B) |
| 250 | #define TPM_CC_PCR_Event (TPM_CC)(0x0000013C) |
| 251 | #define TPM_CC_PCR_Reset (TPM_CC)(0x0000013D) |
| 252 | #define TPM_CC_SequenceComplete (TPM_CC)(0x0000013E) |
| 253 | #define TPM_CC_SetAlgorithmSet (TPM_CC)(0x0000013F) |
| 254 | #define TPM_CC_SetCommandCodeAuditStatus (TPM_CC)(0x00000140) |
| 255 | #define TPM_CC_FieldUpgradeData (TPM_CC)(0x00000141) |
| 256 | #define TPM_CC_IncrementalSelfTest (TPM_CC)(0x00000142) |
| 257 | #define TPM_CC_SelfTest (TPM_CC)(0x00000143) |
| 258 | #define TPM_CC_Startup (TPM_CC)(0x00000144) |
| 259 | #define TPM_CC_Shutdown (TPM_CC)(0x00000145) |
| 260 | #define TPM_CC_StirRandom (TPM_CC)(0x00000146) |
| 261 | #define TPM_CC_ActivateCredential (TPM_CC)(0x00000147) |
| 262 | #define TPM_CC_Certify (TPM_CC)(0x00000148) |
| 263 | #define TPM_CC_PolicyNV (TPM_CC)(0x00000149) |
| 264 | #define TPM_CC_CertifyCreation (TPM_CC)(0x0000014A) |
| 265 | #define TPM_CC_Duplicate (TPM_CC)(0x0000014B) |
| 266 | #define TPM_CC_GetTime (TPM_CC)(0x0000014C) |
| 267 | #define TPM_CC_GetSessionAuditDigest (TPM_CC)(0x0000014D) |
| 268 | #define TPM_CC_NV_Read (TPM_CC)(0x0000014E) |
| 269 | #define TPM_CC_NV_ReadLock (TPM_CC)(0x0000014F) |
| 270 | #define TPM_CC_ObjectChangeAuth (TPM_CC)(0x00000150) |
| 271 | #define TPM_CC_PolicySecret (TPM_CC)(0x00000151) |
| 272 | #define TPM_CC_Rewrap (TPM_CC)(0x00000152) |
| 273 | #define TPM_CC_Create (TPM_CC)(0x00000153) |
| 274 | #define TPM_CC_ECDH_ZGen (TPM_CC)(0x00000154) |
| 275 | #define TPM_CC_HMAC (TPM_CC)(0x00000155) |
| 276 | #define TPM_CC_Import (TPM_CC)(0x00000156) |
| 277 | #define TPM_CC_Load (TPM_CC)(0x00000157) |
| 278 | #define TPM_CC_Quote (TPM_CC)(0x00000158) |
| 279 | #define TPM_CC_RSA_Decrypt (TPM_CC)(0x00000159) |
| 280 | #define TPM_CC_HMAC_Start (TPM_CC)(0x0000015B) |
| 281 | #define TPM_CC_SequenceUpdate (TPM_CC)(0x0000015C) |
| 282 | #define TPM_CC_Sign (TPM_CC)(0x0000015D) |
| 283 | #define TPM_CC_Unseal (TPM_CC)(0x0000015E) |
| 284 | #define TPM_CC_PolicySigned (TPM_CC)(0x00000160) |
| 285 | #define TPM_CC_ContextLoad (TPM_CC)(0x00000161) |
| 286 | #define TPM_CC_ContextSave (TPM_CC)(0x00000162) |
| 287 | #define TPM_CC_ECDH_KeyGen (TPM_CC)(0x00000163) |
| 288 | #define TPM_CC_EncryptDecrypt (TPM_CC)(0x00000164) |
| 289 | #define TPM_CC_FlushContext (TPM_CC)(0x00000165) |
| 290 | #define TPM_CC_LoadExternal (TPM_CC)(0x00000167) |
| 291 | #define TPM_CC_MakeCredential (TPM_CC)(0x00000168) |
| 292 | #define TPM_CC_NV_ReadPublic (TPM_CC)(0x00000169) |
| 293 | #define TPM_CC_PolicyAuthorize (TPM_CC)(0x0000016A) |
| 294 | #define TPM_CC_PolicyAuthValue (TPM_CC)(0x0000016B) |
| 295 | #define TPM_CC_PolicyCommandCode (TPM_CC)(0x0000016C) |
| 296 | #define TPM_CC_PolicyCounterTimer (TPM_CC)(0x0000016D) |
| 297 | #define TPM_CC_PolicyCpHash (TPM_CC)(0x0000016E) |
| 298 | #define TPM_CC_PolicyLocality (TPM_CC)(0x0000016F) |
| 299 | #define TPM_CC_PolicyNameHash (TPM_CC)(0x00000170) |
| 300 | #define TPM_CC_PolicyOR (TPM_CC)(0x00000171) |
| 301 | #define TPM_CC_PolicyTicket (TPM_CC)(0x00000172) |
| 302 | #define TPM_CC_ReadPublic (TPM_CC)(0x00000173) |
| 303 | #define TPM_CC_RSA_Encrypt (TPM_CC)(0x00000174) |
| 304 | #define TPM_CC_StartAuthSession (TPM_CC)(0x00000176) |
| 305 | #define TPM_CC_VerifySignature (TPM_CC)(0x00000177) |
| 306 | #define TPM_CC_ECC_Parameters (TPM_CC)(0x00000178) |
| 307 | #define TPM_CC_FirmwareRead (TPM_CC)(0x00000179) |
| 308 | #define TPM_CC_GetCapability (TPM_CC)(0x0000017A) |
| 309 | #define TPM_CC_GetRandom (TPM_CC)(0x0000017B) |
| 310 | #define TPM_CC_GetTestResult (TPM_CC)(0x0000017C) |
| 311 | #define TPM_CC_Hash (TPM_CC)(0x0000017D) |
| 312 | #define TPM_CC_PCR_Read (TPM_CC)(0x0000017E) |
| 313 | #define TPM_CC_PolicyPCR (TPM_CC)(0x0000017F) |
| 314 | #define TPM_CC_PolicyRestart (TPM_CC)(0x00000180) |
| 315 | #define TPM_CC_ReadClock (TPM_CC)(0x00000181) |
| 316 | #define TPM_CC_PCR_Extend (TPM_CC)(0x00000182) |
| 317 | #define TPM_CC_PCR_SetAuthValue (TPM_CC)(0x00000183) |
| 318 | #define TPM_CC_NV_Certify (TPM_CC)(0x00000184) |
| 319 | #define TPM_CC_EventSequenceComplete (TPM_CC)(0x00000185) |
| 320 | #define TPM_CC_HashSequenceStart (TPM_CC)(0x00000186) |
| 321 | #define TPM_CC_PolicyPhysicalPresence (TPM_CC)(0x00000187) |
| 322 | #define TPM_CC_PolicyDuplicationSelect (TPM_CC)(0x00000188) |
| 323 | #define TPM_CC_PolicyGetDigest (TPM_CC)(0x00000189) |
| 324 | #define TPM_CC_TestParms (TPM_CC)(0x0000018A) |
| 325 | #define TPM_CC_Commit (TPM_CC)(0x0000018B) |
| 326 | #define TPM_CC_PolicyPassword (TPM_CC)(0x0000018C) |
| 327 | #define TPM_CC_ZGen_2Phase (TPM_CC)(0x0000018D) |
| 328 | #define TPM_CC_EC_Ephemeral (TPM_CC)(0x0000018E) |
| 329 | #define TPM_CC_LAST (TPM_CC)(0x0000018E) |
| 330 | |
| 331 | // Table 15 - TPM_RC Constants (Actions) |
| 332 | typedef UINT32 TPM_RC; |
| 333 | #define TPM_RC_SUCCESS (TPM_RC)(0x000) |
| 334 | #define TPM_RC_BAD_TAG (TPM_RC)(0x030) |
| 335 | #define RC_VER1 (TPM_RC)(0x100) |
| 336 | #define TPM_RC_INITIALIZE (TPM_RC)(RC_VER1 + 0x000) |
| 337 | #define TPM_RC_FAILURE (TPM_RC)(RC_VER1 + 0x001) |
| 338 | #define TPM_RC_SEQUENCE (TPM_RC)(RC_VER1 + 0x003) |
| 339 | #define TPM_RC_PRIVATE (TPM_RC)(RC_VER1 + 0x00B) |
| 340 | #define TPM_RC_HMAC (TPM_RC)(RC_VER1 + 0x019) |
| 341 | #define TPM_RC_DISABLED (TPM_RC)(RC_VER1 + 0x020) |
| 342 | #define TPM_RC_EXCLUSIVE (TPM_RC)(RC_VER1 + 0x021) |
| 343 | #define TPM_RC_AUTH_TYPE (TPM_RC)(RC_VER1 + 0x024) |
| 344 | #define TPM_RC_AUTH_MISSING (TPM_RC)(RC_VER1 + 0x025) |
| 345 | #define TPM_RC_POLICY (TPM_RC)(RC_VER1 + 0x026) |
| 346 | #define TPM_RC_PCR (TPM_RC)(RC_VER1 + 0x027) |
| 347 | #define TPM_RC_PCR_CHANGED (TPM_RC)(RC_VER1 + 0x028) |
| 348 | #define TPM_RC_UPGRADE (TPM_RC)(RC_VER1 + 0x02D) |
| 349 | #define TPM_RC_TOO_MANY_CONTEXTS (TPM_RC)(RC_VER1 + 0x02E) |
| 350 | #define TPM_RC_AUTH_UNAVAILABLE (TPM_RC)(RC_VER1 + 0x02F) |
| 351 | #define TPM_RC_REBOOT (TPM_RC)(RC_VER1 + 0x030) |
| 352 | #define TPM_RC_UNBALANCED (TPM_RC)(RC_VER1 + 0x031) |
| 353 | #define TPM_RC_COMMAND_SIZE (TPM_RC)(RC_VER1 + 0x042) |
| 354 | #define TPM_RC_COMMAND_CODE (TPM_RC)(RC_VER1 + 0x043) |
| 355 | #define TPM_RC_AUTHSIZE (TPM_RC)(RC_VER1 + 0x044) |
| 356 | #define TPM_RC_AUTH_CONTEXT (TPM_RC)(RC_VER1 + 0x045) |
| 357 | #define TPM_RC_NV_RANGE (TPM_RC)(RC_VER1 + 0x046) |
| 358 | #define TPM_RC_NV_SIZE (TPM_RC)(RC_VER1 + 0x047) |
| 359 | #define TPM_RC_NV_LOCKED (TPM_RC)(RC_VER1 + 0x048) |
| 360 | #define TPM_RC_NV_AUTHORIZATION (TPM_RC)(RC_VER1 + 0x049) |
| 361 | #define TPM_RC_NV_UNINITIALIZED (TPM_RC)(RC_VER1 + 0x04A) |
| 362 | #define TPM_RC_NV_SPACE (TPM_RC)(RC_VER1 + 0x04B) |
| 363 | #define TPM_RC_NV_DEFINED (TPM_RC)(RC_VER1 + 0x04C) |
| 364 | #define TPM_RC_BAD_CONTEXT (TPM_RC)(RC_VER1 + 0x050) |
| 365 | #define TPM_RC_CPHASH (TPM_RC)(RC_VER1 + 0x051) |
| 366 | #define TPM_RC_PARENT (TPM_RC)(RC_VER1 + 0x052) |
| 367 | #define TPM_RC_NEEDS_TEST (TPM_RC)(RC_VER1 + 0x053) |
| 368 | #define TPM_RC_NO_RESULT (TPM_RC)(RC_VER1 + 0x054) |
| 369 | #define TPM_RC_SENSITIVE (TPM_RC)(RC_VER1 + 0x055) |
| 370 | #define RC_MAX_FM0 (TPM_RC)(RC_VER1 + 0x07F) |
| 371 | #define RC_FMT1 (TPM_RC)(0x080) |
| 372 | #define TPM_RC_ASYMMETRIC (TPM_RC)(RC_FMT1 + 0x001) |
| 373 | #define TPM_RC_ATTRIBUTES (TPM_RC)(RC_FMT1 + 0x002) |
| 374 | #define TPM_RC_HASH (TPM_RC)(RC_FMT1 + 0x003) |
| 375 | #define TPM_RC_VALUE (TPM_RC)(RC_FMT1 + 0x004) |
| 376 | #define TPM_RC_HIERARCHY (TPM_RC)(RC_FMT1 + 0x005) |
| 377 | #define TPM_RC_KEY_SIZE (TPM_RC)(RC_FMT1 + 0x007) |
| 378 | #define TPM_RC_MGF (TPM_RC)(RC_FMT1 + 0x008) |
| 379 | #define TPM_RC_MODE (TPM_RC)(RC_FMT1 + 0x009) |
| 380 | #define TPM_RC_TYPE (TPM_RC)(RC_FMT1 + 0x00A) |
| 381 | #define TPM_RC_HANDLE (TPM_RC)(RC_FMT1 + 0x00B) |
| 382 | #define TPM_RC_KDF (TPM_RC)(RC_FMT1 + 0x00C) |
| 383 | #define TPM_RC_RANGE (TPM_RC)(RC_FMT1 + 0x00D) |
| 384 | #define TPM_RC_AUTH_FAIL (TPM_RC)(RC_FMT1 + 0x00E) |
| 385 | #define TPM_RC_NONCE (TPM_RC)(RC_FMT1 + 0x00F) |
| 386 | #define TPM_RC_PP (TPM_RC)(RC_FMT1 + 0x010) |
| 387 | #define TPM_RC_SCHEME (TPM_RC)(RC_FMT1 + 0x012) |
| 388 | #define TPM_RC_SIZE (TPM_RC)(RC_FMT1 + 0x015) |
| 389 | #define TPM_RC_SYMMETRIC (TPM_RC)(RC_FMT1 + 0x016) |
| 390 | #define TPM_RC_TAG (TPM_RC)(RC_FMT1 + 0x017) |
| 391 | #define TPM_RC_SELECTOR (TPM_RC)(RC_FMT1 + 0x018) |
| 392 | #define TPM_RC_INSUFFICIENT (TPM_RC)(RC_FMT1 + 0x01A) |
| 393 | #define TPM_RC_SIGNATURE (TPM_RC)(RC_FMT1 + 0x01B) |
| 394 | #define TPM_RC_KEY (TPM_RC)(RC_FMT1 + 0x01C) |
| 395 | #define TPM_RC_POLICY_FAIL (TPM_RC)(RC_FMT1 + 0x01D) |
| 396 | #define TPM_RC_INTEGRITY (TPM_RC)(RC_FMT1 + 0x01F) |
| 397 | #define TPM_RC_TICKET (TPM_RC)(RC_FMT1 + 0x020) |
| 398 | #define TPM_RC_RESERVED_BITS (TPM_RC)(RC_FMT1 + 0x021) |
| 399 | #define TPM_RC_BAD_AUTH (TPM_RC)(RC_FMT1 + 0x022) |
| 400 | #define TPM_RC_EXPIRED (TPM_RC)(RC_FMT1 + 0x023) |
| 401 | #define TPM_RC_POLICY_CC (TPM_RC)(RC_FMT1 + 0x024 ) |
| 402 | #define TPM_RC_BINDING (TPM_RC)(RC_FMT1 + 0x025) |
| 403 | #define TPM_RC_CURVE (TPM_RC)(RC_FMT1 + 0x026) |
| 404 | #define TPM_RC_ECC_POINT (TPM_RC)(RC_FMT1 + 0x027) |
| 405 | #define RC_WARN (TPM_RC)(0x900) |
| 406 | #define TPM_RC_CONTEXT_GAP (TPM_RC)(RC_WARN + 0x001) |
| 407 | #define TPM_RC_OBJECT_MEMORY (TPM_RC)(RC_WARN + 0x002) |
| 408 | #define TPM_RC_SESSION_MEMORY (TPM_RC)(RC_WARN + 0x003) |
| 409 | #define TPM_RC_MEMORY (TPM_RC)(RC_WARN + 0x004) |
| 410 | #define TPM_RC_SESSION_HANDLES (TPM_RC)(RC_WARN + 0x005) |
| 411 | #define TPM_RC_OBJECT_HANDLES (TPM_RC)(RC_WARN + 0x006) |
| 412 | #define TPM_RC_LOCALITY (TPM_RC)(RC_WARN + 0x007) |
| 413 | #define TPM_RC_YIELDED (TPM_RC)(RC_WARN + 0x008) |
| 414 | #define TPM_RC_CANCELED (TPM_RC)(RC_WARN + 0x009) |
| 415 | #define TPM_RC_TESTING (TPM_RC)(RC_WARN + 0x00A) |
| 416 | #define TPM_RC_REFERENCE_H0 (TPM_RC)(RC_WARN + 0x010) |
| 417 | #define TPM_RC_REFERENCE_H1 (TPM_RC)(RC_WARN + 0x011) |
| 418 | #define TPM_RC_REFERENCE_H2 (TPM_RC)(RC_WARN + 0x012) |
| 419 | #define TPM_RC_REFERENCE_H3 (TPM_RC)(RC_WARN + 0x013) |
| 420 | #define TPM_RC_REFERENCE_H4 (TPM_RC)(RC_WARN + 0x014) |
| 421 | #define TPM_RC_REFERENCE_H5 (TPM_RC)(RC_WARN + 0x015) |
| 422 | #define TPM_RC_REFERENCE_H6 (TPM_RC)(RC_WARN + 0x016) |
| 423 | #define TPM_RC_REFERENCE_S0 (TPM_RC)(RC_WARN + 0x018) |
| 424 | #define TPM_RC_REFERENCE_S1 (TPM_RC)(RC_WARN + 0x019) |
| 425 | #define TPM_RC_REFERENCE_S2 (TPM_RC)(RC_WARN + 0x01A) |
| 426 | #define TPM_RC_REFERENCE_S3 (TPM_RC)(RC_WARN + 0x01B) |
| 427 | #define TPM_RC_REFERENCE_S4 (TPM_RC)(RC_WARN + 0x01C) |
| 428 | #define TPM_RC_REFERENCE_S5 (TPM_RC)(RC_WARN + 0x01D) |
| 429 | #define TPM_RC_REFERENCE_S6 (TPM_RC)(RC_WARN + 0x01E) |
| 430 | #define TPM_RC_NV_RATE (TPM_RC)(RC_WARN + 0x020) |
| 431 | #define TPM_RC_LOCKOUT (TPM_RC)(RC_WARN + 0x021) |
| 432 | #define TPM_RC_RETRY (TPM_RC)(RC_WARN + 0x022) |
| 433 | #define TPM_RC_NV_UNAVAILABLE (TPM_RC)(RC_WARN + 0x023) |
| 434 | #define TPM_RC_NOT_USED (TPM_RC)(RC_WARN + 0x7F) |
| 435 | #define TPM_RC_H (TPM_RC)(0x000) |
| 436 | #define TPM_RC_P (TPM_RC)(0x040) |
| 437 | #define TPM_RC_S (TPM_RC)(0x800) |
| 438 | #define TPM_RC_1 (TPM_RC)(0x100) |
| 439 | #define TPM_RC_2 (TPM_RC)(0x200) |
| 440 | #define TPM_RC_3 (TPM_RC)(0x300) |
| 441 | #define TPM_RC_4 (TPM_RC)(0x400) |
| 442 | #define TPM_RC_5 (TPM_RC)(0x500) |
| 443 | #define TPM_RC_6 (TPM_RC)(0x600) |
| 444 | #define TPM_RC_7 (TPM_RC)(0x700) |
| 445 | #define TPM_RC_8 (TPM_RC)(0x800) |
| 446 | #define TPM_RC_9 (TPM_RC)(0x900) |
| 447 | #define TPM_RC_A (TPM_RC)(0xA00) |
| 448 | #define TPM_RC_B (TPM_RC)(0xB00) |
| 449 | #define TPM_RC_C (TPM_RC)(0xC00) |
| 450 | #define TPM_RC_D (TPM_RC)(0xD00) |
| 451 | #define TPM_RC_E (TPM_RC)(0xE00) |
| 452 | #define TPM_RC_F (TPM_RC)(0xF00) |
| 453 | #define TPM_RC_N_MASK (TPM_RC)(0xF00) |
| 454 | |
| 455 | // Table 16 - TPM_CLOCK_ADJUST Constants |
| 456 | typedef INT8 TPM_CLOCK_ADJUST; |
| 457 | #define TPM_CLOCK_COARSE_SLOWER (TPM_CLOCK_ADJUST)(-3) |
| 458 | #define TPM_CLOCK_MEDIUM_SLOWER (TPM_CLOCK_ADJUST)(-2) |
| 459 | #define TPM_CLOCK_FINE_SLOWER (TPM_CLOCK_ADJUST)(-1) |
| 460 | #define TPM_CLOCK_NO_CHANGE (TPM_CLOCK_ADJUST)(0) |
| 461 | #define TPM_CLOCK_FINE_FASTER (TPM_CLOCK_ADJUST)(1) |
| 462 | #define TPM_CLOCK_MEDIUM_FASTER (TPM_CLOCK_ADJUST)(2) |
| 463 | #define TPM_CLOCK_COARSE_FASTER (TPM_CLOCK_ADJUST)(3) |
| 464 | |
| 465 | // Table 17 - TPM_EO Constants |
| 466 | typedef UINT16 TPM_EO; |
| 467 | #define TPM_EO_EQ (TPM_EO)(0x0000) |
| 468 | #define TPM_EO_NEQ (TPM_EO)(0x0001) |
| 469 | #define TPM_EO_SIGNED_GT (TPM_EO)(0x0002) |
| 470 | #define TPM_EO_UNSIGNED_GT (TPM_EO)(0x0003) |
| 471 | #define TPM_EO_SIGNED_LT (TPM_EO)(0x0004) |
| 472 | #define TPM_EO_UNSIGNED_LT (TPM_EO)(0x0005) |
| 473 | #define TPM_EO_SIGNED_GE (TPM_EO)(0x0006) |
| 474 | #define TPM_EO_UNSIGNED_GE (TPM_EO)(0x0007) |
| 475 | #define TPM_EO_SIGNED_LE (TPM_EO)(0x0008) |
| 476 | #define TPM_EO_UNSIGNED_LE (TPM_EO)(0x0009) |
| 477 | #define TPM_EO_BITSET (TPM_EO)(0x000A) |
| 478 | #define TPM_EO_BITCLEAR (TPM_EO)(0x000B) |
| 479 | |
| 480 | // Table 18 - TPM_ST Constants |
| 481 | typedef UINT16 TPM_ST; |
| 482 | #define TPM_ST_RSP_COMMAND (TPM_ST)(0x00C4) |
Subrata Banik | 8e6d5f2 | 2020-08-30 13:51:44 +0530 | [diff] [blame] | 483 | #define TPM_ST_NULL (TPM_ST)(0x8000) |
Jonathan Zhang | 6d27778 | 2020-06-09 17:56:53 -0700 | [diff] [blame] | 484 | #define TPM_ST_NO_SESSIONS (TPM_ST)(0x8001) |
| 485 | #define TPM_ST_SESSIONS (TPM_ST)(0x8002) |
| 486 | #define TPM_ST_ATTEST_NV (TPM_ST)(0x8014) |
| 487 | #define TPM_ST_ATTEST_COMMAND_AUDIT (TPM_ST)(0x8015) |
| 488 | #define TPM_ST_ATTEST_SESSION_AUDIT (TPM_ST)(0x8016) |
| 489 | #define TPM_ST_ATTEST_CERTIFY (TPM_ST)(0x8017) |
| 490 | #define TPM_ST_ATTEST_QUOTE (TPM_ST)(0x8018) |
| 491 | #define TPM_ST_ATTEST_TIME (TPM_ST)(0x8019) |
| 492 | #define TPM_ST_ATTEST_CREATION (TPM_ST)(0x801A) |
| 493 | #define TPM_ST_CREATION (TPM_ST)(0x8021) |
| 494 | #define TPM_ST_VERIFIED (TPM_ST)(0x8022) |
| 495 | #define TPM_ST_AUTH_SECRET (TPM_ST)(0x8023) |
| 496 | #define TPM_ST_HASHCHECK (TPM_ST)(0x8024) |
| 497 | #define TPM_ST_AUTH_SIGNED (TPM_ST)(0x8025) |
| 498 | #define TPM_ST_FU_MANIFEST (TPM_ST)(0x8029) |
| 499 | |
| 500 | // Table 19 - TPM_SU Constants |
| 501 | typedef UINT16 TPM_SU; |
| 502 | #define TPM_SU_CLEAR (TPM_SU)(0x0000) |
| 503 | #define TPM_SU_STATE (TPM_SU)(0x0001) |
| 504 | |
| 505 | // Table 20 - TPM_SE Constants |
| 506 | typedef UINT8 TPM_SE; |
| 507 | #define TPM_SE_HMAC (TPM_SE)(0x00) |
| 508 | #define TPM_SE_POLICY (TPM_SE)(0x01) |
| 509 | #define TPM_SE_TRIAL (TPM_SE)(0x03) |
| 510 | |
| 511 | // Table 21 - TPM_CAP Constants |
| 512 | typedef UINT32 TPM_CAP; |
| 513 | #define TPM_CAP_FIRST (TPM_CAP)(0x00000000) |
| 514 | #define TPM_CAP_ALGS (TPM_CAP)(0x00000000) |
| 515 | #define TPM_CAP_HANDLES (TPM_CAP)(0x00000001) |
| 516 | #define TPM_CAP_COMMANDS (TPM_CAP)(0x00000002) |
| 517 | #define TPM_CAP_PP_COMMANDS (TPM_CAP)(0x00000003) |
| 518 | #define TPM_CAP_AUDIT_COMMANDS (TPM_CAP)(0x00000004) |
| 519 | #define TPM_CAP_PCRS (TPM_CAP)(0x00000005) |
| 520 | #define TPM_CAP_TPM_PROPERTIES (TPM_CAP)(0x00000006) |
| 521 | #define TPM_CAP_PCR_PROPERTIES (TPM_CAP)(0x00000007) |
| 522 | #define TPM_CAP_ECC_CURVES (TPM_CAP)(0x00000008) |
| 523 | #define TPM_CAP_LAST (TPM_CAP)(0x00000008) |
| 524 | #define TPM_CAP_VENDOR_PROPERTY (TPM_CAP)(0x00000100) |
| 525 | |
| 526 | // Table 22 - TPM_PT Constants |
| 527 | typedef UINT32 TPM_PT; |
| 528 | #define TPM_PT_NONE (TPM_PT)(0x00000000) |
| 529 | #define PT_GROUP (TPM_PT)(0x00000100) |
| 530 | #define PT_FIXED (TPM_PT)(PT_GROUP * 1) |
| 531 | #define TPM_PT_FAMILY_INDICATOR (TPM_PT)(PT_FIXED + 0) |
| 532 | #define TPM_PT_LEVEL (TPM_PT)(PT_FIXED + 1) |
| 533 | #define TPM_PT_REVISION (TPM_PT)(PT_FIXED + 2) |
| 534 | #define TPM_PT_DAY_OF_YEAR (TPM_PT)(PT_FIXED + 3) |
| 535 | #define TPM_PT_YEAR (TPM_PT)(PT_FIXED + 4) |
| 536 | #define TPM_PT_MANUFACTURER (TPM_PT)(PT_FIXED + 5) |
| 537 | #define TPM_PT_VENDOR_STRING_1 (TPM_PT)(PT_FIXED + 6) |
| 538 | #define TPM_PT_VENDOR_STRING_2 (TPM_PT)(PT_FIXED + 7) |
| 539 | #define TPM_PT_VENDOR_STRING_3 (TPM_PT)(PT_FIXED + 8) |
| 540 | #define TPM_PT_VENDOR_STRING_4 (TPM_PT)(PT_FIXED + 9) |
| 541 | #define TPM_PT_VENDOR_TPM_TYPE (TPM_PT)(PT_FIXED + 10) |
| 542 | #define TPM_PT_FIRMWARE_VERSION_1 (TPM_PT)(PT_FIXED + 11) |
| 543 | #define TPM_PT_FIRMWARE_VERSION_2 (TPM_PT)(PT_FIXED + 12) |
| 544 | #define TPM_PT_INPUT_BUFFER (TPM_PT)(PT_FIXED + 13) |
| 545 | #define TPM_PT_HR_TRANSIENT_MIN (TPM_PT)(PT_FIXED + 14) |
| 546 | #define TPM_PT_HR_PERSISTENT_MIN (TPM_PT)(PT_FIXED + 15) |
| 547 | #define TPM_PT_HR_LOADED_MIN (TPM_PT)(PT_FIXED + 16) |
| 548 | #define TPM_PT_ACTIVE_SESSIONS_MAX (TPM_PT)(PT_FIXED + 17) |
| 549 | #define TPM_PT_PCR_COUNT (TPM_PT)(PT_FIXED + 18) |
| 550 | #define TPM_PT_PCR_SELECT_MIN (TPM_PT)(PT_FIXED + 19) |
| 551 | #define TPM_PT_CONTEXT_GAP_MAX (TPM_PT)(PT_FIXED + 20) |
| 552 | #define TPM_PT_NV_COUNTERS_MAX (TPM_PT)(PT_FIXED + 22) |
| 553 | #define TPM_PT_NV_INDEX_MAX (TPM_PT)(PT_FIXED + 23) |
| 554 | #define TPM_PT_MEMORY (TPM_PT)(PT_FIXED + 24) |
| 555 | #define TPM_PT_CLOCK_UPDATE (TPM_PT)(PT_FIXED + 25) |
| 556 | #define TPM_PT_CONTEXT_HASH (TPM_PT)(PT_FIXED + 26) |
| 557 | #define TPM_PT_CONTEXT_SYM (TPM_PT)(PT_FIXED + 27) |
| 558 | #define TPM_PT_CONTEXT_SYM_SIZE (TPM_PT)(PT_FIXED + 28) |
| 559 | #define TPM_PT_ORDERLY_COUNT (TPM_PT)(PT_FIXED + 29) |
| 560 | #define TPM_PT_MAX_COMMAND_SIZE (TPM_PT)(PT_FIXED + 30) |
| 561 | #define TPM_PT_MAX_RESPONSE_SIZE (TPM_PT)(PT_FIXED + 31) |
| 562 | #define TPM_PT_MAX_DIGEST (TPM_PT)(PT_FIXED + 32) |
| 563 | #define TPM_PT_MAX_OBJECT_CONTEXT (TPM_PT)(PT_FIXED + 33) |
| 564 | #define TPM_PT_MAX_SESSION_CONTEXT (TPM_PT)(PT_FIXED + 34) |
| 565 | #define TPM_PT_PS_FAMILY_INDICATOR (TPM_PT)(PT_FIXED + 35) |
| 566 | #define TPM_PT_PS_LEVEL (TPM_PT)(PT_FIXED + 36) |
| 567 | #define TPM_PT_PS_REVISION (TPM_PT)(PT_FIXED + 37) |
| 568 | #define TPM_PT_PS_DAY_OF_YEAR (TPM_PT)(PT_FIXED + 38) |
| 569 | #define TPM_PT_PS_YEAR (TPM_PT)(PT_FIXED + 39) |
| 570 | #define TPM_PT_SPLIT_MAX (TPM_PT)(PT_FIXED + 40) |
| 571 | #define TPM_PT_TOTAL_COMMANDS (TPM_PT)(PT_FIXED + 41) |
| 572 | #define TPM_PT_LIBRARY_COMMANDS (TPM_PT)(PT_FIXED + 42) |
| 573 | #define TPM_PT_VENDOR_COMMANDS (TPM_PT)(PT_FIXED + 43) |
| 574 | #define PT_VAR (TPM_PT)(PT_GROUP * 2) |
| 575 | #define TPM_PT_PERMANENT (TPM_PT)(PT_VAR + 0) |
| 576 | #define TPM_PT_STARTUP_CLEAR (TPM_PT)(PT_VAR + 1) |
| 577 | #define TPM_PT_HR_NV_INDEX (TPM_PT)(PT_VAR + 2) |
| 578 | #define TPM_PT_HR_LOADED (TPM_PT)(PT_VAR + 3) |
| 579 | #define TPM_PT_HR_LOADED_AVAIL (TPM_PT)(PT_VAR + 4) |
| 580 | #define TPM_PT_HR_ACTIVE (TPM_PT)(PT_VAR + 5) |
| 581 | #define TPM_PT_HR_ACTIVE_AVAIL (TPM_PT)(PT_VAR + 6) |
| 582 | #define TPM_PT_HR_TRANSIENT_AVAIL (TPM_PT)(PT_VAR + 7) |
| 583 | #define TPM_PT_HR_PERSISTENT (TPM_PT)(PT_VAR + 8) |
| 584 | #define TPM_PT_HR_PERSISTENT_AVAIL (TPM_PT)(PT_VAR + 9) |
| 585 | #define TPM_PT_NV_COUNTERS (TPM_PT)(PT_VAR + 10) |
| 586 | #define TPM_PT_NV_COUNTERS_AVAIL (TPM_PT)(PT_VAR + 11) |
| 587 | #define TPM_PT_ALGORITHM_SET (TPM_PT)(PT_VAR + 12) |
| 588 | #define TPM_PT_LOADED_CURVES (TPM_PT)(PT_VAR + 13) |
| 589 | #define TPM_PT_LOCKOUT_COUNTER (TPM_PT)(PT_VAR + 14) |
| 590 | #define TPM_PT_MAX_AUTH_FAIL (TPM_PT)(PT_VAR + 15) |
| 591 | #define TPM_PT_LOCKOUT_INTERVAL (TPM_PT)(PT_VAR + 16) |
| 592 | #define TPM_PT_LOCKOUT_RECOVERY (TPM_PT)(PT_VAR + 17) |
| 593 | #define TPM_PT_NV_WRITE_RECOVERY (TPM_PT)(PT_VAR + 18) |
| 594 | #define TPM_PT_AUDIT_COUNTER_0 (TPM_PT)(PT_VAR + 19) |
| 595 | #define TPM_PT_AUDIT_COUNTER_1 (TPM_PT)(PT_VAR + 20) |
| 596 | |
| 597 | // Table 23 - TPM_PT_PCR Constants |
| 598 | typedef UINT32 TPM_PT_PCR; |
| 599 | #define TPM_PT_PCR_FIRST (TPM_PT_PCR)(0x00000000) |
| 600 | #define TPM_PT_PCR_SAVE (TPM_PT_PCR)(0x00000000) |
| 601 | #define TPM_PT_PCR_EXTEND_L0 (TPM_PT_PCR)(0x00000001) |
| 602 | #define TPM_PT_PCR_RESET_L0 (TPM_PT_PCR)(0x00000002) |
| 603 | #define TPM_PT_PCR_EXTEND_L1 (TPM_PT_PCR)(0x00000003) |
| 604 | #define TPM_PT_PCR_RESET_L1 (TPM_PT_PCR)(0x00000004) |
| 605 | #define TPM_PT_PCR_EXTEND_L2 (TPM_PT_PCR)(0x00000005) |
| 606 | #define TPM_PT_PCR_RESET_L2 (TPM_PT_PCR)(0x00000006) |
| 607 | #define TPM_PT_PCR_EXTEND_L3 (TPM_PT_PCR)(0x00000007) |
| 608 | #define TPM_PT_PCR_RESET_L3 (TPM_PT_PCR)(0x00000008) |
| 609 | #define TPM_PT_PCR_EXTEND_L4 (TPM_PT_PCR)(0x00000009) |
| 610 | #define TPM_PT_PCR_RESET_L4 (TPM_PT_PCR)(0x0000000A) |
| 611 | #define TPM_PT_PCR_NO_INCREMENT (TPM_PT_PCR)(0x00000011) |
| 612 | #define TPM_PT_PCR_DRTM_RESET (TPM_PT_PCR)(0x00000012) |
| 613 | #define TPM_PT_PCR_POLICY (TPM_PT_PCR)(0x00000013) |
| 614 | #define TPM_PT_PCR_AUTH (TPM_PT_PCR)(0x00000014) |
| 615 | #define TPM_PT_PCR_LAST (TPM_PT_PCR)(0x00000014) |
| 616 | |
| 617 | // Table 24 - TPM_PS Constants |
| 618 | typedef UINT32 TPM_PS; |
| 619 | #define TPM_PS_MAIN (TPM_PS)(0x00000000) |
| 620 | #define TPM_PS_PC (TPM_PS)(0x00000001) |
| 621 | #define TPM_PS_PDA (TPM_PS)(0x00000002) |
| 622 | #define TPM_PS_CELL_PHONE (TPM_PS)(0x00000003) |
| 623 | #define TPM_PS_SERVER (TPM_PS)(0x00000004) |
| 624 | #define TPM_PS_PERIPHERAL (TPM_PS)(0x00000005) |
| 625 | #define TPM_PS_TSS (TPM_PS)(0x00000006) |
| 626 | #define TPM_PS_STORAGE (TPM_PS)(0x00000007) |
| 627 | #define TPM_PS_AUTHENTICATION (TPM_PS)(0x00000008) |
| 628 | #define TPM_PS_EMBEDDED (TPM_PS)(0x00000009) |
| 629 | #define TPM_PS_HARDCOPY (TPM_PS)(0x0000000A) |
| 630 | #define TPM_PS_INFRASTRUCTURE (TPM_PS)(0x0000000B) |
| 631 | #define TPM_PS_VIRTUALIZATION (TPM_PS)(0x0000000C) |
| 632 | #define TPM_PS_TNC (TPM_PS)(0x0000000D) |
| 633 | #define TPM_PS_MULTI_TENANT (TPM_PS)(0x0000000E) |
| 634 | #define TPM_PS_TC (TPM_PS)(0x0000000F) |
| 635 | |
| 636 | // 7 Handles |
| 637 | |
| 638 | // Table 25 - Handles Types |
| 639 | // |
| 640 | // NOTE: Comment because it has same name as TPM1.2 (value is same, so not runtime issue) |
| 641 | // |
| 642 | //typedef UINT32 TPM_HANDLE; |
| 643 | |
| 644 | // Table 26 - TPM_HT Constants |
| 645 | typedef UINT8 TPM_HT; |
| 646 | #define TPM_HT_PCR (TPM_HT)(0x00) |
| 647 | #define TPM_HT_NV_INDEX (TPM_HT)(0x01) |
| 648 | #define TPM_HT_HMAC_SESSION (TPM_HT)(0x02) |
| 649 | #define TPM_HT_LOADED_SESSION (TPM_HT)(0x02) |
| 650 | #define TPM_HT_POLICY_SESSION (TPM_HT)(0x03) |
| 651 | #define TPM_HT_ACTIVE_SESSION (TPM_HT)(0x03) |
| 652 | #define TPM_HT_PERMANENT (TPM_HT)(0x40) |
| 653 | #define TPM_HT_TRANSIENT (TPM_HT)(0x80) |
| 654 | #define TPM_HT_PERSISTENT (TPM_HT)(0x81) |
| 655 | |
| 656 | // Table 27 - TPM_RH Constants |
| 657 | typedef UINT32 TPM_RH; |
| 658 | #define TPM_RH_FIRST (TPM_RH)(0x40000000) |
| 659 | #define TPM_RH_SRK (TPM_RH)(0x40000000) |
| 660 | #define TPM_RH_OWNER (TPM_RH)(0x40000001) |
| 661 | #define TPM_RH_REVOKE (TPM_RH)(0x40000002) |
| 662 | #define TPM_RH_TRANSPORT (TPM_RH)(0x40000003) |
| 663 | #define TPM_RH_OPERATOR (TPM_RH)(0x40000004) |
| 664 | #define TPM_RH_ADMIN (TPM_RH)(0x40000005) |
| 665 | #define TPM_RH_EK (TPM_RH)(0x40000006) |
| 666 | #define TPM_RH_NULL (TPM_RH)(0x40000007) |
| 667 | #define TPM_RH_UNASSIGNED (TPM_RH)(0x40000008) |
| 668 | #define TPM_RS_PW (TPM_RH)(0x40000009) |
| 669 | #define TPM_RH_LOCKOUT (TPM_RH)(0x4000000A) |
| 670 | #define TPM_RH_ENDORSEMENT (TPM_RH)(0x4000000B) |
| 671 | #define TPM_RH_PLATFORM (TPM_RH)(0x4000000C) |
| 672 | #define TPM_RH_PLATFORM_NV (TPM_RH)(0x4000000D) |
| 673 | #define TPM_RH_AUTH_00 (TPM_RH)(0x40000010) |
| 674 | #define TPM_RH_AUTH_FF (TPM_RH)(0x4000010F) |
| 675 | #define TPM_RH_LAST (TPM_RH)(0x4000010F) |
| 676 | |
| 677 | // Table 28 - TPM_HC Constants |
| 678 | typedef TPM_HANDLE TPM_HC; |
| 679 | #define HR_HANDLE_MASK (TPM_HC)(0x00FFFFFF) |
| 680 | #define HR_RANGE_MASK (TPM_HC)(0xFF000000) |
| 681 | #define HR_SHIFT (TPM_HC)(24) |
| 682 | #define HR_PCR (TPM_HC)((TPM_HC)TPM_HT_PCR << HR_SHIFT) |
| 683 | #define HR_HMAC_SESSION (TPM_HC)((TPM_HC)TPM_HT_HMAC_SESSION << HR_SHIFT) |
| 684 | #define HR_POLICY_SESSION (TPM_HC)((TPM_HC)TPM_HT_POLICY_SESSION << HR_SHIFT) |
| 685 | #define HR_TRANSIENT (TPM_HC)((TPM_HC)TPM_HT_TRANSIENT << HR_SHIFT) |
| 686 | #define HR_PERSISTENT (TPM_HC)((TPM_HC)TPM_HT_PERSISTENT << HR_SHIFT) |
| 687 | #define HR_NV_INDEX (TPM_HC)((TPM_HC)TPM_HT_NV_INDEX << HR_SHIFT) |
| 688 | #define HR_PERMANENT (TPM_HC)((TPM_HC)TPM_HT_PERMANENT << HR_SHIFT) |
| 689 | #define PCR_FIRST (TPM_HC)(HR_PCR + 0) |
| 690 | #define PCR_LAST (TPM_HC)(PCR_FIRST + IMPLEMENTATION_PCR - 1) |
| 691 | #define HMAC_SESSION_FIRST (TPM_HC)(HR_HMAC_SESSION + 0) |
| 692 | #define HMAC_SESSION_LAST (TPM_HC)(HMAC_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1) |
| 693 | #define LOADED_SESSION_FIRST (TPM_HC)(HMAC_SESSION_FIRST) |
| 694 | #define LOADED_SESSION_LAST (TPM_HC)(HMAC_SESSION_LAST) |
| 695 | #define POLICY_SESSION_FIRST (TPM_HC)(HR_POLICY_SESSION + 0) |
| 696 | #define POLICY_SESSION_LAST (TPM_HC)(POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1) |
| 697 | #define TRANSIENT_FIRST (TPM_HC)(HR_TRANSIENT + 0) |
| 698 | #define ACTIVE_SESSION_FIRST (TPM_HC)(POLICY_SESSION_FIRST) |
| 699 | #define ACTIVE_SESSION_LAST (TPM_HC)(POLICY_SESSION_LAST) |
| 700 | #define TRANSIENT_LAST (TPM_HC)(TRANSIENT_FIRST+MAX_LOADED_OBJECTS - 1) |
| 701 | #define PERSISTENT_FIRST (TPM_HC)(HR_PERSISTENT + 0) |
| 702 | #define PERSISTENT_LAST (TPM_HC)(PERSISTENT_FIRST + 0x00FFFFFF) |
| 703 | #define PLATFORM_PERSISTENT (TPM_HC)(PERSISTENT_FIRST + 0x00800000) |
| 704 | #define NV_INDEX_FIRST (TPM_HC)(HR_NV_INDEX + 0) |
| 705 | #define NV_INDEX_LAST (TPM_HC)(NV_INDEX_FIRST + 0x00FFFFFF) |
| 706 | #define PERMANENT_FIRST (TPM_HC)(TPM_RH_FIRST) |
| 707 | #define PERMANENT_LAST (TPM_HC)(TPM_RH_LAST) |
| 708 | |
| 709 | // 8 Attribute Structures |
| 710 | |
| 711 | // Table 29 - TPMA_ALGORITHM Bits |
| 712 | typedef struct { |
| 713 | UINT32 asymmetric : 1; |
| 714 | UINT32 symmetric : 1; |
| 715 | UINT32 hash : 1; |
| 716 | UINT32 object : 1; |
| 717 | UINT32 reserved4_7 : 4; |
| 718 | UINT32 signing : 1; |
| 719 | UINT32 encrypting : 1; |
| 720 | UINT32 method : 1; |
| 721 | UINT32 reserved11_31 : 21; |
| 722 | } TPMA_ALGORITHM; |
| 723 | |
| 724 | // Table 30 - TPMA_OBJECT Bits |
| 725 | typedef struct { |
| 726 | UINT32 reserved1 : 1; |
| 727 | UINT32 fixedTPM : 1; |
| 728 | UINT32 stClear : 1; |
| 729 | UINT32 reserved4 : 1; |
| 730 | UINT32 fixedParent : 1; |
| 731 | UINT32 sensitiveDataOrigin : 1; |
| 732 | UINT32 userWithAuth : 1; |
| 733 | UINT32 adminWithPolicy : 1; |
| 734 | UINT32 reserved8_9 : 2; |
| 735 | UINT32 noDA : 1; |
| 736 | UINT32 encryptedDuplication : 1; |
| 737 | UINT32 reserved12_15 : 4; |
| 738 | UINT32 restricted : 1; |
| 739 | UINT32 decrypt : 1; |
| 740 | UINT32 sign : 1; |
| 741 | UINT32 reserved19_31 : 13; |
| 742 | } TPMA_OBJECT; |
| 743 | |
| 744 | // Table 31 - TPMA_SESSION Bits |
| 745 | typedef struct { |
| 746 | UINT8 continueSession : 1; |
| 747 | UINT8 auditExclusive : 1; |
| 748 | UINT8 auditReset : 1; |
| 749 | UINT8 reserved3_4 : 2; |
| 750 | UINT8 decrypt : 1; |
| 751 | UINT8 encrypt : 1; |
| 752 | UINT8 audit : 1; |
| 753 | } TPMA_SESSION; |
| 754 | |
| 755 | // Table 32 - TPMA_LOCALITY Bits |
| 756 | // |
| 757 | // NOTE: Use low case here to resolve conflict |
| 758 | // |
| 759 | typedef struct { |
| 760 | UINT8 locZero : 1; |
| 761 | UINT8 locOne : 1; |
| 762 | UINT8 locTwo : 1; |
| 763 | UINT8 locThree : 1; |
| 764 | UINT8 locFour : 1; |
| 765 | UINT8 Extended : 3; |
| 766 | } TPMA_LOCALITY; |
| 767 | |
| 768 | // Table 33 - TPMA_PERMANENT Bits |
| 769 | typedef struct { |
| 770 | UINT32 ownerAuthSet : 1; |
| 771 | UINT32 endorsementAuthSet : 1; |
| 772 | UINT32 lockoutAuthSet : 1; |
| 773 | UINT32 reserved3_7 : 5; |
| 774 | UINT32 disableClear : 1; |
| 775 | UINT32 inLockout : 1; |
| 776 | UINT32 tpmGeneratedEPS : 1; |
| 777 | UINT32 reserved11_31 : 21; |
| 778 | } TPMA_PERMANENT; |
| 779 | |
| 780 | // Table 34 - TPMA_STARTUP_CLEAR Bits |
| 781 | typedef struct { |
| 782 | UINT32 phEnable : 1; |
| 783 | UINT32 shEnable : 1; |
| 784 | UINT32 ehEnable : 1; |
| 785 | UINT32 reserved3_30 : 28; |
| 786 | UINT32 orderly : 1; |
| 787 | } TPMA_STARTUP_CLEAR; |
| 788 | |
| 789 | // Table 35 - TPMA_MEMORY Bits |
| 790 | typedef struct { |
| 791 | UINT32 sharedRAM : 1; |
| 792 | UINT32 sharedNV : 1; |
| 793 | UINT32 objectCopiedToRam : 1; |
| 794 | UINT32 reserved3_31 : 29; |
| 795 | } TPMA_MEMORY; |
| 796 | |
| 797 | // Table 36 - TPMA_CC Bits |
| 798 | typedef struct { |
| 799 | UINT32 commandIndex : 16; |
| 800 | UINT32 reserved16_21 : 6; |
| 801 | UINT32 nv : 1; |
| 802 | UINT32 extensive : 1; |
| 803 | UINT32 flushed : 1; |
| 804 | UINT32 cHandles : 3; |
| 805 | UINT32 rHandle : 1; |
| 806 | UINT32 V : 1; |
| 807 | UINT32 Res : 2; |
| 808 | } TPMA_CC; |
| 809 | |
| 810 | // 9 Interface Types |
| 811 | |
| 812 | // Table 37 - TPMI_YES_NO Type |
| 813 | typedef BYTE TPMI_YES_NO; |
| 814 | |
| 815 | // Table 38 - TPMI_DH_OBJECT Type |
| 816 | typedef TPM_HANDLE TPMI_DH_OBJECT; |
| 817 | |
| 818 | // Table 39 - TPMI_DH_PERSISTENT Type |
| 819 | typedef TPM_HANDLE TPMI_DH_PERSISTENT; |
| 820 | |
| 821 | // Table 40 - TPMI_DH_ENTITY Type |
| 822 | typedef TPM_HANDLE TPMI_DH_ENTITY; |
| 823 | |
| 824 | // Table 41 - TPMI_DH_PCR Type |
| 825 | typedef TPM_HANDLE TPMI_DH_PCR; |
| 826 | |
| 827 | // Table 42 - TPMI_SH_AUTH_SESSION Type |
| 828 | typedef TPM_HANDLE TPMI_SH_AUTH_SESSION; |
| 829 | |
| 830 | // Table 43 - TPMI_SH_HMAC Type |
| 831 | typedef TPM_HANDLE TPMI_SH_HMAC; |
| 832 | |
| 833 | // Table 44 - TPMI_SH_POLICY Type |
| 834 | typedef TPM_HANDLE TPMI_SH_POLICY; |
| 835 | |
| 836 | // Table 45 - TPMI_DH_CONTEXT Type |
| 837 | typedef TPM_HANDLE TPMI_DH_CONTEXT; |
| 838 | |
| 839 | // Table 46 - TPMI_RH_HIERARCHY Type |
| 840 | typedef TPM_HANDLE TPMI_RH_HIERARCHY; |
| 841 | |
| 842 | // Table 47 - TPMI_RH_HIERARCHY_AUTH Type |
| 843 | typedef TPM_HANDLE TPMI_RH_HIERARCHY_AUTH; |
| 844 | |
| 845 | // Table 48 - TPMI_RH_PLATFORM Type |
| 846 | typedef TPM_HANDLE TPMI_RH_PLATFORM; |
| 847 | |
| 848 | // Table 49 - TPMI_RH_OWNER Type |
| 849 | typedef TPM_HANDLE TPMI_RH_OWNER; |
| 850 | |
| 851 | // Table 50 - TPMI_RH_ENDORSEMENT Type |
| 852 | typedef TPM_HANDLE TPMI_RH_ENDORSEMENT; |
| 853 | |
| 854 | // Table 51 - TPMI_RH_PROVISION Type |
| 855 | typedef TPM_HANDLE TPMI_RH_PROVISION; |
| 856 | |
| 857 | // Table 52 - TPMI_RH_CLEAR Type |
| 858 | typedef TPM_HANDLE TPMI_RH_CLEAR; |
| 859 | |
| 860 | // Table 53 - TPMI_RH_NV_AUTH Type |
| 861 | typedef TPM_HANDLE TPMI_RH_NV_AUTH; |
| 862 | |
| 863 | // Table 54 - TPMI_RH_LOCKOUT Type |
| 864 | typedef TPM_HANDLE TPMI_RH_LOCKOUT; |
| 865 | |
| 866 | // Table 55 - TPMI_RH_NV_INDEX Type |
| 867 | typedef TPM_HANDLE TPMI_RH_NV_INDEX; |
| 868 | |
| 869 | // Table 56 - TPMI_ALG_HASH Type |
| 870 | typedef TPM_ALG_ID TPMI_ALG_HASH; |
| 871 | |
| 872 | // Table 57 - TPMI_ALG_ASYM Type |
| 873 | typedef TPM_ALG_ID TPMI_ALG_ASYM; |
| 874 | |
| 875 | // Table 58 - TPMI_ALG_SYM Type |
| 876 | typedef TPM_ALG_ID TPMI_ALG_SYM; |
| 877 | |
| 878 | // Table 59 - TPMI_ALG_SYM_OBJECT Type |
| 879 | typedef TPM_ALG_ID TPMI_ALG_SYM_OBJECT; |
| 880 | |
| 881 | // Table 60 - TPMI_ALG_SYM_MODE Type |
| 882 | typedef TPM_ALG_ID TPMI_ALG_SYM_MODE; |
| 883 | |
| 884 | // Table 61 - TPMI_ALG_KDF Type |
| 885 | typedef TPM_ALG_ID TPMI_ALG_KDF; |
| 886 | |
| 887 | // Table 62 - TPMI_ALG_SIG_SCHEME Type |
| 888 | typedef TPM_ALG_ID TPMI_ALG_SIG_SCHEME; |
| 889 | |
| 890 | // Table 63 - TPMI_ECC_KEY_EXCHANGE Type |
| 891 | typedef TPM_ALG_ID TPMI_ECC_KEY_EXCHANGE; |
| 892 | |
| 893 | // Table 64 - TPMI_ST_COMMAND_TAG Type |
| 894 | typedef TPM_ST TPMI_ST_COMMAND_TAG; |
| 895 | |
| 896 | // 10 Structure Definitions |
| 897 | |
| 898 | // Table 65 - TPMS_ALGORITHM_DESCRIPTION Structure |
| 899 | typedef struct { |
| 900 | TPM_ALG_ID alg; |
| 901 | TPMA_ALGORITHM attributes; |
| 902 | } TPMS_ALGORITHM_DESCRIPTION; |
| 903 | |
| 904 | // Table 66 - TPMU_HA Union |
| 905 | typedef union { |
| 906 | BYTE sha1[SHA1_DIGEST_SIZE]; |
| 907 | BYTE sha256[SHA256_DIGEST_SIZE]; |
| 908 | BYTE sm3_256[SM3_256_DIGEST_SIZE]; |
| 909 | BYTE sha384[SHA384_DIGEST_SIZE]; |
| 910 | BYTE sha512[SHA512_DIGEST_SIZE]; |
| 911 | } TPMU_HA; |
| 912 | |
| 913 | // Table 67 - TPMT_HA Structure |
| 914 | typedef struct { |
| 915 | TPMI_ALG_HASH hashAlg; |
| 916 | TPMU_HA digest; |
| 917 | } TPMT_HA; |
| 918 | |
| 919 | // Table 68 - TPM2B_DIGEST Structure |
| 920 | typedef struct { |
| 921 | UINT16 size; |
| 922 | BYTE buffer[sizeof(TPMU_HA)]; |
| 923 | } TPM2B_DIGEST; |
| 924 | |
| 925 | // Table 69 - TPM2B_DATA Structure |
| 926 | typedef struct { |
| 927 | UINT16 size; |
| 928 | BYTE buffer[sizeof(TPMT_HA)]; |
| 929 | } TPM2B_DATA; |
| 930 | |
| 931 | // Table 70 - TPM2B_NONCE Types |
| 932 | typedef TPM2B_DIGEST TPM2B_NONCE; |
| 933 | |
| 934 | // Table 71 - TPM2B_AUTH Types |
| 935 | typedef TPM2B_DIGEST TPM2B_AUTH; |
| 936 | |
| 937 | // Table 72 - TPM2B_OPERAND Types |
| 938 | typedef TPM2B_DIGEST TPM2B_OPERAND; |
| 939 | |
| 940 | // Table 73 - TPM2B_EVENT Structure |
| 941 | typedef struct { |
| 942 | UINT16 size; |
| 943 | BYTE buffer[1024]; |
| 944 | } TPM2B_EVENT; |
| 945 | |
| 946 | // Table 74 - TPM2B_MAX_BUFFER Structure |
| 947 | typedef struct { |
| 948 | UINT16 size; |
| 949 | BYTE buffer[MAX_DIGEST_BUFFER]; |
| 950 | } TPM2B_MAX_BUFFER; |
| 951 | |
| 952 | // Table 75 - TPM2B_MAX_NV_BUFFER Structure |
| 953 | typedef struct { |
| 954 | UINT16 size; |
| 955 | BYTE buffer[MAX_NV_INDEX_SIZE]; |
| 956 | } TPM2B_MAX_NV_BUFFER; |
| 957 | |
| 958 | // Table 76 - TPM2B_TIMEOUT Structure |
| 959 | typedef struct { |
| 960 | UINT16 size; |
| 961 | BYTE buffer[sizeof(UINT64)]; |
| 962 | } TPM2B_TIMEOUT; |
| 963 | |
| 964 | // Table 77 -- TPM2B_IV Structure <I/O> |
| 965 | typedef struct { |
| 966 | UINT16 size; |
| 967 | BYTE buffer[MAX_SYM_BLOCK_SIZE]; |
| 968 | } TPM2B_IV; |
| 969 | |
| 970 | // Table 78 - TPMU_NAME Union |
| 971 | typedef union { |
| 972 | TPMT_HA digest; |
| 973 | TPM_HANDLE handle; |
| 974 | } TPMU_NAME; |
| 975 | |
| 976 | // Table 79 - TPM2B_NAME Structure |
| 977 | typedef struct { |
| 978 | UINT16 size; |
| 979 | BYTE name[sizeof(TPMU_NAME)]; |
| 980 | } TPM2B_NAME; |
| 981 | |
| 982 | // Table 80 - TPMS_PCR_SELECT Structure |
| 983 | typedef struct { |
| 984 | UINT8 sizeofSelect; |
| 985 | BYTE pcrSelect[PCR_SELECT_MAX]; |
| 986 | } TPMS_PCR_SELECT; |
| 987 | |
| 988 | // Table 81 - TPMS_PCR_SELECTION Structure |
| 989 | typedef struct { |
| 990 | TPMI_ALG_HASH hash; |
| 991 | UINT8 sizeofSelect; |
| 992 | BYTE pcrSelect[PCR_SELECT_MAX]; |
| 993 | } TPMS_PCR_SELECTION; |
| 994 | |
| 995 | // Table 84 - TPMT_TK_CREATION Structure |
| 996 | typedef struct { |
| 997 | TPM_ST tag; |
| 998 | TPMI_RH_HIERARCHY hierarchy; |
| 999 | TPM2B_DIGEST digest; |
| 1000 | } TPMT_TK_CREATION; |
| 1001 | |
| 1002 | // Table 85 - TPMT_TK_VERIFIED Structure |
| 1003 | typedef struct { |
| 1004 | TPM_ST tag; |
| 1005 | TPMI_RH_HIERARCHY hierarchy; |
| 1006 | TPM2B_DIGEST digest; |
| 1007 | } TPMT_TK_VERIFIED; |
| 1008 | |
| 1009 | // Table 86 - TPMT_TK_AUTH Structure |
| 1010 | typedef struct { |
| 1011 | TPM_ST tag; |
| 1012 | TPMI_RH_HIERARCHY hierarchy; |
| 1013 | TPM2B_DIGEST digest; |
| 1014 | } TPMT_TK_AUTH; |
| 1015 | |
| 1016 | // Table 87 - TPMT_TK_HASHCHECK Structure |
| 1017 | typedef struct { |
| 1018 | TPM_ST tag; |
| 1019 | TPMI_RH_HIERARCHY hierarchy; |
| 1020 | TPM2B_DIGEST digest; |
| 1021 | } TPMT_TK_HASHCHECK; |
| 1022 | |
| 1023 | // Table 88 - TPMS_ALG_PROPERTY Structure |
| 1024 | typedef struct { |
| 1025 | TPM_ALG_ID alg; |
| 1026 | TPMA_ALGORITHM algProperties; |
| 1027 | } TPMS_ALG_PROPERTY; |
| 1028 | |
| 1029 | // Table 89 - TPMS_TAGGED_PROPERTY Structure |
| 1030 | typedef struct { |
| 1031 | TPM_PT property; |
| 1032 | UINT32 value; |
| 1033 | } TPMS_TAGGED_PROPERTY; |
| 1034 | |
| 1035 | // Table 90 - TPMS_TAGGED_PCR_SELECT Structure |
| 1036 | typedef struct { |
| 1037 | TPM_PT tag; |
| 1038 | UINT8 sizeofSelect; |
| 1039 | BYTE pcrSelect[PCR_SELECT_MAX]; |
| 1040 | } TPMS_TAGGED_PCR_SELECT; |
| 1041 | |
| 1042 | // Table 91 - TPML_CC Structure |
| 1043 | typedef struct { |
| 1044 | UINT32 count; |
| 1045 | TPM_CC commandCodes[MAX_CAP_CC]; |
| 1046 | } TPML_CC; |
| 1047 | |
| 1048 | // Table 92 - TPML_CCA Structure |
| 1049 | typedef struct { |
| 1050 | UINT32 count; |
| 1051 | TPMA_CC commandAttributes[MAX_CAP_CC]; |
| 1052 | } TPML_CCA; |
| 1053 | |
| 1054 | // Table 93 - TPML_ALG Structure |
| 1055 | typedef struct { |
| 1056 | UINT32 count; |
| 1057 | TPM_ALG_ID algorithms[MAX_ALG_LIST_SIZE]; |
| 1058 | } TPML_ALG; |
| 1059 | |
| 1060 | // Table 94 - TPML_HANDLE Structure |
| 1061 | typedef struct { |
| 1062 | UINT32 count; |
| 1063 | TPM_HANDLE handle[MAX_CAP_HANDLES]; |
| 1064 | } TPML_HANDLE; |
| 1065 | |
| 1066 | // Table 95 - TPML_DIGEST Structure |
| 1067 | typedef struct { |
| 1068 | UINT32 count; |
| 1069 | TPM2B_DIGEST digests[8]; |
| 1070 | } TPML_DIGEST; |
| 1071 | |
| 1072 | // Table 96 -- TPML_DIGEST_VALUES Structure <I/O> |
| 1073 | typedef struct { |
| 1074 | UINT32 count; |
| 1075 | TPMT_HA digests[HASH_COUNT]; |
| 1076 | } TPML_DIGEST_VALUES; |
| 1077 | |
| 1078 | // Table 97 - TPM2B_DIGEST_VALUES Structure |
| 1079 | typedef struct { |
| 1080 | UINT16 size; |
| 1081 | BYTE buffer[sizeof(TPML_DIGEST_VALUES)]; |
| 1082 | } TPM2B_DIGEST_VALUES; |
| 1083 | |
| 1084 | // Table 98 - TPML_PCR_SELECTION Structure |
| 1085 | typedef struct { |
| 1086 | UINT32 count; |
| 1087 | TPMS_PCR_SELECTION pcrSelections[HASH_COUNT]; |
| 1088 | } TPML_PCR_SELECTION; |
| 1089 | |
| 1090 | // Table 99 - TPML_ALG_PROPERTY Structure |
| 1091 | typedef struct { |
| 1092 | UINT32 count; |
| 1093 | TPMS_ALG_PROPERTY algProperties[MAX_CAP_ALGS]; |
| 1094 | } TPML_ALG_PROPERTY; |
| 1095 | |
| 1096 | // Table 100 - TPML_TAGGED_TPM_PROPERTY Structure |
| 1097 | typedef struct { |
| 1098 | UINT32 count; |
| 1099 | TPMS_TAGGED_PROPERTY tpmProperty[MAX_TPM_PROPERTIES]; |
| 1100 | } TPML_TAGGED_TPM_PROPERTY; |
| 1101 | |
| 1102 | // Table 101 - TPML_TAGGED_PCR_PROPERTY Structure |
| 1103 | typedef struct { |
| 1104 | UINT32 count; |
| 1105 | TPMS_TAGGED_PCR_SELECT pcrProperty[MAX_PCR_PROPERTIES]; |
| 1106 | } TPML_TAGGED_PCR_PROPERTY; |
| 1107 | |
| 1108 | // Table 102 - TPML_ECC_CURVE Structure |
| 1109 | typedef struct { |
| 1110 | UINT32 count; |
| 1111 | TPM_ECC_CURVE eccCurves[MAX_ECC_CURVES]; |
| 1112 | } TPML_ECC_CURVE; |
| 1113 | |
| 1114 | // Table 103 - TPMU_CAPABILITIES Union |
| 1115 | typedef union { |
| 1116 | TPML_ALG_PROPERTY algorithms; |
| 1117 | TPML_HANDLE handles; |
| 1118 | TPML_CCA command; |
| 1119 | TPML_CC ppCommands; |
| 1120 | TPML_CC auditCommands; |
| 1121 | TPML_PCR_SELECTION assignedPCR; |
| 1122 | TPML_TAGGED_TPM_PROPERTY tpmProperties; |
| 1123 | TPML_TAGGED_PCR_PROPERTY pcrProperties; |
| 1124 | TPML_ECC_CURVE eccCurves; |
| 1125 | } TPMU_CAPABILITIES; |
| 1126 | |
| 1127 | // Table 104 - TPMS_CAPABILITY_DATA Structure |
| 1128 | typedef struct { |
| 1129 | TPM_CAP capability; |
| 1130 | TPMU_CAPABILITIES data; |
| 1131 | } TPMS_CAPABILITY_DATA; |
| 1132 | |
| 1133 | // Table 105 - TPMS_CLOCK_INFO Structure |
| 1134 | typedef struct { |
| 1135 | UINT64 clock; |
| 1136 | UINT32 resetCount; |
| 1137 | UINT32 restartCount; |
| 1138 | TPMI_YES_NO safe; |
| 1139 | } TPMS_CLOCK_INFO; |
| 1140 | |
| 1141 | // Table 106 - TPMS_TIME_INFO Structure |
| 1142 | typedef struct { |
| 1143 | UINT64 time; |
| 1144 | TPMS_CLOCK_INFO clockInfo; |
| 1145 | } TPMS_TIME_INFO; |
| 1146 | |
| 1147 | // Table 107 - TPMS_TIME_ATTEST_INFO Structure |
| 1148 | typedef struct { |
| 1149 | TPMS_TIME_INFO time; |
| 1150 | UINT64 firmwareVersion; |
| 1151 | } TPMS_TIME_ATTEST_INFO; |
| 1152 | |
| 1153 | // Table 108 - TPMS_CERTIFY_INFO Structure |
| 1154 | typedef struct { |
| 1155 | TPM2B_NAME name; |
| 1156 | TPM2B_NAME qualifiedName; |
| 1157 | } TPMS_CERTIFY_INFO; |
| 1158 | |
| 1159 | // Table 109 - TPMS_QUOTE_INFO Structure |
| 1160 | typedef struct { |
| 1161 | TPML_PCR_SELECTION pcrSelect; |
| 1162 | TPM2B_DIGEST pcrDigest; |
| 1163 | } TPMS_QUOTE_INFO; |
| 1164 | |
| 1165 | // Table 110 - TPMS_COMMAND_AUDIT_INFO Structure |
| 1166 | typedef struct { |
| 1167 | UINT64 auditCounter; |
| 1168 | TPM_ALG_ID digestAlg; |
| 1169 | TPM2B_DIGEST auditDigest; |
| 1170 | TPM2B_DIGEST commandDigest; |
| 1171 | } TPMS_COMMAND_AUDIT_INFO; |
| 1172 | |
| 1173 | // Table 111 - TPMS_SESSION_AUDIT_INFO Structure |
| 1174 | typedef struct { |
| 1175 | TPMI_YES_NO exclusiveSession; |
| 1176 | TPM2B_DIGEST sessionDigest; |
| 1177 | } TPMS_SESSION_AUDIT_INFO; |
| 1178 | |
| 1179 | // Table 112 - TPMS_CREATION_INFO Structure |
| 1180 | typedef struct { |
| 1181 | TPM2B_NAME objectName; |
| 1182 | TPM2B_DIGEST creationHash; |
| 1183 | } TPMS_CREATION_INFO; |
| 1184 | |
| 1185 | // Table 113 - TPMS_NV_CERTIFY_INFO Structure |
| 1186 | typedef struct { |
| 1187 | TPM2B_NAME indexName; |
| 1188 | UINT16 offset; |
| 1189 | TPM2B_MAX_NV_BUFFER nvContents; |
| 1190 | } TPMS_NV_CERTIFY_INFO; |
| 1191 | |
| 1192 | // Table 114 - TPMI_ST_ATTEST Type |
| 1193 | typedef TPM_ST TPMI_ST_ATTEST; |
| 1194 | |
| 1195 | // Table 115 - TPMU_ATTEST Union |
| 1196 | typedef union { |
| 1197 | TPMS_CERTIFY_INFO certify; |
| 1198 | TPMS_CREATION_INFO creation; |
| 1199 | TPMS_QUOTE_INFO quote; |
| 1200 | TPMS_COMMAND_AUDIT_INFO commandAudit; |
| 1201 | TPMS_SESSION_AUDIT_INFO sessionAudit; |
| 1202 | TPMS_TIME_ATTEST_INFO time; |
| 1203 | TPMS_NV_CERTIFY_INFO nv; |
| 1204 | } TPMU_ATTEST; |
| 1205 | |
| 1206 | // Table 116 - TPMS_ATTEST Structure |
| 1207 | typedef struct { |
| 1208 | TPM_GENERATED magic; |
| 1209 | TPMI_ST_ATTEST type; |
| 1210 | TPM2B_NAME qualifiedSigner; |
| 1211 | TPM2B_DATA extraData; |
| 1212 | TPMS_CLOCK_INFO clockInfo; |
| 1213 | UINT64 firmwareVersion; |
| 1214 | TPMU_ATTEST attested; |
| 1215 | } TPMS_ATTEST; |
| 1216 | |
| 1217 | // Table 117 - TPM2B_ATTEST Structure |
| 1218 | typedef struct { |
| 1219 | UINT16 size; |
| 1220 | BYTE attestationData[sizeof(TPMS_ATTEST)]; |
| 1221 | } TPM2B_ATTEST; |
| 1222 | |
| 1223 | // Table 118 - TPMS_AUTH_COMMAND Structure |
| 1224 | typedef struct { |
| 1225 | TPMI_SH_AUTH_SESSION sessionHandle; |
| 1226 | TPM2B_NONCE nonce; |
| 1227 | TPMA_SESSION sessionAttributes; |
| 1228 | TPM2B_AUTH hmac; |
| 1229 | } TPMS_AUTH_COMMAND; |
| 1230 | |
| 1231 | // Table 119 - TPMS_AUTH_RESPONSE Structure |
| 1232 | typedef struct { |
| 1233 | TPM2B_NONCE nonce; |
| 1234 | TPMA_SESSION sessionAttributes; |
| 1235 | TPM2B_AUTH hmac; |
| 1236 | } TPMS_AUTH_RESPONSE; |
| 1237 | |
| 1238 | // 11 Algorithm Parameters and Structures |
| 1239 | |
| 1240 | // Table 120 - TPMI_AES_KEY_BITS Type |
| 1241 | typedef TPM_KEY_BITS TPMI_AES_KEY_BITS; |
| 1242 | |
| 1243 | // Table 121 - TPMI_SM4_KEY_BITS Type |
| 1244 | typedef TPM_KEY_BITS TPMI_SM4_KEY_BITS; |
| 1245 | |
| 1246 | // Table 122 - TPMU_SYM_KEY_BITS Union |
| 1247 | typedef union { |
| 1248 | TPMI_AES_KEY_BITS aes; |
| 1249 | TPMI_SM4_KEY_BITS SM4; |
| 1250 | TPM_KEY_BITS sym; |
| 1251 | TPMI_ALG_HASH xor; |
| 1252 | } TPMU_SYM_KEY_BITS; |
| 1253 | |
| 1254 | // Table 123 - TPMU_SYM_MODE Union |
| 1255 | typedef union { |
| 1256 | TPMI_ALG_SYM_MODE aes; |
| 1257 | TPMI_ALG_SYM_MODE SM4; |
| 1258 | TPMI_ALG_SYM_MODE sym; |
| 1259 | } TPMU_SYM_MODE; |
| 1260 | |
| 1261 | // Table 125 - TPMT_SYM_DEF Structure |
| 1262 | typedef struct { |
| 1263 | TPMI_ALG_SYM algorithm; |
| 1264 | TPMU_SYM_KEY_BITS keyBits; |
| 1265 | TPMU_SYM_MODE mode; |
| 1266 | } TPMT_SYM_DEF; |
| 1267 | |
| 1268 | // Table 126 - TPMT_SYM_DEF_OBJECT Structure |
| 1269 | typedef struct { |
| 1270 | TPMI_ALG_SYM_OBJECT algorithm; |
| 1271 | TPMU_SYM_KEY_BITS keyBits; |
| 1272 | TPMU_SYM_MODE mode; |
| 1273 | } TPMT_SYM_DEF_OBJECT; |
| 1274 | |
| 1275 | // Table 127 - TPM2B_SYM_KEY Structure |
| 1276 | typedef struct { |
| 1277 | UINT16 size; |
| 1278 | BYTE buffer[MAX_SYM_KEY_BYTES]; |
| 1279 | } TPM2B_SYM_KEY; |
| 1280 | |
| 1281 | // Table 128 - TPMS_SYMCIPHER_PARMS Structure |
| 1282 | typedef struct { |
| 1283 | TPMT_SYM_DEF_OBJECT sym; |
| 1284 | } TPMS_SYMCIPHER_PARMS; |
| 1285 | |
| 1286 | // Table 129 - TPM2B_SENSITIVE_DATA Structure |
| 1287 | typedef struct { |
| 1288 | UINT16 size; |
| 1289 | BYTE buffer[MAX_SYM_DATA]; |
| 1290 | } TPM2B_SENSITIVE_DATA; |
| 1291 | |
| 1292 | // Table 130 - TPMS_SENSITIVE_CREATE Structure |
| 1293 | typedef struct { |
| 1294 | TPM2B_AUTH userAuth; |
| 1295 | TPM2B_SENSITIVE_DATA data; |
| 1296 | } TPMS_SENSITIVE_CREATE; |
| 1297 | |
| 1298 | // Table 131 - TPM2B_SENSITIVE_CREATE Structure |
| 1299 | typedef struct { |
| 1300 | UINT16 size; |
| 1301 | TPMS_SENSITIVE_CREATE sensitive; |
| 1302 | } TPM2B_SENSITIVE_CREATE; |
| 1303 | |
| 1304 | // Table 132 - TPMS_SCHEME_SIGHASH Structure |
| 1305 | typedef struct { |
| 1306 | TPMI_ALG_HASH hashAlg; |
| 1307 | } TPMS_SCHEME_SIGHASH; |
| 1308 | |
| 1309 | // Table 133 - TPMI_ALG_KEYEDHASH_SCHEME Type |
| 1310 | typedef TPM_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME; |
| 1311 | |
| 1312 | // Table 134 - HMAC_SIG_SCHEME Types |
| 1313 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_HMAC; |
| 1314 | |
| 1315 | // Table 135 - TPMS_SCHEME_XOR Structure |
| 1316 | typedef struct { |
| 1317 | TPMI_ALG_HASH hashAlg; |
| 1318 | TPMI_ALG_KDF kdf; |
| 1319 | } TPMS_SCHEME_XOR; |
| 1320 | |
| 1321 | // Table 136 - TPMU_SCHEME_KEYEDHASH Union |
| 1322 | typedef union { |
| 1323 | TPMS_SCHEME_HMAC hmac; |
| 1324 | TPMS_SCHEME_XOR xor; |
| 1325 | } TPMU_SCHEME_KEYEDHASH; |
| 1326 | |
| 1327 | // Table 137 - TPMT_KEYEDHASH_SCHEME Structure |
| 1328 | typedef struct { |
| 1329 | TPMI_ALG_KEYEDHASH_SCHEME scheme; |
| 1330 | TPMU_SCHEME_KEYEDHASH details; |
| 1331 | } TPMT_KEYEDHASH_SCHEME; |
| 1332 | |
| 1333 | // Table 138 - RSA_SIG_SCHEMES Types |
| 1334 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_RSASSA; |
| 1335 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_RSAPSS; |
| 1336 | |
| 1337 | // Table 139 - ECC_SIG_SCHEMES Types |
| 1338 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_ECDSA; |
| 1339 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_SM2; |
| 1340 | typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_ECSCHNORR; |
| 1341 | |
| 1342 | // Table 140 - TPMS_SCHEME_ECDAA Structure |
| 1343 | typedef struct { |
| 1344 | TPMI_ALG_HASH hashAlg; |
| 1345 | UINT16 count; |
| 1346 | } TPMS_SCHEME_ECDAA; |
| 1347 | |
| 1348 | // Table 141 - TPMU_SIG_SCHEME Union |
| 1349 | typedef union { |
| 1350 | TPMS_SCHEME_RSASSA rsassa; |
| 1351 | TPMS_SCHEME_RSAPSS rsapss; |
| 1352 | TPMS_SCHEME_ECDSA ecdsa; |
| 1353 | TPMS_SCHEME_ECDAA ecdaa; |
| 1354 | TPMS_SCHEME_ECSCHNORR ecSchnorr; |
| 1355 | TPMS_SCHEME_HMAC hmac; |
| 1356 | TPMS_SCHEME_SIGHASH any; |
| 1357 | } TPMU_SIG_SCHEME; |
| 1358 | |
| 1359 | // Table 142 - TPMT_SIG_SCHEME Structure |
| 1360 | typedef struct { |
| 1361 | TPMI_ALG_SIG_SCHEME scheme; |
| 1362 | TPMU_SIG_SCHEME details; |
| 1363 | } TPMT_SIG_SCHEME; |
| 1364 | |
| 1365 | // Table 143 - TPMS_SCHEME_OAEP Structure |
| 1366 | typedef struct { |
| 1367 | TPMI_ALG_HASH hashAlg; |
| 1368 | } TPMS_SCHEME_OAEP; |
| 1369 | |
| 1370 | // Table 144 - TPMS_SCHEME_ECDH Structure |
| 1371 | typedef struct { |
| 1372 | TPMI_ALG_HASH hashAlg; |
| 1373 | } TPMS_SCHEME_ECDH; |
| 1374 | |
| 1375 | // Table 145 - TPMS_SCHEME_MGF1 Structure |
| 1376 | typedef struct { |
| 1377 | TPMI_ALG_HASH hashAlg; |
| 1378 | } TPMS_SCHEME_MGF1; |
| 1379 | |
| 1380 | // Table 146 - TPMS_SCHEME_KDF1_SP800_56a Structure |
| 1381 | typedef struct { |
| 1382 | TPMI_ALG_HASH hashAlg; |
| 1383 | } TPMS_SCHEME_KDF1_SP800_56a; |
| 1384 | |
| 1385 | // Table 147 - TPMS_SCHEME_KDF2 Structure |
| 1386 | typedef struct { |
| 1387 | TPMI_ALG_HASH hashAlg; |
| 1388 | } TPMS_SCHEME_KDF2; |
| 1389 | |
| 1390 | // Table 148 - TPMS_SCHEME_KDF1_SP800_108 Structure |
| 1391 | typedef struct { |
| 1392 | TPMI_ALG_HASH hashAlg; |
| 1393 | } TPMS_SCHEME_KDF1_SP800_108; |
| 1394 | |
| 1395 | // Table 149 - TPMU_KDF_SCHEME Union |
| 1396 | typedef union { |
| 1397 | TPMS_SCHEME_MGF1 mgf1; |
| 1398 | TPMS_SCHEME_KDF1_SP800_56a kdf1_SP800_56a; |
| 1399 | TPMS_SCHEME_KDF2 kdf2; |
| 1400 | TPMS_SCHEME_KDF1_SP800_108 kdf1_sp800_108; |
| 1401 | } TPMU_KDF_SCHEME; |
| 1402 | |
| 1403 | // Table 150 - TPMT_KDF_SCHEME Structure |
| 1404 | typedef struct { |
| 1405 | TPMI_ALG_KDF scheme; |
| 1406 | TPMU_KDF_SCHEME details; |
| 1407 | } TPMT_KDF_SCHEME; |
| 1408 | |
| 1409 | // Table 151 - TPMI_ALG_ASYM_SCHEME Type |
| 1410 | typedef TPM_ALG_ID TPMI_ALG_ASYM_SCHEME; |
| 1411 | |
| 1412 | // Table 152 - TPMU_ASYM_SCHEME Union |
| 1413 | typedef union { |
| 1414 | TPMS_SCHEME_RSASSA rsassa; |
| 1415 | TPMS_SCHEME_RSAPSS rsapss; |
| 1416 | TPMS_SCHEME_OAEP oaep; |
| 1417 | TPMS_SCHEME_ECDSA ecdsa; |
| 1418 | TPMS_SCHEME_ECDAA ecdaa; |
| 1419 | TPMS_SCHEME_ECSCHNORR ecSchnorr; |
| 1420 | TPMS_SCHEME_SIGHASH anySig; |
| 1421 | } TPMU_ASYM_SCHEME; |
| 1422 | |
| 1423 | // Table 153 - TPMT_ASYM_SCHEME Structure |
| 1424 | typedef struct { |
| 1425 | TPMI_ALG_ASYM_SCHEME scheme; |
| 1426 | TPMU_ASYM_SCHEME details; |
| 1427 | } TPMT_ASYM_SCHEME; |
| 1428 | |
| 1429 | // Table 154 - TPMI_ALG_RSA_SCHEME Type |
| 1430 | typedef TPM_ALG_ID TPMI_ALG_RSA_SCHEME; |
| 1431 | |
| 1432 | // Table 155 - TPMT_RSA_SCHEME Structure |
| 1433 | typedef struct { |
| 1434 | TPMI_ALG_RSA_SCHEME scheme; |
| 1435 | TPMU_ASYM_SCHEME details; |
| 1436 | } TPMT_RSA_SCHEME; |
| 1437 | |
| 1438 | // Table 156 - TPMI_ALG_RSA_DECRYPT Type |
| 1439 | typedef TPM_ALG_ID TPMI_ALG_RSA_DECRYPT; |
| 1440 | |
| 1441 | // Table 157 - TPMT_RSA_DECRYPT Structure |
| 1442 | typedef struct { |
| 1443 | TPMI_ALG_RSA_DECRYPT scheme; |
| 1444 | TPMU_ASYM_SCHEME details; |
| 1445 | } TPMT_RSA_DECRYPT; |
| 1446 | |
| 1447 | // Table 158 - TPM2B_PUBLIC_KEY_RSA Structure |
| 1448 | typedef struct { |
| 1449 | UINT16 size; |
| 1450 | BYTE buffer[MAX_RSA_KEY_BYTES]; |
| 1451 | } TPM2B_PUBLIC_KEY_RSA; |
| 1452 | |
| 1453 | // Table 159 - TPMI_RSA_KEY_BITS Type |
| 1454 | typedef TPM_KEY_BITS TPMI_RSA_KEY_BITS; |
| 1455 | |
| 1456 | // Table 160 - TPM2B_PRIVATE_KEY_RSA Structure |
| 1457 | typedef struct { |
| 1458 | UINT16 size; |
| 1459 | BYTE buffer[MAX_RSA_KEY_BYTES/2]; |
| 1460 | } TPM2B_PRIVATE_KEY_RSA; |
| 1461 | |
| 1462 | // Table 161 - TPM2B_ECC_PARAMETER Structure |
| 1463 | typedef struct { |
| 1464 | UINT16 size; |
| 1465 | BYTE buffer[MAX_ECC_KEY_BYTES]; |
| 1466 | } TPM2B_ECC_PARAMETER; |
| 1467 | |
| 1468 | // Table 162 - TPMS_ECC_POINT Structure |
| 1469 | typedef struct { |
| 1470 | TPM2B_ECC_PARAMETER x; |
| 1471 | TPM2B_ECC_PARAMETER y; |
| 1472 | } TPMS_ECC_POINT; |
| 1473 | |
| 1474 | // Table 163 -- TPM2B_ECC_POINT Structure <I/O> |
| 1475 | typedef struct { |
| 1476 | UINT16 size; |
| 1477 | TPMS_ECC_POINT point; |
| 1478 | } TPM2B_ECC_POINT; |
| 1479 | |
| 1480 | // Table 164 - TPMI_ALG_ECC_SCHEME Type |
| 1481 | typedef TPM_ALG_ID TPMI_ALG_ECC_SCHEME; |
| 1482 | |
| 1483 | // Table 165 - TPMI_ECC_CURVE Type |
| 1484 | typedef TPM_ECC_CURVE TPMI_ECC_CURVE; |
| 1485 | |
| 1486 | // Table 166 - TPMT_ECC_SCHEME Structure |
| 1487 | typedef struct { |
| 1488 | TPMI_ALG_ECC_SCHEME scheme; |
| 1489 | TPMU_SIG_SCHEME details; |
| 1490 | } TPMT_ECC_SCHEME; |
| 1491 | |
| 1492 | // Table 167 - TPMS_ALGORITHM_DETAIL_ECC Structure |
| 1493 | typedef struct { |
| 1494 | TPM_ECC_CURVE curveID; |
| 1495 | UINT16 keySize; |
| 1496 | TPMT_KDF_SCHEME kdf; |
| 1497 | TPMT_ECC_SCHEME sign; |
| 1498 | TPM2B_ECC_PARAMETER p; |
| 1499 | TPM2B_ECC_PARAMETER a; |
| 1500 | TPM2B_ECC_PARAMETER b; |
| 1501 | TPM2B_ECC_PARAMETER gX; |
| 1502 | TPM2B_ECC_PARAMETER gY; |
| 1503 | TPM2B_ECC_PARAMETER n; |
| 1504 | TPM2B_ECC_PARAMETER h; |
| 1505 | } TPMS_ALGORITHM_DETAIL_ECC; |
| 1506 | |
| 1507 | // Table 168 - TPMS_SIGNATURE_RSASSA Structure |
| 1508 | typedef struct { |
| 1509 | TPMI_ALG_HASH hash; |
| 1510 | TPM2B_PUBLIC_KEY_RSA sig; |
| 1511 | } TPMS_SIGNATURE_RSASSA; |
| 1512 | |
| 1513 | // Table 169 - TPMS_SIGNATURE_RSAPSS Structure |
| 1514 | typedef struct { |
| 1515 | TPMI_ALG_HASH hash; |
| 1516 | TPM2B_PUBLIC_KEY_RSA sig; |
| 1517 | } TPMS_SIGNATURE_RSAPSS; |
| 1518 | |
| 1519 | // Table 170 - TPMS_SIGNATURE_ECDSA Structure |
| 1520 | typedef struct { |
| 1521 | TPMI_ALG_HASH hash; |
| 1522 | TPM2B_ECC_PARAMETER signatureR; |
| 1523 | TPM2B_ECC_PARAMETER signatureS; |
| 1524 | } TPMS_SIGNATURE_ECDSA; |
| 1525 | |
| 1526 | // Table 171 - TPMU_SIGNATURE Union |
| 1527 | typedef union { |
| 1528 | TPMS_SIGNATURE_RSASSA rsassa; |
| 1529 | TPMS_SIGNATURE_RSAPSS rsapss; |
| 1530 | TPMS_SIGNATURE_ECDSA ecdsa; |
| 1531 | TPMS_SIGNATURE_ECDSA sm2; |
| 1532 | TPMS_SIGNATURE_ECDSA ecdaa; |
| 1533 | TPMS_SIGNATURE_ECDSA ecschnorr; |
| 1534 | TPMT_HA hmac; |
| 1535 | TPMS_SCHEME_SIGHASH any; |
| 1536 | } TPMU_SIGNATURE; |
| 1537 | |
| 1538 | // Table 172 - TPMT_SIGNATURE Structure |
| 1539 | typedef struct { |
| 1540 | TPMI_ALG_SIG_SCHEME sigAlg; |
| 1541 | TPMU_SIGNATURE signature; |
| 1542 | } TPMT_SIGNATURE; |
| 1543 | |
| 1544 | // Table 173 - TPMU_ENCRYPTED_SECRET Union |
| 1545 | typedef union { |
| 1546 | BYTE ecc[sizeof(TPMS_ECC_POINT)]; |
| 1547 | BYTE rsa[MAX_RSA_KEY_BYTES]; |
| 1548 | BYTE symmetric[sizeof(TPM2B_DIGEST)]; |
| 1549 | BYTE keyedHash[sizeof(TPM2B_DIGEST)]; |
| 1550 | } TPMU_ENCRYPTED_SECRET; |
| 1551 | |
| 1552 | // Table 174 - TPM2B_ENCRYPTED_SECRET Structure |
| 1553 | typedef struct { |
| 1554 | UINT16 size; |
| 1555 | BYTE secret[sizeof(TPMU_ENCRYPTED_SECRET)]; |
| 1556 | } TPM2B_ENCRYPTED_SECRET; |
| 1557 | |
| 1558 | // 12 Key/Object Complex |
| 1559 | |
| 1560 | // Table 175 - TPMI_ALG_PUBLIC Type |
| 1561 | typedef TPM_ALG_ID TPMI_ALG_PUBLIC; |
| 1562 | |
| 1563 | // Table 176 - TPMU_PUBLIC_ID Union |
| 1564 | typedef union { |
| 1565 | TPM2B_DIGEST keyedHash; |
| 1566 | TPM2B_DIGEST sym; |
| 1567 | TPM2B_PUBLIC_KEY_RSA rsa; |
| 1568 | TPMS_ECC_POINT ecc; |
| 1569 | } TPMU_PUBLIC_ID; |
| 1570 | |
| 1571 | // Table 177 - TPMS_KEYEDHASH_PARMS Structure |
| 1572 | typedef struct { |
| 1573 | TPMT_KEYEDHASH_SCHEME scheme; |
| 1574 | } TPMS_KEYEDHASH_PARMS; |
| 1575 | |
| 1576 | // Table 178 - TPMS_ASYM_PARMS Structure |
| 1577 | typedef struct { |
| 1578 | TPMT_SYM_DEF_OBJECT symmetric; |
| 1579 | TPMT_ASYM_SCHEME scheme; |
| 1580 | } TPMS_ASYM_PARMS; |
| 1581 | |
| 1582 | // Table 179 - TPMS_RSA_PARMS Structure |
| 1583 | typedef struct { |
| 1584 | TPMT_SYM_DEF_OBJECT symmetric; |
| 1585 | TPMT_RSA_SCHEME scheme; |
| 1586 | TPMI_RSA_KEY_BITS keyBits; |
| 1587 | UINT32 exponent; |
| 1588 | } TPMS_RSA_PARMS; |
| 1589 | |
| 1590 | // Table 180 - TPMS_ECC_PARMS Structure |
| 1591 | typedef struct { |
| 1592 | TPMT_SYM_DEF_OBJECT symmetric; |
| 1593 | TPMT_ECC_SCHEME scheme; |
| 1594 | TPMI_ECC_CURVE curveID; |
| 1595 | TPMT_KDF_SCHEME kdf; |
| 1596 | } TPMS_ECC_PARMS; |
| 1597 | |
| 1598 | // Table 181 - TPMU_PUBLIC_PARMS Union |
| 1599 | typedef union { |
| 1600 | TPMS_KEYEDHASH_PARMS keyedHashDetail; |
| 1601 | TPMT_SYM_DEF_OBJECT symDetail; |
| 1602 | TPMS_RSA_PARMS rsaDetail; |
| 1603 | TPMS_ECC_PARMS eccDetail; |
| 1604 | TPMS_ASYM_PARMS asymDetail; |
| 1605 | } TPMU_PUBLIC_PARMS; |
| 1606 | |
| 1607 | // Table 182 - TPMT_PUBLIC_PARMS Structure |
| 1608 | typedef struct { |
| 1609 | TPMI_ALG_PUBLIC type; |
| 1610 | TPMU_PUBLIC_PARMS parameters; |
| 1611 | } TPMT_PUBLIC_PARMS; |
| 1612 | |
| 1613 | // Table 183 - TPMT_PUBLIC Structure |
| 1614 | typedef struct { |
| 1615 | TPMI_ALG_PUBLIC type; |
| 1616 | TPMI_ALG_HASH nameAlg; |
| 1617 | TPMA_OBJECT objectAttributes; |
| 1618 | TPM2B_DIGEST authPolicy; |
| 1619 | TPMU_PUBLIC_PARMS parameters; |
| 1620 | TPMU_PUBLIC_ID unique; |
| 1621 | } TPMT_PUBLIC; |
| 1622 | |
| 1623 | // Table 184 - TPM2B_PUBLIC Structure |
| 1624 | typedef struct { |
| 1625 | UINT16 size; |
| 1626 | TPMT_PUBLIC publicArea; |
| 1627 | } TPM2B_PUBLIC; |
| 1628 | |
| 1629 | // Table 185 - TPM2B_PRIVATE_VENDOR_SPECIFIC Structure |
| 1630 | typedef struct { |
| 1631 | UINT16 size; |
| 1632 | BYTE buffer[PRIVATE_VENDOR_SPECIFIC_BYTES]; |
| 1633 | } TPM2B_PRIVATE_VENDOR_SPECIFIC; |
| 1634 | |
| 1635 | // Table 186 - TPMU_SENSITIVE_COMPOSITE Union |
| 1636 | typedef union { |
| 1637 | TPM2B_PRIVATE_KEY_RSA rsa; |
| 1638 | TPM2B_ECC_PARAMETER ecc; |
| 1639 | TPM2B_SENSITIVE_DATA bits; |
| 1640 | TPM2B_SYM_KEY sym; |
| 1641 | TPM2B_PRIVATE_VENDOR_SPECIFIC any; |
| 1642 | } TPMU_SENSITIVE_COMPOSITE; |
| 1643 | |
| 1644 | // Table 187 - TPMT_SENSITIVE Structure |
| 1645 | typedef struct { |
| 1646 | TPMI_ALG_PUBLIC sensitiveType; |
| 1647 | TPM2B_AUTH authValue; |
| 1648 | TPM2B_DIGEST seedValue; |
| 1649 | TPMU_SENSITIVE_COMPOSITE sensitive; |
| 1650 | } TPMT_SENSITIVE; |
| 1651 | |
| 1652 | // Table 188 - TPM2B_SENSITIVE Structure |
| 1653 | typedef struct { |
| 1654 | UINT16 size; |
| 1655 | TPMT_SENSITIVE sensitiveArea; |
| 1656 | } TPM2B_SENSITIVE; |
| 1657 | |
| 1658 | // Table 189 - _PRIVATE Structure |
| 1659 | typedef struct { |
| 1660 | TPM2B_DIGEST integrityOuter; |
| 1661 | TPM2B_DIGEST integrityInner; |
| 1662 | TPMT_SENSITIVE sensitive; |
| 1663 | } _PRIVATE; |
| 1664 | |
| 1665 | // Table 190 - TPM2B_PRIVATE Structure |
| 1666 | typedef struct { |
| 1667 | UINT16 size; |
| 1668 | BYTE buffer[sizeof(_PRIVATE)]; |
| 1669 | } TPM2B_PRIVATE; |
| 1670 | |
| 1671 | // Table 191 - _ID_OBJECT Structure |
| 1672 | typedef struct { |
| 1673 | TPM2B_DIGEST integrityHMAC; |
| 1674 | TPM2B_DIGEST encIdentity; |
| 1675 | } _ID_OBJECT; |
| 1676 | |
| 1677 | // Table 192 - TPM2B_ID_OBJECT Structure |
| 1678 | typedef struct { |
| 1679 | UINT16 size; |
| 1680 | BYTE credential[sizeof(_ID_OBJECT)]; |
| 1681 | } TPM2B_ID_OBJECT; |
| 1682 | |
| 1683 | // 13 NV Storage Structures |
| 1684 | |
| 1685 | // Table 193 - TPM_NV_INDEX Bits |
| 1686 | // |
| 1687 | // NOTE: Comment here to resolve conflict |
| 1688 | // |
| 1689 | //typedef struct { |
| 1690 | // UINT32 index : 22; |
| 1691 | // UINT32 space : 2; |
| 1692 | // UINT32 RH_NV : 8; |
| 1693 | //} TPM_NV_INDEX; |
| 1694 | |
| 1695 | // Table 195 - TPMA_NV Bits |
| 1696 | typedef struct { |
| 1697 | UINT32 TPMA_NV_PPWRITE : 1; |
| 1698 | UINT32 TPMA_NV_OWNERWRITE : 1; |
| 1699 | UINT32 TPMA_NV_AUTHWRITE : 1; |
| 1700 | UINT32 TPMA_NV_POLICYWRITE : 1; |
| 1701 | UINT32 TPMA_NV_COUNTER : 1; |
| 1702 | UINT32 TPMA_NV_BITS : 1; |
| 1703 | UINT32 TPMA_NV_EXTEND : 1; |
| 1704 | UINT32 reserved7_9 : 3; |
| 1705 | UINT32 TPMA_NV_POLICY_DELETE : 1; |
| 1706 | UINT32 TPMA_NV_WRITELOCKED : 1; |
| 1707 | UINT32 TPMA_NV_WRITEALL : 1; |
| 1708 | UINT32 TPMA_NV_WRITEDEFINE : 1; |
| 1709 | UINT32 TPMA_NV_WRITE_STCLEAR : 1; |
| 1710 | UINT32 TPMA_NV_GLOBALLOCK : 1; |
| 1711 | UINT32 TPMA_NV_PPREAD : 1; |
| 1712 | UINT32 TPMA_NV_OWNERREAD : 1; |
| 1713 | UINT32 TPMA_NV_AUTHREAD : 1; |
| 1714 | UINT32 TPMA_NV_POLICYREAD : 1; |
| 1715 | UINT32 reserved20_24 : 5; |
| 1716 | UINT32 TPMA_NV_NO_DA : 1; |
| 1717 | UINT32 TPMA_NV_ORDERLY : 1; |
| 1718 | UINT32 TPMA_NV_CLEAR_STCLEAR : 1; |
| 1719 | UINT32 TPMA_NV_READLOCKED : 1; |
| 1720 | UINT32 TPMA_NV_WRITTEN : 1; |
| 1721 | UINT32 TPMA_NV_PLATFORMCREATE : 1; |
| 1722 | UINT32 TPMA_NV_READ_STCLEAR : 1; |
| 1723 | } TPMA_NV; |
| 1724 | |
| 1725 | // Table 196 - TPMS_NV_PUBLIC Structure |
| 1726 | typedef struct { |
| 1727 | TPMI_RH_NV_INDEX nvIndex; |
| 1728 | TPMI_ALG_HASH nameAlg; |
| 1729 | TPMA_NV attributes; |
| 1730 | TPM2B_DIGEST authPolicy; |
| 1731 | UINT16 dataSize; |
| 1732 | } TPMS_NV_PUBLIC; |
| 1733 | |
| 1734 | // Table 197 - TPM2B_NV_PUBLIC Structure |
| 1735 | typedef struct { |
| 1736 | UINT16 size; |
| 1737 | TPMS_NV_PUBLIC nvPublic; |
| 1738 | } TPM2B_NV_PUBLIC; |
| 1739 | |
| 1740 | // 14 Context Data |
| 1741 | |
| 1742 | // Table 198 - TPM2B_CONTEXT_SENSITIVE Structure |
| 1743 | typedef struct { |
| 1744 | UINT16 size; |
| 1745 | BYTE buffer[MAX_CONTEXT_SIZE]; |
| 1746 | } TPM2B_CONTEXT_SENSITIVE; |
| 1747 | |
| 1748 | // Table 199 - TPMS_CONTEXT_DATA Structure |
| 1749 | typedef struct { |
| 1750 | TPM2B_DIGEST integrity; |
| 1751 | TPM2B_CONTEXT_SENSITIVE encrypted; |
| 1752 | } TPMS_CONTEXT_DATA; |
| 1753 | |
| 1754 | // Table 200 - TPM2B_CONTEXT_DATA Structure |
| 1755 | typedef struct { |
| 1756 | UINT16 size; |
| 1757 | BYTE buffer[sizeof(TPMS_CONTEXT_DATA)]; |
| 1758 | } TPM2B_CONTEXT_DATA; |
| 1759 | |
| 1760 | // Table 201 - TPMS_CONTEXT Structure |
| 1761 | typedef struct { |
| 1762 | UINT64 sequence; |
| 1763 | TPMI_DH_CONTEXT savedHandle; |
| 1764 | TPMI_RH_HIERARCHY hierarchy; |
| 1765 | TPM2B_CONTEXT_DATA contextBlob; |
| 1766 | } TPMS_CONTEXT; |
| 1767 | |
| 1768 | // 15 Creation Data |
| 1769 | |
| 1770 | // Table 203 - TPMS_CREATION_DATA Structure |
| 1771 | typedef struct { |
| 1772 | TPML_PCR_SELECTION pcrSelect; |
| 1773 | TPM2B_DIGEST pcrDigest; |
| 1774 | TPMA_LOCALITY locality; |
| 1775 | TPM_ALG_ID parentNameAlg; |
| 1776 | TPM2B_NAME parentName; |
| 1777 | TPM2B_NAME parentQualifiedName; |
| 1778 | TPM2B_DATA outsideInfo; |
| 1779 | } TPMS_CREATION_DATA; |
| 1780 | |
| 1781 | // Table 204 - TPM2B_CREATION_DATA Structure |
| 1782 | typedef struct { |
| 1783 | UINT16 size; |
| 1784 | TPMS_CREATION_DATA creationData; |
| 1785 | } TPM2B_CREATION_DATA; |
| 1786 | |
| 1787 | |
| 1788 | // |
| 1789 | // Command Header |
| 1790 | // |
| 1791 | typedef struct { |
| 1792 | TPM_ST tag; |
| 1793 | UINT32 paramSize; |
| 1794 | TPM_CC commandCode; |
| 1795 | } TPM2_COMMAND_HEADER; |
| 1796 | |
| 1797 | typedef struct { |
| 1798 | TPM_ST tag; |
| 1799 | UINT32 paramSize; |
| 1800 | TPM_RC responseCode; |
| 1801 | } TPM2_RESPONSE_HEADER; |
| 1802 | |
| 1803 | #pragma pack () |
| 1804 | |
| 1805 | // |
| 1806 | // TCG Algorithm Registry |
| 1807 | // |
| 1808 | #define HASH_ALG_SHA1 0x00000001 |
| 1809 | #define HASH_ALG_SHA256 0x00000002 |
| 1810 | #define HASH_ALG_SHA384 0x00000004 |
| 1811 | #define HASH_ALG_SHA512 0x00000008 |
| 1812 | #define HASH_ALG_SM3_256 0x00000010 |
| 1813 | |
| 1814 | #endif |