1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /***********************************************************************;
3  * Copyright (c) 2015 - 2018 Intel Corporation
4  * All rights reserved.
5  ***********************************************************************/
6 
7 #ifndef TSS2_TPMS_TYPES_H
8 #define TSS2_TPMS_TYPES_H
9 
10 #include "tss2_common.h"
11 
12 #ifndef TSS2_API_VERSION_1_2_1_108
13 #error Version mismatch among TSS2 header files.
14 #endif  /* TSS2_API_VERSION_1_2_1_108 */
15 
16 #include <stdint.h>
17 
18 #define TPM2_MAX_COMMAND_SIZE  4096 /* maximum size of a command */
19 #define TPM2_MAX_RESPONSE_SIZE 4096 /* maximum size of a response */
20 
21 /* TPM constants for buffer sizes */
22 #define TPM2_NUM_PCR_BANKS      16
23 #define TPM2_MAX_DIGEST_BUFFER  1024
24 #define TPM2_MAX_NV_BUFFER_SIZE 2048
25 #define TPM2_MAX_PCRS           32
26 #define TPM2_MAX_ALG_LIST_SIZE  128
27 #define TPM2_MAX_CAP_CC         256
28 #define TPM2_MAX_CAP_BUFFER     1024
29 #define TPM2_MAX_CONTEXT_SIZE   5120
30 
31 /* Hash algorithm sizes */
32 #define TPM2_SHA_DIGEST_SIZE     20
33 #define TPM2_SHA1_DIGEST_SIZE    20
34 #define TPM2_SHA256_DIGEST_SIZE  32
35 #define TPM2_SHA384_DIGEST_SIZE  48
36 #define TPM2_SHA512_DIGEST_SIZE  64
37 #define TPM2_SM3_256_DIGEST_SIZE 32
38 
39 /* Encryption algorithm sizes */
40 #define TPM2_MAX_SYM_BLOCK_SIZE 16
41 #define TPM2_MAX_SYM_DATA       256
42 #define TPM2_MAX_ECC_KEY_BYTES  128
43 #define TPM2_MAX_SYM_KEY_BYTES  32
44 #define TPM2_MAX_RSA_KEY_BYTES  512
45 
46 /* Capability buffer sizes*/
47 #define TPM2_LABEL_MAX_BUFFER 32
48 #define TPM2_PCR_SELECT_MAX      ((TPM2_MAX_PCRS + 7) / 8)
49 #define TPM2_MAX_CAP_HANDLES     ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
50                                   sizeof(UINT32)) / sizeof(TPM2_HANDLE))
51 #define TPM2_MAX_CAP_ALGS        ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
52                                   sizeof(UINT32)) / sizeof(TPMS_ALG_PROPERTY))
53 #define TPM2_MAX_TPM_PROPERTIES  ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
54                                   sizeof(UINT32)) / sizeof(TPMS_TAGGED_PROPERTY))
55 #define TPM2_MAX_PCR_PROPERTIES  ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
56                                   sizeof(UINT32)) / sizeof(TPMS_TAGGED_PCR_SELECT))
57 #define TPM2_MAX_ECC_CURVES      ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
58                                   sizeof(UINT32)) / sizeof(TPM2_ECC_CURVE))
59 #define TPM2_MAX_TAGGED_POLICIES ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
60                                   sizeof(UINT32)) / sizeof(TPMS_TAGGED_POLICY))
61 #define TPM2_MAX_ACT_DATA        ((TPM2_MAX_CAP_BUFFER - sizeof(TPM2_CAP) - \
62                                   sizeof(UINT32)) / sizeof(TPMS_ACT_DATA))
63 #define TPM2_PRIVATE_VENDOR_SPECIFIC_BYTES ((TPM2_MAX_RSA_KEY_BYTES / 2) * (3 + 2))
64 
65 /* Vendor Specific Defines */
66 #define TPM2_MAX_PTT_PROPERTIES (TPM2_MAX_CAP_BUFFER / sizeof(UINT32))
67 
68 /* Attached Component Capabilities */
69 #define TPM2_MAX_AC_CAPABILITIES (TPM2_MAX_CAP_BUFFER / sizeof(TPMS_AC_OUTPUT))
70 
71 /* From TCG Algorithm Registry: Definition of TPM2_ALG_ID Constants */
72 typedef UINT16 TPM2_ALG_ID;
73 
74 #define TPM2_ALG_ERROR               ((TPM2_ALG_ID) 0x0000)
75 #define TPM2_ALG_RSA                 ((TPM2_ALG_ID) 0x0001)
76 #define TPM2_ALG_TDES                ((TPM2_ALG_ID) 0x0003)
77 #define TPM2_ALG_SHA                 ((TPM2_ALG_ID) 0x0004)
78 #define TPM2_ALG_SHA1                ((TPM2_ALG_ID) 0x0004)
79 #define TPM2_ALG_HMAC                ((TPM2_ALG_ID) 0x0005)
80 #define TPM2_ALG_AES                 ((TPM2_ALG_ID) 0x0006)
81 #define TPM2_ALG_MGF1                ((TPM2_ALG_ID) 0x0007)
82 #define TPM2_ALG_KEYEDHASH           ((TPM2_ALG_ID) 0x0008)
83 #define TPM2_ALG_XOR                 ((TPM2_ALG_ID) 0x000A)
84 #define TPM2_ALG_SHA256              ((TPM2_ALG_ID) 0x000B)
85 #define TPM2_ALG_SHA384              ((TPM2_ALG_ID) 0x000C)
86 #define TPM2_ALG_SHA512              ((TPM2_ALG_ID) 0x000D)
87 #define TPM2_ALG_NULL                ((TPM2_ALG_ID) 0x0010)
88 #define TPM2_ALG_SM3_256             ((TPM2_ALG_ID) 0x0012)
89 #define TPM2_ALG_SM4                 ((TPM2_ALG_ID) 0x0013)
90 #define TPM2_ALG_RSASSA              ((TPM2_ALG_ID) 0x0014)
91 #define TPM2_ALG_RSAES               ((TPM2_ALG_ID) 0x0015)
92 #define TPM2_ALG_RSAPSS              ((TPM2_ALG_ID) 0x0016)
93 #define TPM2_ALG_OAEP                ((TPM2_ALG_ID) 0x0017)
94 #define TPM2_ALG_ECDSA               ((TPM2_ALG_ID) 0x0018)
95 #define TPM2_ALG_ECDH                ((TPM2_ALG_ID) 0x0019)
96 #define TPM2_ALG_ECDAA               ((TPM2_ALG_ID) 0x001A)
97 #define TPM2_ALG_SM2                 ((TPM2_ALG_ID) 0x001B)
98 #define TPM2_ALG_ECSCHNORR           ((TPM2_ALG_ID) 0x001C)
99 #define TPM2_ALG_ECMQV               ((TPM2_ALG_ID) 0x001D)
100 #define TPM2_ALG_KDF1_SP800_56A      ((TPM2_ALG_ID) 0x0020)
101 #define TPM2_ALG_KDF2                ((TPM2_ALG_ID) 0x0021)
102 #define TPM2_ALG_KDF1_SP800_108      ((TPM2_ALG_ID) 0x0022)
103 #define TPM2_ALG_ECC                 ((TPM2_ALG_ID) 0x0023)
104 #define TPM2_ALG_SYMCIPHER           ((TPM2_ALG_ID) 0x0025)
105 #define TPM2_ALG_CAMELLIA            ((TPM2_ALG_ID) 0x0026)
106 #define TPM2_ALG_CMAC                ((TPM2_ALG_ID) 0x003F)
107 #define TPM2_ALG_CTR                 ((TPM2_ALG_ID) 0x0040)
108 #define TPM2_ALG_SHA3_256            ((TPM2_ALG_ID) 0x0027)
109 #define TPM2_ALG_SHA3_384            ((TPM2_ALG_ID) 0x0028)
110 #define TPM2_ALG_SHA3_512            ((TPM2_ALG_ID) 0x0029)
111 #define TPM2_ALG_OFB                 ((TPM2_ALG_ID) 0x0041)
112 #define TPM2_ALG_CBC                 ((TPM2_ALG_ID) 0x0042)
113 #define TPM2_ALG_CFB                 ((TPM2_ALG_ID) 0x0043)
114 #define TPM2_ALG_ECB                 ((TPM2_ALG_ID) 0x0044)
115 #define TPM2_ALG_FIRST               ((TPM2_ALG_ID) 0x0001)
116 #define TPM2_ALG_LAST                ((TPM2_ALG_ID) 0x0044)
117 
118 /* From TCG Algorithm Registry: Definition of TPM2_ECC_CURVE Constants */
119 typedef UINT16                TPM2_ECC_CURVE;
120 #define TPM2_ECC_NONE         ((TPM2_ECC_CURVE) 0x0000)
121 #define TPM2_ECC_NIST_P192    ((TPM2_ECC_CURVE) 0x0001)
122 #define TPM2_ECC_NIST_P224    ((TPM2_ECC_CURVE) 0x0002)
123 #define TPM2_ECC_NIST_P256    ((TPM2_ECC_CURVE) 0x0003)
124 #define TPM2_ECC_NIST_P384    ((TPM2_ECC_CURVE) 0x0004)
125 #define TPM2_ECC_NIST_P521    ((TPM2_ECC_CURVE) 0x0005)
126 #define TPM2_ECC_BN_P256      ((TPM2_ECC_CURVE) 0x0010)
127 #define TPM2_ECC_BN_P638      ((TPM2_ECC_CURVE) 0x0011)
128 #define TPM2_ECC_SM2_P256     ((TPM2_ECC_CURVE) 0x0020)
129 
130 /* From TPM 2.0 Part 2: Definition of TPM2_CC Constants */
131 typedef UINT32                                TPM2_CC;
132 #define TPM2_CC_NV_UndefineSpaceSpecial       ((TPM2_CC) 0x0000011f)
133 #define TPM2_CC_FIRST TPM2_CC_NV_UndefineSpaceSpecial
134 #define TPM2_CC_EvictControl                  ((TPM2_CC) 0x00000120)
135 #define TPM2_CC_HierarchyControl              ((TPM2_CC) 0x00000121)
136 #define TPM2_CC_NV_UndefineSpace              ((TPM2_CC) 0x00000122)
137 #define TPM2_CC_ChangeEPS                     ((TPM2_CC) 0x00000124)
138 #define TPM2_CC_ChangePPS                     ((TPM2_CC) 0x00000125)
139 #define TPM2_CC_Clear                         ((TPM2_CC) 0x00000126)
140 #define TPM2_CC_ClearControl                  ((TPM2_CC) 0x00000127)
141 #define TPM2_CC_ClockSet                      ((TPM2_CC) 0x00000128)
142 #define TPM2_CC_HierarchyChangeAuth           ((TPM2_CC) 0x00000129)
143 #define TPM2_CC_NV_DefineSpace                ((TPM2_CC) 0x0000012a)
144 #define TPM2_CC_PCR_Allocate                  ((TPM2_CC) 0x0000012b)
145 #define TPM2_CC_PCR_SetAuthPolicy             ((TPM2_CC) 0x0000012c)
146 #define TPM2_CC_PP_Commands                   ((TPM2_CC) 0x0000012d)
147 #define TPM2_CC_SetPrimaryPolicy              ((TPM2_CC) 0x0000012e)
148 #define TPM2_CC_FieldUpgradeStart             ((TPM2_CC) 0x0000012f)
149 #define TPM2_CC_ClockRateAdjust               ((TPM2_CC) 0x00000130)
150 #define TPM2_CC_CreatePrimary                 ((TPM2_CC) 0x00000131)
151 #define TPM2_CC_NV_GlobalWriteLock            ((TPM2_CC) 0x00000132)
152 #define TPM2_CC_GetCommandAuditDigest         ((TPM2_CC) 0x00000133)
153 #define TPM2_CC_NV_Increment                  ((TPM2_CC) 0x00000134)
154 #define TPM2_CC_NV_SetBits                    ((TPM2_CC) 0x00000135)
155 #define TPM2_CC_NV_Extend                     ((TPM2_CC) 0x00000136)
156 #define TPM2_CC_NV_Write                      ((TPM2_CC) 0x00000137)
157 #define TPM2_CC_NV_WriteLock                  ((TPM2_CC) 0x00000138)
158 #define TPM2_CC_DictionaryAttackLockReset     ((TPM2_CC) 0x00000139)
159 #define TPM2_CC_DictionaryAttackParameters    ((TPM2_CC) 0x0000013a)
160 #define TPM2_CC_NV_ChangeAuth                 ((TPM2_CC) 0x0000013b)
161 #define TPM2_CC_PCR_Event                     ((TPM2_CC) 0x0000013c)
162 #define TPM2_CC_PCR_Reset                     ((TPM2_CC) 0x0000013d)
163 #define TPM2_CC_SequenceComplete              ((TPM2_CC) 0x0000013e)
164 #define TPM2_CC_SetAlgorithmSet               ((TPM2_CC) 0x0000013f)
165 #define TPM2_CC_SetCommandCodeAuditStatus     ((TPM2_CC) 0x00000140)
166 #define TPM2_CC_FieldUpgradeData              ((TPM2_CC) 0x00000141)
167 #define TPM2_CC_IncrementalSelfTest           ((TPM2_CC) 0x00000142)
168 #define TPM2_CC_SelfTest                      ((TPM2_CC) 0x00000143)
169 #define TPM2_CC_Startup                       ((TPM2_CC) 0x00000144)
170 #define TPM2_CC_Shutdown                      ((TPM2_CC) 0x00000145)
171 #define TPM2_CC_StirRandom                    ((TPM2_CC) 0x00000146)
172 #define TPM2_CC_ActivateCredential            ((TPM2_CC) 0x00000147)
173 #define TPM2_CC_Certify                       ((TPM2_CC) 0x00000148)
174 #define TPM2_CC_PolicyNV                      ((TPM2_CC) 0x00000149)
175 #define TPM2_CC_CertifyCreation               ((TPM2_CC) 0x0000014a)
176 #define TPM2_CC_Duplicate                     ((TPM2_CC) 0x0000014b)
177 #define TPM2_CC_GetTime                       ((TPM2_CC) 0x0000014c)
178 #define TPM2_CC_GetSessionAuditDigest         ((TPM2_CC) 0x0000014d)
179 #define TPM2_CC_NV_Read                       ((TPM2_CC) 0x0000014e)
180 #define TPM2_CC_NV_ReadLock                   ((TPM2_CC) 0x0000014f)
181 #define TPM2_CC_ObjectChangeAuth              ((TPM2_CC) 0x00000150)
182 #define TPM2_CC_PolicySecret                  ((TPM2_CC) 0x00000151)
183 #define TPM2_CC_Rewrap                        ((TPM2_CC) 0x00000152)
184 #define TPM2_CC_Create                        ((TPM2_CC) 0x00000153)
185 #define TPM2_CC_ECDH_ZGen                     ((TPM2_CC) 0x00000154)
186 #define TPM2_CC_HMAC                          ((TPM2_CC) 0x00000155)
187 #define TPM2_CC_Import                        ((TPM2_CC) 0x00000156)
188 #define TPM2_CC_Load                          ((TPM2_CC) 0x00000157)
189 #define TPM2_CC_Quote                         ((TPM2_CC) 0x00000158)
190 #define TPM2_CC_RSA_Decrypt                   ((TPM2_CC) 0x00000159)
191 #define TPM2_CC_HMAC_Start                    ((TPM2_CC) 0x0000015b)
192 #define TPM2_CC_SequenceUpdate                ((TPM2_CC) 0x0000015c)
193 #define TPM2_CC_Sign                          ((TPM2_CC) 0x0000015d)
194 #define TPM2_CC_Unseal                        ((TPM2_CC) 0x0000015e)
195 #define TPM2_CC_PolicySigned                  ((TPM2_CC) 0x00000160)
196 #define TPM2_CC_ContextLoad                   ((TPM2_CC) 0x00000161)
197 #define TPM2_CC_ContextSave                   ((TPM2_CC) 0x00000162)
198 #define TPM2_CC_ECDH_KeyGen                   ((TPM2_CC) 0x00000163)
199 #define TPM2_CC_EncryptDecrypt                ((TPM2_CC) 0x00000164)
200 #define TPM2_CC_FlushContext                  ((TPM2_CC) 0x00000165)
201 #define TPM2_CC_LoadExternal                  ((TPM2_CC) 0x00000167)
202 #define TPM2_CC_MakeCredential                ((TPM2_CC) 0x00000168)
203 #define TPM2_CC_NV_ReadPublic                 ((TPM2_CC) 0x00000169)
204 #define TPM2_CC_PolicyAuthorize               ((TPM2_CC) 0x0000016a)
205 #define TPM2_CC_PolicyAuthValue               ((TPM2_CC) 0x0000016b)
206 #define TPM2_CC_PolicyCommandCode             ((TPM2_CC) 0x0000016c)
207 #define TPM2_CC_PolicyCounterTimer            ((TPM2_CC) 0x0000016d)
208 #define TPM2_CC_PolicyCpHash                  ((TPM2_CC) 0x0000016e)
209 #define TPM2_CC_PolicyLocality                ((TPM2_CC) 0x0000016f)
210 #define TPM2_CC_PolicyNameHash                ((TPM2_CC) 0x00000170)
211 #define TPM2_CC_PolicyOR                      ((TPM2_CC) 0x00000171)
212 #define TPM2_CC_PolicyTicket                  ((TPM2_CC) 0x00000172)
213 #define TPM2_CC_ReadPublic                    ((TPM2_CC) 0x00000173)
214 #define TPM2_CC_RSA_Encrypt                   ((TPM2_CC) 0x00000174)
215 #define TPM2_CC_StartAuthSession              ((TPM2_CC) 0x00000176)
216 #define TPM2_CC_VerifySignature               ((TPM2_CC) 0x00000177)
217 #define TPM2_CC_ECC_Parameters                ((TPM2_CC) 0x00000178)
218 #define TPM2_CC_FirmwareRead                  ((TPM2_CC) 0x00000179)
219 #define TPM2_CC_GetCapability                 ((TPM2_CC) 0x0000017a)
220 #define TPM2_CC_GetRandom                     ((TPM2_CC) 0x0000017b)
221 #define TPM2_CC_GetTestResult                 ((TPM2_CC) 0x0000017c)
222 #define TPM2_CC_Hash                          ((TPM2_CC) 0x0000017d)
223 #define TPM2_CC_PCR_Read                      ((TPM2_CC) 0x0000017e)
224 #define TPM2_CC_PolicyPCR                     ((TPM2_CC) 0x0000017f)
225 #define TPM2_CC_PolicyRestart                 ((TPM2_CC) 0x00000180)
226 #define TPM2_CC_ReadClock                     ((TPM2_CC) 0x00000181)
227 #define TPM2_CC_PCR_Extend                    ((TPM2_CC) 0x00000182)
228 #define TPM2_CC_PCR_SetAuthValue              ((TPM2_CC) 0x00000183)
229 #define TPM2_CC_NV_Certify                    ((TPM2_CC) 0x00000184)
230 #define TPM2_CC_EventSequenceComplete         ((TPM2_CC) 0x00000185)
231 #define TPM2_CC_HashSequenceStart             ((TPM2_CC) 0x00000186)
232 #define TPM2_CC_PolicyPhysicalPresence        ((TPM2_CC) 0x00000187)
233 #define TPM2_CC_PolicyDuplicationSelect       ((TPM2_CC) 0x00000188)
234 #define TPM2_CC_PolicyGetDigest               ((TPM2_CC) 0x00000189)
235 #define TPM2_CC_TestParms                     ((TPM2_CC) 0x0000018a)
236 #define TPM2_CC_Commit                        ((TPM2_CC) 0x0000018b)
237 #define TPM2_CC_PolicyPassword                ((TPM2_CC) 0x0000018c)
238 #define TPM2_CC_ZGen_2Phase                   ((TPM2_CC) 0x0000018d)
239 #define TPM2_CC_EC_Ephemeral                  ((TPM2_CC) 0x0000018e)
240 #define TPM2_CC_PolicyNvWritten               ((TPM2_CC) 0x0000018f)
241 #define TPM2_CC_PolicyTemplate                ((TPM2_CC) 0x00000190)
242 #define TPM2_CC_CreateLoaded                  ((TPM2_CC) 0x00000191)
243 #define TPM2_CC_PolicyAuthorizeNV             ((TPM2_CC) 0x00000192)
244 #define TPM2_CC_EncryptDecrypt2               ((TPM2_CC) 0x00000193)
245 #define TPM2_CC_AC_GetCapability              ((TPM2_CC) 0x00000194)
246 #define TPM2_CC_AC_Send                       ((TPM2_CC) 0x00000195)
247 #define TPM2_CC_Policy_AC_SendSelect          ((TPM2_CC) 0x00000196)
248 #define TPM2_CC_CertifyX509                   ((TPM2_CC) 0x00000197)
249 #define TPM2_CC_ACT_SetTimeout                ((TPM2_CC) 0x00000198)
250 #define TPM2_CC_LAST                          ((TPM2_CC) 0x00000198)
251 #define TPM2_CC_Vendor_TCG_Test               ((TPM2_CC) 0x20000000)
252 
253 /* Definition of Types for Documentation Clarity */
254 typedef UINT32 TPM2_ALGORITHM_ID;       /* this is the 1.2 compatible form of the TPM2_ALG_ID */
255 typedef UINT32 TPM2_MODIFIER_INDICATOR;
256 typedef UINT32 TPM2_AUTHORIZATION_SIZE; /* the authorizationSize parameter in a command */
257 typedef UINT32 TPM2_PARAMETER_SIZE;     /* the parameterSize parameter in a command */
258 typedef UINT16 TPM2_KEY_SIZE;           /* a key size in octets */
259 typedef UINT16 TPM2_KEY_BITS;           /* a key size in bits */
260 
261 /* Definition of UINT32 TPM2_SPEC Constants <> */
262 typedef UINT32 TPM2_SPEC;
263 #define TPM2_SPEC_FAMILY      ((TPM2_SPEC) 0x322E3000) /* ASCII 2.0 with null terminator */
264 #define TPM2_SPEC_LEVEL       ((TPM2_SPEC) 00)         /* the level number for the specification */
265 #define TPM2_SPEC_VERSION     ((TPM2_SPEC) 126)        /* the version number of the spec 001.26 * 100 */
266 #define TPM2_SPEC_YEAR        ((TPM2_SPEC) 2015)       /* the year of the version */
267 #define TPM2_SPEC_DAY_OF_YEAR ((TPM2_SPEC) 233)        /* the day of the year August 21 2015 */
268 
269 /* Definition of UINT32 TPM2_GENERATED Constants <O> */
270 typedef UINT32 TPM2_GENERATED;
271 #define TPM2_GENERATED_VALUE   ((TPM2_GENERATED) (0xff544347)) /* 0xFF TCG FF 54 43 4716 */
272 
273 /* Definition of UINT32 TPM2_RC Constants Actions <OUT> */
274 typedef UINT32 TPM2_RC;
275 #define TPM2_RC_SUCCESS            ((TPM2_RC)                 0x000)
276 #define TPM2_RC_BAD_TAG            ((TPM2_RC)                 0x01E) /* defined for compatibility with TPM 1.2 */
277 #define TPM2_RC_VER1               ((TPM2_RC)                 0x100) /* set for all format 0 response codes */
278 #define TPM2_RC_INITIALIZE         ((TPM2_RC) (TPM2_RC_VER1 + 0x000)) /* TPM not initialized by TPM2_Startup or already initialized */
279 #define TPM2_RC_FAILURE            ((TPM2_RC) (TPM2_RC_VER1 + 0x001)) /* commands not being accepted because of a TPM failure. NOTE This may be returned by TPM2_GetTestResult as the testResult parameter. */
280 #define TPM2_RC_SEQUENCE           ((TPM2_RC) (TPM2_RC_VER1 + 0x003)) /* improper use of a sequence handle */
281 #define TPM2_RC_PRIVATE            ((TPM2_RC) (TPM2_RC_VER1 + 0x00B)) /* not currently used */
282 #define TPM2_RC_HMAC               ((TPM2_RC) (TPM2_RC_VER1 + 0x019)) /* not currently used */
283 #define TPM2_RC_DISABLED           ((TPM2_RC) (TPM2_RC_VER1 + 0x020)) /* the command is disabled */
284 #define TPM2_RC_EXCLUSIVE          ((TPM2_RC) (TPM2_RC_VER1 + 0x021)) /* command failed because audit sequence required exclusivity */
285 #define TPM2_RC_AUTH_TYPE          ((TPM2_RC) (TPM2_RC_VER1 + 0x024)) /* authorization handle is not correct for command */
286 #define TPM2_RC_AUTH_MISSING       ((TPM2_RC) (TPM2_RC_VER1 + 0x025)) /* command requires an authorization session for handle and it is not present. */
287 #define TPM2_RC_POLICY             ((TPM2_RC) (TPM2_RC_VER1 + 0x026)) /* policy failure in math operation or an invalid authPolicy value */
288 #define TPM2_RC_PCR                ((TPM2_RC) (TPM2_RC_VER1 + 0x027)) /* PCR check fail */
289 #define TPM2_RC_PCR_CHANGED        ((TPM2_RC) (TPM2_RC_VER1 + 0x028)) /* PCR have changed since checked. */
290 #define TPM2_RC_UPGRADE            ((TPM2_RC) (TPM2_RC_VER1 + 0x02D)) /* For all commands, other than TPM2_FieldUpgradeData, this code indicates that the TPM is in field upgrade mode. For TPM2_FieldUpgradeData, this code indicates that the TPM is not in field upgrade mode */
291 #define TPM2_RC_TOO_MANY_CONTEXTS  ((TPM2_RC) (TPM2_RC_VER1 + 0x02E)) /* context ID counter is at maximum. */
292 #define TPM2_RC_AUTH_UNAVAILABLE   ((TPM2_RC) (TPM2_RC_VER1 + 0x02F)) /* authValue or authPolicy is not available for selected entity. */
293 #define TPM2_RC_REBOOT             ((TPM2_RC) (TPM2_RC_VER1 + 0x030)) /* a _TPM_Init and StartupCLEAR is required before the TPM can resume operation. */
294 #define TPM2_RC_UNBALANCED         ((TPM2_RC) (TPM2_RC_VER1 + 0x031)) /* the protection algorithms hash and symmetric are not reasonably balanced. The digest size of the hash must be larger than the key size of the symmetric algorithm. */
295 #define TPM2_RC_COMMAND_SIZE       ((TPM2_RC) (TPM2_RC_VER1 + 0x042)) /* command commandSize value is inconsistent with contents of the command buffer. Either the size is not the same as the octets loaded by the hardware interface layer or the value is not large enough to hold a command header */
296 #define TPM2_RC_COMMAND_CODE       ((TPM2_RC) (TPM2_RC_VER1 + 0x043)) /* command code not supported */
297 #define TPM2_RC_AUTHSIZE           ((TPM2_RC) (TPM2_RC_VER1 + 0x044)) /* the value of authorizationSize is out of range or the number of octets in the Authorization Area is greater than required */
298 #define TPM2_RC_AUTH_CONTEXT       ((TPM2_RC) (TPM2_RC_VER1 + 0x045)) /* use of an authorization session with a context command or another command that cannot have an authorization session. */
299 #define TPM2_RC_NV_RANGE           ((TPM2_RC) (TPM2_RC_VER1 + 0x046)) /* NV offset+size is out of range. */
300 #define TPM2_RC_NV_SIZE            ((TPM2_RC) (TPM2_RC_VER1 + 0x047)) /* Requested allocation size is larger than allowed. */
301 #define TPM2_RC_NV_LOCKED          ((TPM2_RC) (TPM2_RC_VER1 + 0x048)) /* NV access locked. */
302 #define TPM2_RC_NV_AUTHORIZATION   ((TPM2_RC) (TPM2_RC_VER1 + 0x049)) /* NV access authorization fails in command actions this failure does not affect lockout.action */
303 #define TPM2_RC_NV_UNINITIALIZED   ((TPM2_RC) (TPM2_RC_VER1 + 0x04A)) /* an NV Index is used before being initialized or the state saved by TPM2_ShutdownSTATE could not be restored */
304 #define TPM2_RC_NV_SPACE           ((TPM2_RC) (TPM2_RC_VER1 + 0x04B)) /* insufficient space for NV allocation */
305 #define TPM2_RC_NV_DEFINED         ((TPM2_RC) (TPM2_RC_VER1 + 0x04C)) /* NV Index or persistent object already defined */
306 #define TPM2_RC_BAD_CONTEXT        ((TPM2_RC) (TPM2_RC_VER1 + 0x050)) /* context in TPM2_ContextLoad is not valid */
307 #define TPM2_RC_CPHASH             ((TPM2_RC) (TPM2_RC_VER1 + 0x051)) /* cpHash value already set or not correct for use */
308 #define TPM2_RC_PARENT             ((TPM2_RC) (TPM2_RC_VER1 + 0x052)) /* handle for parent is not a valid parent */
309 #define TPM2_RC_NEEDS_TEST         ((TPM2_RC) (TPM2_RC_VER1 + 0x053)) /* some function needs testing. */
310 #define TPM2_RC_NO_RESULT          ((TPM2_RC) (TPM2_RC_VER1 + 0x054)) /* returned when an internal function cannot process a request due to an unspecified problem. This code is usually related to invalid parameters that are not properly filtered by the input unmarshaling code. */
311 #define TPM2_RC_SENSITIVE          ((TPM2_RC) (TPM2_RC_VER1 + 0x055)) /* the sensitive area did not unmarshal correctly after decryption. This code is used in lieu of the other unmarshaling errors so that an attacker cannot determine where the unmarshaling error occurred */
312 #define TPM2_RC_MAX_FM0            ((TPM2_RC) (TPM2_RC_VER1 + 0x07F)) /* largest version 1 code that is not a warning */
313 #define TPM2_RC_FMT1                              ((TPM2_RC)  0x080)  /* This bit is SET in all format 1 response codes. The codes in this group may have a value added to them to indicate the handle session or parameter to which they apply. */
314 #define TPM2_RC_ASYMMETRIC         ((TPM2_RC) (TPM2_RC_FMT1 + 0x001)) /* asymmetric algorithm not supported or not correct */
315 #define TPM2_RC_ATTRIBUTES         ((TPM2_RC) (TPM2_RC_FMT1 + 0x002)) /* inconsistent attributes */
316 #define TPM2_RC_HASH               ((TPM2_RC) (TPM2_RC_FMT1 + 0x003)) /* hash algorithm not supported or not appropriate */
317 #define TPM2_RC_VALUE              ((TPM2_RC) (TPM2_RC_FMT1 + 0x004)) /* value is out of range or is not correct for the context */
318 #define TPM2_RC_HIERARCHY          ((TPM2_RC) (TPM2_RC_FMT1 + 0x005)) /* hierarchy is not enabled or is not correct for the use */
319 #define TPM2_RC_KEY_SIZE           ((TPM2_RC) (TPM2_RC_FMT1 + 0x007)) /* key size is not supported */
320 #define TPM2_RC_MGF                ((TPM2_RC) (TPM2_RC_FMT1 + 0x008)) /* mask generation function not supported */
321 #define TPM2_RC_MODE               ((TPM2_RC) (TPM2_RC_FMT1 + 0x009)) /* mode of operation not supported */
322 #define TPM2_RC_TYPE               ((TPM2_RC) (TPM2_RC_FMT1 + 0x00A)) /* the type of the value is not appropriate for the use */
323 #define TPM2_RC_HANDLE             ((TPM2_RC) (TPM2_RC_FMT1 + 0x00B)) /* the handle is not correct for the use */
324 #define TPM2_RC_KDF                ((TPM2_RC) (TPM2_RC_FMT1 + 0x00C)) /* unsupported key derivation function or function not appropriate for use */
325 #define TPM2_RC_RANGE              ((TPM2_RC) (TPM2_RC_FMT1 + 0x00D)) /* value was out of allowed range. */
326 #define TPM2_RC_AUTH_FAIL          ((TPM2_RC) (TPM2_RC_FMT1 + 0x00E)) /* the authorization HMAC check failed and DA counter incremented */
327 #define TPM2_RC_NONCE              ((TPM2_RC) (TPM2_RC_FMT1 + 0x00F)) /* invalid nonce size or nonce value mismatch */
328 #define TPM2_RC_PP                 ((TPM2_RC) (TPM2_RC_FMT1 + 0x010)) /* authorization requires assertion of PP */
329 #define TPM2_RC_SCHEME             ((TPM2_RC) (TPM2_RC_FMT1 + 0x012)) /* unsupported or incompatible scheme */
330 #define TPM2_RC_SIZE               ((TPM2_RC) (TPM2_RC_FMT1 + 0x015)) /* structure is the wrong size */
331 #define TPM2_RC_SYMMETRIC          ((TPM2_RC) (TPM2_RC_FMT1 + 0x016)) /* unsupported symmetric algorithm or key size or not appropriate for instance */
332 #define TPM2_RC_TAG                ((TPM2_RC) (TPM2_RC_FMT1 + 0x017)) /* incorrect structure tag */
333 #define TPM2_RC_SELECTOR           ((TPM2_RC) (TPM2_RC_FMT1 + 0x018)) /* union selector is incorrect */
334 #define TPM2_RC_INSUFFICIENT       ((TPM2_RC) (TPM2_RC_FMT1 + 0x01A)) /* the TPM was unable to unmarshal a value because there were not enough octets in the input buffer */
335 #define TPM2_RC_SIGNATURE          ((TPM2_RC) (TPM2_RC_FMT1 + 0x01B)) /* the signature is not valid */
336 #define TPM2_RC_KEY                ((TPM2_RC) (TPM2_RC_FMT1 + 0x01C)) /* key fields are not compatible with the selected use */
337 #define TPM2_RC_POLICY_FAIL        ((TPM2_RC) (TPM2_RC_FMT1 + 0x01D)) /* a policy check failed */
338 #define TPM2_RC_INTEGRITY          ((TPM2_RC) (TPM2_RC_FMT1 + 0x01F)) /* integrity check failed */
339 #define TPM2_RC_TICKET             ((TPM2_RC) (TPM2_RC_FMT1 + 0x020)) /* invalid ticket */
340 #define TPM2_RC_RESERVED_BITS      ((TPM2_RC) (TPM2_RC_FMT1 + 0x021)) /* reserved bits not set to zero as required */
341 #define TPM2_RC_BAD_AUTH           ((TPM2_RC) (TPM2_RC_FMT1 + 0x022)) /* authorization failure without DA implications */
342 #define TPM2_RC_EXPIRED            ((TPM2_RC) (TPM2_RC_FMT1 + 0x023)) /* the policy has expired */
343 #define TPM2_RC_POLICY_CC          ((TPM2_RC) (TPM2_RC_FMT1 + 0x024)) /* the commandCode in the policy is not the commandCode of the command or the command code in a policy command references a command that is not implemented */
344 #define TPM2_RC_BINDING            ((TPM2_RC) (TPM2_RC_FMT1 + 0x025)) /* public and sensitive portions of an object are not cryptographically bound */
345 #define TPM2_RC_CURVE              ((TPM2_RC) (TPM2_RC_FMT1 + 0x026)) /* curve not supported */
346 #define TPM2_RC_ECC_POINT          ((TPM2_RC) (TPM2_RC_FMT1 + 0x027)) /* point is not on the required curve. */
347 #define TPM2_RC_WARN                              ((TPM2_RC)  0x900)  /* set for warning response codes */
348 #define TPM2_RC_CONTEXT_GAP        ((TPM2_RC) (TPM2_RC_WARN + 0x001)) /* gap for context ID is too large */
349 #define TPM2_RC_OBJECT_MEMORY      ((TPM2_RC) (TPM2_RC_WARN + 0x002)) /* out of memory for object contexts */
350 #define TPM2_RC_SESSION_MEMORY     ((TPM2_RC) (TPM2_RC_WARN + 0x003)) /* out of memory for session contexts */
351 #define TPM2_RC_MEMORY             ((TPM2_RC) (TPM2_RC_WARN + 0x004)) /* out of shared objectsession memory or need space for internal operations */
352 #define TPM2_RC_SESSION_HANDLES    ((TPM2_RC) (TPM2_RC_WARN + 0x005)) /* out of session handles  a session must be flushed before a new session may be created */
353 #define TPM2_RC_OBJECT_HANDLES     ((TPM2_RC) (TPM2_RC_WARN + 0x006)) /* out of object handles. The handle space for objects is depleted and a reboot is required. NOTE This cannot occur on the reference implementation. NOTE There is no reason why an implementation would implement a design that would deplete handle space. Platform specifications are encouraged to forbid it. */
354 #define TPM2_RC_LOCALITY           ((TPM2_RC) (TPM2_RC_WARN + 0x007)) /* bad locality */
355 #define TPM2_RC_YIELDED            ((TPM2_RC) (TPM2_RC_WARN + 0x008)) /* the TPM has suspended operation on the command forward progress was made and the command may be retried. See TPM 2.0 Part 1 Multitasking. NOTE This cannot occur on the reference implementation. */
356 #define TPM2_RC_CANCELED           ((TPM2_RC) (TPM2_RC_WARN + 0x009)) /* the command was canceled */
357 #define TPM2_RC_TESTING            ((TPM2_RC) (TPM2_RC_WARN + 0x00A)) /* TPM is performing selftests */
358 #define TPM2_RC_REFERENCE_H0       ((TPM2_RC) (TPM2_RC_WARN + 0x010)) /* the 1st handle in the handle area references a transient object or session that is not loaded */
359 #define TPM2_RC_REFERENCE_H1       ((TPM2_RC) (TPM2_RC_WARN + 0x011)) /* the 2nd handle in the handle area references a transient object or session that is not loaded */
360 #define TPM2_RC_REFERENCE_H2       ((TPM2_RC) (TPM2_RC_WARN + 0x012)) /* the 3rd handle in the handle area references a transient object or session that is not loaded */
361 #define TPM2_RC_REFERENCE_H3       ((TPM2_RC) (TPM2_RC_WARN + 0x013)) /* the 4th handle in the handle area references a transient object or session that is not loaded */
362 #define TPM2_RC_REFERENCE_H4       ((TPM2_RC) (TPM2_RC_WARN + 0x014)) /* the 5th handle in the handle area references a transient object or session that is not loaded */
363 #define TPM2_RC_REFERENCE_H5       ((TPM2_RC) (TPM2_RC_WARN + 0x015)) /* the 6th handle in the handle area references a transient object or session that is not loaded */
364 #define TPM2_RC_REFERENCE_H6       ((TPM2_RC) (TPM2_RC_WARN + 0x016)) /* the 7th handle in the handle area references a transient object or session that is not loaded */
365 #define TPM2_RC_REFERENCE_S0       ((TPM2_RC) (TPM2_RC_WARN + 0x018)) /* the 1st authorization session handle references a session that is not loaded */
366 #define TPM2_RC_REFERENCE_S1       ((TPM2_RC) (TPM2_RC_WARN + 0x019)) /* the 2nd authorization session handle references a session that is not loaded */
367 #define TPM2_RC_REFERENCE_S2       ((TPM2_RC) (TPM2_RC_WARN + 0x01A)) /* the 3rd authorization session handle references a session that is not loaded */
368 #define TPM2_RC_REFERENCE_S3       ((TPM2_RC) (TPM2_RC_WARN + 0x01B)) /* the 4th authorization session handle references a session that is not loaded */
369 #define TPM2_RC_REFERENCE_S4       ((TPM2_RC) (TPM2_RC_WARN + 0x01C)) /* the 5th session handle references a session that is not loaded */
370 #define TPM2_RC_REFERENCE_S5       ((TPM2_RC) (TPM2_RC_WARN + 0x01D)) /* the 6th session handle references a session that is not loaded */
371 #define TPM2_RC_REFERENCE_S6       ((TPM2_RC) (TPM2_RC_WARN + 0x01E)) /* the 7th authorization session handle references a session that is not loaded */
372 #define TPM2_RC_NV_RATE            ((TPM2_RC) (TPM2_RC_WARN + 0x020)) /* the TPM is rate limiting accesses to prevent wearout of NV */
373 #define TPM2_RC_LOCKOUT            ((TPM2_RC) (TPM2_RC_WARN + 0x021)) /* authorizations for objects subject to DA protection are not allowed at this time because the TPM is in DA lockout mode */
374 #define TPM2_RC_RETRY              ((TPM2_RC) (TPM2_RC_WARN + 0x022)) /* the TPM was not able to start the command */
375 #define TPM2_RC_NV_UNAVAILABLE     ((TPM2_RC) (TPM2_RC_WARN + 0x023)) /* the command may require writing of NV and NV is not current accessible */
376 #define TPM2_RC_NOT_USED           ((TPM2_RC) (TPM2_RC_WARN + 0x07F)) /* this value is reserved and shall not be returned by the TPM */
377 #define TPM2_RC_H                                 ((TPM2_RC) 0x000) /* add to a handle related error */
378 #define TPM2_RC_P                                 ((TPM2_RC) 0x040) /* add to a parameter-related error */
379 #define TPM2_RC_S                                 ((TPM2_RC) 0x800) /* add to a session-related error */
380 #define TPM2_RC_1                                 ((TPM2_RC) 0x100) /* add to a parameter handle or session-related error */
381 #define TPM2_RC_2                                 ((TPM2_RC) 0x200) /* add to a parameter handle or session-related error */
382 #define TPM2_RC_3                                 ((TPM2_RC) 0x300) /* add to a parameter handle or session-related error */
383 #define TPM2_RC_4                                 ((TPM2_RC) 0x400) /* add to a parameter handle or session-related error */
384 #define TPM2_RC_5                                 ((TPM2_RC) 0x500) /* add to a parameter handle or session-related error */
385 #define TPM2_RC_6                                 ((TPM2_RC) 0x600) /* add to a parameter handle or session-related error */
386 #define TPM2_RC_7                                 ((TPM2_RC) 0x700) /* add to a parameter handle or session-related error */
387 #define TPM2_RC_8                                 ((TPM2_RC) 0x800) /* add to a parameter-related error */
388 #define TPM2_RC_9                                 ((TPM2_RC) 0x900) /* add to a parameter-related error */
389 #define TPM2_RC_A                                 ((TPM2_RC) 0xA00) /* add to a parameter-related error */
390 #define TPM2_RC_B                                 ((TPM2_RC) 0xB00) /* add to a parameter-related error */
391 #define TPM2_RC_C                                 ((TPM2_RC) 0xC00) /* add to a parameter-related error */
392 #define TPM2_RC_D                                 ((TPM2_RC) 0xD00) /* add to a parameter-related error */
393 #define TPM2_RC_E                                 ((TPM2_RC) 0xE00) /* add to a parameter-related error */
394 #define TPM2_RC_F                                 ((TPM2_RC) 0xF00) /* add to a parameter-related error */
395 #define TPM2_RC_N_MASK                            ((TPM2_RC) 0xF00) /* number mask */
396 
397 /* Definition of INT8 TPM2_CLOCK_ADJUST Constants <IN> */
398 typedef INT8 TPM2_CLOCK_ADJUST;
399 #define TPM2_CLOCK_COARSE_SLOWER ((TPM2_CLOCK_ADJUST) -3) /* Slow the Clock update rate by one coarse adjustment step. */
400 #define TPM2_CLOCK_MEDIUM_SLOWER ((TPM2_CLOCK_ADJUST) -2) /* Slow the Clock update rate by one medium adjustment step. */
401 #define TPM2_CLOCK_FINE_SLOWER   ((TPM2_CLOCK_ADJUST) -1) /* Slow the Clock update rate by one fine adjustment step. */
402 #define TPM2_CLOCK_NO_CHANGE      ((TPM2_CLOCK_ADJUST) 0) /* No change to the Clock update rate. */
403 #define TPM2_CLOCK_FINE_FASTER    ((TPM2_CLOCK_ADJUST) 1) /* Speed the Clock update rate by one fine adjustment step. */
404 #define TPM2_CLOCK_MEDIUM_FASTER  ((TPM2_CLOCK_ADJUST) 2) /* Speed the Clock update rate by one medium adjustment step. */
405 #define TPM2_CLOCK_COARSE_FASTER  ((TPM2_CLOCK_ADJUST) 3) /* Speed the Clock update rate by one coarse adjustment step. */
406 
407 /* Definition of UINT16 TPM2_EO Constants <INOUT> */
408 typedef UINT16 TPM2_EO;
409 #define TPM2_EO_EQ          ((TPM2_EO) 0x0000) /* A  B */
410 #define TPM2_EO_NEQ         ((TPM2_EO) 0x0001) /* A  B */
411 #define TPM2_EO_SIGNED_GT   ((TPM2_EO) 0x0002) /* A > B signed */
412 #define TPM2_EO_UNSIGNED_GT ((TPM2_EO) 0x0003) /* A > B unsigned */
413 #define TPM2_EO_SIGNED_LT   ((TPM2_EO) 0x0004) /* A < B signed */
414 #define TPM2_EO_UNSIGNED_LT ((TPM2_EO) 0x0005) /* A < B unsigned */
415 #define TPM2_EO_SIGNED_GE   ((TPM2_EO) 0x0006) /* A  B signed */
416 #define TPM2_EO_UNSIGNED_GE ((TPM2_EO) 0x0007) /* A  B unsigned */
417 #define TPM2_EO_SIGNED_LE   ((TPM2_EO) 0x0008) /* A  B signed */
418 #define TPM2_EO_UNSIGNED_LE ((TPM2_EO) 0x0009) /* A  B unsigned */
419 #define TPM2_EO_BITSET      ((TPM2_EO) 0x000A) /* All bits SET in B are SET in A. ABB */
420 #define TPM2_EO_BITCLEAR    ((TPM2_EO) 0x000B) /* All bits SET in B are CLEAR in A. AB0 */
421 
422 /* Definition of UINT16 TPM2_ST Constants <INOUT S> */
423 typedef UINT16 TPM2_ST;
424 #define TPM2_ST_RSP_COMMAND          ((TPM2_ST) 0x00C4) /* Tag value for a response used when there is an error in the tag. This is also the value returned from a TPM 1.2 when an error occurs. This value is used in this specification because an error in the command tag may prevent determination of the family. When this tag is used in the response the response code will be TPM2_RC_BAD_TAG 0 1E16 which has the same numeric value as the TPM 1.2 response code for TPM_BADTAG. NOTE In a previously published version of this specification TPM2_RC_BAD_TAG was incorrectly assigned a value of 0x030 instead of 30 0x01e. Some implementations my return the old value instead of the new value. */
425 #define TPM2_ST_NULL                 ((TPM2_ST) 0X8000) /* no structure type specified */
426 #define TPM2_ST_NO_SESSIONS          ((TPM2_ST) 0x8001) /* tag value for a command response for a command defined in this specification indicating that the command response has no attached sessions and no authorizationSizeparameterSize value is present. If the responseCode from the TPM is not TPM2_RC_SUCCESS then the response tag shall have this value. */
427 #define TPM2_ST_SESSIONS             ((TPM2_ST) 0x8002) /* tag value for a command response for a command defined in this specification indicating that the command response has one or more attached sessions and the authorizationSizeparameterSize field is present */
428 #define TPM2_ST_RESERVED1            ((TPM2_ST) 0x8003) /* When used between application software and the TPM resource manager, this tag indicates that the command has no sessions and the handles are using the Name format rather than the 32-bit handle format. NOTE 1 The response to application software will have a tag of TPM2_ST_NO_SESSIONS. Between the TRM and TPM, this tag would occur in a response from a TPM that overlaps the tag parameter of a request with the tag parameter of a response when the response has no associated sessions. NOTE 2 This tag is not used by all TPM or TRM implementations. */
429 #define TPM2_ST_RESERVED2            ((TPM2_ST) 0x8004) /* When used between application software and the TPM resource manager. This tag indicates that the command has sessions and the handles are using the Name format rather than the 32-bit handle format. NOTE 1 If the command completes successfully the response to application software will have a tag of TPM2_ST_SESSIONS. Between the TRM and TPM would occur in a response from a TPM that overlaps the tag parameter of a request with the tag parameter of a response when the response has authorization sessions. NOTE 2 This tag is not used by all TPM or TRM implementations. */
430 #define TPM2_ST_ATTEST_NV            ((TPM2_ST) 0x8014) /* tag for an attestation structure */
431 #define TPM2_ST_ATTEST_COMMAND_AUDIT ((TPM2_ST) 0x8015) /* tag for an attestation structure */
432 #define TPM2_ST_ATTEST_SESSION_AUDIT ((TPM2_ST) 0x8016) /* tag for an attestation structure */
433 #define TPM2_ST_ATTEST_CERTIFY       ((TPM2_ST) 0x8017) /* tag for an attestation structure */
434 #define TPM2_ST_ATTEST_QUOTE         ((TPM2_ST) 0x8018) /* tag for an attestation structure */
435 #define TPM2_ST_ATTEST_TIME          ((TPM2_ST) 0x8019) /* tag for an attestation structure */
436 #define TPM2_ST_ATTEST_CREATION      ((TPM2_ST) 0x801A) /* tag for an attestation structure */
437 #define TPM2_ST_RESERVED3            ((TPM2_ST) 0x801B) /* do not use . NOTE This was previously assigned to TPM2_ST_ATTEST_NV. The tag is changed because the structure has changed */
438 #define TPM2_ST_CREATION             ((TPM2_ST) 0x8021) /* tag for a ticket type */
439 #define TPM2_ST_VERIFIED             ((TPM2_ST) 0x8022) /* tag for a ticket type */
440 #define TPM2_ST_AUTH_SECRET          ((TPM2_ST) 0x8023) /* tag for a ticket type */
441 #define TPM2_ST_HASHCHECK            ((TPM2_ST) 0x8024) /* tag for a ticket type */
442 #define TPM2_ST_AUTH_SIGNED          ((TPM2_ST) 0x8025) /* tag for a ticket type */
443 #define TPM2_ST_FU_MANIFEST          ((TPM2_ST) 0x8029) /* tag for a structure describing a Field Upgrade Policy */
444 
445 /* Definition of UINT16 TPM2_SU Constants <IN> */
446 typedef UINT16 TPM2_SU;
447 #define TPM2_SU_CLEAR    ((TPM2_SU) 0x0000) /* On TPM2_Shutdown indicates that the TPM should prepare for loss of power and save state required for an orderly startup TPM Reset. On TPM2_Startup indicates that the TPM should perform TPM Reset or TPM Restart */
448 #define TPM2_SU_STATE    ((TPM2_SU) 0x0001) /* On TPM2_Shutdown indicates that the TPM should prepare for loss of power and save state required for an orderly startup. TPM Restart or TPM Resume on TPM2_Startup indicates that the TPM should restore the state saved by TPM2_Shutdown TPM2_SU_STATE */
449 
450 /* Definition of UINT8 TPM2_SE Constants <IN> */
451 typedef UINT8 TPM2_SE;
452 #define TPM2_SE_HMAC    ((TPM2_SE) 0x00)
453 #define TPM2_SE_POLICY  ((TPM2_SE) 0x01)
454 #define TPM2_SE_TRIAL   ((TPM2_SE) 0x03) /* The policy session is being used to compute the policyHash and not for command authorization.This setting modifies some policy commands and prevents session from being used to authorize a command. */
455 
456 /* Definition of UINT32 TPM2_CAP Constants */
457 typedef UINT32 TPM2_CAP;
458 #define TPM2_CAP_FIRST           ((TPM2_CAP) 0x00000000)
459 #define TPM2_CAP_ALGS            ((TPM2_CAP) 0x00000000) /* TPM2_ALG_ID1 */
460 #define TPM2_CAP_HANDLES         ((TPM2_CAP) 0x00000001) /* TPM2_HANDLE */
461 #define TPM2_CAP_COMMANDS        ((TPM2_CAP) 0x00000002) /* TPM2_CC */
462 #define TPM2_CAP_PP_COMMANDS     ((TPM2_CAP) 0x00000003) /* TPM2_CC */
463 #define TPM2_CAP_AUDIT_COMMANDS  ((TPM2_CAP) 0x00000004) /* TPM2_CC */
464 #define TPM2_CAP_PCRS            ((TPM2_CAP) 0x00000005) /* reserved */
465 #define TPM2_CAP_TPM_PROPERTIES  ((TPM2_CAP) 0x00000006) /* TPM2_PT */
466 #define TPM2_CAP_PCR_PROPERTIES  ((TPM2_CAP) 0x00000007) /* TPM2_PT_PCR */
467 #define TPM2_CAP_ECC_CURVES      ((TPM2_CAP) 0x00000008) /* TPM2_ECC_CURVE1 */
468 #define TPM2_CAP_LAST            ((TPM2_CAP) 0x00000008)
469 #define TPM2_CAP_VENDOR_PROPERTY ((TPM2_CAP) 0x00000100) /* manufacturer specific */
470 
471 /* Definition of UINT32 TPM2_PT Constants <INOUT S> */
472 typedef UINT32 TPM2_PT;
473 #define TPM2_PT_NONE                     ((TPM2_PT) 0x00000000) /* indicates no property type */
474 #define TPM2_PT_GROUP                    ((TPM2_PT) 0x00000100) /* The number of properties in each group. NOTE The first group with any properties is group 1 TPM2_PT_GROUP * 1. Group 0 is reserved. */
475 #define TPM2_PT_FIXED                    ((TPM2_PT) (TPM2_PT_GROUP * 1)) /* the group of fixed properties returned as TPMS_TAGGED_PROPERTY. The values in this group are only changed due to a firmware change in the TPM. */
476 #define TPM2_PT_FAMILY_INDICATOR         ((TPM2_PT) (TPM2_PT_FIXED + 0)) /* a 4-octet character string containing the TPM Family value TPM2_SPEC_FAMILY */
477 #define TPM2_PT_LEVEL                    ((TPM2_PT) (TPM2_PT_FIXED + 1)) /* the level of the specification. NOTE 1 For this specification the level is zero. NOTE 2 The level is on the title page of the specification. */
478 #define TPM2_PT_REVISION                 ((TPM2_PT) (TPM2_PT_FIXED + 2)) /* the specification Revision times 100. EXAMPLE Revision 01.01 would have a value of 101. NOTE The Revision value is on the title page of the specification. */
479 #define TPM2_PT_DAY_OF_YEAR              ((TPM2_PT) (TPM2_PT_FIXED + 3)) /* the specification day of year using TCG calendar. EXAMPLE November 15 2010 has a day of year value of 319 00 00 01 3F16. NOTE The specification date is on the title page of the specification. */
480 #define TPM2_PT_YEAR                     ((TPM2_PT) (TPM2_PT_FIXED + 4)) /* the specification year using the CE. EXAMPLE The year 2010 has a value of 00 00 07 DA16. NOTE The specification date is on the title page of the specification. */
481 #define TPM2_PT_MANUFACTURER             ((TPM2_PT) (TPM2_PT_FIXED + 5)) /* the vendor ID unique to each TPM manufacturer */
482 #define TPM2_PT_VENDOR_STRING_1          ((TPM2_PT) (TPM2_PT_FIXED + 6)) /* the first four characters of the vendor ID string. NOTE When the vendor string is fewer than 16 octets the additional property values do not have to be present. A vendor string of 4 octets can be represented in one 32-bit value and no null terminating character is required. */
483 #define TPM2_PT_VENDOR_STRING_2          ((TPM2_PT) (TPM2_PT_FIXED + 7)) /* the second four characters of the vendor ID string */
484 #define TPM2_PT_VENDOR_STRING_3          ((TPM2_PT) (TPM2_PT_FIXED + 8)) /* the third four characters of the vendor ID string */
485 #define TPM2_PT_VENDOR_STRING_4          ((TPM2_PT) (TPM2_PT_FIXED + 9)) /* the fourth four characters of the vendor ID sting */
486 #define TPM2_PT_VENDOR_TPM_TYPE          ((TPM2_PT) (TPM2_PT_FIXED + 10)) /* vendor defined value indicating the TPM model */
487 #define TPM2_PT_FIRMWARE_VERSION_1       ((TPM2_PT) (TPM2_PT_FIXED + 11)) /* the most significant 32 bits of a TPM vendor-specific value indicating the version number of the firmware. See 10.12.2 and 10.12.8. */
488 #define TPM2_PT_FIRMWARE_VERSION_2       ((TPM2_PT) (TPM2_PT_FIXED + 12)) /* the least significant 32 bits of a TPM vendor-specific value indicating the version number of the firmware. See 10.12.2 and 10.12.8. */
489 #define TPM2_PT_INPUT_BUFFER             ((TPM2_PT) (TPM2_PT_FIXED + 13)) /* the maximum size of a parameter typically a TPM2B_MAX_BUFFER */
490 #define TPM2_PT_HR_TRANSIENT_MIN         ((TPM2_PT) (TPM2_PT_FIXED + 14)) /* the minimum number of transient objects that can be held in TPM RAM. NOTE This minimum shall be no less than the minimum value required by the platforms-pecific specification to which the TPM is built. */
491 #define TPM2_PT_HR_PERSISTENT_MIN        ((TPM2_PT) (TPM2_PT_FIXED + 15)) /* the minimum number of persistent objects that can be held in TPM NV memory. NOTE This minimum shall be no less than the minimum value required by the platform-specific specification to which the TPM is built. */
492 #define TPM2_PT_HR_LOADED_MIN            ((TPM2_PT) (TPM2_PT_FIXED + 16)) /* the minimum number of authorization sessions that can be held in TPM RAM . NOTE This minimum shall be no less than the minimum value required by the platform-specific specification to which the TPM is built. */
493 #define TPM2_PT_ACTIVE_SESSIONS_MAX      ((TPM2_PT) (TPM2_PT_FIXED + 17)) /* the number of authorization sessions that may be active at a time. A session is active when it has a context associated with its handle. The context may either be in TPM RAM or be context saved. NOTE This value shall be no less than the minimum value required by the platform-specific specification to which the TPM is built. */
494 #define TPM2_PT_PCR_COUNT                ((TPM2_PT) (TPM2_PT_FIXED + 18)) /* the number of PCR implemented. NOTE This number is determined by the defined attributes not the number of PCR that are populated. */
495 #define TPM2_PT_PCR_SELECT_MIN           ((TPM2_PT) (TPM2_PT_FIXED + 19)) /* the minimum number of octets in a TPMS_PCR_SELECT.sizeofSelect. NOTE This value is not determined by the number of PCR implemented but by the number of PCR required by the platform-specific specification with which the TPM is compliant or by the implementer if not adhering to a platform-specific specification. */
496 #define TPM2_PT_CONTEXT_GAP_MAX          ((TPM2_PT) (TPM2_PT_FIXED + 20)) /* the maximum allowed difference unsigned between the contextID values of two saved session contexts. This value shall be 2n1 where n is at least 16. */
497 #define TPM2_PT_NV_COUNTERS_MAX          ((TPM2_PT) (TPM2_PT_FIXED + 22)) /* the maximum number of NV Indexes that are allowed to have the TPM2_NT_COUNTER attribute. NOTE It is allowed for this value to be larger than the number of NV Indexes that can be defined. This would be indicative of a TPM implementation that did not use different implementation technology for different NV Index types. */
498 #define TPM2_PT_NV_INDEX_MAX             ((TPM2_PT) (TPM2_PT_FIXED + 23)) /* the maximum size of an NV Index data area */
499 #define TPM2_PT_MEMORY                   ((TPM2_PT) (TPM2_PT_FIXED + 24)) /* a TPMA_MEMORY indicating the memory management method for the TPM */
500 #define TPM2_PT_CLOCK_UPDATE             ((TPM2_PT) (TPM2_PT_FIXED + 25)) /* interval in milliseconds between updates to the copy of TPMS_CLOCK_INFO.clock in NV */
501 #define TPM2_PT_CONTEXT_HASH             ((TPM2_PT) (TPM2_PT_FIXED + 26)) /* the algorithm used for the integrity HMAC on saved contexts and for hashing the fuData of TPM2_FirmwareRead */
502 #define TPM2_PT_CONTEXT_SYM              ((TPM2_PT) (TPM2_PT_FIXED + 27)) /* TPM2_ALG_ID the algorithm used for encryption of saved contexts */
503 #define TPM2_PT_CONTEXT_SYM_SIZE         ((TPM2_PT) (TPM2_PT_FIXED + 28)) /* TPM2_KEY_BITS the size of the key used for encryption of saved contexts */
504 #define TPM2_PT_ORDERLY_COUNT            ((TPM2_PT) (TPM2_PT_FIXED + 29)) /* the modulus 1 of the count for NV update of an orderly counter. The returned value is MAX_ORDERLY_COUNT. This will have a value of 2N  1 where 1  N  32. NOTE An orderly counter is an NV Index with an TPM2_NT of TPM_NV_COUNTER and TPMA_NV_ORDERLY SET. NOTE When the low-order bits of a counter equal this value an NV write occurs on the next increment. */
505 #define TPM2_PT_MAX_COMMAND_SIZE         ((TPM2_PT) (TPM2_PT_FIXED + 30)) /* the maximum value for commandSize in a command */
506 #define TPM2_PT_MAX_RESPONSE_SIZE        ((TPM2_PT) (TPM2_PT_FIXED + 31)) /* the maximum value for responseSize in a response */
507 #define TPM2_PT_MAX_DIGEST               ((TPM2_PT) (TPM2_PT_FIXED + 32)) /* the maximum size of a digest that can be produced by the TPM */
508 #define TPM2_PT_MAX_OBJECT_CONTEXT       ((TPM2_PT) (TPM2_PT_FIXED + 33)) /* the maximum size of an object context that will be returned by TPM2_ContextSave */
509 #define TPM2_PT_MAX_SESSION_CONTEXT      ((TPM2_PT) (TPM2_PT_FIXED + 34)) /* the maximum size of a session context that will be returned by TPM2_ContextSave */
510 #define TPM2_PT_PS_FAMILY_INDICATOR      ((TPM2_PT) (TPM2_PT_FIXED + 35)) /* platform-specific family. A TPM2_PS value. See Table 25. NOTE The platform-specific values for the TPM2_PT_PS parameters are in the relevant platform-specific specification. In the reference implementation all of these values are 0. */
511 #define TPM2_PT_PS_LEVEL                 ((TPM2_PT) (TPM2_PT_FIXED + 36)) /* the level of the platform-specific specification */
512 #define TPM2_PT_PS_REVISION              ((TPM2_PT) (TPM2_PT_FIXED + 37)) /* the specification Revision times 100 for the platform-specific specification */
513 #define TPM2_PT_PS_DAY_OF_YEAR           ((TPM2_PT) (TPM2_PT_FIXED + 38)) /* the platform-specific specification day of year using TCG calendar */
514 #define TPM2_PT_PS_YEAR                  ((TPM2_PT) (TPM2_PT_FIXED + 39)) /* the platform-specific specification year using the CE */
515 #define TPM2_PT_SPLIT_MAX                ((TPM2_PT) (TPM2_PT_FIXED + 40)) /* the number of split signing operations supported by the TPM */
516 #define TPM2_PT_TOTAL_COMMANDS           ((TPM2_PT) (TPM2_PT_FIXED + 41)) /* total number of commands implemented in the TPM */
517 #define TPM2_PT_LIBRARY_COMMANDS         ((TPM2_PT) (TPM2_PT_FIXED + 42)) /* number of commands from the TPM library that are implemented */
518 #define TPM2_PT_VENDOR_COMMANDS          ((TPM2_PT) (TPM2_PT_FIXED + 43)) /* number of vendor commands that are implemented */
519 #define TPM2_PT_NV_BUFFER_MAX            ((TPM2_PT) (TPM2_PT_FIXED + 44)) /* the maximum data size in one NV write command */
520 #define TPM2_PT_MODES                    ((TPM2_PT) (TPM2_PT_FIXED + 45)) /* a TPMA_MODES value indicating that the TPM is designed for these modes. */
521 #define TPM2_PT_MAX_CAP_BUFFER           ((TPM2_PT) (TPM2_PT_FIXED + 46)) /* the maximum size of a TPMS_CAPABILITY_DATA structure returned in TPM2_GetCapability(). */
522 #define TPM2_PT_VAR                      ((TPM2_PT) (TPM2_PT_GROUP * 2)) /* the group of variable properties returned as TPMS_TAGGED_PROPERTY. The properties in this group change because of a Protected Capability other than a firmware update. The values are not necessarily persistent across all power transitions. */
523 #define TPM2_PT_PERMANENT                ((TPM2_PT) (TPM2_PT_VAR + 0)) /* TPMA_PERMANENT */
524 #define TPM2_PT_STARTUP_CLEAR            ((TPM2_PT) (TPM2_PT_VAR + 1)) /* TPMA_STARTUP_CLEAR */
525 #define TPM2_PT_HR_NV_INDEX              ((TPM2_PT) (TPM2_PT_VAR + 2)) /* the number of NV Indexes currently defined */
526 #define TPM2_PT_HR_LOADED                ((TPM2_PT) (TPM2_PT_VAR + 3)) /* the number of authorization sessions currently loaded into TPM RAM */
527 #define TPM2_PT_HR_LOADED_AVAIL          ((TPM2_PT) (TPM2_PT_VAR + 4)) /* the number of additional authorization sessions of any type that could be loaded into TPM RAM. This value is an estimate. If this value is at least 1 then at least one authorization session of any type may be loaded. Any command that changes the RAM memory allocation can make this estimate invalid. NOTE A valid implementation may return 1 even if more than one authorization session would fit into RAM. */
528 #define TPM2_PT_HR_ACTIVE                ((TPM2_PT) (TPM2_PT_VAR + 5)) /* the number of active authorization sessions currently being tracked by the TPMThis is the sum of the loaded and saved sessions. */
529 #define TPM2_PT_HR_ACTIVE_AVAIL          ((TPM2_PT) (TPM2_PT_VAR + 6)) /* the number of additional authorization sessions of any type that could be created. This value is an estimate. If this value is at least 1 then at least one authorization session of any type may be created. Any command that changes the RAM memory allocation can make this estimate invalid. NOTE A valid implementation may return 1 even if more than one authorization session could be created. */
530 #define TPM2_PT_HR_TRANSIENT_AVAIL       ((TPM2_PT) (TPM2_PT_VAR + 7)) /* estimate of the number of additional transient objects that could be loaded into TPM RAM. This value is an estimate. If this value is at least 1 then at least one object of any type may be loaded. Any command that changes the memory allocation can make this estimate invalid. NOTE A valid implementation may return 1 even if more than one transient object would fit into RAM. */
531 #define TPM2_PT_HR_PERSISTENT            ((TPM2_PT) (TPM2_PT_VAR + 8)) /* the number of persistent objects currently loaded into TPM NV memory */
532 #define TPM2_PT_HR_PERSISTENT_AVAIL      ((TPM2_PT) (TPM2_PT_VAR + 9)) /* the number of additional persistent objects that could be loaded into NV memory. This value is an estimate. If this value is at least 1 then at least one object of any type may be made persistent. Any command that changes the NV memory allocation can make this estimate invalid. NOTE A valid implementation may return 1 even if more than one persistent object would fit into NV memory. */
533 #define TPM2_PT_NV_COUNTERS              ((TPM2_PT) (TPM2_PT_VAR + 10)) /* the number of defined NV Indexes that have NV the TPM2_NT_COUNTER attribute */
534 #define TPM2_PT_NV_COUNTERS_AVAIL        ((TPM2_PT) (TPM2_PT_VAR + 11)) /* the number of additional NV Indexes that can be defined with their TPM2_NT of TPM_NV_COUNTER and the TPMA_NV_ORDERLY attribute SET. This value is an estimate. If this value is at least 1 then at least one NV Index may be created with a TPM2_NT of TPM_NV_COUNTER and the TPMA_NV_ORDERLY attributes. Any command that changes the NV memory allocation can make this estimate invalid. NOTE A valid implementation may return 1 even if more than one NV counter could be defined. */
535 #define TPM2_PT_ALGORITHM_SET            ((TPM2_PT) (TPM2_PT_VAR + 12)) /* code that limits the algorithms that may be used with the TPM */
536 #define TPM2_PT_LOADED_CURVES            ((TPM2_PT) (TPM2_PT_VAR + 13)) /* the number of loaded ECC curves */
537 #define TPM2_PT_LOCKOUT_COUNTER          ((TPM2_PT) (TPM2_PT_VAR + 14)) /* the current value of the lockout counter failedTries */
538 #define TPM2_PT_MAX_AUTH_FAIL            ((TPM2_PT) (TPM2_PT_VAR + 15)) /* the number of authorization failures before DA lockout is invoked */
539 #define TPM2_PT_LOCKOUT_INTERVAL         ((TPM2_PT) (TPM2_PT_VAR + 16)) /* the number of seconds before the value reported by TPM2_PT_LOCKOUT_COUNTER is decremented */
540 #define TPM2_PT_LOCKOUT_RECOVERY         ((TPM2_PT) (TPM2_PT_VAR + 17)) /* the number of seconds after a lockoutAuth failure before use of lockoutAuth may be attempted again */
541 #define TPM2_PT_NV_WRITE_RECOVERY        ((TPM2_PT) (TPM2_PT_VAR + 18)) /* number of milliseconds before the TPM will accept another command that will modify NVThis value is an approximation and may go up or down over time. */
542 #define TPM2_PT_AUDIT_COUNTER_0          ((TPM2_PT) (TPM2_PT_VAR + 19)) /* the high-order 32 bits of the command audit counter */
543 #define TPM2_PT_AUDIT_COUNTER_1          ((TPM2_PT) (TPM2_PT_VAR + 20)) /* the low-order 32 bits of the command audit counter */
544 
545 /* Definition of UINT32 TPM2_PT_PCR Constants <INOUT S> */
546 typedef UINT32 TPM2_PT_PCR;
547 #define TPM2_PT_TPM2_PCR_FIRST        ((TPM2_PT_PCR) 0x00000000) /* bottom of the range of TPM2_PT_PCR properties */
548 #define TPM2_PT_PCR_SAVE         ((TPM2_PT_PCR) 0x00000000) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR is saved and restored by TPM2_SU_STATE */
549 #define TPM2_PT_PCR_EXTEND_L0    ((TPM2_PT_PCR) 0x00000001) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be extended from locality 0This property is only present if a locality other than 0 is implemented. */
550 #define TPM2_PT_PCR_RESET_L0     ((TPM2_PT_PCR) 0x00000002) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be reset by TPM2_PCR_Reset from locality 0 */
551 #define TPM2_PT_PCR_EXTEND_L1    ((TPM2_PT_PCR) 0x00000003) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be extended from locality 1 This property is only present if locality 1 is implemented. */
552 #define TPM2_PT_PCR_RESET_L1     ((TPM2_PT_PCR) 0x00000004) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be reset by TPM2_PCR_Reset from locality 1This property is only present if locality 1 is implemented. */
553 #define TPM2_PT_PCR_EXTEND_L2    ((TPM2_PT_PCR) 0x00000005) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be extended from locality 2 This property is only present if localities 1 and 2 are implemented. */
554 #define TPM2_PT_PCR_RESET_L2     ((TPM2_PT_PCR) 0x00000006) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be reset by TPM2_PCR_Reset from locality 2This property is only present if localities 1 and 2 are implemented. */
555 #define TPM2_PT_PCR_EXTEND_L3    ((TPM2_PT_PCR) 0x00000007) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be extended from locality 3This property is only present if localities 1 2 and 3 are implemented. */
556 #define TPM2_PT_PCR_RESET_L3     ((TPM2_PT_PCR) 0x00000008) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be reset by TPM2_PCR_Reset from locality 3This property is only present if localities 1 2 and 3 are implemented. */
557 #define TPM2_PT_PCR_EXTEND_L4    ((TPM2_PT_PCR) 0x00000009) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be extended from locality 4This property is only present if localities 1 2 3 and 4 are implemented. */
558 #define TPM2_PT_PCR_RESET_L4     ((TPM2_PT_PCR) 0x0000000A) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR may be reset by TPM2_PCR_Reset from locality 4This property is only present if localities 1 2 3 and 4 are implemented. */
559 /* NOTE: The values in the range 0x0000000B - 0x00000010 are reserved.
560  * They correspond to values that may be used to describe attributes
561  * associated with the extended localities (32-255).
562  * The meaning of these properties need not be the same as the meaning
563  * for the Extend and Reset properties above.
564  */
565 #define TPM2_PT_PCR_NO_INCREMENT ((TPM2_PT_PCR) 0x00000011) /* a SET bit in the TPMS_PCR_SELECT indicates that modifications to this PCR reset or Extend will not increment the pcrUpdateCounter */
566 #define TPM2_PT_PCR_DRTM_RESET   ((TPM2_PT_PCR) 0x00000012) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR is reset by a DRTM event. These PCR are reset to 1 on TPM2_Startup and reset to 0 on a _TPM_Hash_End event following a _TPM_Hash_Start event. */
567 #define TPM2_PT_PCR_POLICY       ((TPM2_PT_PCR) 0x00000013) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR is controlled by policy. This property is only present if the TPM supports policy control of a PCR. */
568 #define TPM2_PT_PCR_AUTH         ((TPM2_PT_PCR) 0x00000014) /* a SET bit in the TPMS_PCR_SELECT indicates that the PCR is controlled by an authorization value. This property is only present if the TPM supports authorization control of a PCR. */
569 #define TPM2_PT_TPM2_PCR_LAST         ((TPM2_PT_PCR) 0x00000014) /* top of the range of TPM2_PT_PCR properties of the implementation. If the TPM receives a request for a PCR property with a value larger than this the TPM will return a zero length list and set the moreData parameter to NO. NOTE This is an implementation-specific value. The value shown reflects the reference code implementation. */
570 /* NOTE: The following values are reserved:
571  * 0x00000015 is reserved for the next 2nd TPM2_PT_PCR_POLICY set.
572  * 0x00000016 is reserved for the next 2nd TPM2_PT_PCR_AUTH set.
573  * 0x00000017 - 0x00000210 are reserved for the 2nd through 255th TPM2_PT_PCR_POLICY and TPM2_PT_PCR_AUTH values.
574  * 0x00000211 is reserved to the 256th and highest allowed TPM2_PT_PCR_POLICY set.
575  * 0x00000212 is reserved to the 256th and highest allowed TPM2_PT_PCR_AUTH set.
576  * A new PCR property values may be assigned starting with value 0x00000213.
577  */
578 
579 /* Definition of UINT32 TPM2_PS Constants <OUT> */
580 typedef UINT32 TPM2_PS;
581 #define TPM2_PS_MAIN           ((TPM2_PS) 0x00000000) /* not platform-specific */
582 #define TPM2_PS_PC             ((TPM2_PS) 0x00000001) /* PC Client */
583 #define TPM2_PS_PDA            ((TPM2_PS) 0x00000002) /* PDA includes all mobile devices that are not specifically cell phones */
584 #define TPM2_PS_CELL_PHONE     ((TPM2_PS) 0x00000003) /* Cell Phone */
585 #define TPM2_PS_SERVER         ((TPM2_PS) 0x00000004) /* Server WG */
586 #define TPM2_PS_PERIPHERAL     ((TPM2_PS) 0x00000005) /* Peripheral WG */
587 #define TPM2_PS_TSS            ((TPM2_PS) 0x00000006) /* TSS WG */
588 #define TPM2_PS_STORAGE        ((TPM2_PS) 0x00000007) /* Storage WG */
589 #define TPM2_PS_AUTHENTICATION ((TPM2_PS) 0x00000008) /* Authentication WG */
590 #define TPM2_PS_EMBEDDED       ((TPM2_PS) 0x00000009) /* Embedded WG */
591 #define TPM2_PS_HARDCOPY       ((TPM2_PS) 0x0000000A) /* Hardcopy WG */
592 #define TPM2_PS_INFRASTRUCTURE ((TPM2_PS) 0x0000000B) /* Infrastructure WG */
593 #define TPM2_PS_VIRTUALIZATION ((TPM2_PS) 0x0000000C) /* Virtualization WG */
594 #define TPM2_PS_TNC            ((TPM2_PS) 0x0000000D) /* Trusted Network Connect WG */
595 #define TPM2_PS_MULTI_TENANT   ((TPM2_PS) 0x0000000E) /* Multi-tenant WG */
596 #define TPM2_PS_TC             ((TPM2_PS) 0x0000000F) /* Technical Committee */
597 
598 /* Definition of Types for Handles */
599 typedef UINT32 TPM2_HANDLE;
600 
601 /* Definition of UINT8 TPM2_HT Constants <S> */
602 typedef UINT8 TPM2_HT;
603 #define TPM2_HT_PCR            ((TPM2_HT) 0x00) /* PCR  consecutive numbers starting at 0 that reference the PCR registers. A platform-specific specification will set the minimum number of PCR and an implementation may have more. */
604 #define TPM2_HT_NV_INDEX       ((TPM2_HT) 0x01) /* NV Index  assigned by the caller */
605 #define TPM2_HT_HMAC_SESSION   ((TPM2_HT) 0x02) /* HMAC Authorization Session  assigned by the TPM when the session is created */
606 #define TPM2_HT_LOADED_SESSION ((TPM2_HT) 0x02) /* Loaded Authorization Session  used only in the context of TPM2_GetCapability. This type references both loaded HMAC and loaded policy authorization sessions. */
607 #define TPM2_HT_POLICY_SESSION ((TPM2_HT) 0x03) /* Policy Authorization Session  assigned by the TPM when the session is created */
608 #define TPM2_HT_SAVED_SESSION  ((TPM2_HT) 0x03) /* Saved Authorization Session  used only in the context of TPM2_GetCapability. This type references saved authorization session contexts for which the TPM is maintaining tracking information. */
609 #define TPM2_HT_PERMANENT      ((TPM2_HT) 0x40) /* Permanent Values  assigned by this specification in */
610 #define TPM2_HT_TRANSIENT      ((TPM2_HT) 0x80) /* Transient Objects  assigned by the TPM when an object is loaded into transient object memory or when a persistent object is converted to a transient object */
611 #define TPM2_HT_PERSISTENT     ((TPM2_HT) 0x81) /* Persistent Objects  assigned by the TPM when a loaded transient object is made persistent */
612 
613 /* Definition of TPM2_HANDLE TPM2_RH Constants <S> */
614 typedef TPM2_HANDLE TPM2_RH;
615 #define TPM2_RH_FIRST       ((TPM2_RH) 0x40000000) /* R */
616 #define TPM2_RH_SRK         ((TPM2_RH) 0x40000000) /* R */
617 #define TPM2_RH_OWNER       ((TPM2_RH) 0x40000001) /* K A P */
618 #define TPM2_RH_REVOKE      ((TPM2_RH) 0x40000002) /* R */
619 #define TPM2_RH_TRANSPORT   ((TPM2_RH) 0x40000003) /* R */
620 #define TPM2_RH_OPERATOR    ((TPM2_RH) 0x40000004) /* R */
621 #define TPM2_RH_ADMIN       ((TPM2_RH) 0x40000005) /* R */
622 #define TPM2_RH_EK          ((TPM2_RH) 0x40000006) /* R */
623 #define TPM2_RH_NULL        ((TPM2_RH) 0x40000007) /* K A P */
624 #define TPM2_RH_UNASSIGNED  ((TPM2_RH) 0x40000008) /* R */
625 #define TPM2_RS_PW          ((TPM2_RH) 0x40000009) /* S */
626 #define TPM2_RH_LOCKOUT     ((TPM2_RH) 0x4000000A) /* A */
627 #define TPM2_RH_ENDORSEMENT ((TPM2_RH) 0x4000000B) /* K A P */
628 #define TPM2_RH_PLATFORM    ((TPM2_RH) 0x4000000C) /* K A P */
629 #define TPM2_RH_PLATFORM_NV ((TPM2_RH) 0x4000000D) /* C */
630 #define TPM2_RH_AUTH_00     ((TPM2_RH) 0x40000010) /* A */
631 #define TPM2_RH_AUTH_FF     ((TPM2_RH) 0x4000010F) /* A */
632 #define TPM2_RH_ACT_0       ((TPM2_RH) 0x40000110) /* A P */
633 #define TPM2_RH_ACT_F       ((TPM2_RH) 0x4000011F) /* A P */
634 #define TPM2_RH_LAST        ((TPM2_RH) 0x4000011F) /* R */
635 
636 /* Definition of TPM2_HANDLE TPM2_HC Constants <S> */
637 typedef TPM2_HANDLE TPM2_HC;
638 #define TPM2_HR_HANDLE_MASK       ((TPM2_HC) 0x00FFFFFF) /* to mask off the HR */
639 #define TPM2_HR_RANGE_MASK        ((TPM2_HC) 0xFF000000) /* to mask off the variable part */
640 #define TPM2_HR_SHIFT             ((TPM2_HC) 24)
641 #define TPM2_HR_PCR               ((TPM2_HC) (TPM2_HT_PCR << TPM2_HR_SHIFT))
642 #define TPM2_HR_HMAC_SESSION      ((TPM2_HC) (TPM2_HT_HMAC_SESSION << TPM2_HR_SHIFT))
643 #define TPM2_HR_POLICY_SESSION    ((TPM2_HC) (TPM2_HT_POLICY_SESSION << TPM2_HR_SHIFT))
644 #define TPM2_HR_TRANSIENT         ((TPM2_HC) (TPM2_HT_TRANSIENT << TPM2_HR_SHIFT))
645 #define TPM2_HR_PERSISTENT        ((TPM2_HC) (TPM2_HT_PERSISTENT << TPM2_HR_SHIFT))
646 #define TPM2_HR_NV_INDEX          ((TPM2_HC) (TPM2_HT_NV_INDEX << TPM2_HR_SHIFT))
647 #define TPM2_HR_PERMANENT         ((TPM2_HC) (TPM2_HT_PERMANENT << TPM2_HR_SHIFT))
648 #define TPM2_PCR_FIRST            ((TPM2_HC) (TPM2_HR_PCR + 0)) /* first PCR */
649 #define TPM2_PCR_LAST             ((TPM2_HC) (TPM2_PCR_FIRST + TPM2_MAX_PCRS - 1)) /* last PCR */
650 #define TPM2_HMAC_SESSION_FIRST   ((TPM2_HC) (TPM2_HR_HMAC_SESSION + 0)) /* first HMAC session */
651 #define TPM2_HMAC_SESSION_LAST    ((TPM2_HC) (TPM2_HMAC_SESSION_FIRST + 0x00fffffe)) /* last HMAC session */
652 #define TPM2_LOADED_SESSION_FIRST ((TPM2_HC) TPM2_HMAC_SESSION_FIRST) /* used in GetCapability */
653 #define TPM2_LOADED_SESSION_LAST  ((TPM2_HC) TPM2_HMAC_SESSION_LAST) /* used in GetCapability */
654 #define TPM2_POLICY_SESSION_FIRST ((TPM2_HC) (TPM2_HR_POLICY_SESSION + 0)) /* first policy session */
655 #define TPM2_POLICY_SESSION_LAST  ((TPM2_HC) (TPM2_POLICY_SESSION_FIRST + 0x00fffffe)) /* last policy session */
656 #define TPM2_TRANSIENT_FIRST      ((TPM2_HC) (TPM2_HR_TRANSIENT + 0)) /* first transient object */
657 #define TPM2_ACTIVE_SESSION_FIRST ((TPM2_HC) TPM2_POLICY_SESSION_FIRST) /* used in GetCapability */
658 #define TPM2_ACTIVE_SESSION_LAST  ((TPM2_HC) TPM2_POLICY_SESSION_LAST) /* used in GetCapability */
659 #define TPM2_TRANSIENT_LAST       ((TPM2_HC) (TPM2_TRANSIENT_FIRST + 0x00fffffe)) /* last transient object */
660 #define TPM2_PERSISTENT_FIRST     ((TPM2_HC) (TPM2_HR_PERSISTENT + 0)) /* first persistent object */
661 #define TPM2_PERSISTENT_LAST      ((TPM2_HC) (TPM2_PERSISTENT_FIRST + 0x00FFFFFF)) /* last persistent object */
662 #define TPM2_PLATFORM_PERSISTENT  ((TPM2_HC) (TPM2_PERSISTENT_FIRST + 0x00800000)) /* first platform persistent object */
663 #define TPM2_NV_INDEX_FIRST       ((TPM2_HC) (TPM2_HR_NV_INDEX + 0)) /* first allowed NV Index */
664 #define TPM2_NV_INDEX_LAST        ((TPM2_HC) (TPM2_NV_INDEX_FIRST + 0x00FFFFFF)) /* last allowed NV Index */
665 #define TPM2_PERMANENT_FIRST      ((TPM2_HC) TPM2_RH_FIRST)
666 #define TPM2_PERMANENT_LAST       ((TPM2_HC) TPM2_RH_LAST)
667 
668 /* Definition of UINT32 TPMA_ALGORITHM Bits */
669 typedef uint32_t TPMA_ALGORITHM;
670 
671 #define TPMA_ALGORITHM_ASYMMETRIC     ((TPMA_ALGORITHM) 0x00000001) /* SET 1 an asymmetric algorithm with public and private portions. CLEAR 0 not an asymmetric algorithm */
672 #define TPMA_ALGORITHM_SYMMETRIC      ((TPMA_ALGORITHM) 0x00000002) /* SET 1 a symmetric block cipher. CLEAR 0 not a symmetric block cipher */
673 #define TPMA_ALGORITHM_HASH           ((TPMA_ALGORITHM) 0x00000004) /* SET 1 a hash algorithm. CLEAR 0 not a hash algorithm */
674 #define TPMA_ALGORITHM_OBJECT         ((TPMA_ALGORITHM) 0x00000008) /* SET 1 an algorithm that may be used as an object type. CLEAR 0 an algorithm that is not used as an object type */
675 #define TPMA_ALGORITHM_RESERVED1_MASK ((TPMA_ALGORITHM) 0x000000F0)
676 #define TPMA_ALGORITHM_SIGNING        ((TPMA_ALGORITHM) 0x00000100) /* SET 1 a signing algorithm. The setting of asymmetric symmetric and hash will indicate the type of signing algorithm. CLEAR 0 not a signing algorithm */
677 #define TPMA_ALGORITHM_ENCRYPTING     ((TPMA_ALGORITHM) 0x00000200) /* SET 1 an encryptiondecryption algorithm. The setting of asymmetric symmetric and hash will indicate the type of encryptiondecryption algorithm. CLEAR 0 not an encryption-decryption algorithm */
678 #define TPMA_ALGORITHM_METHOD         ((TPMA_ALGORITHM) 0x00000400) /* SET 1 a method such as a key derivative function KDF. CLEAR 0 not a method */
679 #define TPMA_ALGORITHM_RESERVED2_MASK ((TPMA_ALGORITHM) 0xFFFFF800)
680 
681 /* Definition of UINT32 TPMA_OBJECT Bits */
682 typedef uint32_t TPMA_OBJECT;
683 
684 #define TPMA_OBJECT_RESERVED1_MASK       ((TPMA_OBJECT) 0x00000001) /* shall be zero */
685 #define TPMA_OBJECT_FIXEDTPM             ((TPMA_OBJECT) 0x00000002) /* SET 1 The hierarchy of the object as indicated by its Qualified Name may not change. CLEAR 0 The hierarchy of the object may change as a result of this object or an ancestor key being duplicated for use in another hierarchy. */
686 #define TPMA_OBJECT_STCLEAR              ((TPMA_OBJECT) 0x00000004) /* SET 1 Previously saved contexts of this object may not be loaded after StartupCLEAR. CLEAR 0 Saved contexts of this object may be used after a ShutdownSTATE and subsequent Startup. */
687 #define TPMA_OBJECT_RESERVED2_MASK       ((TPMA_OBJECT) 0x00000008) /* shall be zero */
688 #define TPMA_OBJECT_FIXEDPARENT          ((TPMA_OBJECT) 0x00000010) /* SET 1 The parent of the object may not change. CLEAR 0 The parent of the object may change as the result of a TPM2_Duplicate of the object. */
689 #define TPMA_OBJECT_SENSITIVEDATAORIGIN  ((TPMA_OBJECT) 0x00000020) /* SET 1 Indicates that when the object was created with TPM2_Create or TPM2_CreatePrimary the TPM generated all of the sensitive data other than the authValue. CLEAR 0 A portion of the sensitive data other than the authValue was provided by the caller. */
690 #define TPMA_OBJECT_USERWITHAUTH         ((TPMA_OBJECT) 0x00000040) /* SET 1 Approval of USER role actions with this object may be with an HMAC session or with a password using the authValue of the object or a policy session. CLEAR 0 Approval of USER role actions with this object may only be done with a policy session. */
691 #define TPMA_OBJECT_ADMINWITHPOLICY      ((TPMA_OBJECT) 0x00000080) /* SET 1 Approval of ADMIN role actions with this object may only be done with a policy session. CLEAR 0 Approval of ADMIN role actions with this object may be with an HMAC session or with a password using the authValue of the object or a policy session. */
692 #define TPMA_OBJECT_RESERVED3_MASK       ((TPMA_OBJECT) 0x00000300) /* shall be zero */
693 #define TPMA_OBJECT_NODA                 ((TPMA_OBJECT) 0x00000400) /* SET 1 The object is not subject to dictionary attack protections. CLEAR 0 The object is subject to dictionary attack protections. */
694 #define TPMA_OBJECT_ENCRYPTEDDUPLICATION ((TPMA_OBJECT) 0x00000800) /* SET 1 If the object is duplicated then symmetricAlg shall not be TPM2_ALG_NULL and newParentHandle shall not be TPM2_RH_NULL. CLEAR 0 The object may be duplicated without an inner wrapper on the private portion of the object and the new parent may be TPM2_RH_NULL. */
695 #define TPMA_OBJECT_RESERVED4_MASK       ((TPMA_OBJECT) 0x0000F000) /* shall be zero */
696 #define TPMA_OBJECT_RESTRICTED           ((TPMA_OBJECT) 0x00010000) /* SET 1 Key usage is restricted to manipulate structures of known format the parent of this key shall have restricted SET. CLEAR 0 Key usage is not restricted to use on special formats. */
697 #define TPMA_OBJECT_DECRYPT              ((TPMA_OBJECT) 0x00020000) /* SET 1 The private portion of the key may be used to decrypt. CLEAR 0 The private portion of the key may not be used to decrypt. */
698 #define TPMA_OBJECT_SIGN_ENCRYPT         ((TPMA_OBJECT) 0x00040000) /* SET 1 For a symmetric cipher object the private portion of the key may be used to encrypt. For other objects the private portion of the key may be used to sign. CLEAR 0 The private portion of the key may not be used to sign or encrypt. */
699 #define TPMA_OBJECT_X509SIGN             ((TPMA_OBJECT) 0x00080000) /* SET 1 For asymmetric key the private portion of the key may not be used as the signing key in TPM2_Sign. CLEAR 0 key can be used as the signing key in TPM2_Sign */
700 #define TPMA_OBJECT_RESERVED5_MASK       ((TPMA_OBJECT) 0xFFF80000) /* shall be zero */
701 
702 /* Definition of UINT8 TPMA_SESSION Bits <INOUT> */
703 typedef UINT8 TPMA_SESSION;
704 
705 #define TPMA_SESSION_CONTINUESESSION ((TPMA_SESSION) 0x00000001) /* SET 1 In a command this setting indicates that the session is to remain active after successful completion of the command. In a response it indicates that the session is still active. If SET in the command this attribute shall be SET in the response. CLEAR 0 In a command this setting indicates that the TPM should close the session and flush any related context when the command completes successfully. In a response it indicates that the session is closed and the context is no longer active. This attribute has no meaning for a password authorization and the TPM will allow any setting of the attribute in the command and SET the attribute in the response. This attribute will only be CLEAR in one response for a logical session. If the attribute is CLEAR the context associated with the session is no longer in use and the space is available. A session created after another session is ended may have the same handle but logically is not the same session. This attribute has no effect if the command does not complete successfully. */
706 #define TPMA_SESSION_AUDITEXCLUSIVE  ((TPMA_SESSION) 0x00000002) /* SET 1 In a command this setting indicates that the command should only be executed if the session is exclusive at the start of the command. In a response it indicates that the session is exclusive. This setting is only allowed if the audit attribute is SET TPM2_RC_ATTRIBUTES. CLEAR 0 In a command indicates that the session need not be exclusive at the start of the command.  In a response indicates that the session is not exclusive. In this revision if audit is CLEAR auditExclusive must be CLEAR in the command and will be CLEAR in the response.  In a future revision this bit may have a different meaning if audit is CLEAR. See Exclusive Audit Session clause in TPM 2.0 Part 1. */
707 #define TPMA_SESSION_AUDITRESET      ((TPMA_SESSION) 0x00000004) /* SET 1 In a command this setting indicates that the audit digest of the session should be initialized and the exclusive status of the session SET. This setting is only allowed if the audit attribute is SET TPM2_RC_ATTRIBUTES. CLEAR 0 In a command indicates that the audit digest should not be initialized. This bit is always CLEAR in a response. In this revision if audit is CLEAR auditReset must be clear in the command and will be CLEAR in the response.  In a future revision this bit may have a different meaning if audit is CLEAR. */
708 #define TPMA_SESSION_RESERVED1_MASK  ((TPMA_SESSION) 0x00000018) /* shall be CLEAR */
709 #define TPMA_SESSION_DECRYPT         ((TPMA_SESSION) 0x00000020) /* SET 1 In a command this setting indicates that the first parameter in the command is symmetrically encrypted using the parameter encryption scheme described in TPM 2.0 Part 1. The TPM will decrypt the parameter after performing any HMAC computations and before unmarshaling the parameter. In a response the attribute is copied from the request but has no effect on the response. CLEAR 0 Session not used for encryption. For a password authorization this attribute will be CLEAR in both the command and response. This attribute may only be SET in one session per command. This attribute may be SET in a session that is not associated with a command handle. Such a session is provided for purposes of encrypting a parameter and not for authorization. This attribute may be SET in combination with any other session attributes. This attribute may only be SET if the first parameter of the command is a sized buffer TPM2B_. */
710 #define TPMA_SESSION_ENCRYPT         ((TPMA_SESSION) 0x00000040) /* SET 1 In a command this setting indicates that the TPM should use this session to encrypt the first parameter in the response. In a response it indicates that the attribute was set in the command and that the TPM used the session to encrypt the first parameter in the response using the parameter encryption scheme described in TPM 2.0 Part 1. CLEAR 0 Session not used for encryption. For a password authorization this attribute will be CLEAR in both the command and response. This attribute may only be SET in one session per command. This attribute may be SET in a session that is not associated with a command handle. Such a session is provided for purposes of encrypting a parameter and not for authorization. This attribute may only be SET if the first parameter of a response is a sized buffer TPM2B_. */
711 #define TPMA_SESSION_AUDIT           ((TPMA_SESSION) 0x00000080) /* SET 1 In a command or response this setting indicates that the session is for audit and that auditExclusive and auditReset have meaning. This session may also be used for authorization encryption or decryption. The encrypted and encrypt fields may be SET or CLEAR. CLEAR 0 Session is not used for audit. This attribute may only be SET in one session per command or response. If SET in the command then this attribute will be SET in the response. */
712 
713 /* Definition of UINT8 TPMA_LOCALITY Bits <INOUT> */
714 typedef UINT8 TPMA_LOCALITY;
715 
716 #define TPMA_LOCALITY_TPM2_LOC_ZERO    ((TPMA_LOCALITY) 0x00000001)
717 #define TPMA_LOCALITY_TPM2_LOC_ONE     ((TPMA_LOCALITY) 0x00000002)
718 #define TPMA_LOCALITY_TPM2_LOC_TWO     ((TPMA_LOCALITY) 0x00000004)
719 #define TPMA_LOCALITY_TPM2_LOC_THREE   ((TPMA_LOCALITY) 0x00000008)
720 #define TPMA_LOCALITY_TPM2_LOC_FOUR    ((TPMA_LOCALITY) 0x00000010)
721 #define TPMA_LOCALITY_EXTENDED_MASK    ((TPMA_LOCALITY) 0x000000E0) /* If any of these bits is set an extended locality is indicated */
722 #define TPMA_LOCALITY_EXTENDED_SHIFT   (5)
723 
724 /* Definition of UINT32 TPMA_PERMANENT Bits <OUT> */
725 typedef uint32_t TPMA_PERMANENT;
726 
727 #define TPMA_PERMANENT_OWNERAUTHSET        ((TPMA_PERMANENT) 0x00000001) /* SET 1 TPM2_HierarchyChangeAuth with ownerAuth has been executed since the last TPM2_Clear. CLEAR 0 ownerAuth has not been changed since TPM2_Clear. */
728 #define TPMA_PERMANENT_ENDORSEMENTAUTHSET  ((TPMA_PERMANENT) 0x00000002) /* SET 1 TPM2_HierarchyChangeAuth with endorsementAuth has been executed since the last TPM2_Clear. CLEAR 0 endorsementAuth has not been changed since TPM2_Clear. */
729 #define TPMA_PERMANENT_LOCKOUTAUTHSET      ((TPMA_PERMANENT) 0x00000004) /* SET 1 TPM2_HierarchyChangeAuth with lockoutAuth has been executed since the last TPM2_Clear. CLEAR 0 lockoutAuth has not been changed since TPM2_Clear. */
730 #define TPMA_PERMANENT_RESERVED1_MASK      ((TPMA_PERMANENT) 0x000000F8)
731 #define TPMA_PERMANENT_DISABLECLEAR        ((TPMA_PERMANENT) 0x00000100) /* SET 1 TPM2_Clear is disabled. CLEAR 0 TPM2_Clear is enabled. NOTE See TPM2_ClearControl in TPM 2.0 Part 3 for details on changing this attribute. */
732 #define TPMA_PERMANENT_INLOCKOUT           ((TPMA_PERMANENT) 0x00000200) /* SET 1 The TPM is in lockout and commands that require authorization with other than Platform Authorization or Lockout Authorization will not succeed. */
733 #define TPMA_PERMANENT_TPMGENERATEDEPS     ((TPMA_PERMANENT) 0x00000400) /* SET 1 The EPS was created by the TPM. CLEAR 0 The EPS was created outside of the TPM using a manufacturer specific process. */
734 #define TPMA_PERMANENT_RESERVED2_MASK      ((TPMA_PERMANENT) 0xFFFFF800)
735 
736 /* Definition of UINT32 TPMA_STARTUP_CLEAR Bits <OUT> */
737 typedef uint32_t TPMA_STARTUP_CLEAR;
738 
739 #define TPMA_STARTUP_CLEAR_PHENABLE       ((TPMA_STARTUP_CLEAR) 0x00000001) /* SET 1 The platform hierarchy is enabled and platformAuth or platformPolicy may be used for authorization. CLEAR 0 platformAuth and platformPolicy may not be used for authorizations and objects in the platform hierarchy including persistent objects cannot be used. NOTE See TPM2_HierarchyControl in TPM 2.0 Part 3 for details on changing this attribute. */
740 #define TPMA_STARTUP_CLEAR_SHENABLE       ((TPMA_STARTUP_CLEAR) 0x00000002) /* SET 1 The Storage hierarchy is enabled and ownerAuth or ownerPolicy may be used for authorization. NV indices defined using owner authorization are accessible. CLEAR 0 ownerAuth and ownerPolicy may not be used for authorizations and objects in the Storage hierarchy persistent objects and NV indices defined using owner authorization cannot be used. NOTE See TPM2_HierarchyControl in TPM 2.0 Part 3 for details on changing this attribute. */
741 #define TPMA_STARTUP_CLEAR_EHENABLE       ((TPMA_STARTUP_CLEAR) 0x00000004) /* SET 1 The EPS hierarchy is enabled and Endorsement Authorization may be used to authorize commands. CLEAR 0 Endorsement Authorization may not be used for authorizations and objects in the endorsement hierarchy including persistent objects cannot be used. NOTE See TPM2_HierarchyControl in TPM 2.0 Part 3 for details on changing this attribute. */
742 #define TPMA_STARTUP_CLEAR_PHENABLENV     ((TPMA_STARTUP_CLEAR) 0x00000008) /* SET 1 NV indices that have TPMA_PLATFORM_CREATE SET may be read or written. The platform can create define and undefine indices. CLEAR 0 NV indices that have TPMA_PLATFORM_CREATE SET may not be read or written TPM2_RC_HANDLE. The platform cannot  define TPM2_RC_HIERARCHY or undefined TPM2_RC_HANDLE indices. NOTE See TPM2_HierarchyControl in TPM 2.0 Part 3 for details on changing this attribute. NOTE read refers to these commands TPM2_NV_Read TPM2_NV_ReadPublic TPM_NV_Certify TPM2_PolicyNVwrite refers to these commands TPM2_NV_Write TPM2_NV_Increment TPM2_NV_Extend TPM2_NV_SetBitsNOTE The TPM must query the index TPMA_PLATFORM_CREATE attribute to determine whether phEnableNV is applicable. Since the TPM will return TPM2_RC_HANDLE if the index does not exist it also returns this error code if the index is disabled. Otherwise the TPM would leak the existence of an index even when disabled. */
743 #define TPMA_STARTUP_CLEAR_RESERVED1_MASK ((TPMA_STARTUP_CLEAR) 0x7FFFFFF0) /* shall be zero */
744 #define TPMA_STARTUP_CLEAR_ORDERLY        ((TPMA_STARTUP_CLEAR) 0x80000000) /* SET 1 The TPM received a TPM2_Shutdown and a matching TPM2_Startup. CLEAR 0 TPM2_StartupTPM2_SU_CLEAR was not preceded by a TPM2_Shutdown of any type. NOTE A shutdown is orderly if the TPM receives a TPM2_Shutdown of any type followed by a TPM2_Startup of any type. However the TPM will return an error if TPM2_StartupTPM2_SU_STATE was not preceded by TPM2_State_SaveTPM2_SU_STATE. */
745 
746 /* Definition of UINT32 TPMA_MEMORY Bits <Out> */
747 typedef uint32_t TPMA_MEMORY;
748 
749 #define TPMA_MEMORY_SHAREDRAM            ((TPMA_MEMORY) 0x00000001) /* SET 1 indicates that the RAM memory used for authorization session contexts is shared with the memory used for transient objects. CLEAR 0 indicates that the memory used for authorization sessions is not shared with memory used for transient objects */
750 #define TPMA_MEMORY_SHAREDNV             ((TPMA_MEMORY) 0x00000002) /* SET 1 indicates that the NV memory used for persistent objects is shared with the NV memory used for NV Index values. CLEAR 0 indicates that the persistent objects and NV Index values are allocated from separate sections of NV */
751 #define TPMA_MEMORY_OBJECTCOPIEDTORAM    ((TPMA_MEMORY) 0x00000004) /* SET 1 indicates that the TPM copies persistent objects to a transientobject slot in RAM when the persistent object is referenced in a command. The TRM is required to make sure that an object slot is available. CLEAR 0 indicates that the TPM does not use transientobject slots when persistent objects are referenced */
752 #define TPMA_MEMORY_RESERVED1_MASK       ((TPMA_MEMORY) 0xFFFFFFF8) /* shall be zero */
753 
754 /* Definition of TPM2_CC TPMA_CC Bits <OUT> */
755 typedef uint32_t TPMA_CC;
756 
757 #define TPMA_CC_COMMANDINDEX_MASK  ((TPMA_CC) 0x0000FFFF) /* indicates the command being selected */
758 #define TPMA_CC_COMMANDINDEX_SHIFT (0)
759 #define TPMA_CC_RESERVED1_MASK     ((TPMA_CC) 0x003F0000) /* shall be zero */
760 #define TPMA_CC_NV                 ((TPMA_CC) 0x00400000) /* SET 1 indicates that the command may write to NV. CLEAR 0 indicates that the command does not write to NV */
761 #define TPMA_CC_EXTENSIVE          ((TPMA_CC) 0x00800000) /* SET 1 This command could flush any number of loaded contexts. CLEAR 0 no additional changes other than indicated by the flushed attribute */
762 #define TPMA_CC_FLUSHED            ((TPMA_CC) 0x01000000) /* SET 1 The context associated with any transient handle in the command will be flushed when this command completes. CLEAR 0 No context is flushed as a side effect of this command. */
763 #define TPMA_CC_CHANDLES_MASK      ((TPMA_CC) 0x0E000000) /* indicates the number of the handles in the handle area for this command */
764 #define TPMA_CC_CHANDLES_SHIFT     (25)
765 #define TPMA_CC_RHANDLE            ((TPMA_CC) 0x10000000) /* SET 1 indicates the presence of the handle area in the response */
766 #define TPMA_CC_V                  ((TPMA_CC) 0x20000000) /* SET 1 indicates that the command is vendor-specific. CLEAR 0 indicates that the command is defined in a version of this specification */
767 #define TPMA_CC_RES_MASK           ((TPMA_CC) 0xC0000000) /* allocated for software shall be zero */
768 #define TPMA_CC_RES_SHIFT          (30)
769 
770 /* Definition of UINT32 TPMA_MODES Bits <Out> */
771 typedef uint32_t TPMA_MODES;
772 
773 #define TPMA_MODES_FIPS_140_2     ((TPMA_MODES) 0x00000001) /* SET 1 indicates that the TPM is designed to comply with all of the FIPS 1402 requirements at Level 1 or higher. */
774 #define TPMA_MODES_RESERVED1_MASK ((TPMA_MODES) 0xFFFFFFFE) /* shall be zero */
775 
776 /* Definition of UINT32 TPMA_X509_KEY_USAGE Bits */
777 typedef uint32_t TPMA_X509_KEY_USAGE;
778 
779 #define TPMA_X509_KEY_USAGE_RESERVED_MASK    ((TPMA_X509_KEY_USAGE) 0x007FFFFF) /* shall be zero */
780 #define TPMA_X509_KEY_USAGE_DECIPHER_ONLY    ((TPMA_X509_KEY_USAGE) 0x00800000) /* As described in RFC5280. Requires objct attributes.Decrypt to be SET */
781 #define TPMA_X509_KEY_USAGE_ENCIPHER_ONLY    ((TPMA_X509_KEY_USAGE) 0x01000000) /* As described in RFC5280. Requires objct attributes.Decrypt to be SET */
782 #define TPMA_X509_KEY_USAGE_CRLSIGN          ((TPMA_X509_KEY_USAGE) 0x02000000) /* As described in RFC5280. Requires objct attributes.Sign to be SET */
783 #define TPMA_X509_KEY_USAGE_KEYCERTSIGN      ((TPMA_X509_KEY_USAGE) 0x04000000) /* As described in RFC5280. Requires objct attributes.Sign to be SET */
784 #define TPMA_X509_KEY_USAGE_KEYAGREEMENT     ((TPMA_X509_KEY_USAGE) 0x08000000) /* As described in RFC5280. Requires objct attributes.Decrypt to be SET */
785 #define TPMA_X509_KEY_USAGE_DATAENCIPHERMENT ((TPMA_X509_KEY_USAGE) 0x10000000) /* As described in RFC5280. Requires objct attributes.Decrypt to be SET */
786 #define TPMA_X509_KEY_USAGE_KEYENCIPHERMENT  ((TPMA_X509_KEY_USAGE) 0x20000000) /* As described in RFC5280. Requires objct attributes.Decrypt and Restricted to be SET */
787 #define TPMA_X509_KEY_USAGE_NONREPUDIATION   ((TPMA_X509_KEY_USAGE) 0x40000000) /* As described in RFC5280. Requires objct attributes.fixedTPM to be SET in the SubjectKey */
788 #define TPMA_X509_KEY_USAGE_DIGITALSIGNATURE ((TPMA_X509_KEY_USAGE) 0x80000000) /* As described in RFC5280. Requires objct attributes.Sign to be SET in the SubjectKey */
789 
790 /* Definition of UINT32 TPMA_ACT Bits */
791 typedef uint32_t TPMA_ACT;
792 
793 #define TPMA_ACT_SIGNALED         ((TPMA_ACT) 0x00000000) /* SET 1 The ACT has signaled. CLEAR 0 The ACT has not signaled */
794 #define TPMA_ACT_PRESERVESIGNALED ((TPMA_ACT) 0x00000001) /* SET 1 The ACT signaled bit is preserved over a power cycle. CLEAR 0 The ACT signaled bit is not preserved over a power cycle */
795 #define TPMA_ACT_RESERVED_MASK    ((TPMA_ACT) 0xFFFFFFFC) /* shall be zero */
796 
797 /* Definition of BYTE TPMI_YES_NO Type */
798 typedef BYTE TPMI_YES_NO;
799 #define TPM2_NO  0 /* a value of 0 */
800 #define TPM2_YES 1 /* a value of 1 */
801 
802 /* Definition of TPM2_HANDLE TPMI_DH_OBJECT Type */
803 typedef TPM2_HANDLE TPMI_DH_OBJECT;
804 
805 /* Definition of TPM2_HANDLE TPMI_DH_PERSISTENT Type */
806 typedef TPM2_HANDLE TPMI_DH_PERSISTENT;
807 
808 /* Definition of TPM2_HANDLE TPMI_DH_ENTITY Type <IN> */
809 typedef TPM2_HANDLE TPMI_DH_ENTITY;
810 
811 /* Definition of TPM2_HANDLE TPMI_DH_PCR Type <IN> */
812 typedef TPM2_HANDLE TPMI_DH_PCR;
813 
814 /* Definition of TPM2_HANDLE TPMI_SH_AUTH_SESSION Type <INOUT> */
815 typedef TPM2_HANDLE TPMI_SH_AUTH_SESSION;
816 
817 /* Definition of TPM2_HANDLE TPMI_SH_HMAC Type <INOUT> */
818 typedef TPM2_HANDLE TPMI_SH_HMAC;
819 
820 /* Definition of TPM2_HANDLE TPMI_SH_POLICY Type <INOUT> */
821 typedef TPM2_HANDLE TPMI_SH_POLICY;
822 
823 /* Definition of TPM2_HANDLE TPMI_DH_CONTEXT Type */
824 typedef TPM2_HANDLE TPMI_DH_CONTEXT;
825 
826 /* Definition of TPM2_HANDLE TPMI_DH_SAVED Type */
827 typedef TPM2_HANDLE TPMI_DH_SAVED;
828 #define TPMI_DH_SAVED_TRANSIENT       ((TPMI_DH_SAVED) 0x80000000) /* an ordinary transient object */
829 #define TPMI_DH_SAVED_SEQUENCE        ((TPMI_DH_SAVED) 0x80000001) /* a sequence object */
830 #define TPMI_DH_SAVED_TRANSIENT_CLEAR ((TPMI_DH_SAVED) 0x80000002) /* a transient object with the stClear attribute SET */
831 
832 /* Definition of TPM2_HANDLE TPMI_RH_HIERARCHY Type */
833 typedef TPM2_HANDLE TPMI_RH_HIERARCHY;
834 
835 /* Definition of TPM2_HANDLE TPMI_RH_ENABLES Type */
836 typedef TPM2_HANDLE TPMI_RH_ENABLES;
837 
838 /* Definition of TPM2_HANDLE TPMI_RH_HIERARCHY_AUTH Type <IN> */
839 typedef TPM2_HANDLE TPMI_RH_HIERARCHY_AUTH;
840 
841 /* Definition of TPM2_HANDLE TPMI_RH_HIERARCHY_POLICY Type <IN> */
842 typedef TPM2_HANDLE TPMI_RH_HIERARCHY_POLICY;
843 
844 /* Definition of TPM2_HANDLE TPMI_RH_PLATFORM Type <IN> */
845 typedef TPM2_HANDLE TPMI_RH_PLATFORM;
846 
847 /* Definition of TPM2_HANDLE TPMI_RH_OWNER Type <IN> */
848 typedef TPM2_HANDLE TPMI_RH_OWNER;
849 
850 /* Definition of TPM2_HANDLE TPMI_RH_ENDORSEMENT Type <IN> */
851 typedef TPM2_HANDLE TPMI_RH_ENDORSEMENT;
852 
853 /* Definition of TPM2_HANDLE TPMI_RH_PROVISION Type <IN> */
854 typedef TPM2_HANDLE TPMI_RH_PROVISION;
855 
856 /* Definition of TPM2_HANDLE TPMI_RH_CLEAR Type <IN> */
857 typedef TPM2_HANDLE TPMI_RH_CLEAR;
858 
859 /* Definition of TPM2_HANDLE TPMI_RH_NV_AUTH Type <IN> */
860 typedef TPM2_HANDLE TPMI_RH_NV_AUTH;
861 
862 /* Definition of TPM2_HANDLE TPMI_RH_LOCKOUT Type <IN> */
863 typedef TPM2_HANDLE TPMI_RH_LOCKOUT;
864 
865 /* Definition of TPM2_HANDLE TPMI_RH_NV_INDEX Type <INOUT> */
866 typedef TPM2_HANDLE TPMI_RH_NV_INDEX;
867 
868 /* Definition of TPM2_HANDLE TPMI_RH_AC Type <IN> */
869 typedef TPM2_HANDLE TPMI_RH_AC; /* Interface used to identify an attached component */
870 
871 /* Definition of TPM2_HANDLE TPMI_RH_AC Type */
872 typedef TPM2_HANDLE TPMI_RH_ACT;
873 
874 /* Definition of TPM2_ALG_ID TPMI_ALG_HASH Type */
875 typedef TPM2_ALG_ID TPMI_ALG_HASH;
876 
877 /* Definition of TPM2_ALG_ID TPMI_ALG_ASYM Type */
878 typedef TPM2_ALG_ID TPMI_ALG_ASYM;
879 
880 /* Definition of TPM2_ALG_ID TPMI_ALG_SYM Type */
881 typedef TPM2_ALG_ID TPMI_ALG_SYM;
882 
883 /* Definition of TPM2_ALG_ID TPMI_ALG_SYM_OBJECT Type */
884 typedef TPM2_ALG_ID TPMI_ALG_SYM_OBJECT;
885 
886 /* Definition of TPM2_ALG_ID TPMI_ALG_SYM_MODE Type */
887 typedef TPM2_ALG_ID TPMI_ALG_SYM_MODE;
888 
889 /* Definition of TPM2_ALG_ID TPMI_ALG_KDF Type */
890 typedef TPM2_ALG_ID TPMI_ALG_KDF;
891 
892 /* Definition of TPM2_ALG_ID TPMI_ALG_SIG_SCHEME Type */
893 typedef TPM2_ALG_ID TPMI_ALG_SIG_SCHEME;
894 
895 /* Definition of TPM2_ALG_IDECC TPMI_ECC_KEY_EXCHANGE Type */
896 typedef TPM2_ALG_ID TPMI_ECC_KEY_EXCHANGE;
897 
898 /* Definition of TPM2_ST TPMI_ST_COMMAND_TAG Type */
899 typedef TPM2_ST TPMI_ST_COMMAND_TAG;
900 
901 /* Definition of TPM2_ALG_ID TPMI_ALG_MAC_SCHEME Type */
902 typedef TPM2_ALG_ID TPMI_ALG_MAC_SCHEME;
903 
904 /* Definition of TPM2_ALG_ID TPMI_ALG_CIPHER_MODE Type */
905 typedef TPM2_ALG_ID TPMI_ALG_CIPHER_MODE;
906 
907 /* Definition of TPMS_EMPTY Structure <INOUT> */
908 typedef struct TPMS_EMPTY TPMS_EMPTY;
909 struct TPMS_EMPTY {
910     BYTE empty[1]; /* a structure with no member */
911 };
912 
913 /* Definition of TPMS_ALGORITHM_DESCRIPTION Structure <OUT> */
914 typedef struct TPMS_ALGORITHM_DESCRIPTION TPMS_ALGORITHM_DESCRIPTION;
915 struct TPMS_ALGORITHM_DESCRIPTION {
916     TPM2_ALG_ID alg;            /* an algorithm */
917     TPMA_ALGORITHM  attributes; /* the attributes of the algorithm */
918 };
919 
920 /* Definition of TPMU_HA Union <INOUT S> */
921 typedef union TPMU_HA TPMU_HA;
922 union TPMU_HA {
923     BYTE sha1[TPM2_SHA1_DIGEST_SIZE];
924     BYTE sha256[TPM2_SHA256_DIGEST_SIZE];
925     BYTE sha384[TPM2_SHA384_DIGEST_SIZE];
926     BYTE sha512[TPM2_SHA512_DIGEST_SIZE];
927     BYTE sm3_256[TPM2_SM3_256_DIGEST_SIZE];
928 };
929 
930 /* Definition of TPMT_HA Structure <INOUT> */
931 typedef struct TPMT_HA TPMT_HA;
932 struct TPMT_HA {
933     TPMI_ALG_HASH hashAlg; /* selector of the hash contained in the digest that implies the size of the digest. NOTE The leading + on the type indicates that this structure should pass an indication to the unmarshaling function for TPMI_ALG_HASH so that TPM2_ALG_NULL will be allowed if a use of a TPMT_HA allows TPM2_ALG_NULL. */
934     TPMU_HA digest;        /* the digest data */
935 };
936 
937 /* Definition of TPM2B_DIGEST Structure */
938 typedef struct TPM2B_DIGEST TPM2B_DIGEST;
939 struct TPM2B_DIGEST {
940     UINT16 size;
941     BYTE buffer[sizeof(TPMU_HA)];
942 };
943 
944 /* Definition of TPM2B_DATA Structure */
945 typedef struct TPM2B_DATA TPM2B_DATA;
946 struct TPM2B_DATA {
947     UINT16 size;
948     BYTE buffer[sizeof(TPMU_HA)];
949 };
950 
951 /* Definition of Types for TPM2B_NONCE */
952 typedef TPM2B_DIGEST  TPM2B_NONCE; /* size limited to the same as the digest structure */
953 
954 /* Definition of Types for TPM2B_AUTH */
955 typedef TPM2B_DIGEST  TPM2B_AUTH; /* size limited to the same as the digest structure */
956 
957 /* Definition of Types for TPM2B_OPERAND */
958 typedef TPM2B_DIGEST  TPM2B_OPERAND; /* size limited to the same as the digest structure */
959 
960 /* Definition of TPM2B_EVENT Structure */
961 typedef struct TPM2B_EVENT TPM2B_EVENT;
962 struct TPM2B_EVENT {
963     UINT16 size;
964     BYTE buffer[1024];
965 };
966 
967 /* Definition of TPM2B_MAX_BUFFER Structure */
968 typedef struct TPM2B_MAX_BUFFER TPM2B_MAX_BUFFER;
969 struct TPM2B_MAX_BUFFER {
970     UINT16 size;
971     BYTE buffer[TPM2_MAX_DIGEST_BUFFER];
972 };
973 
974 /* Definition of TPM2B_MAX_NV_BUFFER Structure */
975 typedef struct TPM2B_MAX_NV_BUFFER TPM2B_MAX_NV_BUFFER;
976 struct TPM2B_MAX_NV_BUFFER {
977     UINT16 size;
978     BYTE buffer[TPM2_MAX_NV_BUFFER_SIZE];
979 };
980 
981 /* Definition of Types for TPM2B_TIMEOUT */
982 typedef TPM2B_DIGEST  TPM2B_TIMEOUT; /* size limited to the same as the digest structure */
983 
984 /* Definition of TPM2B_IV Structure <INOUT> */
985 typedef struct TPM2B_IV TPM2B_IV;
986 struct TPM2B_IV {
987     UINT16 size;
988     BYTE buffer[TPM2_MAX_SYM_BLOCK_SIZE];
989 };
990 
991 /* Definition of TPMU_NAME Union <> */
992 typedef union TPMU_NAME TPMU_NAME;
993 union TPMU_NAME {
994     TPMT_HA digest;     /* when the Name is a digest */
995     TPM2_HANDLE handle; /* when the Name is a handle */
996 };
997 
998 /* Definition of TPM2B_NAME Structure */
999 typedef struct TPM2B_NAME TPM2B_NAME;
1000 struct TPM2B_NAME {
1001     UINT16 size;
1002     BYTE name[sizeof(TPMU_NAME)];
1003 };
1004 
1005 /* Definition of TPMS_PCR_SELECT Structure */
1006 typedef struct TPMS_PCR_SELECT TPMS_PCR_SELECT;
1007 struct TPMS_PCR_SELECT {
1008     UINT8 sizeofSelect;                  /* the size in octets of the pcrSelect array */
1009     BYTE pcrSelect[TPM2_PCR_SELECT_MAX]; /* the bit map of selected PCR */
1010 };
1011 
1012 /* Definition of TPMS_PCR_SELECTION Structure */
1013 typedef struct TPMS_PCR_SELECTION TPMS_PCR_SELECTION;
1014 struct TPMS_PCR_SELECTION {
1015     TPMI_ALG_HASH hash; /* the hash algorithm associated with the selection */
1016     UINT8 sizeofSelect; /* the size in octets of the pcrSelect array */
1017     BYTE pcrSelect[TPM2_PCR_SELECT_MAX]; /* the bit map of selected PCR */
1018 };
1019 
1020 /* Definition of TPMT_TK_CREATION Structure */
1021 typedef struct TPMT_TK_CREATION TPMT_TK_CREATION;
1022 struct TPMT_TK_CREATION {
1023     TPM2_ST tag;                 /* ticket structure tag */
1024     TPMI_RH_HIERARCHY hierarchy; /* the hierarchy containing name */
1025     TPM2B_DIGEST digest;         /* This shall be the HMAC produced using a proof value of hierarchy. */
1026 };
1027 
1028 /* Definition of TPMT_TK_VERIFIED Structure */
1029 typedef struct TPMT_TK_VERIFIED TPMT_TK_VERIFIED;
1030 struct TPMT_TK_VERIFIED {
1031     TPM2_ST tag;                 /* ticket structure tag */
1032     TPMI_RH_HIERARCHY hierarchy; /* the hierarchy containing keyName */
1033     TPM2B_DIGEST digest;         /* This shall be the HMAC produced using a proof value of hierarchy. */
1034 };
1035 
1036 /* Definition of TPMT_TK_AUTH Structure */
1037 typedef struct TPMT_TK_AUTH TPMT_TK_AUTH;
1038 struct TPMT_TK_AUTH {
1039     TPM2_ST tag;                 /* ticket structure tag */
1040     TPMI_RH_HIERARCHY hierarchy; /* the hierarchy of the object used to produce the ticket */
1041     TPM2B_DIGEST digest;         /* This shall be the HMAC produced using a proof value of hierarchy. */
1042 };
1043 
1044 /* Definition of TPMT_TK_HASHCHECK Structure */
1045 typedef struct TPMT_TK_HASHCHECK TPMT_TK_HASHCHECK;
1046 struct TPMT_TK_HASHCHECK {
1047     TPM2_ST tag;                 /* ticket structure tag */
1048     TPMI_RH_HIERARCHY hierarchy; /* the hierarchy */
1049     TPM2B_DIGEST digest;         /* This shall be the HMAC produced using a proof value of hierarchy. */
1050 };
1051 
1052 /* Definition of TPMS_ALG_PROPERTY Structure <OUT> */
1053 typedef struct TPMS_ALG_PROPERTY TPMS_ALG_PROPERTY;
1054 struct TPMS_ALG_PROPERTY {
1055     TPM2_ALG_ID alg;               /* an algorithm identifier */
1056     TPMA_ALGORITHM algProperties;  /* the attributes of the algorithm */
1057 };
1058 
1059 /* Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */
1060 typedef struct TPMS_TAGGED_PROPERTY TPMS_TAGGED_PROPERTY;
1061 struct TPMS_TAGGED_PROPERTY {
1062     TPM2_PT property; /* a property identifier */
1063     UINT32 value;     /* the value of the property */
1064 };
1065 
1066 /* Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */
1067 typedef struct TPMS_TAGGED_PCR_SELECT TPMS_TAGGED_PCR_SELECT;
1068 struct TPMS_TAGGED_PCR_SELECT {
1069     TPM2_PT_PCR tag; /* the property identifier */
1070     UINT8 sizeofSelect; /* the size in octets of the pcrSelect array */
1071     BYTE pcrSelect[TPM2_PCR_SELECT_MAX]; /* the bit map of PCR with the identified property */
1072 };
1073 
1074 /* Definition of TPMS_TAGGED_POLICY Structure */
1075 typedef struct TPMS_TAGGED_POLICY TPMS_TAGGED_POLICY;
1076 struct TPMS_TAGGED_POLICY {
1077     TPM2_HANDLE handle;
1078     TPMT_HA policyHash;
1079 };
1080 
1081 /* Definition of TPMS_ACT_DATA Structure <OUT> */
1082 typedef struct TPMS_ACT_DATA TPMS_ACT_DATA;
1083 struct TPMS_ACT_DATA {
1084     TPM2_HANDLE handle;
1085     UINT32 timeout;
1086     TPMA_ACT attributes;
1087 };
1088 
1089 /* Definition of TPML_CC Structure */
1090 typedef struct TPML_CC TPML_CC;
1091 struct TPML_CC {
1092     UINT32 count; /* number of commands in the commandCode list may be 0 */
1093     TPM2_CC commandCodes[TPM2_MAX_CAP_CC]; /* a list of command codes. The maximum only applies to a command code list in a command. The response size is limited only by the size of the parameter buffer. */
1094 };
1095 
1096 /* Definition of TPML_CCA Structure <OUT> */
1097 typedef struct TPML_CCA TPML_CCA;
1098 struct TPML_CCA {
1099     UINT32 count;     /* number of values in the commandAttributes list may be 0 */
1100     TPMA_CC commandAttributes[TPM2_MAX_CAP_CC]; /* a list of command codes attributes */
1101 };
1102 
1103 /* Definition of TPML_ALG Structure */
1104 typedef struct TPML_ALG TPML_ALG;
1105 struct TPML_ALG {
1106     UINT32 count; /* number of algorithms in the algorithms list may be 0 */
1107     TPM2_ALG_ID algorithms[TPM2_MAX_ALG_LIST_SIZE]; /* a list of algorithm IDs. The maximum only applies to an algorithm list in a command. The response size is limited only by the size of the parameter buffer. */
1108 };
1109 
1110 /* Definition of TPML_HANDLE Structure <OUT> */
1111 typedef struct TPML_HANDLE TPML_HANDLE;
1112 struct TPML_HANDLE {
1113     UINT32 count; /* the number of handles in the list. May have a value of 0 */
1114     TPM2_HANDLE handle[TPM2_MAX_CAP_HANDLES]; /* an array of handles */
1115 };
1116 
1117 /* Definition of TPML_DIGEST Structure */
1118 typedef struct TPML_DIGEST TPML_DIGEST;
1119 struct TPML_DIGEST {
1120     UINT32 count; /* number of digests in the list minimum is two for TPM2_PolicyOR. */
1121     TPM2B_DIGEST digests[8]; /* a list of digestsFor TPM2_PolicyOR all digests will have been computed using the digest of the policy session. For TPM2_PCR_Read each digest will be the size of the digest for the bank containing the PCR. */
1122 };
1123 
1124 /* Definition of TPML_DIGEST_VALUES Structure */
1125 typedef struct TPML_DIGEST_VALUES TPML_DIGEST_VALUES;
1126 struct TPML_DIGEST_VALUES {
1127     UINT32 count; /* number of digests in the list */
1128     TPMT_HA digests[TPM2_NUM_PCR_BANKS]; /* a list of tagged digests */
1129 };
1130 
1131 /* Definition of TPML_PCR_SELECTION Structure */
1132 typedef struct TPML_PCR_SELECTION TPML_PCR_SELECTION;
1133 struct TPML_PCR_SELECTION {
1134     UINT32 count; /* number of selection structures. A value of zero is allowed. */
1135     TPMS_PCR_SELECTION pcrSelections[TPM2_NUM_PCR_BANKS]; /* list of selections */
1136 };
1137 
1138 /* Definition of TPML_ALG_PROPERTY Structure <OUT> */
1139 typedef struct TPML_ALG_PROPERTY TPML_ALG_PROPERTY;
1140 struct TPML_ALG_PROPERTY {
1141     UINT32 count; /* number of algorithm properties structures. A value of zero is allowed. */
1142     TPMS_ALG_PROPERTY algProperties[TPM2_MAX_CAP_ALGS]; /* list of properties */
1143 };
1144 
1145 /* Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */
1146 typedef struct TPML_TAGGED_TPM_PROPERTY TPML_TAGGED_TPM_PROPERTY;
1147 struct TPML_TAGGED_TPM_PROPERTY {
1148     UINT32 count; /* number of properties. A value of zero is allowed. */
1149     TPMS_TAGGED_PROPERTY tpmProperty[TPM2_MAX_TPM_PROPERTIES]; /* an array of tagged properties */
1150 };
1151 
1152 /* Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */
1153 typedef struct TPML_TAGGED_PCR_PROPERTY TPML_TAGGED_PCR_PROPERTY;
1154 struct TPML_TAGGED_PCR_PROPERTY {
1155     UINT32 count; /* number of properties. A value of zero is allowed. */
1156     TPMS_TAGGED_PCR_SELECT pcrProperty[TPM2_MAX_PCR_PROPERTIES]; /* a tagged PCR selection */
1157 };
1158 
1159 /* Definition of ECC TPML_ECC_CURVE Structure <OUT> */
1160 typedef struct TPML_ECC_CURVE TPML_ECC_CURVE;
1161 struct TPML_ECC_CURVE {
1162     UINT32 count; /* number of curves. A value of zero is allowed. */
1163     TPM2_ECC_CURVE eccCurves[TPM2_MAX_ECC_CURVES]; /* array of ECC curve identifiers */
1164 };
1165 
1166 /* Definition of ECC TPML_TAGGED_POLICY Structure <OUT> */
1167 typedef struct TPML_TAGGED_POLICY TPML_TAGGED_POLICY;
1168 struct TPML_TAGGED_POLICY {
1169     UINT32 count; /* number of tagged policies. A value of zero is allowed. */
1170     TPMS_TAGGED_POLICY policies[TPM2_MAX_TAGGED_POLICIES]; /* array of tagged policies */
1171 };
1172 
1173 /* Definition of ECC TPML_ACT_DATA Structure <OUT> */
1174 typedef struct TPML_ACT_DATA TPML_ACT_DATA;
1175 struct TPML_ACT_DATA {
1176     UINT32 count; /* number of ACT instances. A value of zero is allowed. */
1177     TPMS_ACT_DATA actData[TPM2_MAX_ACT_DATA]; /* array of array of ACT data */
1178 };
1179 
1180 /* Implementation specific structure to hold Intel PTT specific property data. */
1181 typedef struct TPML_INTEL_PTT_PROPERTY TPML_INTEL_PTT_PROPERTY;
1182 struct TPML_INTEL_PTT_PROPERTY {
1183     UINT32 count;                             /* number of properties zero is allowed. */
1184     UINT32 property[TPM2_MAX_PTT_PROPERTIES]; /* property value */
1185 };
1186 
1187 /* Definition of TPMU_CAPABILITIES Union <OUT> */
1188 typedef union TPMU_CAPABILITIES TPMU_CAPABILITIES;
1189 union TPMU_CAPABILITIES {
1190     TPML_ALG_PROPERTY algorithms;
1191     TPML_HANDLE handles;
1192     TPML_CCA command;
1193     TPML_CC ppCommands;
1194     TPML_CC auditCommands;
1195     TPML_PCR_SELECTION assignedPCR;
1196     TPML_TAGGED_TPM_PROPERTY tpmProperties;
1197     TPML_TAGGED_PCR_PROPERTY pcrProperties;
1198     TPML_ECC_CURVE eccCurves;
1199     TPML_INTEL_PTT_PROPERTY intelPttProperty;
1200 };
1201 
1202 /* Definition of TPMS_CAPABILITY_DATA Structure <OUT> */
1203 typedef struct TPMS_CAPABILITY_DATA TPMS_CAPABILITY_DATA;
1204 struct TPMS_CAPABILITY_DATA {
1205     TPM2_CAP capability;     /* the capability */
1206     TPMU_CAPABILITIES data;  /* the capability data */
1207 };
1208 
1209 /* Definition of TPMS_CLOCK_INFO Structure */
1210 typedef struct TPMS_CLOCK_INFO TPMS_CLOCK_INFO;
1211 struct TPMS_CLOCK_INFO {
1212     UINT64 clock;        /* time in milliseconds during which the TPM has been powered. This structure element is used to report on the TPMs Clock value. The value of Clock shall be recorded in nonvolatile memory no less often than once per 69.9 minutes, 222 milliseconds of TPM operation. The reference for the millisecond timer is the TPM oscillator. This value is reset to zero when the Storage Primary Seed is changed TPM2_Clear. This value may be advanced by TPM2_AdvanceClock. */
1213     UINT32 resetCount;   /* number of occurrences of TPM Reset since the last TPM2_Clear */
1214     UINT32 restartCount; /* number of times that TPM2_Shutdown or _TPM_Hash_Start have occurred since the last TPM Reset or TPM2_Clear. */
1215     TPMI_YES_NO safe;    /* no value of Clock greater than the current value of Clock has been previously reported by the TPM. Set to YES on TPM2_Clear. */
1216 };
1217 
1218 /* Definition of TPMS_TIME_INFO Structure */
1219 typedef struct TPMS_TIME_INFO TPMS_TIME_INFO;
1220 struct TPMS_TIME_INFO {
1221     UINT64 time;               /* time in milliseconds since the last _TPM_Init or TPM2_Startup. This structure element is used to report on the TPMs Time value. */
1222     TPMS_CLOCK_INFO clockInfo; /* a structure containing the clock information */
1223 };
1224 
1225 /* Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */
1226 typedef struct TPMS_TIME_ATTEST_INFO TPMS_TIME_ATTEST_INFO;
1227 struct TPMS_TIME_ATTEST_INFO {
1228     TPMS_TIME_INFO time;    /* the Time Clock resetCount restartCount and Safe indicator */
1229     UINT64 firmwareVersion; /* a TPM vendor-specific value indicating the version number of the firmware */
1230 };
1231 
1232 /* Definition of TPMS_CERTIFY_INFO Structure <OUT> */
1233 typedef struct TPMS_CERTIFY_INFO TPMS_CERTIFY_INFO;
1234 struct TPMS_CERTIFY_INFO {
1235     TPM2B_NAME name;          /* Name of the certified object */
1236     TPM2B_NAME qualifiedName; /* Qualified Name of the certified object */
1237 };
1238 
1239 /* Definition of TPMS_QUOTE_INFO Structure <OUT> */
1240 typedef struct TPMS_QUOTE_INFO TPMS_QUOTE_INFO;
1241 struct TPMS_QUOTE_INFO {
1242     TPML_PCR_SELECTION pcrSelect; /* information on algID PCR selected and digest */
1243     TPM2B_DIGEST pcrDigest;       /* digest of the selected PCR using the hash of the signing key */
1244 };
1245 
1246 /* Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */
1247 typedef struct TPMS_COMMAND_AUDIT_INFO TPMS_COMMAND_AUDIT_INFO;
1248 struct TPMS_COMMAND_AUDIT_INFO {
1249     UINT64 auditCounter;        /* the monotonic audit counter */
1250     TPM2_ALG_ID digestAlg;      /* hash algorithm used for the command audit */
1251     TPM2B_DIGEST auditDigest;   /* the current value of the audit digest */
1252     TPM2B_DIGEST commandDigest; /* digest of the command codes being audited using digestAlg */
1253 };
1254 
1255 /* Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */
1256 typedef struct TPMS_SESSION_AUDIT_INFO TPMS_SESSION_AUDIT_INFO;
1257 struct TPMS_SESSION_AUDIT_INFO {
1258     TPMI_YES_NO exclusiveSession; /* current exclusive status of the session. TRUE if all of the commands recorded in the sessionDigest were executed without any intervening TPM command that did not use this audit session */
1259     TPM2B_DIGEST sessionDigest;   /* the current value of the session audit digest */
1260 };
1261 
1262 /* Definition of TPMS_CREATION_INFO Structure <OUT> */
1263 typedef struct TPMS_CREATION_INFO TPMS_CREATION_INFO;
1264 struct TPMS_CREATION_INFO {
1265     TPM2B_NAME objectName;     /* Name of the object */
1266     TPM2B_DIGEST creationHash; /* creationHash */
1267 };
1268 
1269 /* Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */
1270 typedef struct TPMS_NV_CERTIFY_INFO TPMS_NV_CERTIFY_INFO;
1271 struct TPMS_NV_CERTIFY_INFO {
1272     TPM2B_NAME indexName;           /* Name of the NV Index */
1273     UINT16 offset;                  /* the offset parameter of TPM2_NV_Certify */
1274     TPM2B_MAX_NV_BUFFER nvContents; /* contents of the NV Index */
1275 };
1276 
1277 /* Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */
1278 typedef struct TPMS_NV_DIGEST_CERTIFY_INFO TPMS_NV_DIGEST_CERTIFY_INFO;
1279 struct TPMS_NV_DIGEST_CERTIFY_INFO {
1280     TPM2B_NAME indexName;      /* Name of the NV Index */
1281     TPM2B_DIGEST nvDigest;     /* hash of the contents of the index */
1282 };
1283 
1284 /* Definition of TPM2_ST TPMI_ST_ATTEST Type <OUT> */
1285 typedef TPM2_ST TPMI_ST_ATTEST;
1286 
1287 /* Definition of TPMU_ATTEST Union <OUT> */
1288 typedef union TPMU_ATTEST TPMU_ATTEST;
1289 union TPMU_ATTEST {
1290     TPMS_CERTIFY_INFO certify;
1291     TPMS_CREATION_INFO creation;
1292     TPMS_QUOTE_INFO quote;
1293     TPMS_COMMAND_AUDIT_INFO commandAudit;
1294     TPMS_SESSION_AUDIT_INFO sessionAudit;
1295     TPMS_TIME_ATTEST_INFO time;
1296     TPMS_NV_CERTIFY_INFO nv;
1297 };
1298 
1299 /* Definition of TPMS_ATTEST Structure <OUT> */
1300 typedef struct TPMS_ATTEST TPMS_ATTEST;
1301 struct TPMS_ATTEST {
1302     TPM2_GENERATED magic;       /* the indication that this structure was created by a TPM always TPM2_GENERATED_VALUE */
1303     TPMI_ST_ATTEST type;        /* type of the attestation structure */
1304     TPM2B_NAME qualifiedSigner; /* Qualified Name of the signing key */
1305     TPM2B_DATA extraData;       /* external information supplied by caller. NOTE A TPM2B_DATA structure provides room for a digest and a method indicator to indicate the components of the digest. The definition of this method indicator is outside the scope of this specification. */
1306     TPMS_CLOCK_INFO clockInfo;  /* Clock resetCount restartCount and Safe */
1307     UINT64 firmwareVersion;     /* TPM vendor-specific value identifying the version number of the firmware */
1308     TPMU_ATTEST attested;       /* the type-specific attestation information */
1309 };
1310 
1311 /* Definition of TPM2B_ATTEST Structure <OUT> */
1312 typedef struct TPM2B_ATTEST TPM2B_ATTEST;
1313 struct TPM2B_ATTEST {
1314     UINT16 size;
1315     BYTE attestationData[sizeof(TPMS_ATTEST)];
1316 };
1317 
1318 /* Definition of TPMS_AUTH_COMMAND Structure <IN> */
1319 typedef struct TPMS_AUTH_COMMAND TPMS_AUTH_COMMAND;
1320 struct TPMS_AUTH_COMMAND {
1321     TPMI_SH_AUTH_SESSION sessionHandle; /* the session handle */
1322     TPM2B_NONCE nonce;                  /* the session nonce may be the Empty Buffer */
1323     TPMA_SESSION sessionAttributes;     /* the session attributes */
1324     TPM2B_AUTH hmac;                    /* either an HMAC a password or an EmptyAuth */
1325 };
1326 
1327 /* Definition of TPMS_AUTH_RESPONSE Structure <OUT> */
1328 typedef struct TPMS_AUTH_RESPONSE TPMS_AUTH_RESPONSE;
1329 struct TPMS_AUTH_RESPONSE {
1330     TPM2B_NONCE nonce;              /* the session nonce may be the Empty Buffer */
1331     TPMA_SESSION sessionAttributes; /* the session attributes */
1332     TPM2B_AUTH hmac;                /* either an HMAC or an EmptyAuth */
1333 };
1334 
1335 /* Definition of  AES TPM2_KEY_BITS TPMI_AES_KEY_BITS   Type */
1336 typedef TPM2_KEY_BITS TPMI_AES_KEY_BITS;
1337 
1338 /* Definition of  SM4 TPM2_KEY_BITS TPMI_SM4_KEY_BITS   Type */
1339 typedef TPM2_KEY_BITS TPMI_SM4_KEY_BITS;
1340 
1341 /* Definition of  CAMELLIA TPM2_KEY_BITS TPMI_CAMELLIA_KEY_BITS   Type */
1342 typedef TPM2_KEY_BITS TPMI_CAMELLIA_KEY_BITS;
1343 
1344 /* Definition of TPMU_SYM_KEY_BITS Union */
1345 typedef union TPMU_SYM_KEY_BITS TPMU_SYM_KEY_BITS;
1346 union TPMU_SYM_KEY_BITS {
1347     TPMI_AES_KEY_BITS aes;                /* all symmetric algorithms */
1348     TPMI_SM4_KEY_BITS sm4;                /* all symmetric algorithms */
1349     TPMI_CAMELLIA_KEY_BITS camellia;      /* all symmetric algorithms */
1350     TPM2_KEY_BITS sym;                    /* when selector may be any of the symmetric block ciphers */
1351     TPMI_ALG_HASH exclusiveOr;            /* overload for using xor. NOTE TPM2_ALG_NULL is not allowed */
1352 };
1353 
1354 /* Definition of TPMU_SYM_MODE Union */
1355 typedef union TPMU_SYM_MODE TPMU_SYM_MODE;
1356 union TPMU_SYM_MODE {
1357     TPMI_ALG_SYM_MODE aes;
1358     TPMI_ALG_SYM_MODE sm4;
1359     TPMI_ALG_SYM_MODE camellia;
1360     TPMI_ALG_SYM_MODE sym;  /* when selector may be any of the symmetric block ciphers */
1361 };
1362 
1363 /* Definition of TPMT_SYM_DEF Structure */
1364 typedef struct TPMT_SYM_DEF TPMT_SYM_DEF;
1365 struct TPMT_SYM_DEF {
1366     TPMI_ALG_SYM algorithm;    /* indicates a symmetric algorithm */
1367     TPMU_SYM_KEY_BITS keyBits; /* a supported key size */
1368     TPMU_SYM_MODE mode;        /* the mode for the key */
1369 };
1370 
1371 /* Definition of TPMT_SYM_DEF_OBJECT Structure */
1372 typedef struct TPMT_SYM_DEF_OBJECT TPMT_SYM_DEF_OBJECT;
1373 struct TPMT_SYM_DEF_OBJECT {
1374     TPMI_ALG_SYM_OBJECT algorithm; /* selects a symmetric block cipher */
1375     TPMU_SYM_KEY_BITS keyBits;     /* the key size */
1376     TPMU_SYM_MODE mode;            /* default mode */
1377 };
1378 
1379 /* Definition of TPM2B_SYM_KEY Structure */
1380 typedef struct TPM2B_SYM_KEY TPM2B_SYM_KEY;
1381 struct TPM2B_SYM_KEY {
1382     UINT16 size;
1383     BYTE buffer[TPM2_MAX_SYM_KEY_BYTES];
1384 };
1385 
1386 /* Definition of TPMS_SYMCIPHER_PARMS Structure */
1387 typedef struct TPMS_SYMCIPHER_PARMS TPMS_SYMCIPHER_PARMS;
1388 struct TPMS_SYMCIPHER_PARMS {
1389     TPMT_SYM_DEF_OBJECT sym;   /* a symmetric block cipher */
1390 };
1391 
1392 /* Definition of TPM2B_SENSITIVE_DATA Structure */
1393 typedef struct TPM2B_SENSITIVE_DATA TPM2B_SENSITIVE_DATA;
1394 struct TPM2B_SENSITIVE_DATA {
1395     UINT16 size;
1396     BYTE buffer[TPM2_MAX_SYM_DATA];
1397 };
1398 
1399 /* Definition of TPMS_SENSITIVE_CREATE Structure <IN> */
1400 typedef struct TPMS_SENSITIVE_CREATE TPMS_SENSITIVE_CREATE;
1401 struct TPMS_SENSITIVE_CREATE {
1402     TPM2B_AUTH userAuth;       /* the USER auth secret value */
1403     TPM2B_SENSITIVE_DATA data; /* data to be sealed */
1404 };
1405 
1406 /* Definition of TPM2B_SENSITIVE_CREATE Structure <IN S> */
1407 typedef struct TPM2B_SENSITIVE_CREATE TPM2B_SENSITIVE_CREATE;
1408 struct TPM2B_SENSITIVE_CREATE {
1409     UINT16  size;
1410     TPMS_SENSITIVE_CREATE sensitive;
1411 };
1412 
1413 /* Definition of TPMS_SCHEME_HASH Structure */
1414 typedef struct TPMS_SCHEME_HASH TPMS_SCHEME_HASH;
1415 struct TPMS_SCHEME_HASH {
1416     TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */
1417 };
1418 
1419 /* Definition of ECC TPMS_SCHEME_ECDAA Structure */
1420 typedef struct TPMS_SCHEME_ECDAA TPMS_SCHEME_ECDAA;
1421 struct TPMS_SCHEME_ECDAA {
1422     TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */
1423     UINT16 count;          /* the counter value that is used between TPM2_Commit and the sign operation */
1424 };
1425 
1426 /* Definition of TPM2_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME Type */
1427 typedef TPM2_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME;
1428 
1429 /* Definition of Types for HMAC_SIG_SCHEME */
1430 typedef TPMS_SCHEME_HASH TPMS_SCHEME_HMAC;
1431 
1432 /* Definition of TPMS_SCHEME_XOR Structure */
1433 typedef struct TPMS_SCHEME_XOR TPMS_SCHEME_XOR;
1434 struct TPMS_SCHEME_XOR {
1435     TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */
1436     TPMI_ALG_KDF kdf;      /* the key derivation function */
1437 };
1438 
1439 /* Definition of TPMU_SCHEME_KEYEDHASH Union <INOUT S> */
1440 typedef union TPMU_SCHEME_KEYEDHASH TPMU_SCHEME_KEYEDHASH;
1441 union TPMU_SCHEME_KEYEDHASH {
1442     TPMS_SCHEME_HMAC hmac;       /* the signing scheme */
1443     TPMS_SCHEME_XOR exclusiveOr; /* the obfuscation scheme */
1444 };
1445 
1446 /* Definition of TPMT_KEYEDHASH_SCHEME Structure */
1447 typedef struct TPMT_KEYEDHASH_SCHEME TPMT_KEYEDHASH_SCHEME;
1448 struct TPMT_KEYEDHASH_SCHEME {
1449     TPMI_ALG_KEYEDHASH_SCHEME scheme;  /* selects the scheme */
1450     TPMU_SCHEME_KEYEDHASH details;     /* the scheme parameters */
1451 };
1452 
1453 /* Definition of RSA Types for RSA Signature Schemes */
1454 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSASSA;
1455 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSAPSS;
1456 
1457 /* Definition of ECC Types for ECC Signature Schemes */
1458 typedef TPMS_SCHEME_HASH  TPMS_SIG_SCHEME_ECDSA;     /* all asymmetric signing schemes */
1459 typedef TPMS_SCHEME_HASH  TPMS_SIG_SCHEME_SM2;       /* all asymmetric signing schemes */
1460 typedef TPMS_SCHEME_HASH  TPMS_SIG_SCHEME_ECSCHNORR; /* all asymmetric signing schemes */
1461 typedef TPMS_SCHEME_ECDAA TPMS_SIG_SCHEME_ECDAA;     /* schemes that need a hash and a count */
1462 
1463 /* Definition of TPMU_SIG_SCHEME Union <INOUT S> */
1464 typedef union TPMU_SIG_SCHEME TPMU_SIG_SCHEME;
1465 union TPMU_SIG_SCHEME {
1466     TPMS_SIG_SCHEME_RSASSA rsassa;       /* all signing schemes including anonymous schemes */
1467     TPMS_SIG_SCHEME_RSAPSS rsapss;       /* all signing schemes including anonymous schemes */
1468     TPMS_SIG_SCHEME_ECDSA ecdsa;         /* all signing schemes including anonymous schemes */
1469     TPMS_SIG_SCHEME_ECDAA ecdaa;         /* all signing schemes including anonymous schemes */
1470     TPMS_SIG_SCHEME_SM2 sm2;             /* all signing schemes including anonymous schemes */
1471     TPMS_SIG_SCHEME_ECSCHNORR ecschnorr; /* all signing schemes including anonymous schemes */
1472     TPMS_SCHEME_HMAC hmac;               /* the HMAC scheme */
1473     TPMS_SCHEME_HASH any;                /* selector that allows access to digest for any signing scheme */
1474 };
1475 
1476 /* Definition of TPMT_SIG_SCHEME Structure */
1477 typedef struct TPMT_SIG_SCHEME TPMT_SIG_SCHEME;
1478 struct TPMT_SIG_SCHEME {
1479     TPMI_ALG_SIG_SCHEME scheme; /* scheme selector */
1480     TPMU_SIG_SCHEME details;    /* scheme parameters */
1481 };
1482 
1483 /* Definition of Types for RSA Encryption Schemes */
1484 typedef TPMS_SCHEME_HASH TPMS_ENC_SCHEME_OAEP; /* schemes that only need a hash */
1485 typedef TPMS_EMPTY TPMS_ENC_SCHEME_RSAES;      /* schemes that need nothing */
1486 
1487 /* Definition of Types for ECC ECC Key Exchange */
1488 typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECDH;  /* schemes that need a hash */
1489 typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECMQV; /* schemes that need a hash */
1490 
1491 /* Definition of Types for KDF Schemes */
1492 typedef TPMS_SCHEME_HASH TPMS_SCHEME_MGF1;           /* hash-based key or mask generation functions */
1493 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_56A; /* hash-based key or mask generation functions */
1494 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF2;           /* hash-based key or mask generation functions */
1495 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_108; /* hash-based key or mask generation functions */
1496 
1497 /* Definition of TPMU_KDF_SCHEME Union <INOUT S> */
1498 typedef union TPMU_KDF_SCHEME TPMU_KDF_SCHEME;
1499 union TPMU_KDF_SCHEME {
1500     TPMS_SCHEME_MGF1 mgf1;
1501     TPMS_SCHEME_KDF1_SP800_56A kdf1_sp800_56a;
1502     TPMS_SCHEME_KDF2 kdf2;
1503     TPMS_SCHEME_KDF1_SP800_108 kdf1_sp800_108;
1504 };
1505 
1506 /* Definition of TPMT_KDF_SCHEME Structure */
1507 typedef struct TPMT_KDF_SCHEME TPMT_KDF_SCHEME;
1508 struct TPMT_KDF_SCHEME {
1509     TPMI_ALG_KDF scheme;     /* scheme selector */
1510     TPMU_KDF_SCHEME details; /* scheme parameters */
1511 };
1512 
1513 /* Definition of TPM2_ALG_ID TPMI_ALG_ASYM_SCHEME Type <> */
1514 typedef TPM2_ALG_ID TPMI_ALG_ASYM_SCHEME;
1515 
1516 /* Definition of TPMU_ASYM_SCHEME Union */
1517 typedef union TPMU_ASYM_SCHEME TPMU_ASYM_SCHEME;
1518 union TPMU_ASYM_SCHEME {
1519     TPMS_KEY_SCHEME_ECDH ecdh;
1520     TPMS_KEY_SCHEME_ECMQV ecmqv;
1521     TPMS_SIG_SCHEME_RSASSA rsassa;       /* signing and anonymous signing */
1522     TPMS_SIG_SCHEME_RSAPSS rsapss;       /* signing and anonymous signing */
1523     TPMS_SIG_SCHEME_ECDSA ecdsa;         /* signing and anonymous signing */
1524     TPMS_SIG_SCHEME_ECDAA ecdaa;         /* signing and anonymous signing */
1525     TPMS_SIG_SCHEME_SM2 sm2;             /* signing and anonymous signing */
1526     TPMS_SIG_SCHEME_ECSCHNORR ecschnorr; /* signing and anonymous signing */
1527     TPMS_ENC_SCHEME_RSAES rsaes;         /* schemes with no hash */
1528     TPMS_ENC_SCHEME_OAEP oaep;           /* schemes with no hash */
1529     TPMS_SCHEME_HASH anySig;
1530 };
1531 
1532 /* Definition of TPMT_ASYM_SCHEME Structure <> */
1533 typedef struct TPMT_ASYM_SCHEME TPMT_ASYM_SCHEME;
1534 struct TPMT_ASYM_SCHEME {
1535     TPMI_ALG_ASYM_SCHEME scheme; /* scheme selector */
1536     TPMU_ASYM_SCHEME details;    /* scheme parameters */
1537 };
1538 
1539 /* Definition of TPM2_ALG_ID RSA TPMI_ALG_RSA_SCHEME Type */
1540 typedef TPM2_ALG_ID TPMI_ALG_RSA_SCHEME;
1541 
1542 /* Definition of RSA TPMT_RSA_SCHEME Structure */
1543 typedef struct TPMT_RSA_SCHEME TPMT_RSA_SCHEME;
1544 struct TPMT_RSA_SCHEME {
1545     TPMI_ALG_RSA_SCHEME scheme; /* scheme selector */
1546     TPMU_ASYM_SCHEME details;   /* scheme parameters */
1547 };
1548 
1549 /* Definition of TPM2_ALG_ID RSA TPMI_ALG_RSA_DECRYPT Type */
1550 typedef TPM2_ALG_ID TPMI_ALG_RSA_DECRYPT;
1551 
1552 /* Definition of RSA TPMT_RSA_DECRYPT Structure */
1553 typedef struct TPMT_RSA_DECRYPT TPMT_RSA_DECRYPT;
1554 struct TPMT_RSA_DECRYPT {
1555     TPMI_ALG_RSA_DECRYPT scheme;  /* scheme selector */
1556     TPMU_ASYM_SCHEME details;     /* scheme parameters */
1557 };
1558 
1559 /* Definition of RSA TPM2B_PUBLIC_KEY_RSA Structure */
1560 typedef struct TPM2B_PUBLIC_KEY_RSA TPM2B_PUBLIC_KEY_RSA;
1561 struct TPM2B_PUBLIC_KEY_RSA {
1562     UINT16 size;
1563     BYTE buffer[TPM2_MAX_RSA_KEY_BYTES];
1564 };
1565 
1566 /* Definition of RSA TPM2_KEY_BITS TPMI_RSA_KEY_BITS Type */
1567 typedef TPM2_KEY_BITS TPMI_RSA_KEY_BITS;
1568 
1569 /* Definition of RSA TPM2B_PRIVATE_KEY_RSA Structure */
1570 typedef struct TPM2B_PRIVATE_KEY_RSA TPM2B_PRIVATE_KEY_RSA;
1571 struct TPM2B_PRIVATE_KEY_RSA {
1572     UINT16 size;
1573     BYTE buffer[TPM2_MAX_RSA_KEY_BYTES/2];
1574 };
1575 
1576 /* Definition of ECC TPM2B_ECC_PARAMETER Structure */
1577 typedef struct TPM2B_ECC_PARAMETER TPM2B_ECC_PARAMETER;
1578 struct TPM2B_ECC_PARAMETER {
1579     UINT16 size;
1580     BYTE buffer[TPM2_MAX_ECC_KEY_BYTES];
1581 };
1582 
1583 /* Definition of ECC TPMS_ECC_POINT Structure */
1584 typedef struct TPMS_ECC_POINT TPMS_ECC_POINT;
1585 struct TPMS_ECC_POINT {
1586     TPM2B_ECC_PARAMETER x; /* X coordinate */
1587     TPM2B_ECC_PARAMETER y; /* Y coordinate */
1588 };
1589 
1590 /* Definition of ECC TPM2B_ECC_POINT Structure */
1591 typedef struct TPM2B_ECC_POINT TPM2B_ECC_POINT;
1592 struct TPM2B_ECC_POINT {
1593     UINT16  size;
1594     TPMS_ECC_POINT point;
1595 };
1596 
1597 /* Definition of TPM2_ALG_ID ECC TPMI_ALG_ECC_SCHEME Type */
1598 typedef TPM2_ALG_ID TPMI_ALG_ECC_SCHEME;
1599 
1600 /* Definition of ECC TPM2_ECC_CURVE TPMI_ECC_CURVE Type */
1601 typedef TPM2_ECC_CURVE TPMI_ECC_CURVE;
1602 
1603 /* Definition of TPMT_SIG_SCHEME ECC TPMT_ECC_SCHEME Structure */
1604 typedef struct TPMT_ECC_SCHEME TPMT_ECC_SCHEME;
1605 struct TPMT_ECC_SCHEME {
1606     TPMI_ALG_ECC_SCHEME scheme;   /* scheme selector */
1607     TPMU_ASYM_SCHEME details;     /* scheme parameters */
1608 };
1609 
1610 /* Definition of ECC TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */
1611 typedef struct TPMS_ALGORITHM_DETAIL_ECC TPMS_ALGORITHM_DETAIL_ECC;
1612 struct TPMS_ALGORITHM_DETAIL_ECC {
1613     TPM2_ECC_CURVE      curveID; /* identifier for the curve */
1614     UINT16              keySize; /* Size in bits of the key */
1615     TPMT_KDF_SCHEME     kdf;     /* if not TPM2_ALG_NULL the required KDF and hash algorithm used in secret sharing operations */
1616     TPMT_ECC_SCHEME     sign;    /* If not TPM2_ALG_NULL this is the mandatory signature scheme that is required to be used with this curve. */
1617     TPM2B_ECC_PARAMETER p;       /* Fp the modulus */
1618     TPM2B_ECC_PARAMETER a;       /* coefficient of the linear term in the curve equation */
1619     TPM2B_ECC_PARAMETER b;       /* constant term for curve equation */
1620     TPM2B_ECC_PARAMETER gX;      /* x coordinate of base point G */
1621     TPM2B_ECC_PARAMETER gY;      /* y coordinate of base point G */
1622     TPM2B_ECC_PARAMETER n;       /* order of G */
1623     TPM2B_ECC_PARAMETER h;       /* cofactor a size of zero indicates a cofactor of 1 */
1624 };
1625 
1626 /* Definition of RSA TPMS_SIGNATURE_RSA Structure */
1627 typedef struct TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSA;
1628 struct TPMS_SIGNATURE_RSA {
1629     TPMI_ALG_HASH hash;       /* the hash algorithm used to digest the message. TPM2_ALG_NULL is not allowed. */
1630     TPM2B_PUBLIC_KEY_RSA sig; /* The signature is the size of a public key. */
1631 };
1632 
1633 /* Definition of Types for RSA Signature */
1634 typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSASSA;
1635 typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSAPSS;
1636 
1637 /* Definition of ECC TPMS_SIGNATURE_ECC Structure */
1638 typedef struct TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECC;
1639 struct TPMS_SIGNATURE_ECC {
1640     TPMI_ALG_HASH hash;     /* the hash algorithm used in the signature processTPM2_ALG_NULL is not allowed. */
1641     TPM2B_ECC_PARAMETER signatureR;
1642     TPM2B_ECC_PARAMETER signatureS;
1643 };
1644 
1645 /* Definition of Types for ECC TPMS_SIGNATURE_ECC */
1646 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDSA;
1647 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDAA;
1648 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_SM2;
1649 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECSCHNORR;
1650 
1651 /* Definition of TPMU_SIGNATURE Union <INOUT S> */
1652 typedef union TPMU_SIGNATURE TPMU_SIGNATURE;
1653 union TPMU_SIGNATURE {
1654     TPMS_SIGNATURE_RSASSA rsassa;       /* all asymmetric signatures */
1655     TPMS_SIGNATURE_RSAPSS rsapss;       /* all asymmetric signatures */
1656     TPMS_SIGNATURE_ECDSA ecdsa;         /* all asymmetric signatures */
1657     TPMS_SIGNATURE_ECDAA ecdaa;         /* all asymmetric signatures */
1658     TPMS_SIGNATURE_SM2 sm2;             /* all asymmetric signatures */
1659     TPMS_SIGNATURE_ECSCHNORR ecschnorr; /* all asymmetric signatures */
1660     TPMT_HA hmac;                       /* HMAC signature required to be supported */
1661     TPMS_SCHEME_HASH any;               /* used to access the hash */
1662 };
1663 
1664 /* Definition of TPMT_SIGNATURE Structure */
1665 typedef struct TPMT_SIGNATURE TPMT_SIGNATURE;
1666 struct TPMT_SIGNATURE {
1667     TPMI_ALG_SIG_SCHEME sigAlg; /* selector of the algorithm used to construct the signature */
1668     TPMU_SIGNATURE signature;   /* This shall be the actual signature information. */
1669 };
1670 
1671 /* Definition of TPMU_ENCRYPTED_SECRET Union <S> */
1672 typedef union TPMU_ENCRYPTED_SECRET TPMU_ENCRYPTED_SECRET;
1673 union TPMU_ENCRYPTED_SECRET {
1674     BYTE ecc[sizeof(TPMS_ECC_POINT)];
1675     BYTE rsa[TPM2_MAX_RSA_KEY_BYTES];
1676     BYTE symmetric[sizeof(TPM2B_DIGEST)];
1677     BYTE keyedHash[sizeof(TPM2B_DIGEST)]; /* Any symmetrically encrypted secret value will be limited to be no larger than a digest. */
1678 };
1679 
1680 /* Definition of TPM2B_ENCRYPTED_SECRET Structure */
1681 typedef struct TPM2B_ENCRYPTED_SECRET TPM2B_ENCRYPTED_SECRET;
1682 struct TPM2B_ENCRYPTED_SECRET {
1683     UINT16 size;
1684     BYTE secret[sizeof(TPMU_ENCRYPTED_SECRET)];
1685 };
1686 
1687 /* Definition of TPM2_ALG_ID TPMI_ALG_PUBLIC Type */
1688 typedef TPM2_ALG_ID TPMI_ALG_PUBLIC;
1689 
1690 /* Definition of TPMU_PUBLIC_ID Union <INOUT S> */
1691 typedef union TPMU_PUBLIC_ID TPMU_PUBLIC_ID;
1692 union TPMU_PUBLIC_ID {
1693     TPM2B_DIGEST keyedHash;
1694     TPM2B_DIGEST sym;
1695     TPM2B_PUBLIC_KEY_RSA rsa;
1696     TPMS_ECC_POINT ecc;
1697 };
1698 
1699 /* Definition of TPMS_KEYEDHASH_PARMS Structure */
1700 typedef struct TPMS_KEYEDHASH_PARMS TPMS_KEYEDHASH_PARMS;
1701 struct TPMS_KEYEDHASH_PARMS {
1702     TPMT_KEYEDHASH_SCHEME scheme; /* Indicates the signing method used for a keyedHash signing object. This field also determines the size of the data field for a data object created with TPM2_Create or TPM2_CreatePrimary. */
1703 };
1704 
1705 /* Definition of TPMS_ASYM_PARMS Structure <> */
1706 typedef struct TPMS_ASYM_PARMS TPMS_ASYM_PARMS;
1707 struct TPMS_ASYM_PARMS {
1708     TPMT_SYM_DEF_OBJECT symmetric; /* the companion symmetric algorithm for a restricted decryption key and shall be set to a supported symmetric algorithm. This field is optional for keys that are not decryption keys and shall be set to TPM2_ALG_NULL if not used. */
1709     TPMT_ASYM_SCHEME scheme; /* For a key with the sign attribute SET a valid signing scheme for the key type. For a key with the decrypt attribute SET a valid key exchange protocol. For a key with sign and decrypt attributes shall be TPM2_ALG_NULL */
1710 };
1711 
1712 /* Definition of RSA TPMS_RSA_PARMS Structure */
1713 typedef struct TPMS_RSA_PARMS TPMS_RSA_PARMS;
1714 struct TPMS_RSA_PARMS {
1715     TPMT_SYM_DEF_OBJECT symmetric; /* for a restricted decryption key shall be set to a supported symmetric algorithm key size and mode. if the key is not a restricted decryption key this field shall be set to TPM2_ALG_NULL. */
1716     TPMT_RSA_SCHEME scheme;        /* scheme. scheme shall before an unrestricted signing key either TPM2_ALG_RSAPSS TPM2_ALG_RSASSA or TPM2_ALG_NULLfor a restricted signing key either TPM2_ALG_RSAPSS or TPM2_ALG_RSASSA for an unrestricted decryption key TPM2_ALG_RSAES TPM2_ALG_OAEP or TPM2_ALG_NULL unless the object also has the sign attribute for a restricted decryption key TPM2_ALG_NULL. NOTE When both sign and decrypt are SET restricted shall be CLEAR and scheme shall be TPM2_ALG_NULL. */
1717     TPMI_RSA_KEY_BITS keyBits;     /* number of bits in the public modulus */
1718     UINT32 exponent;               /* the public exponent A prime number greater than 2. When zero indicates that the exponent is the default of 216 + 1 */
1719 };
1720 
1721 /* Definition of ECC TPMS_ECC_PARMS Structure */
1722 typedef struct TPMS_ECC_PARMS TPMS_ECC_PARMS;
1723 struct TPMS_ECC_PARMS {
1724     TPMT_SYM_DEF_OBJECT symmetric; /* for a restricted decryption key shall be set to a supported symmetric algorithm key size. and mode. if the key is not a restricted decryption key this field shall be set to TPM2_ALG_NULL. */
1725     TPMT_ECC_SCHEME scheme;        /* If the sign attribute of the key is SET then this shall be a valid signing scheme. NOTE If the sign parameter in curveID indicates a mandatory scheme then this field shall have the same value. If the decrypt attribute of the key is SET then this shall be a valid key exchange scheme or TPM2_ALG_NULL. If the key is a Storage Key then this field shall be TPM2_ALG_NULL. */
1726     TPMI_ECC_CURVE curveID;        /* ECC curve ID */
1727     TPMT_KDF_SCHEME kdf;           /* an optional key derivation scheme for generating a symmetric key from a Z value. If the kdf  parameter associated with curveID is not TPM2_ALG_NULL then this is required to be NULL. NOTE There are currently no commands where this parameter has effect and in the reference code this field needs to be set to TPM2_ALG_NULL. */
1728 };
1729 
1730 /* Definition of TPMU_PUBLIC_PARMS Union <INOUT S> */
1731 typedef union TPMU_PUBLIC_PARMS TPMU_PUBLIC_PARMS;
1732 union TPMU_PUBLIC_PARMS {
1733     TPMS_KEYEDHASH_PARMS keyedHashDetail; /* sign  decrypt  neither */
1734     TPMS_SYMCIPHER_PARMS symDetail;       /* a symmetric block cipher */
1735     TPMS_RSA_PARMS rsaDetail;             /* decrypt + sign2 */
1736     TPMS_ECC_PARMS eccDetail;             /* decrypt + sign2 */
1737     TPMS_ASYM_PARMS asymDetail;           /* common scheme structure for RSA and ECC keys */
1738 };
1739 
1740 /* Definition of TPMT_PUBLIC_PARMS Structure */
1741 typedef struct TPMT_PUBLIC_PARMS TPMT_PUBLIC_PARMS;
1742 struct TPMT_PUBLIC_PARMS {
1743     TPMI_ALG_PUBLIC type;         /* the algorithm to be tested */
1744     TPMU_PUBLIC_PARMS parameters; /* the algorithm details */
1745 };
1746 
1747 /* Definition of TPMT_PUBLIC Structure */
1748 typedef struct TPMT_PUBLIC TPMT_PUBLIC;
1749 struct TPMT_PUBLIC {
1750     TPMI_ALG_PUBLIC type;         /* algorithm associated with this object */
1751     TPMI_ALG_HASH nameAlg;        /* algorithm used for computing the Name of the object NOTE The + indicates that the instance of a TPMT_PUBLIC may have a + to indicate that the nameAlg may be TPM2_ALG_NULL. */
1752     TPMA_OBJECT objectAttributes; /* attributes that along with type determine the manipulations of this object */
1753     TPM2B_DIGEST authPolicy;      /* optional policy for using this key. The policy is computed using the nameAlg of the object. NOTE Shall be the Empty Policy if no authorization policy is present. */
1754     TPMU_PUBLIC_PARMS parameters; /* the algorithm or structure details */
1755     TPMU_PUBLIC_ID unique;        /* the unique identifier of the structure. For an asymmetric key this would be the public key. */
1756 };
1757 
1758 /* Definition of TPM2B_PUBLIC Structure */
1759 typedef struct TPM2B_PUBLIC TPM2B_PUBLIC;
1760 struct TPM2B_PUBLIC {
1761     UINT16  size;
1762     TPMT_PUBLIC publicArea;
1763 };
1764 
1765 /* Definition of TPM2B_TEMPLATE Structure */
1766 typedef struct TPM2B_TEMPLATE TPM2B_TEMPLATE;
1767 struct TPM2B_TEMPLATE {
1768     UINT16 size;
1769     BYTE buffer[sizeof(TPMT_PUBLIC)];
1770 };
1771 
1772 /* Definition of TPM2B_PRIVATE_VENDOR_SPECIFIC Structure<> */
1773 typedef struct TPM2B_PRIVATE_VENDOR_SPECIFIC TPM2B_PRIVATE_VENDOR_SPECIFIC;
1774 struct TPM2B_PRIVATE_VENDOR_SPECIFIC {
1775     UINT16 size;
1776     BYTE buffer[TPM2_PRIVATE_VENDOR_SPECIFIC_BYTES];
1777 };
1778 
1779 /* Definition of TPMU_SENSITIVE_COMPOSITE Union <INOUT S> */
1780 typedef union TPMU_SENSITIVE_COMPOSITE TPMU_SENSITIVE_COMPOSITE;
1781 union TPMU_SENSITIVE_COMPOSITE {
1782     TPM2B_PRIVATE_KEY_RSA rsa;         /* a prime factor of the public key */
1783     TPM2B_ECC_PARAMETER ecc;           /* the integer private key */
1784     TPM2B_SENSITIVE_DATA bits;         /* the private data */
1785     TPM2B_SYM_KEY sym;                 /* the symmetric key */
1786     TPM2B_PRIVATE_VENDOR_SPECIFIC any; /* vendor-specific size for key storage */
1787 };
1788 
1789 /* Definition of TPMT_SENSITIVE Structure */
1790 typedef struct TPMT_SENSITIVE TPMT_SENSITIVE;
1791 struct TPMT_SENSITIVE {
1792     TPMI_ALG_PUBLIC sensitiveType; /* identifier for the sensitive area. This shall be the same as the type parameter of the associated public area. */
1793     TPM2B_AUTH authValue;          /* user authorization data. The authValue may be a zero-length string. This value shall not be larger than the size of the digest produced by the nameAlg of the object. */
1794     TPM2B_DIGEST seedValue;        /* for asymmetric key object the optional protection seed for other objects the obfuscation value. This value shall not be larger than the size of the digest produced by nameAlg of the object. */
1795     TPMU_SENSITIVE_COMPOSITE sensitive; /* the type-specific private data */
1796 };
1797 
1798 /* Definition of TPM2B_SENSITIVE Structure <INOUT> */
1799 typedef struct TPM2B_SENSITIVE TPM2B_SENSITIVE;
1800 struct TPM2B_SENSITIVE {
1801     UINT16  size;
1802     TPMT_SENSITIVE sensitiveArea;
1803 };
1804 
1805 /* Definition of _PRIVATE Structure <> */
1806 typedef struct _PRIVATE _PRIVATE;
1807 struct _PRIVATE {
1808     TPM2B_DIGEST integrityOuter;
1809     TPM2B_DIGEST integrityInner; /* could also be a TPM2B_IV */
1810     TPM2B_SENSITIVE sensitive;   /* the sensitive area */
1811 };
1812 
1813 /* Definition of TPM2B_PRIVATE Structure <INOUT S> */
1814 typedef struct TPM2B_PRIVATE TPM2B_PRIVATE;
1815 struct TPM2B_PRIVATE {
1816     UINT16 size;
1817     BYTE buffer[sizeof(_PRIVATE)];
1818 };
1819 
1820 /* Definition of TPMS_ID_OBJECT Structure <> */
1821 typedef struct TPMS_ID_OBJECT TPMS_ID_OBJECT;
1822 struct TPMS_ID_OBJECT {
1823     TPM2B_DIGEST integrityHMAC; /* HMAC using the nameAlg of the storage key on the target TPM */
1824     TPM2B_DIGEST encIdentity;   /* credential protector information returned if name matches the referenced objectAll of the encIdentity is encrypted including the size field. NOTE The TPM is not required to check that the size is not larger than the digest of the nameAlg. However if the size is larger the ID object may not be usable on a TPM that has no digest larger than produced by nameAlg. */
1825 };
1826 
1827 /* Definition of TPM2B_ID_OBJECT Structure <INOUT> */
1828 typedef struct TPM2B_ID_OBJECT TPM2B_ID_OBJECT;
1829 struct TPM2B_ID_OBJECT {
1830     UINT16 size;
1831     BYTE credential[sizeof(TPMS_ID_OBJECT)];
1832 };
1833 
1834 /* Definition of UINT32 TPM2_NV_INDEX Bits <> */
1835 typedef uint32_t TPM2_NV_INDEX;
1836 
1837 #define TPM2_NV_INDEX_INDEX_MASK  ((TPM2_NV_INDEX) 0x00FFFFFF) /* The Index of the NV location */
1838 #define TPM2_NV_INDEX_INDEX_SHIFT (0)
1839 #define TPM2_NV_INDEX_RH_NV_MASK  ((TPM2_NV_INDEX) 0xFF000000) /* constant value of TPM2_HT_NV_INDEX indicating the NV Index range */
1840 #define TPM2_NV_INDEX_RH_NV_SHIFT (24)
1841 
1842 /* Definition of TPM2_NT Constants */
1843 typedef UINT8 TPM2_NT;
1844 
1845 #define TPM2_NT_ORDINARY ((TPM2_NT) 0x0) /* Ordinary contains data that is opaque to the TPM that can only be modified using TPM2_NV_Write. */
1846 #define TPM2_NT_COUNTER  ((TPM2_NT) 0x1) /* Counter contains an 8-octet value that is to be used as a counter and can only be modified with TPM2_NV_Increment */
1847 #define TPM2_NT_BITS     ((TPM2_NT) 0x2) /* Bit Field contains an 8-octet value to be used as a bit field and can only be modified with TPM2_NV_SetBits. */
1848 #define TPM2_NT_EXTEND   ((TPM2_NT) 0x4) /* Extend contains a digestsized value used like a PCR. The Index can only be modified using TPM2_NV_Extend. The extend will use the nameAlg of the Index. */
1849 #define TPM2_NT_PIN_FAIL ((TPM2_NT) 0x8) /* PIN Fail contains a pinCount that increments on a PIN authorization failure and a pinLimit */
1850 #define TPM2_NT_PIN_PASS ((TPM2_NT) 0x9) /* PIN Pass contains a pinCount that increments on a PIN authorization success and a pinLimit */
1851 
1852 /* Definition of TPMS_NV_PIN_COUNTER_PARAMETERS Structure */
1853 typedef struct TPMS_NV_PIN_COUNTER_PARAMETERS TPMS_NV_PIN_COUNTER_PARAMETERS;
1854 struct TPMS_NV_PIN_COUNTER_PARAMETERS {
1855     UINT32 pinCount; /* This counter shows the current number of successful authValue authorization attempts to access a TPM2_NT_PIN_PASS index or the current number of unsuccessful authValue authorization attempts to access a TPM2_NT_PIN_FAIL index. */
1856     UINT32 pinLimit; /* This threshold is the value of pinCount at which the authValue authorization of the host TPM2_NT_PIN_PASS or TPM2_NT_PIN_FAIL index is locked out. */
1857 };
1858 
1859 /* Definition of UINT32 TPMA_NV Bits */
1860 typedef uint32_t TPMA_NV;
1861 
1862 #define TPMA_NV_PPWRITE        ((TPMA_NV) 0x00000001) /* SET 1 The Index data can be written if Platform Authorization is provided. CLEAR 0 Writing of the Index data cannot be authorized with Platform Authorization. */
1863 #define TPMA_NV_OWNERWRITE     ((TPMA_NV) 0x00000002) /* SET 1 The Index data can be written if Owner Authorization is provided. CLEAR 0 Writing of the Index data cannot be authorized with Owner Authorization. */
1864 #define TPMA_NV_AUTHWRITE      ((TPMA_NV) 0x00000004) /* SET 1 Authorizations to change the Index contents that require USER role may be provided with an HMAC session or password. CLEAR 0 Authorizations to change the Index contents that require USER role may not be provided with an HMAC session or password. */
1865 #define TPMA_NV_POLICYWRITE    ((TPMA_NV) 0x00000008) /* SET 1 Authorizations to change the Index contents that require USER role may be provided with a policy session. CLEAR 0 Authorizations to change the Index contents that require USER role may not be provided with a policy session. NOTE TPM2_NV_ChangeAuth always requires that authorization be provided in a policy session. */
1866 #define TPMA_NV_TPM2_NT_MASK   ((TPMA_NV) 0x000000F0) /* The type of the index. NOTE A TPM is not required to support all TPM2_NT values */
1867 #define TPMA_NV_TPM2_NT_SHIFT  (4)
1868 #define TPMA_NV_RESERVED1_MASK ((TPMA_NV) 0x00000300) /* shall be zero. Reserved for future use */
1869 #define TPMA_NV_POLICY_DELETE  ((TPMA_NV) 0x00000400) /* SET 1 Index may not be deleted unless the authPolicy is satisfied using TPM2_NV_UndefineSpaceSpecial. CLEAR 0 Index may be deleted with proper platform or owner authorization using TPM2_NV_UndefineSpace. */
1870 #define TPMA_NV_WRITELOCKED    ((TPMA_NV) 0x00000800) /* SET 1 Index cannot be written. CLEAR 0 Index can be written. */
1871 #define TPMA_NV_WRITEALL       ((TPMA_NV) 0x00001000) /* SET 1 A partial write of the Index data is not allowed. The write size shall match the defined space size. CLEAR 0 Partial writes are allowed. This setting is required if the .dataSize of the Index is larger than NV_MAX_BUFFER_SIZE for the implementation. */
1872 #define TPMA_NV_WRITEDEFINE    ((TPMA_NV) 0x00002000) /* SET 1 TPM2_NV_WriteLock may be used to prevent further writes to this location. CLEAR 0 TPM2_NV_WriteLock does not block subsequent writes if TPMA_NV_WRITE_STCLEAR is also CLEAR. */
1873 #define TPMA_NV_WRITE_STCLEAR  ((TPMA_NV) 0x00004000) /* SET 1 TPM2_NV_WriteLock may be used to prevent further writes to this location until the next TPM Reset or TPM Restart. CLEAR 0 TPM2_NV_WriteLock does not block subsequent writes if TPMA_NV_WRITEDEFINE is also CLEAR. */
1874 #define TPMA_NV_GLOBALLOCK     ((TPMA_NV) 0x00008000) /* SET 1 If TPM2_NV_GlobalWriteLock is successful then further writes to this location are not permitted until the next TPM Reset or TPM Restart. CLEAR 0 TPM2_NV_GlobalWriteLock has no effect on the writing of the data at this Index. */
1875 #define TPMA_NV_PPREAD         ((TPMA_NV) 0x00010000) /* SET 1 The Index data can be read if Platform Authorization is provided. CLEAR 0 Reading of the Index data cannot be authorized with Platform Authorization. */
1876 #define TPMA_NV_OWNERREAD      ((TPMA_NV) 0x00020000) /* SET 1 The Index data can be read if Owner Authorization is provided. CLEAR 0 Reading of the Index data cannot be authorized with Owner Authorization. */
1877 #define TPMA_NV_AUTHREAD       ((TPMA_NV) 0x00040000) /* SET 1 The Index data may be read if the authValue is provided. CLEAR 0 Reading of the Index data cannot be authorized with the Index authValue. */
1878 #define TPMA_NV_POLICYREAD     ((TPMA_NV) 0x00080000) /* SET 1 The Index data may be read if the authPolicy is satisfied. CLEAR 0 Reading of the Index data cannot be authorized with the Index authPolicy. */
1879 #define TPMA_NV_RESERVED2_MASK ((TPMA_NV) 0x01F00000) /* shall be zero. Reserved for future use */
1880 #define TPMA_NV_NO_DA          ((TPMA_NV) 0x02000000) /* SET 1 Authorization failures of the Index do not affect the DA logic and authorization of the Index is not blocked when the TPM is in Lockout mode. CLEAR 0 Authorization failures of the Index will increment the authorization failure counter and authorizations of this Index are not allowed when the TPM is in Lockout mode. */
1881 #define TPMA_NV_ORDERLY        ((TPMA_NV) 0x04000000) /* SET 1 NV Index state is only required to be saved when the TPM performs an orderly shutdown TPM2_Shutdown. CLEAR 0 NV Index state is required to be persistent after the command to update the Index completes successfully, that is, the NV update is synchronous with the update command. */
1882 #define TPMA_NV_CLEAR_STCLEAR  ((TPMA_NV) 0x08000000) /* SET 1 TPMA_NV_WRITTEN for the Index is CLEAR by TPM Reset or TPM Restart. CLEAR 0 TPMA_NV_WRITTEN is not changed by TPM Restart. NOTE 1    This attribute may only be SET if TPM2_NT is not TPM2_NT_COUNTER. NOTE 2    If the TPMA_NV_ORDERLY is SET TPMA_NV_WRITTEN will be CLEAR by TPM Reset. */
1883 #define TPMA_NV_READLOCKED     ((TPMA_NV) 0x10000000) /* SET 1 Reads of the Index are blocked until the next TPM Reset or TPM Restart. CLEAR 0 Reads of the Index are allowed if proper authorization is provided. */
1884 #define TPMA_NV_WRITTEN        ((TPMA_NV) 0x20000000) /* SET 1 Index has been written. CLEAR 0 Index has not been written. */
1885 #define TPMA_NV_PLATFORMCREATE ((TPMA_NV) 0x40000000) /* SET 1 This Index may be undefined with Platform Authorization but not with Owner Authorization. CLEAR 0 This Index may be undefined using Owner Authorization but not with Platform Authorization. The TPM will validate that this attribute is SET when the Index is defined using Platform Authorization and will validate that this attribute is CLEAR when the Index is defined using Owner Authorization. */
1886 #define TPMA_NV_READ_STCLEAR   ((TPMA_NV) 0x80000000) /* SET 1 TPM2_NV_ReadLock may be used to SET TPMA_NV_READLOCKED for this Index. CLEAR 0 TPM2_NV_ReadLock has no effect on this Index. */
1887 
1888 /* Definition of TPMS_NV_PUBLIC Structure */
1889 typedef struct TPMS_NV_PUBLIC TPMS_NV_PUBLIC;
1890 struct TPMS_NV_PUBLIC {
1891     TPMI_RH_NV_INDEX nvIndex; /* the handle of the data area */
1892     TPMI_ALG_HASH nameAlg;    /* hash algorithm used to compute the name of the Index and used for the authPolicy.  For an extend index the hash algorithm used for the extend. */
1893     TPMA_NV attributes;       /* the Index attributes */
1894     TPM2B_DIGEST authPolicy;  /* optional access policy for the Index. The policy is computed using the nameAlg . NOTE: this shall be the Empty Policy if no authorization policy is present. */
1895     UINT16 dataSize;          /* the size of the data area. The maximum size is implementation dependent. The minimum maximum size is platform-specific. */
1896 };
1897 
1898 /* Definition of TPM2B_NV_PUBLIC Structure */
1899 typedef struct TPM2B_NV_PUBLIC TPM2B_NV_PUBLIC;
1900 struct TPM2B_NV_PUBLIC {
1901     UINT16  size;
1902     TPMS_NV_PUBLIC nvPublic;
1903 };
1904 
1905 /* Definition of TPM2B_CONTEXT_SENSITIVE Structure <INOUT> */
1906 typedef struct TPM2B_CONTEXT_SENSITIVE TPM2B_CONTEXT_SENSITIVE;
1907 struct TPM2B_CONTEXT_SENSITIVE {
1908     UINT16 size;
1909     BYTE buffer[TPM2_MAX_CONTEXT_SIZE];
1910 };
1911 
1912 /* Definition of TPMS_CONTEXT_DATA Structure <INOUT S> */
1913 typedef struct TPMS_CONTEXT_DATA TPMS_CONTEXT_DATA;
1914 struct TPMS_CONTEXT_DATA {
1915     TPM2B_DIGEST integrity;            /* the integrity value */
1916     TPM2B_CONTEXT_SENSITIVE encrypted; /* the sensitive area */
1917 };
1918 
1919 /* Definition of TPM2B_CONTEXT_DATA Structure <INOUT> */
1920 typedef struct TPM2B_CONTEXT_DATA TPM2B_CONTEXT_DATA;
1921 struct TPM2B_CONTEXT_DATA {
1922     UINT16 size;
1923     BYTE buffer[sizeof(TPMS_CONTEXT_DATA)];
1924 };
1925 
1926 /* Definition of TPMS_CONTEXT Structure */
1927 typedef struct TPMS_CONTEXT TPMS_CONTEXT;
1928 struct TPMS_CONTEXT {
1929     UINT64 sequence;                /* the sequence number of the context. NOTE Transient object contexts and session contexts used different counters. */
1930     TPMI_DH_CONTEXT savedHandle;    /* a handle indicating if the context is a session object or sequence objectSee Context Handle Values */
1931     TPMI_RH_HIERARCHY hierarchy;    /* the hierarchy of the context */
1932     TPM2B_CONTEXT_DATA contextBlob; /* the context data and integrity HMAC */
1933 };
1934 
1935 /* Definition of TPMS_CREATION_DATA Structure <OUT> */
1936 typedef struct TPMS_CREATION_DATA TPMS_CREATION_DATA;
1937 struct TPMS_CREATION_DATA {
1938     TPML_PCR_SELECTION pcrSelect;   /* list indicating the PCR included in pcrDigest */
1939     TPM2B_DIGEST pcrDigest;         /* digest of the selected PCR using nameAlg of the object for which this structure is being created. pcrDigest.size shall be zero if the pcrSelect list is empty. */
1940     TPMA_LOCALITY locality;         /* the locality at which the object was created */
1941     TPM2_ALG_ID parentNameAlg;      /* nameAlg of the parent */
1942     TPM2B_NAME parentName;          /* Name of the parent at time of creation. The size will match digest size associated with parentNameAlg unless it is TPM2_ALG_NULL in which case the size will be 4 and parentName will be the hierarchy handle. */
1943     TPM2B_NAME parentQualifiedName; /* Qualified Name of the parent at the time of creationSize is the same as parentName. */
1944     TPM2B_DATA outsideInfo;         /* association with additional information added by the key creator. This will be the contents of the outsideInfo parameter in TPM2_Create or TPM2_CreatePrimary. */
1945 };
1946 
1947 /* Definition of TPM2B_CREATION_DATA Structure <OUT> */
1948 typedef struct TPM2B_CREATION_DATA TPM2B_CREATION_DATA;
1949 struct TPM2B_CREATION_DATA {
1950     UINT16  size;
1951     TPMS_CREATION_DATA creationData;
1952 };
1953 
1954 typedef UINT32 TPM_AT;
1955 
1956 /* Definition of (UINT32) TPM_AT Constants.
1957  * Note: values of ((TPM_AT) 0x80000000) through 0xFFFFFFFF are reserved for vendor-specific use */
1958 #define TPM_AT_ANY   ((TPM_AT) 0x00000000) /* In a command, a non-specific request for AC information. In a response, indicates that outputData is not meaningful */
1959 #define TPM_AT_ERROR ((TPM_AT) 0x00000001) /* Indicates a TCG defined, device-specific error */
1960 #define TPM_AT_PV1   ((TPM_AT) 0x00000002) /* Indicates the most significant 32 bits of a pairing value for the AC */
1961 #define TPM_AT_VEND  ((TPM_AT) 0x80000000) /* Value added to a TPM_AT to indicate a vendor-specific tag value */
1962 
1963 typedef UINT32 TPM_EA;
1964 
1965 #define TPM_AE_NONE  ((TPM_EA)0x00000000) /* In a command, a non-specific request for AC information. In a response, indicates that outputData is not meaningful */
1966 
1967 /* Definition of TPMS_AC_OUTPUT Structure <OUT> */
1968 typedef struct TPMS_AC_OUTPUT TPMS_AC_OUTPUT;
1969 struct TPMS_AC_OUTPUT {
1970     TPM_AT tag;  /* Indicates the contents of data */
1971     UINT32 data; /* Data returned from the AC */
1972 };
1973 
1974 /* Definition of TPML_AC_CAPABILITIES Structure <OUT> */
1975 typedef struct TPML_AC_CAPABILITIES TPML_AC_CAPABILITIES;
1976 struct TPML_AC_CAPABILITIES {
1977     UINT32 count; /* Number of values in the acCapabilities list. May be 0 */
1978     TPMS_AC_OUTPUT acCapabilities[TPM2_MAX_AC_CAPABILITIES]; /* List of AC values */
1979 };
1980 #endif
1981