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