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