1 /* Microsoft Reference Implementation for TPM 2.0
2  *
3  *  The copyright in this software is being made available under the BSD License,
4  *  included below. This software may be subject to other third party and
5  *  contributor rights, including patent rights, and no such rights are granted
6  *  under this license.
7  *
8  *  Copyright (c) Microsoft Corporation
9  *
10  *  All rights reserved.
11  *
12  *  BSD License
13  *
14  *  Redistribution and use in source and binary forms, with or without modification,
15  *  are permitted provided that the following conditions are met:
16  *
17  *  Redistributions of source code must retain the above copyright notice, this list
18  *  of conditions and the following disclaimer.
19  *
20  *  Redistributions in binary form must reproduce the above copyright notice, this
21  *  list of conditions and the following disclaimer in the documentation and/or
22  *  other materials provided with the distribution.
23  *
24  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
25  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /*(Auto-generated)
36  *  Created by TpmStructures; Version 4.4 Mar 26, 2019
37  *  Date: Mar  6, 2020  Time: 01:50:09PM
38  */
39 
40 #ifndef _TPM_TYPES_H_
41 #define _TPM_TYPES_H_
42 
43 // Table 1:2 - Definition of TPM_ALG_ID Constants
44 typedef UINT16                          TPM_ALG_ID;
45 #define TYPE_OF_TPM_ALG_ID              UINT16
46 #define     ALG_ERROR_VALUE             0x0000
47 #define TPM_ALG_ERROR                   (TPM_ALG_ID)(ALG_ERROR_VALUE)
48 #define     ALG_RSA_VALUE               0x0001
49 #define TPM_ALG_RSA                     (TPM_ALG_ID)(ALG_RSA_VALUE)
50 #define     ALG_TDES_VALUE              0x0003
51 #define TPM_ALG_TDES                    (TPM_ALG_ID)(ALG_TDES_VALUE)
52 #define     ALG_SHA_VALUE               0x0004
53 #define TPM_ALG_SHA                     (TPM_ALG_ID)(ALG_SHA_VALUE)
54 #define     ALG_SHA1_VALUE              0x0004
55 #define TPM_ALG_SHA1                    (TPM_ALG_ID)(ALG_SHA1_VALUE)
56 #define     ALG_HMAC_VALUE              0x0005
57 #define TPM_ALG_HMAC                    (TPM_ALG_ID)(ALG_HMAC_VALUE)
58 #define     ALG_AES_VALUE               0x0006
59 #define TPM_ALG_AES                     (TPM_ALG_ID)(ALG_AES_VALUE)
60 #define     ALG_MGF1_VALUE              0x0007
61 #define TPM_ALG_MGF1                    (TPM_ALG_ID)(ALG_MGF1_VALUE)
62 #define     ALG_KEYEDHASH_VALUE         0x0008
63 #define TPM_ALG_KEYEDHASH               (TPM_ALG_ID)(ALG_KEYEDHASH_VALUE)
64 #define     ALG_XOR_VALUE               0x000A
65 #define TPM_ALG_XOR                     (TPM_ALG_ID)(ALG_XOR_VALUE)
66 #define     ALG_SHA256_VALUE            0x000B
67 #define TPM_ALG_SHA256                  (TPM_ALG_ID)(ALG_SHA256_VALUE)
68 #define     ALG_SHA384_VALUE            0x000C
69 #define TPM_ALG_SHA384                  (TPM_ALG_ID)(ALG_SHA384_VALUE)
70 #define     ALG_SHA512_VALUE            0x000D
71 #define TPM_ALG_SHA512                  (TPM_ALG_ID)(ALG_SHA512_VALUE)
72 #define     ALG_NULL_VALUE              0x0010
73 #define TPM_ALG_NULL                    (TPM_ALG_ID)(ALG_NULL_VALUE)
74 #define     ALG_SM3_256_VALUE           0x0012
75 #define TPM_ALG_SM3_256                 (TPM_ALG_ID)(ALG_SM3_256_VALUE)
76 #define     ALG_SM4_VALUE               0x0013
77 #define TPM_ALG_SM4                     (TPM_ALG_ID)(ALG_SM4_VALUE)
78 #define     ALG_RSASSA_VALUE            0x0014
79 #define TPM_ALG_RSASSA                  (TPM_ALG_ID)(ALG_RSASSA_VALUE)
80 #define     ALG_RSAES_VALUE             0x0015
81 #define TPM_ALG_RSAES                   (TPM_ALG_ID)(ALG_RSAES_VALUE)
82 #define     ALG_RSAPSS_VALUE            0x0016
83 #define TPM_ALG_RSAPSS                  (TPM_ALG_ID)(ALG_RSAPSS_VALUE)
84 #define     ALG_OAEP_VALUE              0x0017
85 #define TPM_ALG_OAEP                    (TPM_ALG_ID)(ALG_OAEP_VALUE)
86 #define     ALG_ECDSA_VALUE             0x0018
87 #define TPM_ALG_ECDSA                   (TPM_ALG_ID)(ALG_ECDSA_VALUE)
88 #define     ALG_ECDH_VALUE              0x0019
89 #define TPM_ALG_ECDH                    (TPM_ALG_ID)(ALG_ECDH_VALUE)
90 #define     ALG_ECDAA_VALUE             0x001A
91 #define TPM_ALG_ECDAA                   (TPM_ALG_ID)(ALG_ECDAA_VALUE)
92 #define     ALG_SM2_VALUE               0x001B
93 #define TPM_ALG_SM2                     (TPM_ALG_ID)(ALG_SM2_VALUE)
94 #define     ALG_ECSCHNORR_VALUE         0x001C
95 #define TPM_ALG_ECSCHNORR               (TPM_ALG_ID)(ALG_ECSCHNORR_VALUE)
96 #define     ALG_ECMQV_VALUE             0x001D
97 #define TPM_ALG_ECMQV                   (TPM_ALG_ID)(ALG_ECMQV_VALUE)
98 #define     ALG_KDF1_SP800_56A_VALUE    0x0020
99 #define TPM_ALG_KDF1_SP800_56A          (TPM_ALG_ID)(ALG_KDF1_SP800_56A_VALUE)
100 #define     ALG_KDF2_VALUE              0x0021
101 #define TPM_ALG_KDF2                    (TPM_ALG_ID)(ALG_KDF2_VALUE)
102 #define     ALG_KDF1_SP800_108_VALUE    0x0022
103 #define TPM_ALG_KDF1_SP800_108          (TPM_ALG_ID)(ALG_KDF1_SP800_108_VALUE)
104 #define     ALG_ECC_VALUE               0x0023
105 #define TPM_ALG_ECC                     (TPM_ALG_ID)(ALG_ECC_VALUE)
106 #define     ALG_SYMCIPHER_VALUE         0x0025
107 #define TPM_ALG_SYMCIPHER               (TPM_ALG_ID)(ALG_SYMCIPHER_VALUE)
108 #define     ALG_CAMELLIA_VALUE          0x0026
109 #define TPM_ALG_CAMELLIA                (TPM_ALG_ID)(ALG_CAMELLIA_VALUE)
110 #define     ALG_SHA3_256_VALUE          0x0027
111 #define TPM_ALG_SHA3_256                (TPM_ALG_ID)(ALG_SHA3_256_VALUE)
112 #define     ALG_SHA3_384_VALUE          0x0028
113 #define TPM_ALG_SHA3_384                (TPM_ALG_ID)(ALG_SHA3_384_VALUE)
114 #define     ALG_SHA3_512_VALUE          0x0029
115 #define TPM_ALG_SHA3_512                (TPM_ALG_ID)(ALG_SHA3_512_VALUE)
116 #define     ALG_CMAC_VALUE              0x003F
117 #define TPM_ALG_CMAC                    (TPM_ALG_ID)(ALG_CMAC_VALUE)
118 #define     ALG_CTR_VALUE               0x0040
119 #define TPM_ALG_CTR                     (TPM_ALG_ID)(ALG_CTR_VALUE)
120 #define     ALG_OFB_VALUE               0x0041
121 #define TPM_ALG_OFB                     (TPM_ALG_ID)(ALG_OFB_VALUE)
122 #define     ALG_CBC_VALUE               0x0042
123 #define TPM_ALG_CBC                     (TPM_ALG_ID)(ALG_CBC_VALUE)
124 #define     ALG_CFB_VALUE               0x0043
125 #define TPM_ALG_CFB                     (TPM_ALG_ID)(ALG_CFB_VALUE)
126 #define     ALG_ECB_VALUE               0x0044
127 #define TPM_ALG_ECB                     (TPM_ALG_ID)(ALG_ECB_VALUE)
128 // Values derived from Table 1:2
129 #define     ALG_FIRST_VALUE             0x0001
130 #define TPM_ALG_FIRST                   (TPM_ALG_ID)(ALG_FIRST_VALUE)
131 #define     ALG_LAST_VALUE              0x0044
132 #define TPM_ALG_LAST                    (TPM_ALG_ID)(ALG_LAST_VALUE)
133 
134 // Table 1:4 - Definition of TPM_ECC_CURVE Constants
135 typedef UINT16              TPM_ECC_CURVE;
136 #define TYPE_OF_TPM_ECC_CURVE   UINT16
137 #define TPM_ECC_NONE        (TPM_ECC_CURVE)(0x0000)
138 #define TPM_ECC_NIST_P192   (TPM_ECC_CURVE)(0x0001)
139 #define TPM_ECC_NIST_P224   (TPM_ECC_CURVE)(0x0002)
140 #define TPM_ECC_NIST_P256   (TPM_ECC_CURVE)(0x0003)
141 #define TPM_ECC_NIST_P384   (TPM_ECC_CURVE)(0x0004)
142 #define TPM_ECC_NIST_P521   (TPM_ECC_CURVE)(0x0005)
143 #define TPM_ECC_BN_P256     (TPM_ECC_CURVE)(0x0010)
144 #define TPM_ECC_BN_P638     (TPM_ECC_CURVE)(0x0011)
145 #define TPM_ECC_SM2_P256    (TPM_ECC_CURVE)(0x0020)
146 
147 // Table 2:12 - Definition of TPM_CC Constants
148 typedef UINT32                              TPM_CC;
149 #define TYPE_OF_TPM_CC                      UINT32
150 #define TPM_CC_NV_UndefineSpaceSpecial      (TPM_CC)(0x0000011F)
151 #define TPM_CC_EvictControl                 (TPM_CC)(0x00000120)
152 #define TPM_CC_HierarchyControl             (TPM_CC)(0x00000121)
153 #define TPM_CC_NV_UndefineSpace             (TPM_CC)(0x00000122)
154 #define TPM_CC_ChangeEPS                    (TPM_CC)(0x00000124)
155 #define TPM_CC_ChangePPS                    (TPM_CC)(0x00000125)
156 #define TPM_CC_Clear                        (TPM_CC)(0x00000126)
157 #define TPM_CC_ClearControl                 (TPM_CC)(0x00000127)
158 #define TPM_CC_ClockSet                     (TPM_CC)(0x00000128)
159 #define TPM_CC_HierarchyChangeAuth          (TPM_CC)(0x00000129)
160 #define TPM_CC_NV_DefineSpace               (TPM_CC)(0x0000012A)
161 #define TPM_CC_PCR_Allocate                 (TPM_CC)(0x0000012B)
162 #define TPM_CC_PCR_SetAuthPolicy            (TPM_CC)(0x0000012C)
163 #define TPM_CC_PP_Commands                  (TPM_CC)(0x0000012D)
164 #define TPM_CC_SetPrimaryPolicy             (TPM_CC)(0x0000012E)
165 #define TPM_CC_FieldUpgradeStart            (TPM_CC)(0x0000012F)
166 #define TPM_CC_ClockRateAdjust              (TPM_CC)(0x00000130)
167 #define TPM_CC_CreatePrimary                (TPM_CC)(0x00000131)
168 #define TPM_CC_NV_GlobalWriteLock           (TPM_CC)(0x00000132)
169 #define TPM_CC_GetCommandAuditDigest        (TPM_CC)(0x00000133)
170 #define TPM_CC_NV_Increment                 (TPM_CC)(0x00000134)
171 #define TPM_CC_NV_SetBits                   (TPM_CC)(0x00000135)
172 #define TPM_CC_NV_Extend                    (TPM_CC)(0x00000136)
173 #define TPM_CC_NV_Write                     (TPM_CC)(0x00000137)
174 #define TPM_CC_NV_WriteLock                 (TPM_CC)(0x00000138)
175 #define TPM_CC_DictionaryAttackLockReset    (TPM_CC)(0x00000139)
176 #define TPM_CC_DictionaryAttackParameters   (TPM_CC)(0x0000013A)
177 #define TPM_CC_NV_ChangeAuth                (TPM_CC)(0x0000013B)
178 #define TPM_CC_PCR_Event                    (TPM_CC)(0x0000013C)
179 #define TPM_CC_PCR_Reset                    (TPM_CC)(0x0000013D)
180 #define TPM_CC_SequenceComplete             (TPM_CC)(0x0000013E)
181 #define TPM_CC_SetAlgorithmSet              (TPM_CC)(0x0000013F)
182 #define TPM_CC_SetCommandCodeAuditStatus    (TPM_CC)(0x00000140)
183 #define TPM_CC_FieldUpgradeData             (TPM_CC)(0x00000141)
184 #define TPM_CC_IncrementalSelfTest          (TPM_CC)(0x00000142)
185 #define TPM_CC_SelfTest                     (TPM_CC)(0x00000143)
186 #define TPM_CC_Startup                      (TPM_CC)(0x00000144)
187 #define TPM_CC_Shutdown                     (TPM_CC)(0x00000145)
188 #define TPM_CC_StirRandom                   (TPM_CC)(0x00000146)
189 #define TPM_CC_ActivateCredential           (TPM_CC)(0x00000147)
190 #define TPM_CC_Certify                      (TPM_CC)(0x00000148)
191 #define TPM_CC_PolicyNV                     (TPM_CC)(0x00000149)
192 #define TPM_CC_CertifyCreation              (TPM_CC)(0x0000014A)
193 #define TPM_CC_Duplicate                    (TPM_CC)(0x0000014B)
194 #define TPM_CC_GetTime                      (TPM_CC)(0x0000014C)
195 #define TPM_CC_GetSessionAuditDigest        (TPM_CC)(0x0000014D)
196 #define TPM_CC_NV_Read                      (TPM_CC)(0x0000014E)
197 #define TPM_CC_NV_ReadLock                  (TPM_CC)(0x0000014F)
198 #define TPM_CC_ObjectChangeAuth             (TPM_CC)(0x00000150)
199 #define TPM_CC_PolicySecret                 (TPM_CC)(0x00000151)
200 #define TPM_CC_Rewrap                       (TPM_CC)(0x00000152)
201 #define TPM_CC_Create                       (TPM_CC)(0x00000153)
202 #define TPM_CC_ECDH_ZGen                    (TPM_CC)(0x00000154)
203 #define TPM_CC_HMAC                         (TPM_CC)(0x00000155)
204 #define TPM_CC_MAC                          (TPM_CC)(0x00000155)
205 #define TPM_CC_Import                       (TPM_CC)(0x00000156)
206 #define TPM_CC_Load                         (TPM_CC)(0x00000157)
207 #define TPM_CC_Quote                        (TPM_CC)(0x00000158)
208 #define TPM_CC_RSA_Decrypt                  (TPM_CC)(0x00000159)
209 #define TPM_CC_HMAC_Start                   (TPM_CC)(0x0000015B)
210 #define TPM_CC_MAC_Start                    (TPM_CC)(0x0000015B)
211 #define TPM_CC_SequenceUpdate               (TPM_CC)(0x0000015C)
212 #define TPM_CC_Sign                         (TPM_CC)(0x0000015D)
213 #define TPM_CC_Unseal                       (TPM_CC)(0x0000015E)
214 #define TPM_CC_PolicySigned                 (TPM_CC)(0x00000160)
215 #define TPM_CC_ContextLoad                  (TPM_CC)(0x00000161)
216 #define TPM_CC_ContextSave                  (TPM_CC)(0x00000162)
217 #define TPM_CC_ECDH_KeyGen                  (TPM_CC)(0x00000163)
218 #define TPM_CC_EncryptDecrypt               (TPM_CC)(0x00000164)
219 #define TPM_CC_FlushContext                 (TPM_CC)(0x00000165)
220 #define TPM_CC_LoadExternal                 (TPM_CC)(0x00000167)
221 #define TPM_CC_MakeCredential               (TPM_CC)(0x00000168)
222 #define TPM_CC_NV_ReadPublic                (TPM_CC)(0x00000169)
223 #define TPM_CC_PolicyAuthorize              (TPM_CC)(0x0000016A)
224 #define TPM_CC_PolicyAuthValue              (TPM_CC)(0x0000016B)
225 #define TPM_CC_PolicyCommandCode            (TPM_CC)(0x0000016C)
226 #define TPM_CC_PolicyCounterTimer           (TPM_CC)(0x0000016D)
227 #define TPM_CC_PolicyCpHash                 (TPM_CC)(0x0000016E)
228 #define TPM_CC_PolicyLocality               (TPM_CC)(0x0000016F)
229 #define TPM_CC_PolicyNameHash               (TPM_CC)(0x00000170)
230 #define TPM_CC_PolicyOR                     (TPM_CC)(0x00000171)
231 #define TPM_CC_PolicyTicket                 (TPM_CC)(0x00000172)
232 #define TPM_CC_ReadPublic                   (TPM_CC)(0x00000173)
233 #define TPM_CC_RSA_Encrypt                  (TPM_CC)(0x00000174)
234 #define TPM_CC_StartAuthSession             (TPM_CC)(0x00000176)
235 #define TPM_CC_VerifySignature              (TPM_CC)(0x00000177)
236 #define TPM_CC_ECC_Parameters               (TPM_CC)(0x00000178)
237 #define TPM_CC_FirmwareRead                 (TPM_CC)(0x00000179)
238 #define TPM_CC_GetCapability                (TPM_CC)(0x0000017A)
239 #define TPM_CC_GetRandom                    (TPM_CC)(0x0000017B)
240 #define TPM_CC_GetTestResult                (TPM_CC)(0x0000017C)
241 #define TPM_CC_Hash                         (TPM_CC)(0x0000017D)
242 #define TPM_CC_PCR_Read                     (TPM_CC)(0x0000017E)
243 #define TPM_CC_PolicyPCR                    (TPM_CC)(0x0000017F)
244 #define TPM_CC_PolicyRestart                (TPM_CC)(0x00000180)
245 #define TPM_CC_ReadClock                    (TPM_CC)(0x00000181)
246 #define TPM_CC_PCR_Extend                   (TPM_CC)(0x00000182)
247 #define TPM_CC_PCR_SetAuthValue             (TPM_CC)(0x00000183)
248 #define TPM_CC_NV_Certify                   (TPM_CC)(0x00000184)
249 #define TPM_CC_EventSequenceComplete        (TPM_CC)(0x00000185)
250 #define TPM_CC_HashSequenceStart            (TPM_CC)(0x00000186)
251 #define TPM_CC_PolicyPhysicalPresence       (TPM_CC)(0x00000187)
252 #define TPM_CC_PolicyDuplicationSelect      (TPM_CC)(0x00000188)
253 #define TPM_CC_PolicyGetDigest              (TPM_CC)(0x00000189)
254 #define TPM_CC_TestParms                    (TPM_CC)(0x0000018A)
255 #define TPM_CC_Commit                       (TPM_CC)(0x0000018B)
256 #define TPM_CC_PolicyPassword               (TPM_CC)(0x0000018C)
257 #define TPM_CC_ZGen_2Phase                  (TPM_CC)(0x0000018D)
258 #define TPM_CC_EC_Ephemeral                 (TPM_CC)(0x0000018E)
259 #define TPM_CC_PolicyNvWritten              (TPM_CC)(0x0000018F)
260 #define TPM_CC_PolicyTemplate               (TPM_CC)(0x00000190)
261 #define TPM_CC_CreateLoaded                 (TPM_CC)(0x00000191)
262 #define TPM_CC_PolicyAuthorizeNV            (TPM_CC)(0x00000192)
263 #define TPM_CC_EncryptDecrypt2              (TPM_CC)(0x00000193)
264 #define TPM_CC_AC_GetCapability             (TPM_CC)(0x00000194)
265 #define TPM_CC_AC_Send                      (TPM_CC)(0x00000195)
266 #define TPM_CC_Policy_AC_SendSelect         (TPM_CC)(0x00000196)
267 #define TPM_CC_CertifyX509                  (TPM_CC)(0x00000197)
268 #define TPM_CC_ACT_SetTimeout               (TPM_CC)(0x00000198)
269 #define TPM_CC_ECC_Encrypt                  (TPM_CC)(0x00000199)
270 #define TPM_CC_ECC_Decrypt                  (TPM_CC)(0x0000019A)
271 #define CC_VEND                             0x20000000
272 #define TPM_CC_Vendor_TCG_Test              (TPM_CC)(0x20000000)
273 
274 // Table 2:5 - Definition of Types for Documentation Clarity
275 typedef UINT32              TPM_ALGORITHM_ID;
276 #define TYPE_OF_TPM_ALGORITHM_ID    UINT32
277 typedef UINT32              TPM_MODIFIER_INDICATOR;
278 #define TYPE_OF_TPM_MODIFIER_INDICATOR  UINT32
279 typedef UINT32              TPM_AUTHORIZATION_SIZE;
280 #define TYPE_OF_TPM_AUTHORIZATION_SIZE  UINT32
281 typedef UINT32              TPM_PARAMETER_SIZE;
282 #define TYPE_OF_TPM_PARAMETER_SIZE  UINT32
283 typedef UINT16              TPM_KEY_SIZE;
284 #define TYPE_OF_TPM_KEY_SIZE    UINT16
285 typedef UINT16              TPM_KEY_BITS;
286 #define TYPE_OF_TPM_KEY_BITS    UINT16
287 
288 // Table 2:6 - Definition of TPM_SPEC Constants
289 typedef UINT32                  TPM_SPEC;
290 #define TYPE_OF_TPM_SPEC        UINT32
291 #define SPEC_FAMILY             0x322E3000
292 #define TPM_SPEC_FAMILY         (TPM_SPEC)(SPEC_FAMILY)
293 #define SPEC_LEVEL              00
294 #define TPM_SPEC_LEVEL          (TPM_SPEC)(SPEC_LEVEL)
295 #define SPEC_VERSION            162
296 #define TPM_SPEC_VERSION        (TPM_SPEC)(SPEC_VERSION)
297 #define SPEC_YEAR               2020
298 #define TPM_SPEC_YEAR           (TPM_SPEC)(SPEC_YEAR)
299 #define SPEC_DAY_OF_YEAR        53
300 #define TPM_SPEC_DAY_OF_YEAR    (TPM_SPEC)(SPEC_DAY_OF_YEAR)
301 
302 // Table 2:7 - Definition of TPM_CONSTANTS32 Constants
303 typedef UINT32                      TPM_CONSTANTS32;
304 #define TYPE_OF_TPM_CONSTANTS32     UINT32
305 #define TPM_GENERATED_VALUE         (TPM_CONSTANTS32)(0xFF544347)
306 #define TPM_MAX_DERIVATION_BITS     (TPM_CONSTANTS32)(8192)
307 
308 // Table 2:16 - Definition of TPM_RC Constants
309 typedef UINT32                      TPM_RC;
310 #define TYPE_OF_TPM_RC              UINT32
311 #define TPM_RC_SUCCESS              (TPM_RC)(0x000)
312 #define TPM_RC_BAD_TAG              (TPM_RC)(0x01E)
313 #define RC_VER1                     (TPM_RC)(0x100)
314 #define TPM_RC_INITIALIZE           (TPM_RC)(RC_VER1+0x000)
315 #define TPM_RC_FAILURE              (TPM_RC)(RC_VER1+0x001)
316 #define TPM_RC_SEQUENCE             (TPM_RC)(RC_VER1+0x003)
317 #define TPM_RC_PRIVATE              (TPM_RC)(RC_VER1+0x00B)
318 #define TPM_RC_HMAC                 (TPM_RC)(RC_VER1+0x019)
319 #define TPM_RC_DISABLED             (TPM_RC)(RC_VER1+0x020)
320 #define TPM_RC_EXCLUSIVE            (TPM_RC)(RC_VER1+0x021)
321 #define TPM_RC_AUTH_TYPE            (TPM_RC)(RC_VER1+0x024)
322 #define TPM_RC_AUTH_MISSING         (TPM_RC)(RC_VER1+0x025)
323 #define TPM_RC_POLICY               (TPM_RC)(RC_VER1+0x026)
324 #define TPM_RC_PCR                  (TPM_RC)(RC_VER1+0x027)
325 #define TPM_RC_PCR_CHANGED          (TPM_RC)(RC_VER1+0x028)
326 #define TPM_RC_UPGRADE              (TPM_RC)(RC_VER1+0x02D)
327 #define TPM_RC_TOO_MANY_CONTEXTS    (TPM_RC)(RC_VER1+0x02E)
328 #define TPM_RC_AUTH_UNAVAILABLE     (TPM_RC)(RC_VER1+0x02F)
329 #define TPM_RC_REBOOT               (TPM_RC)(RC_VER1+0x030)
330 #define TPM_RC_UNBALANCED           (TPM_RC)(RC_VER1+0x031)
331 #define TPM_RC_COMMAND_SIZE         (TPM_RC)(RC_VER1+0x042)
332 #define TPM_RC_COMMAND_CODE         (TPM_RC)(RC_VER1+0x043)
333 #define TPM_RC_AUTHSIZE             (TPM_RC)(RC_VER1+0x044)
334 #define TPM_RC_AUTH_CONTEXT         (TPM_RC)(RC_VER1+0x045)
335 #define TPM_RC_NV_RANGE             (TPM_RC)(RC_VER1+0x046)
336 #define TPM_RC_NV_SIZE              (TPM_RC)(RC_VER1+0x047)
337 #define TPM_RC_NV_LOCKED            (TPM_RC)(RC_VER1+0x048)
338 #define TPM_RC_NV_AUTHORIZATION     (TPM_RC)(RC_VER1+0x049)
339 #define TPM_RC_NV_UNINITIALIZED     (TPM_RC)(RC_VER1+0x04A)
340 #define TPM_RC_NV_SPACE             (TPM_RC)(RC_VER1+0x04B)
341 #define TPM_RC_NV_DEFINED           (TPM_RC)(RC_VER1+0x04C)
342 #define TPM_RC_BAD_CONTEXT          (TPM_RC)(RC_VER1+0x050)
343 #define TPM_RC_CPHASH               (TPM_RC)(RC_VER1+0x051)
344 #define TPM_RC_PARENT               (TPM_RC)(RC_VER1+0x052)
345 #define TPM_RC_NEEDS_TEST           (TPM_RC)(RC_VER1+0x053)
346 #define TPM_RC_NO_RESULT            (TPM_RC)(RC_VER1+0x054)
347 #define TPM_RC_SENSITIVE            (TPM_RC)(RC_VER1+0x055)
348 #define RC_MAX_FM0                  (TPM_RC)(RC_VER1+0x07F)
349 #define RC_FMT1                     (TPM_RC)(0x080)
350 #define TPM_RC_ASYMMETRIC           (TPM_RC)(RC_FMT1+0x001)
351 #define TPM_RCS_ASYMMETRIC          (TPM_RC)(RC_FMT1+0x001)
352 #define TPM_RC_ATTRIBUTES           (TPM_RC)(RC_FMT1+0x002)
353 #define TPM_RCS_ATTRIBUTES          (TPM_RC)(RC_FMT1+0x002)
354 #define TPM_RC_HASH                 (TPM_RC)(RC_FMT1+0x003)
355 #define TPM_RCS_HASH                (TPM_RC)(RC_FMT1+0x003)
356 #define TPM_RC_VALUE                (TPM_RC)(RC_FMT1+0x004)
357 #define TPM_RCS_VALUE               (TPM_RC)(RC_FMT1+0x004)
358 #define TPM_RC_HIERARCHY            (TPM_RC)(RC_FMT1+0x005)
359 #define TPM_RCS_HIERARCHY           (TPM_RC)(RC_FMT1+0x005)
360 #define TPM_RC_KEY_SIZE             (TPM_RC)(RC_FMT1+0x007)
361 #define TPM_RCS_KEY_SIZE            (TPM_RC)(RC_FMT1+0x007)
362 #define TPM_RC_MGF                  (TPM_RC)(RC_FMT1+0x008)
363 #define TPM_RCS_MGF                 (TPM_RC)(RC_FMT1+0x008)
364 #define TPM_RC_MODE                 (TPM_RC)(RC_FMT1+0x009)
365 #define TPM_RCS_MODE                (TPM_RC)(RC_FMT1+0x009)
366 #define TPM_RC_TYPE                 (TPM_RC)(RC_FMT1+0x00A)
367 #define TPM_RCS_TYPE                (TPM_RC)(RC_FMT1+0x00A)
368 #define TPM_RC_HANDLE               (TPM_RC)(RC_FMT1+0x00B)
369 #define TPM_RCS_HANDLE              (TPM_RC)(RC_FMT1+0x00B)
370 #define TPM_RC_KDF                  (TPM_RC)(RC_FMT1+0x00C)
371 #define TPM_RCS_KDF                 (TPM_RC)(RC_FMT1+0x00C)
372 #define TPM_RC_RANGE                (TPM_RC)(RC_FMT1+0x00D)
373 #define TPM_RCS_RANGE               (TPM_RC)(RC_FMT1+0x00D)
374 #define TPM_RC_AUTH_FAIL            (TPM_RC)(RC_FMT1+0x00E)
375 #define TPM_RCS_AUTH_FAIL           (TPM_RC)(RC_FMT1+0x00E)
376 #define TPM_RC_NONCE                (TPM_RC)(RC_FMT1+0x00F)
377 #define TPM_RCS_NONCE               (TPM_RC)(RC_FMT1+0x00F)
378 #define TPM_RC_PP                   (TPM_RC)(RC_FMT1+0x010)
379 #define TPM_RCS_PP                  (TPM_RC)(RC_FMT1+0x010)
380 #define TPM_RC_SCHEME               (TPM_RC)(RC_FMT1+0x012)
381 #define TPM_RCS_SCHEME              (TPM_RC)(RC_FMT1+0x012)
382 #define TPM_RC_SIZE                 (TPM_RC)(RC_FMT1+0x015)
383 #define TPM_RCS_SIZE                (TPM_RC)(RC_FMT1+0x015)
384 #define TPM_RC_SYMMETRIC            (TPM_RC)(RC_FMT1+0x016)
385 #define TPM_RCS_SYMMETRIC           (TPM_RC)(RC_FMT1+0x016)
386 #define TPM_RC_TAG                  (TPM_RC)(RC_FMT1+0x017)
387 #define TPM_RCS_TAG                 (TPM_RC)(RC_FMT1+0x017)
388 #define TPM_RC_SELECTOR             (TPM_RC)(RC_FMT1+0x018)
389 #define TPM_RCS_SELECTOR            (TPM_RC)(RC_FMT1+0x018)
390 #define TPM_RC_INSUFFICIENT         (TPM_RC)(RC_FMT1+0x01A)
391 #define TPM_RCS_INSUFFICIENT        (TPM_RC)(RC_FMT1+0x01A)
392 #define TPM_RC_SIGNATURE            (TPM_RC)(RC_FMT1+0x01B)
393 #define TPM_RCS_SIGNATURE           (TPM_RC)(RC_FMT1+0x01B)
394 #define TPM_RC_KEY                  (TPM_RC)(RC_FMT1+0x01C)
395 #define TPM_RCS_KEY                 (TPM_RC)(RC_FMT1+0x01C)
396 #define TPM_RC_POLICY_FAIL          (TPM_RC)(RC_FMT1+0x01D)
397 #define TPM_RCS_POLICY_FAIL         (TPM_RC)(RC_FMT1+0x01D)
398 #define TPM_RC_INTEGRITY            (TPM_RC)(RC_FMT1+0x01F)
399 #define TPM_RCS_INTEGRITY           (TPM_RC)(RC_FMT1+0x01F)
400 #define TPM_RC_TICKET               (TPM_RC)(RC_FMT1+0x020)
401 #define TPM_RCS_TICKET              (TPM_RC)(RC_FMT1+0x020)
402 #define TPM_RC_RESERVED_BITS        (TPM_RC)(RC_FMT1+0x021)
403 #define TPM_RCS_RESERVED_BITS       (TPM_RC)(RC_FMT1+0x021)
404 #define TPM_RC_BAD_AUTH             (TPM_RC)(RC_FMT1+0x022)
405 #define TPM_RCS_BAD_AUTH            (TPM_RC)(RC_FMT1+0x022)
406 #define TPM_RC_EXPIRED              (TPM_RC)(RC_FMT1+0x023)
407 #define TPM_RCS_EXPIRED             (TPM_RC)(RC_FMT1+0x023)
408 #define TPM_RC_POLICY_CC            (TPM_RC)(RC_FMT1+0x024)
409 #define TPM_RCS_POLICY_CC           (TPM_RC)(RC_FMT1+0x024)
410 #define TPM_RC_BINDING              (TPM_RC)(RC_FMT1+0x025)
411 #define TPM_RCS_BINDING             (TPM_RC)(RC_FMT1+0x025)
412 #define TPM_RC_CURVE                (TPM_RC)(RC_FMT1+0x026)
413 #define TPM_RCS_CURVE               (TPM_RC)(RC_FMT1+0x026)
414 #define TPM_RC_ECC_POINT            (TPM_RC)(RC_FMT1+0x027)
415 #define TPM_RCS_ECC_POINT           (TPM_RC)(RC_FMT1+0x027)
416 #define RC_WARN                     (TPM_RC)(0x900)
417 #define TPM_RC_CONTEXT_GAP          (TPM_RC)(RC_WARN+0x001)
418 #define TPM_RC_OBJECT_MEMORY        (TPM_RC)(RC_WARN+0x002)
419 #define TPM_RC_SESSION_MEMORY       (TPM_RC)(RC_WARN+0x003)
420 #define TPM_RC_MEMORY               (TPM_RC)(RC_WARN+0x004)
421 #define TPM_RC_SESSION_HANDLES      (TPM_RC)(RC_WARN+0x005)
422 #define TPM_RC_OBJECT_HANDLES       (TPM_RC)(RC_WARN+0x006)
423 #define TPM_RC_LOCALITY             (TPM_RC)(RC_WARN+0x007)
424 #define TPM_RC_YIELDED              (TPM_RC)(RC_WARN+0x008)
425 #define TPM_RC_CANCELED             (TPM_RC)(RC_WARN+0x009)
426 #define TPM_RC_TESTING              (TPM_RC)(RC_WARN+0x00A)
427 #define TPM_RC_REFERENCE_H0         (TPM_RC)(RC_WARN+0x010)
428 #define TPM_RC_REFERENCE_H1         (TPM_RC)(RC_WARN+0x011)
429 #define TPM_RC_REFERENCE_H2         (TPM_RC)(RC_WARN+0x012)
430 #define TPM_RC_REFERENCE_H3         (TPM_RC)(RC_WARN+0x013)
431 #define TPM_RC_REFERENCE_H4         (TPM_RC)(RC_WARN+0x014)
432 #define TPM_RC_REFERENCE_H5         (TPM_RC)(RC_WARN+0x015)
433 #define TPM_RC_REFERENCE_H6         (TPM_RC)(RC_WARN+0x016)
434 #define TPM_RC_REFERENCE_S0         (TPM_RC)(RC_WARN+0x018)
435 #define TPM_RC_REFERENCE_S1         (TPM_RC)(RC_WARN+0x019)
436 #define TPM_RC_REFERENCE_S2         (TPM_RC)(RC_WARN+0x01A)
437 #define TPM_RC_REFERENCE_S3         (TPM_RC)(RC_WARN+0x01B)
438 #define TPM_RC_REFERENCE_S4         (TPM_RC)(RC_WARN+0x01C)
439 #define TPM_RC_REFERENCE_S5         (TPM_RC)(RC_WARN+0x01D)
440 #define TPM_RC_REFERENCE_S6         (TPM_RC)(RC_WARN+0x01E)
441 #define TPM_RC_NV_RATE              (TPM_RC)(RC_WARN+0x020)
442 #define TPM_RC_LOCKOUT              (TPM_RC)(RC_WARN+0x021)
443 #define TPM_RC_RETRY                (TPM_RC)(RC_WARN+0x022)
444 #define TPM_RC_NV_UNAVAILABLE       (TPM_RC)(RC_WARN+0x023)
445 #define TPM_RC_NOT_USED             (TPM_RC)(RC_WARN+0x7F)
446 #define TPM_RC_H                    (TPM_RC)(0x000)
447 #define TPM_RC_P                    (TPM_RC)(0x040)
448 #define TPM_RC_S                    (TPM_RC)(0x800)
449 #define TPM_RC_1                    (TPM_RC)(0x100)
450 #define TPM_RC_2                    (TPM_RC)(0x200)
451 #define TPM_RC_3                    (TPM_RC)(0x300)
452 #define TPM_RC_4                    (TPM_RC)(0x400)
453 #define TPM_RC_5                    (TPM_RC)(0x500)
454 #define TPM_RC_6                    (TPM_RC)(0x600)
455 #define TPM_RC_7                    (TPM_RC)(0x700)
456 #define TPM_RC_8                    (TPM_RC)(0x800)
457 #define TPM_RC_9                    (TPM_RC)(0x900)
458 #define TPM_RC_A                    (TPM_RC)(0xA00)
459 #define TPM_RC_B                    (TPM_RC)(0xB00)
460 #define TPM_RC_C                    (TPM_RC)(0xC00)
461 #define TPM_RC_D                    (TPM_RC)(0xD00)
462 #define TPM_RC_E                    (TPM_RC)(0xE00)
463 #define TPM_RC_F                    (TPM_RC)(0xF00)
464 #define TPM_RC_N_MASK               (TPM_RC)(0xF00)
465 
466 // Table 2:17 - Definition of TPM_CLOCK_ADJUST Constants
467 typedef INT8                        TPM_CLOCK_ADJUST;
468 #define TYPE_OF_TPM_CLOCK_ADJUST    UINT8
469 #define TPM_CLOCK_COARSE_SLOWER     (TPM_CLOCK_ADJUST)(-3)
470 #define TPM_CLOCK_MEDIUM_SLOWER     (TPM_CLOCK_ADJUST)(-2)
471 #define TPM_CLOCK_FINE_SLOWER       (TPM_CLOCK_ADJUST)(-1)
472 #define TPM_CLOCK_NO_CHANGE         (TPM_CLOCK_ADJUST)(0)
473 #define TPM_CLOCK_FINE_FASTER       (TPM_CLOCK_ADJUST)(1)
474 #define TPM_CLOCK_MEDIUM_FASTER     (TPM_CLOCK_ADJUST)(2)
475 #define TPM_CLOCK_COARSE_FASTER     (TPM_CLOCK_ADJUST)(3)
476 
477 // Table 2:18 - Definition of TPM_EO Constants
478 typedef UINT16              TPM_EO;
479 #define TYPE_OF_TPM_EO      UINT16
480 #define TPM_EO_EQ           (TPM_EO)(0x0000)
481 #define TPM_EO_NEQ          (TPM_EO)(0x0001)
482 #define TPM_EO_SIGNED_GT    (TPM_EO)(0x0002)
483 #define TPM_EO_UNSIGNED_GT  (TPM_EO)(0x0003)
484 #define TPM_EO_SIGNED_LT    (TPM_EO)(0x0004)
485 #define TPM_EO_UNSIGNED_LT  (TPM_EO)(0x0005)
486 #define TPM_EO_SIGNED_GE    (TPM_EO)(0x0006)
487 #define TPM_EO_UNSIGNED_GE  (TPM_EO)(0x0007)
488 #define TPM_EO_SIGNED_LE    (TPM_EO)(0x0008)
489 #define TPM_EO_UNSIGNED_LE  (TPM_EO)(0x0009)
490 #define TPM_EO_BITSET       (TPM_EO)(0x000A)
491 #define TPM_EO_BITCLEAR     (TPM_EO)(0x000B)
492 
493 // Table 2:19 - Definition of TPM_ST Constants
494 typedef UINT16                          TPM_ST;
495 #define TYPE_OF_TPM_ST                  UINT16
496 #define TPM_ST_RSP_COMMAND              (TPM_ST)(0x00C4)
497 #define TPM_ST_NULL                     (TPM_ST)(0x8000)
498 #define TPM_ST_NO_SESSIONS              (TPM_ST)(0x8001)
499 #define TPM_ST_SESSIONS                 (TPM_ST)(0x8002)
500 #define TPM_ST_ATTEST_NV                (TPM_ST)(0x8014)
501 #define TPM_ST_ATTEST_COMMAND_AUDIT     (TPM_ST)(0x8015)
502 #define TPM_ST_ATTEST_SESSION_AUDIT     (TPM_ST)(0x8016)
503 #define TPM_ST_ATTEST_CERTIFY           (TPM_ST)(0x8017)
504 #define TPM_ST_ATTEST_QUOTE             (TPM_ST)(0x8018)
505 #define TPM_ST_ATTEST_TIME              (TPM_ST)(0x8019)
506 #define TPM_ST_ATTEST_CREATION          (TPM_ST)(0x801A)
507 #define TPM_ST_ATTEST_NV_DIGEST         (TPM_ST)(0x801C)
508 #define TPM_ST_CREATION                 (TPM_ST)(0x8021)
509 #define TPM_ST_VERIFIED                 (TPM_ST)(0x8022)
510 #define TPM_ST_AUTH_SECRET              (TPM_ST)(0x8023)
511 #define TPM_ST_HASHCHECK                (TPM_ST)(0x8024)
512 #define TPM_ST_AUTH_SIGNED              (TPM_ST)(0x8025)
513 #define TPM_ST_FU_MANIFEST              (TPM_ST)(0x8029)
514 
515 // Table 2:20 - Definition of TPM_SU Constants
516 typedef UINT16              TPM_SU;
517 #define TYPE_OF_TPM_SU      UINT16
518 #define TPM_SU_CLEAR        (TPM_SU)(0x0000)
519 #define TPM_SU_STATE        (TPM_SU)(0x0001)
520 
521 // Table 2:21 - Definition of TPM_SE Constants
522 typedef UINT8               TPM_SE;
523 #define TYPE_OF_TPM_SE      UINT8
524 #define TPM_SE_HMAC         (TPM_SE)(0x00)
525 #define TPM_SE_POLICY       (TPM_SE)(0x01)
526 #define TPM_SE_TRIAL        (TPM_SE)(0x03)
527 
528 // Table 2:22 - Definition of TPM_CAP Constants
529 typedef UINT32                      TPM_CAP;
530 #define TYPE_OF_TPM_CAP             UINT32
531 #define TPM_CAP_FIRST               (TPM_CAP)(0x00000000)
532 #define TPM_CAP_ALGS                (TPM_CAP)(0x00000000)
533 #define TPM_CAP_HANDLES             (TPM_CAP)(0x00000001)
534 #define TPM_CAP_COMMANDS            (TPM_CAP)(0x00000002)
535 #define TPM_CAP_PP_COMMANDS         (TPM_CAP)(0x00000003)
536 #define TPM_CAP_AUDIT_COMMANDS      (TPM_CAP)(0x00000004)
537 #define TPM_CAP_PCRS                (TPM_CAP)(0x00000005)
538 #define TPM_CAP_TPM_PROPERTIES      (TPM_CAP)(0x00000006)
539 #define TPM_CAP_PCR_PROPERTIES      (TPM_CAP)(0x00000007)
540 #define TPM_CAP_ECC_CURVES          (TPM_CAP)(0x00000008)
541 #define TPM_CAP_AUTH_POLICIES       (TPM_CAP)(0x00000009)
542 #define TPM_CAP_ACT                 (TPM_CAP)(0x0000000A)
543 #define TPM_CAP_LAST                (TPM_CAP)(0x0000000A)
544 #define TPM_CAP_VENDOR_PROPERTY     (TPM_CAP)(0x00000100)
545 
546 // Table 2:23 - Definition of TPM_PT Constants
547 typedef UINT32                      TPM_PT;
548 #define TYPE_OF_TPM_PT              UINT32
549 #define TPM_PT_NONE                 (TPM_PT)(0x00000000)
550 #define PT_GROUP                    (TPM_PT)(0x00000100)
551 #define PT_FIXED                    (TPM_PT)(PT_GROUP*1)
552 #define TPM_PT_FAMILY_INDICATOR     (TPM_PT)(PT_FIXED+0)
553 #define TPM_PT_LEVEL                (TPM_PT)(PT_FIXED+1)
554 #define TPM_PT_REVISION             (TPM_PT)(PT_FIXED+2)
555 #define TPM_PT_DAY_OF_YEAR          (TPM_PT)(PT_FIXED+3)
556 #define TPM_PT_YEAR                 (TPM_PT)(PT_FIXED+4)
557 #define TPM_PT_MANUFACTURER         (TPM_PT)(PT_FIXED+5)
558 #define TPM_PT_VENDOR_STRING_1      (TPM_PT)(PT_FIXED+6)
559 #define TPM_PT_VENDOR_STRING_2      (TPM_PT)(PT_FIXED+7)
560 #define TPM_PT_VENDOR_STRING_3      (TPM_PT)(PT_FIXED+8)
561 #define TPM_PT_VENDOR_STRING_4      (TPM_PT)(PT_FIXED+9)
562 #define TPM_PT_VENDOR_TPM_TYPE      (TPM_PT)(PT_FIXED+10)
563 #define TPM_PT_FIRMWARE_VERSION_1   (TPM_PT)(PT_FIXED+11)
564 #define TPM_PT_FIRMWARE_VERSION_2   (TPM_PT)(PT_FIXED+12)
565 #define TPM_PT_INPUT_BUFFER         (TPM_PT)(PT_FIXED+13)
566 #define TPM_PT_HR_TRANSIENT_MIN     (TPM_PT)(PT_FIXED+14)
567 #define TPM_PT_HR_PERSISTENT_MIN    (TPM_PT)(PT_FIXED+15)
568 #define TPM_PT_HR_LOADED_MIN        (TPM_PT)(PT_FIXED+16)
569 #define TPM_PT_ACTIVE_SESSIONS_MAX  (TPM_PT)(PT_FIXED+17)
570 #define TPM_PT_PCR_COUNT            (TPM_PT)(PT_FIXED+18)
571 #define TPM_PT_PCR_SELECT_MIN       (TPM_PT)(PT_FIXED+19)
572 #define TPM_PT_CONTEXT_GAP_MAX      (TPM_PT)(PT_FIXED+20)
573 #define TPM_PT_NV_COUNTERS_MAX      (TPM_PT)(PT_FIXED+22)
574 #define TPM_PT_NV_INDEX_MAX         (TPM_PT)(PT_FIXED+23)
575 #define TPM_PT_MEMORY               (TPM_PT)(PT_FIXED+24)
576 #define TPM_PT_CLOCK_UPDATE         (TPM_PT)(PT_FIXED+25)
577 #define TPM_PT_CONTEXT_HASH         (TPM_PT)(PT_FIXED+26)
578 #define TPM_PT_CONTEXT_SYM          (TPM_PT)(PT_FIXED+27)
579 #define TPM_PT_CONTEXT_SYM_SIZE     (TPM_PT)(PT_FIXED+28)
580 #define TPM_PT_ORDERLY_COUNT        (TPM_PT)(PT_FIXED+29)
581 #define TPM_PT_MAX_COMMAND_SIZE     (TPM_PT)(PT_FIXED+30)
582 #define TPM_PT_MAX_RESPONSE_SIZE    (TPM_PT)(PT_FIXED+31)
583 #define TPM_PT_MAX_DIGEST           (TPM_PT)(PT_FIXED+32)
584 #define TPM_PT_MAX_OBJECT_CONTEXT   (TPM_PT)(PT_FIXED+33)
585 #define TPM_PT_MAX_SESSION_CONTEXT  (TPM_PT)(PT_FIXED+34)
586 #define TPM_PT_PS_FAMILY_INDICATOR  (TPM_PT)(PT_FIXED+35)
587 #define TPM_PT_PS_LEVEL             (TPM_PT)(PT_FIXED+36)
588 #define TPM_PT_PS_REVISION          (TPM_PT)(PT_FIXED+37)
589 #define TPM_PT_PS_DAY_OF_YEAR       (TPM_PT)(PT_FIXED+38)
590 #define TPM_PT_PS_YEAR              (TPM_PT)(PT_FIXED+39)
591 #define TPM_PT_SPLIT_MAX            (TPM_PT)(PT_FIXED+40)
592 #define TPM_PT_TOTAL_COMMANDS       (TPM_PT)(PT_FIXED+41)
593 #define TPM_PT_LIBRARY_COMMANDS     (TPM_PT)(PT_FIXED+42)
594 #define TPM_PT_VENDOR_COMMANDS      (TPM_PT)(PT_FIXED+43)
595 #define TPM_PT_NV_BUFFER_MAX        (TPM_PT)(PT_FIXED+44)
596 #define TPM_PT_MODES                (TPM_PT)(PT_FIXED+45)
597 #define TPM_PT_MAX_CAP_BUFFER       (TPM_PT)(PT_FIXED+46)
598 #define PT_VAR                      (TPM_PT)(PT_GROUP*2)
599 #define TPM_PT_PERMANENT            (TPM_PT)(PT_VAR+0)
600 #define TPM_PT_STARTUP_CLEAR        (TPM_PT)(PT_VAR+1)
601 #define TPM_PT_HR_NV_INDEX          (TPM_PT)(PT_VAR+2)
602 #define TPM_PT_HR_LOADED            (TPM_PT)(PT_VAR+3)
603 #define TPM_PT_HR_LOADED_AVAIL      (TPM_PT)(PT_VAR+4)
604 #define TPM_PT_HR_ACTIVE            (TPM_PT)(PT_VAR+5)
605 #define TPM_PT_HR_ACTIVE_AVAIL      (TPM_PT)(PT_VAR+6)
606 #define TPM_PT_HR_TRANSIENT_AVAIL   (TPM_PT)(PT_VAR+7)
607 #define TPM_PT_HR_PERSISTENT        (TPM_PT)(PT_VAR+8)
608 #define TPM_PT_HR_PERSISTENT_AVAIL  (TPM_PT)(PT_VAR+9)
609 #define TPM_PT_NV_COUNTERS          (TPM_PT)(PT_VAR+10)
610 #define TPM_PT_NV_COUNTERS_AVAIL    (TPM_PT)(PT_VAR+11)
611 #define TPM_PT_ALGORITHM_SET        (TPM_PT)(PT_VAR+12)
612 #define TPM_PT_LOADED_CURVES        (TPM_PT)(PT_VAR+13)
613 #define TPM_PT_LOCKOUT_COUNTER      (TPM_PT)(PT_VAR+14)
614 #define TPM_PT_MAX_AUTH_FAIL        (TPM_PT)(PT_VAR+15)
615 #define TPM_PT_LOCKOUT_INTERVAL     (TPM_PT)(PT_VAR+16)
616 #define TPM_PT_LOCKOUT_RECOVERY     (TPM_PT)(PT_VAR+17)
617 #define TPM_PT_NV_WRITE_RECOVERY    (TPM_PT)(PT_VAR+18)
618 #define TPM_PT_AUDIT_COUNTER_0      (TPM_PT)(PT_VAR+19)
619 #define TPM_PT_AUDIT_COUNTER_1      (TPM_PT)(PT_VAR+20)
620 
621 // Table 2:24 - Definition of TPM_PT_PCR Constants
622 typedef UINT32                      TPM_PT_PCR;
623 #define TYPE_OF_TPM_PT_PCR          UINT32
624 #define TPM_PT_PCR_FIRST            (TPM_PT_PCR)(0x00000000)
625 #define TPM_PT_PCR_SAVE             (TPM_PT_PCR)(0x00000000)
626 #define TPM_PT_PCR_EXTEND_L0        (TPM_PT_PCR)(0x00000001)
627 #define TPM_PT_PCR_RESET_L0         (TPM_PT_PCR)(0x00000002)
628 #define TPM_PT_PCR_EXTEND_L1        (TPM_PT_PCR)(0x00000003)
629 #define TPM_PT_PCR_RESET_L1         (TPM_PT_PCR)(0x00000004)
630 #define TPM_PT_PCR_EXTEND_L2        (TPM_PT_PCR)(0x00000005)
631 #define TPM_PT_PCR_RESET_L2         (TPM_PT_PCR)(0x00000006)
632 #define TPM_PT_PCR_EXTEND_L3        (TPM_PT_PCR)(0x00000007)
633 #define TPM_PT_PCR_RESET_L3         (TPM_PT_PCR)(0x00000008)
634 #define TPM_PT_PCR_EXTEND_L4        (TPM_PT_PCR)(0x00000009)
635 #define TPM_PT_PCR_RESET_L4         (TPM_PT_PCR)(0x0000000A)
636 #define TPM_PT_PCR_NO_INCREMENT     (TPM_PT_PCR)(0x00000011)
637 #define TPM_PT_PCR_DRTM_RESET       (TPM_PT_PCR)(0x00000012)
638 #define TPM_PT_PCR_POLICY           (TPM_PT_PCR)(0x00000013)
639 #define TPM_PT_PCR_AUTH             (TPM_PT_PCR)(0x00000014)
640 #define TPM_PT_PCR_LAST             (TPM_PT_PCR)(0x00000014)
641 
642 // Table 2:25 - Definition of TPM_PS Constants
643 typedef UINT32                  TPM_PS;
644 #define TYPE_OF_TPM_PS          UINT32
645 #define TPM_PS_MAIN             (TPM_PS)(0x00000000)
646 #define TPM_PS_PC               (TPM_PS)(0x00000001)
647 #define TPM_PS_PDA              (TPM_PS)(0x00000002)
648 #define TPM_PS_CELL_PHONE       (TPM_PS)(0x00000003)
649 #define TPM_PS_SERVER           (TPM_PS)(0x00000004)
650 #define TPM_PS_PERIPHERAL       (TPM_PS)(0x00000005)
651 #define TPM_PS_TSS              (TPM_PS)(0x00000006)
652 #define TPM_PS_STORAGE          (TPM_PS)(0x00000007)
653 #define TPM_PS_AUTHENTICATION   (TPM_PS)(0x00000008)
654 #define TPM_PS_EMBEDDED         (TPM_PS)(0x00000009)
655 #define TPM_PS_HARDCOPY         (TPM_PS)(0x0000000A)
656 #define TPM_PS_INFRASTRUCTURE   (TPM_PS)(0x0000000B)
657 #define TPM_PS_VIRTUALIZATION   (TPM_PS)(0x0000000C)
658 #define TPM_PS_TNC              (TPM_PS)(0x0000000D)
659 #define TPM_PS_MULTI_TENANT     (TPM_PS)(0x0000000E)
660 #define TPM_PS_TC               (TPM_PS)(0x0000000F)
661 
662 // Table 2:26 - Definition of Types for Handles
663 typedef UINT32              TPM_HANDLE;
664 #define TYPE_OF_TPM_HANDLE  UINT32
665 
666 // Table 2:27 - Definition of TPM_HT Constants
667 typedef UINT8                   TPM_HT;
668 #define TYPE_OF_TPM_HT          UINT8
669 #define TPM_HT_PCR              (TPM_HT)(0x00)
670 #define TPM_HT_NV_INDEX         (TPM_HT)(0x01)
671 #define TPM_HT_HMAC_SESSION     (TPM_HT)(0x02)
672 #define TPM_HT_LOADED_SESSION   (TPM_HT)(0x02)
673 #define TPM_HT_POLICY_SESSION   (TPM_HT)(0x03)
674 #define TPM_HT_SAVED_SESSION    (TPM_HT)(0x03)
675 #define TPM_HT_PERMANENT        (TPM_HT)(0x40)
676 #define TPM_HT_TRANSIENT        (TPM_HT)(0x80)
677 #define TPM_HT_PERSISTENT       (TPM_HT)(0x81)
678 #define TPM_HT_AC               (TPM_HT)(0x90)
679 
680 // Table 2:28 - Definition of TPM_RH Constants
681 typedef TPM_HANDLE          TPM_RH;
682 #define TPM_RH_FIRST        (TPM_RH)(0x40000000)
683 #define TPM_RH_SRK          (TPM_RH)(0x40000000)
684 #define TPM_RH_OWNER        (TPM_RH)(0x40000001)
685 #define TPM_RH_REVOKE       (TPM_RH)(0x40000002)
686 #define TPM_RH_TRANSPORT    (TPM_RH)(0x40000003)
687 #define TPM_RH_OPERATOR     (TPM_RH)(0x40000004)
688 #define TPM_RH_ADMIN        (TPM_RH)(0x40000005)
689 #define TPM_RH_EK           (TPM_RH)(0x40000006)
690 #define TPM_RH_NULL         (TPM_RH)(0x40000007)
691 #define TPM_RH_UNASSIGNED   (TPM_RH)(0x40000008)
692 #define TPM_RS_PW           (TPM_RH)(0x40000009)
693 #define TPM_RH_LOCKOUT      (TPM_RH)(0x4000000A)
694 #define TPM_RH_ENDORSEMENT  (TPM_RH)(0x4000000B)
695 #define TPM_RH_PLATFORM     (TPM_RH)(0x4000000C)
696 #define TPM_RH_PLATFORM_NV  (TPM_RH)(0x4000000D)
697 #define TPM_RH_AUTH_00      (TPM_RH)(0x40000010)
698 #define TPM_RH_AUTH_FF      (TPM_RH)(0x4000010F)
699 #define TPM_RH_ACT_0        (TPM_RH)(0x40000110)
700 #define TPM_RH_ACT_F        (TPM_RH)(0x4000011F)
701 #define TPM_RH_LAST         (TPM_RH)(0x4000011F)
702 
703 // Table 2:29 - Definition of TPM_HC Constants
704 typedef TPM_HANDLE              TPM_HC;
705 #define HR_HANDLE_MASK          (TPM_HC)(0x00FFFFFF)
706 #define HR_RANGE_MASK           (TPM_HC)(0xFF000000)
707 #define HR_SHIFT                (TPM_HC)(24)
708 #define HR_PCR                  (TPM_HC)((TPM_HT_PCR<<HR_SHIFT))
709 #define HR_HMAC_SESSION         (TPM_HC)((TPM_HT_HMAC_SESSION<<HR_SHIFT))
710 #define HR_POLICY_SESSION       (TPM_HC)((TPM_HT_POLICY_SESSION<<HR_SHIFT))
711 #define HR_TRANSIENT            (TPM_HC)((TPM_HT_TRANSIENT<<HR_SHIFT))
712 #define HR_PERSISTENT           (TPM_HC)((TPM_HT_PERSISTENT<<HR_SHIFT))
713 #define HR_NV_INDEX             (TPM_HC)((TPM_HT_NV_INDEX<<HR_SHIFT))
714 #define HR_PERMANENT            (TPM_HC)((TPM_HT_PERMANENT<<HR_SHIFT))
715 #define PCR_FIRST               (TPM_HC)((HR_PCR+0))
716 #define PCR_LAST                (TPM_HC)((PCR_FIRST+IMPLEMENTATION_PCR-1))
717 #define HMAC_SESSION_FIRST      (TPM_HC)((HR_HMAC_SESSION+0))
718 #define HMAC_SESSION_LAST       (TPM_HC)((HMAC_SESSION_FIRST+MAX_ACTIVE_SESSIONS-1))
719 #define LOADED_SESSION_FIRST    (TPM_HC)(HMAC_SESSION_FIRST)
720 #define LOADED_SESSION_LAST     (TPM_HC)(HMAC_SESSION_LAST)
721 #define POLICY_SESSION_FIRST    (TPM_HC)((HR_POLICY_SESSION+0))
722 #define POLICY_SESSION_LAST     \
723             (TPM_HC)((POLICY_SESSION_FIRST+MAX_ACTIVE_SESSIONS-1))
724 #define TRANSIENT_FIRST         (TPM_HC)((HR_TRANSIENT+0))
725 #define ACTIVE_SESSION_FIRST    (TPM_HC)(POLICY_SESSION_FIRST)
726 #define ACTIVE_SESSION_LAST     (TPM_HC)(POLICY_SESSION_LAST)
727 #define TRANSIENT_LAST          (TPM_HC)((TRANSIENT_FIRST+MAX_LOADED_OBJECTS-1))
728 #define PERSISTENT_FIRST        (TPM_HC)((HR_PERSISTENT+0))
729 #define PERSISTENT_LAST         (TPM_HC)((PERSISTENT_FIRST+0x00FFFFFF))
730 #define PLATFORM_PERSISTENT     (TPM_HC)((PERSISTENT_FIRST+0x00800000))
731 #define NV_INDEX_FIRST          (TPM_HC)((HR_NV_INDEX+0))
732 #define NV_INDEX_LAST           (TPM_HC)((NV_INDEX_FIRST+0x00FFFFFF))
733 #define PERMANENT_FIRST         (TPM_HC)(TPM_RH_FIRST)
734 #define PERMANENT_LAST          (TPM_HC)(TPM_RH_LAST)
735 #define HR_NV_AC                (TPM_HC)(((TPM_HT_NV_INDEX<<HR_SHIFT)+0xD00000))
736 #define NV_AC_FIRST             (TPM_HC)((HR_NV_AC+0))
737 #define NV_AC_LAST              (TPM_HC)((HR_NV_AC+0x0000FFFF))
738 #define HR_AC                   (TPM_HC)((TPM_HT_AC<<HR_SHIFT))
739 #define AC_FIRST                (TPM_HC)((HR_AC+0))
740 #define AC_LAST                 (TPM_HC)((HR_AC+0x0000FFFF))
741 
742 #define TYPE_OF_TPMA_ALGORITHM  UINT32
743 #define TPMA_ALGORITHM_TO_UINT32(a)  (*((UINT32 *)&(a)))
744 #define UINT32_TO_TPMA_ALGORITHM(a)  (*((TPMA_ALGORITHM *)&(a)))
745 #define TPMA_ALGORITHM_TO_BYTE_ARRAY(i, a)                                         \
746             UINT32_TO_BYTE_ARRAY((TPMA_ALGORITHM_TO_UINT32(i)), (a))
747 #define BYTE_ARRAY_TO_TPMA_ALGORITHM(i, a)                                         \
748             {UINT32 x = BYTE_ARRAY_TO_UINT32(a);                                   \
749              i = UINT32_TO_TPMA_ALGORITHM(x);                                      \
750              }
751 #if USE_BIT_FIELD_STRUCTURES
752 typedef struct TPMA_ALGORITHM {                     // Table 2:30
753     unsigned    asymmetric           : 1;
754     unsigned    symmetric            : 1;
755     unsigned    hash                 : 1;
756     unsigned    object               : 1;
757     unsigned    Reserved_bits_at_4   : 4;
758     unsigned    signing              : 1;
759     unsigned    encrypting           : 1;
760     unsigned    method               : 1;
761     unsigned    Reserved_bits_at_11  : 21;
762 } TPMA_ALGORITHM;                                   /* Bits */
763 // This is the initializer for a TPMA_ALGORITHM structure
764 #define TPMA_ALGORITHM_INITIALIZER(                                                \
765              asymmetric, symmetric,  hash,       object,     bits_at_4,            \
766              signing,    encrypting, method,     bits_at_11)                       \
767             {asymmetric, symmetric,  hash,       object,     bits_at_4,            \
768              signing,    encrypting, method,     bits_at_11}
769 #else // USE_BIT_FIELD_STRUCTURES
770 // This implements Table 2:30 TPMA_ALGORITHM using bit masking
771 typedef UINT32                      TPMA_ALGORITHM;
772 #define TYPE_OF_TPMA_ALGORITHM      UINT32
773 #define TPMA_ALGORITHM_asymmetric   ((TPMA_ALGORITHM)1 << 0)
774 #define TPMA_ALGORITHM_symmetric    ((TPMA_ALGORITHM)1 << 1)
775 #define TPMA_ALGORITHM_hash         ((TPMA_ALGORITHM)1 << 2)
776 #define TPMA_ALGORITHM_object       ((TPMA_ALGORITHM)1 << 3)
777 #define TPMA_ALGORITHM_signing      ((TPMA_ALGORITHM)1 << 8)
778 #define TPMA_ALGORITHM_encrypting   ((TPMA_ALGORITHM)1 << 9)
779 #define TPMA_ALGORITHM_method       ((TPMA_ALGORITHM)1 << 10)
780 //  This is the initializer for a TPMA_ALGORITHM bit array.
781 #define TPMA_ALGORITHM_INITIALIZER(                                                \
782              asymmetric, symmetric,  hash,       object,     bits_at_4,            \
783              signing,    encrypting, method,     bits_at_11)                       \
784     (TPMA_ALGORITHM)(                                                              \
785              (asymmetric << 0) + (symmetric << 1)  + (hash << 2)       +           \
786              (object << 3)     + (signing << 8)    + (encrypting << 9) +           \
787              (method << 10))
788 #endif // USE_BIT_FIELD_STRUCTURES
789 
790 #define TYPE_OF_TPMA_OBJECT UINT32
791 #define TPMA_OBJECT_TO_UINT32(a)     (*((UINT32 *)&(a)))
792 #define UINT32_TO_TPMA_OBJECT(a)     (*((TPMA_OBJECT *)&(a)))
793 #define TPMA_OBJECT_TO_BYTE_ARRAY(i, a)                                            \
794             UINT32_TO_BYTE_ARRAY((TPMA_OBJECT_TO_UINT32(i)), (a))
795 #define BYTE_ARRAY_TO_TPMA_OBJECT(i, a)                                            \
796             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_OBJECT(x); }
797 #if USE_BIT_FIELD_STRUCTURES
798 typedef struct TPMA_OBJECT {                        // Table 2:31
799     unsigned    Reserved_bit_at_0        : 1;
800     unsigned    fixedTPM                 : 1;
801     unsigned    stClear                  : 1;
802     unsigned    Reserved_bit_at_3        : 1;
803     unsigned    fixedParent              : 1;
804     unsigned    sensitiveDataOrigin      : 1;
805     unsigned    userWithAuth             : 1;
806     unsigned    adminWithPolicy          : 1;
807     unsigned    Reserved_bits_at_8       : 2;
808     unsigned    noDA                     : 1;
809     unsigned    encryptedDuplication     : 1;
810     unsigned    Reserved_bits_at_12      : 4;
811     unsigned    restricted               : 1;
812     unsigned    decrypt                  : 1;
813     unsigned    sign                     : 1;
814     unsigned    x509sign                 : 1;
815     unsigned    Reserved_bits_at_20      : 12;
816 } TPMA_OBJECT;                                      /* Bits */
817 // This is the initializer for a TPMA_OBJECT structure
818 #define TPMA_OBJECT_INITIALIZER(                                                   \
819              bit_at_0,             fixedtpm,             stclear,                  \
820              bit_at_3,             fixedparent,          sensitivedataorigin,      \
821              userwithauth,         adminwithpolicy,      bits_at_8,                \
822              noda,                 encryptedduplication, bits_at_12,               \
823              restricted,           decrypt,              sign,                     \
824              x509sign,             bits_at_20)                                     \
825             {bit_at_0,             fixedtpm,             stclear,                  \
826              bit_at_3,             fixedparent,          sensitivedataorigin,      \
827              userwithauth,         adminwithpolicy,      bits_at_8,                \
828              noda,                 encryptedduplication, bits_at_12,               \
829              restricted,           decrypt,              sign,                     \
830              x509sign,             bits_at_20}
831 #else // USE_BIT_FIELD_STRUCTURES
832 // This implements Table 2:31 TPMA_OBJECT using bit masking
833 typedef UINT32                              TPMA_OBJECT;
834 #define TYPE_OF_TPMA_OBJECT                 UINT32
835 #define TPMA_OBJECT_fixedTPM                ((TPMA_OBJECT)1 << 1)
836 #define TPMA_OBJECT_stClear                 ((TPMA_OBJECT)1 << 2)
837 #define TPMA_OBJECT_fixedParent             ((TPMA_OBJECT)1 << 4)
838 #define TPMA_OBJECT_sensitiveDataOrigin     ((TPMA_OBJECT)1 << 5)
839 #define TPMA_OBJECT_userWithAuth            ((TPMA_OBJECT)1 << 6)
840 #define TPMA_OBJECT_adminWithPolicy         ((TPMA_OBJECT)1 << 7)
841 #define TPMA_OBJECT_noDA                    ((TPMA_OBJECT)1 << 10)
842 #define TPMA_OBJECT_encryptedDuplication    ((TPMA_OBJECT)1 << 11)
843 #define TPMA_OBJECT_restricted              ((TPMA_OBJECT)1 << 16)
844 #define TPMA_OBJECT_decrypt                 ((TPMA_OBJECT)1 << 17)
845 #define TPMA_OBJECT_sign                    ((TPMA_OBJECT)1 << 18)
846 #define TPMA_OBJECT_x509sign                ((TPMA_OBJECT)1 << 19)
847 //  This is the initializer for a TPMA_OBJECT bit array.
848 #define TPMA_OBJECT_INITIALIZER(                                                   \
849              bit_at_0,             fixedtpm,             stclear,                  \
850              bit_at_3,             fixedparent,          sensitivedataorigin,      \
851              userwithauth,         adminwithpolicy,      bits_at_8,                \
852              noda,                 encryptedduplication, bits_at_12,               \
853              restricted,           decrypt,              sign,                     \
854              x509sign,             bits_at_20)                                     \
855     (TPMA_OBJECT)(                                                                 \
856              (fixedtpm << 1)              + (stclear << 2)               +         \
857              (fixedparent << 4)           + (sensitivedataorigin << 5)   +         \
858              (userwithauth << 6)          + (adminwithpolicy << 7)       +         \
859              (noda << 10)                 + (encryptedduplication << 11) +         \
860              (restricted << 16)           + (decrypt << 17)              +         \
861              (sign << 18)                 + (x509sign << 19))
862 #endif // USE_BIT_FIELD_STRUCTURES
863 
864 #define TYPE_OF_TPMA_SESSION    UINT8
865 #define TPMA_SESSION_TO_UINT8(a)     (*((UINT8 *)&(a)))
866 #define UINT8_TO_TPMA_SESSION(a)     (*((TPMA_SESSION *)&(a)))
867 #define TPMA_SESSION_TO_BYTE_ARRAY(i, a)                                           \
868             UINT8_TO_BYTE_ARRAY((TPMA_SESSION_TO_UINT8(i)), (a))
869 #define BYTE_ARRAY_TO_TPMA_SESSION(i, a)                                           \
870             { UINT8 x = BYTE_ARRAY_TO_UINT8(a); i = UINT8_TO_TPMA_SESSION(x); }
871 #if USE_BIT_FIELD_STRUCTURES
872 typedef struct TPMA_SESSION {                       // Table 2:32
873     unsigned    continueSession      : 1;
874     unsigned    auditExclusive       : 1;
875     unsigned    auditReset           : 1;
876     unsigned    Reserved_bits_at_3   : 2;
877     unsigned    decrypt              : 1;
878     unsigned    encrypt              : 1;
879     unsigned    audit                : 1;
880 } TPMA_SESSION;                                     /* Bits */
881 // This is the initializer for a TPMA_SESSION structure
882 #define TPMA_SESSION_INITIALIZER(                                                  \
883              continuesession, auditexclusive,  auditreset,      bits_at_3,         \
884              decrypt,         encrypt,         audit)                              \
885             {continuesession, auditexclusive,  auditreset,      bits_at_3,         \
886              decrypt,         encrypt,         audit}
887 #else // USE_BIT_FIELD_STRUCTURES
888 // This implements Table 2:32 TPMA_SESSION using bit masking
889 typedef UINT8                           TPMA_SESSION;
890 #define TYPE_OF_TPMA_SESSION            UINT8
891 #define TPMA_SESSION_continueSession    ((TPMA_SESSION)1 << 0)
892 #define TPMA_SESSION_auditExclusive     ((TPMA_SESSION)1 << 1)
893 #define TPMA_SESSION_auditReset         ((TPMA_SESSION)1 << 2)
894 #define TPMA_SESSION_decrypt            ((TPMA_SESSION)1 << 5)
895 #define TPMA_SESSION_encrypt            ((TPMA_SESSION)1 << 6)
896 #define TPMA_SESSION_audit              ((TPMA_SESSION)1 << 7)
897 //  This is the initializer for a TPMA_SESSION bit array.
898 #define TPMA_SESSION_INITIALIZER(                                                  \
899              continuesession, auditexclusive,  auditreset,      bits_at_3,         \
900              decrypt,         encrypt,         audit)                              \
901     (TPMA_SESSION)(                                                                \
902              (continuesession << 0) + (auditexclusive << 1)  +                     \
903              (auditreset << 2)      + (decrypt << 5)         +                     \
904              (encrypt << 6)         + (audit << 7))
905 #endif // USE_BIT_FIELD_STRUCTURES
906 
907 #define TYPE_OF_TPMA_LOCALITY   UINT8
908 #define TPMA_LOCALITY_TO_UINT8(a)    (*((UINT8 *)&(a)))
909 #define UINT8_TO_TPMA_LOCALITY(a)    (*((TPMA_LOCALITY *)&(a)))
910 #define TPMA_LOCALITY_TO_BYTE_ARRAY(i, a)                                          \
911             UINT8_TO_BYTE_ARRAY((TPMA_LOCALITY_TO_UINT8(i)), (a))
912 #define BYTE_ARRAY_TO_TPMA_LOCALITY(i, a)                                          \
913             { UINT8 x = BYTE_ARRAY_TO_UINT8(a); i = UINT8_TO_TPMA_LOCALITY(x); }
914 #if USE_BIT_FIELD_STRUCTURES
915 typedef struct TPMA_LOCALITY {                      // Table 2:33
916     unsigned    TPM_LOC_ZERO         : 1;
917     unsigned    TPM_LOC_ONE          : 1;
918     unsigned    TPM_LOC_TWO          : 1;
919     unsigned    TPM_LOC_THREE        : 1;
920     unsigned    TPM_LOC_FOUR         : 1;
921     unsigned    Extended             : 3;
922 } TPMA_LOCALITY;                                    /* Bits */
923 // This is the initializer for a TPMA_LOCALITY structure
924 #define TPMA_LOCALITY_INITIALIZER(                                                 \
925              tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three,           \
926              tpm_loc_four,  extended)                                              \
927             {tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three,           \
928              tpm_loc_four,  extended}
929 #else // USE_BIT_FIELD_STRUCTURES
930 // This implements Table 2:33 TPMA_LOCALITY using bit masking
931 typedef UINT8                           TPMA_LOCALITY;
932 #define TYPE_OF_TPMA_LOCALITY           UINT8
933 #define TPMA_LOCALITY_TPM_LOC_ZERO      ((TPMA_LOCALITY)1 << 0)
934 #define TPMA_LOCALITY_TPM_LOC_ONE       ((TPMA_LOCALITY)1 << 1)
935 #define TPMA_LOCALITY_TPM_LOC_TWO       ((TPMA_LOCALITY)1 << 2)
936 #define TPMA_LOCALITY_TPM_LOC_THREE     ((TPMA_LOCALITY)1 << 3)
937 #define TPMA_LOCALITY_TPM_LOC_FOUR      ((TPMA_LOCALITY)1 << 4)
938 #define TPMA_LOCALITY_Extended_SHIFT    5
939 #define TPMA_LOCALITY_Extended          ((TPMA_LOCALITY)0x7 << 5)
940 //  This is the initializer for a TPMA_LOCALITY bit array.
941 #define TPMA_LOCALITY_INITIALIZER(                                                 \
942              tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three,           \
943              tpm_loc_four,  extended)                                              \
944     (TPMA_LOCALITY)(                                                               \
945              (tpm_loc_zero << 0)  + (tpm_loc_one << 1)   + (tpm_loc_two << 2)   +  \
946              (tpm_loc_three << 3) + (tpm_loc_four << 4)  + (extended << 5))
947 #endif // USE_BIT_FIELD_STRUCTURES
948 
949 #define TYPE_OF_TPMA_PERMANENT  UINT32
950 #define TPMA_PERMANENT_TO_UINT32(a)  (*((UINT32 *)&(a)))
951 #define UINT32_TO_TPMA_PERMANENT(a)  (*((TPMA_PERMANENT *)&(a)))
952 #define TPMA_PERMANENT_TO_BYTE_ARRAY(i, a)                                         \
953             UINT32_TO_BYTE_ARRAY((TPMA_PERMANENT_TO_UINT32(i)), (a))
954 #define BYTE_ARRAY_TO_TPMA_PERMANENT(i, a)                                         \
955             {UINT32 x = BYTE_ARRAY_TO_UINT32(a);                                   \
956              i = UINT32_TO_TPMA_PERMANENT(x);                                      \
957              }
958 #if USE_BIT_FIELD_STRUCTURES
959 typedef struct TPMA_PERMANENT {                     // Table 2:34
960     unsigned    ownerAuthSet         : 1;
961     unsigned    endorsementAuthSet   : 1;
962     unsigned    lockoutAuthSet       : 1;
963     unsigned    Reserved_bits_at_3   : 5;
964     unsigned    disableClear         : 1;
965     unsigned    inLockout            : 1;
966     unsigned    tpmGeneratedEPS      : 1;
967     unsigned    Reserved_bits_at_11  : 21;
968 } TPMA_PERMANENT;                                   /* Bits */
969 // This is the initializer for a TPMA_PERMANENT structure
970 #define TPMA_PERMANENT_INITIALIZER(                                                \
971              ownerauthset,       endorsementauthset, lockoutauthset,               \
972              bits_at_3,          disableclear,       inlockout,                    \
973              tpmgeneratedeps,    bits_at_11)                                       \
974             {ownerauthset,       endorsementauthset, lockoutauthset,               \
975              bits_at_3,          disableclear,       inlockout,                    \
976              tpmgeneratedeps,    bits_at_11}
977 #else // USE_BIT_FIELD_STRUCTURES
978 // This implements Table 2:34 TPMA_PERMANENT using bit masking
979 typedef UINT32                              TPMA_PERMANENT;
980 #define TYPE_OF_TPMA_PERMANENT              UINT32
981 #define TPMA_PERMANENT_ownerAuthSet         ((TPMA_PERMANENT)1 << 0)
982 #define TPMA_PERMANENT_endorsementAuthSet   ((TPMA_PERMANENT)1 << 1)
983 #define TPMA_PERMANENT_lockoutAuthSet       ((TPMA_PERMANENT)1 << 2)
984 #define TPMA_PERMANENT_disableClear         ((TPMA_PERMANENT)1 << 8)
985 #define TPMA_PERMANENT_inLockout            ((TPMA_PERMANENT)1 << 9)
986 #define TPMA_PERMANENT_tpmGeneratedEPS      ((TPMA_PERMANENT)1 << 10)
987 //  This is the initializer for a TPMA_PERMANENT bit array.
988 #define TPMA_PERMANENT_INITIALIZER(                                                \
989              ownerauthset,       endorsementauthset, lockoutauthset,               \
990              bits_at_3,          disableclear,       inlockout,                    \
991              tpmgeneratedeps,    bits_at_11)                                       \
992     (TPMA_PERMANENT)(                                                              \
993              (ownerauthset << 0)       + (endorsementauthset << 1) +               \
994              (lockoutauthset << 2)     + (disableclear << 8)       +               \
995              (inlockout << 9)          + (tpmgeneratedeps << 10))
996 #endif // USE_BIT_FIELD_STRUCTURES
997 
998 #define TYPE_OF_TPMA_STARTUP_CLEAR  UINT32
999 #define TPMA_STARTUP_CLEAR_TO_UINT32(a)  (*((UINT32 *)&(a)))
1000 #define UINT32_TO_TPMA_STARTUP_CLEAR(a)  (*((TPMA_STARTUP_CLEAR *)&(a)))
1001 #define TPMA_STARTUP_CLEAR_TO_BYTE_ARRAY(i, a)                                     \
1002             UINT32_TO_BYTE_ARRAY((TPMA_STARTUP_CLEAR_TO_UINT32(i)), (a))
1003 #define BYTE_ARRAY_TO_TPMA_STARTUP_CLEAR(i, a)                                     \
1004             {UINT32 x = BYTE_ARRAY_TO_UINT32(a);                                   \
1005              i = UINT32_TO_TPMA_STARTUP_CLEAR(x);                                  \
1006              }
1007 #if USE_BIT_FIELD_STRUCTURES
1008 typedef struct TPMA_STARTUP_CLEAR {                 // Table 2:35
1009     unsigned    phEnable             : 1;
1010     unsigned    shEnable             : 1;
1011     unsigned    ehEnable             : 1;
1012     unsigned    phEnableNV           : 1;
1013     unsigned    Reserved_bits_at_4   : 27;
1014     unsigned    orderly              : 1;
1015 } TPMA_STARTUP_CLEAR;                               /* Bits */
1016 // This is the initializer for a TPMA_STARTUP_CLEAR structure
1017 #define TPMA_STARTUP_CLEAR_INITIALIZER(                                            \
1018              phenable, shenable, ehenable, phenablenv, bits_at_4, orderly)         \
1019             {phenable, shenable, ehenable, phenablenv, bits_at_4, orderly}
1020 #else // USE_BIT_FIELD_STRUCTURES
1021 // This implements Table 2:35 TPMA_STARTUP_CLEAR using bit masking
1022 typedef UINT32                          TPMA_STARTUP_CLEAR;
1023 #define TYPE_OF_TPMA_STARTUP_CLEAR      UINT32
1024 #define TPMA_STARTUP_CLEAR_phEnable     ((TPMA_STARTUP_CLEAR)1 << 0)
1025 #define TPMA_STARTUP_CLEAR_shEnable     ((TPMA_STARTUP_CLEAR)1 << 1)
1026 #define TPMA_STARTUP_CLEAR_ehEnable     ((TPMA_STARTUP_CLEAR)1 << 2)
1027 #define TPMA_STARTUP_CLEAR_phEnableNV   ((TPMA_STARTUP_CLEAR)1 << 3)
1028 #define TPMA_STARTUP_CLEAR_orderly      ((TPMA_STARTUP_CLEAR)1 << 31)
1029 //  This is the initializer for a TPMA_STARTUP_CLEAR bit array.
1030 #define TPMA_STARTUP_CLEAR_INITIALIZER(                                            \
1031              phenable, shenable, ehenable, phenablenv, bits_at_4, orderly)         \
1032     (TPMA_STARTUP_CLEAR)(                                                          \
1033              (phenable << 0)   + (shenable << 1)   + (ehenable << 2)   +           \
1034              (phenablenv << 3) + (orderly << 31))
1035 #endif // USE_BIT_FIELD_STRUCTURES
1036 
1037 #define TYPE_OF_TPMA_MEMORY UINT32
1038 #define TPMA_MEMORY_TO_UINT32(a)     (*((UINT32 *)&(a)))
1039 #define UINT32_TO_TPMA_MEMORY(a)     (*((TPMA_MEMORY *)&(a)))
1040 #define TPMA_MEMORY_TO_BYTE_ARRAY(i, a)                                            \
1041             UINT32_TO_BYTE_ARRAY((TPMA_MEMORY_TO_UINT32(i)), (a))
1042 #define BYTE_ARRAY_TO_TPMA_MEMORY(i, a)                                            \
1043             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_MEMORY(x); }
1044 #if USE_BIT_FIELD_STRUCTURES
1045 typedef struct TPMA_MEMORY {                        // Table 2:36
1046     unsigned    sharedRAM            : 1;
1047     unsigned    sharedNV             : 1;
1048     unsigned    objectCopiedToRam    : 1;
1049     unsigned    Reserved_bits_at_3   : 29;
1050 } TPMA_MEMORY;                                      /* Bits */
1051 // This is the initializer for a TPMA_MEMORY structure
1052 #define TPMA_MEMORY_INITIALIZER(                                                   \
1053              sharedram, sharednv, objectcopiedtoram, bits_at_3)                    \
1054             {sharedram, sharednv, objectcopiedtoram, bits_at_3}
1055 #else // USE_BIT_FIELD_STRUCTURES
1056 // This implements Table 2:36 TPMA_MEMORY using bit masking
1057 typedef UINT32                          TPMA_MEMORY;
1058 #define TYPE_OF_TPMA_MEMORY             UINT32
1059 #define TPMA_MEMORY_sharedRAM           ((TPMA_MEMORY)1 << 0)
1060 #define TPMA_MEMORY_sharedNV            ((TPMA_MEMORY)1 << 1)
1061 #define TPMA_MEMORY_objectCopiedToRam   ((TPMA_MEMORY)1 << 2)
1062 //  This is the initializer for a TPMA_MEMORY bit array.
1063 #define TPMA_MEMORY_INITIALIZER(                                                   \
1064              sharedram, sharednv, objectcopiedtoram, bits_at_3)                    \
1065     (TPMA_MEMORY)(                                                                 \
1066              (sharedram << 0) + (sharednv << 1) + (objectcopiedtoram << 2))
1067 #endif // USE_BIT_FIELD_STRUCTURES
1068 
1069 #define TYPE_OF_TPMA_CC     UINT32
1070 #define TPMA_CC_TO_UINT32(a)     (*((UINT32 *)&(a)))
1071 #define UINT32_TO_TPMA_CC(a)     (*((TPMA_CC *)&(a)))
1072 #define TPMA_CC_TO_BYTE_ARRAY(i, a)                                                \
1073             UINT32_TO_BYTE_ARRAY((TPMA_CC_TO_UINT32(i)), (a))
1074 #define BYTE_ARRAY_TO_TPMA_CC(i, a)                                                \
1075             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_CC(x); }
1076 #if USE_BIT_FIELD_STRUCTURES
1077 typedef struct TPMA_CC {                            // Table 2:37
1078     unsigned    commandIndex         : 16;
1079     unsigned    Reserved_bits_at_16  : 6;
1080     unsigned    nv                   : 1;
1081     unsigned    extensive            : 1;
1082     unsigned    flushed              : 1;
1083     unsigned    cHandles             : 3;
1084     unsigned    rHandle              : 1;
1085     unsigned    V                    : 1;
1086     unsigned    Reserved_bits_at_30  : 2;
1087 } TPMA_CC;                                          /* Bits */
1088 // This is the initializer for a TPMA_CC structure
1089 #define TPMA_CC_INITIALIZER(                                                       \
1090              commandindex, bits_at_16,   nv,           extensive,    flushed,      \
1091              chandles,     rhandle,      v,            bits_at_30)                 \
1092             {commandindex, bits_at_16,   nv,           extensive,    flushed,      \
1093              chandles,     rhandle,      v,            bits_at_30}
1094 #else // USE_BIT_FIELD_STRUCTURES
1095 // This implements Table 2:37 TPMA_CC using bit masking
1096 typedef UINT32                      TPMA_CC;
1097 #define TYPE_OF_TPMA_CC             UINT32
1098 #define TPMA_CC_commandIndex_SHIFT  0
1099 #define TPMA_CC_commandIndex        ((TPMA_CC)0xffff << 0)
1100 #define TPMA_CC_nv                  ((TPMA_CC)1 << 22)
1101 #define TPMA_CC_extensive           ((TPMA_CC)1 << 23)
1102 #define TPMA_CC_flushed             ((TPMA_CC)1 << 24)
1103 #define TPMA_CC_cHandles_SHIFT      25
1104 #define TPMA_CC_cHandles            ((TPMA_CC)0x7 << 25)
1105 #define TPMA_CC_rHandle             ((TPMA_CC)1 << 28)
1106 #define TPMA_CC_V                   ((TPMA_CC)1 << 29)
1107 //  This is the initializer for a TPMA_CC bit array.
1108 #define TPMA_CC_INITIALIZER(                                                       \
1109              commandindex, bits_at_16,   nv,           extensive,    flushed,      \
1110              chandles,     rhandle,      v,            bits_at_30)                 \
1111     (TPMA_CC)(                                                                     \
1112              (commandindex << 0) + (nv << 22)          + (extensive << 23)   +     \
1113              (flushed << 24)     + (chandles << 25)    + (rhandle << 28)     +     \
1114              (v << 29))
1115 #endif // USE_BIT_FIELD_STRUCTURES
1116 
1117 #define TYPE_OF_TPMA_MODES  UINT32
1118 #define TPMA_MODES_TO_UINT32(a)  (*((UINT32 *)&(a)))
1119 #define UINT32_TO_TPMA_MODES(a)  (*((TPMA_MODES *)&(a)))
1120 #define TPMA_MODES_TO_BYTE_ARRAY(i, a)                                             \
1121             UINT32_TO_BYTE_ARRAY((TPMA_MODES_TO_UINT32(i)), (a))
1122 #define BYTE_ARRAY_TO_TPMA_MODES(i, a)                                             \
1123             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_MODES(x); }
1124 #if USE_BIT_FIELD_STRUCTURES
1125 typedef struct TPMA_MODES {                         // Table 2:38
1126     unsigned    FIPS_140_2           : 1;
1127     unsigned    Reserved_bits_at_1   : 31;
1128 } TPMA_MODES;                                       /* Bits */
1129 // This is the initializer for a TPMA_MODES structure
1130 #define TPMA_MODES_INITIALIZER(fips_140_2, bits_at_1) {fips_140_2, bits_at_1}
1131 #else // USE_BIT_FIELD_STRUCTURES
1132 // This implements Table 2:38 TPMA_MODES using bit masking
1133 typedef UINT32                  TPMA_MODES;
1134 #define TYPE_OF_TPMA_MODES      UINT32
1135 #define TPMA_MODES_FIPS_140_2   ((TPMA_MODES)1 << 0)
1136 //  This is the initializer for a TPMA_MODES bit array.
1137 #define TPMA_MODES_INITIALIZER(fips_140_2, bits_at_1)                              \
1138     (TPMA_MODES)(                                                                  \
1139              (fips_140_2 << 0))
1140 #endif // USE_BIT_FIELD_STRUCTURES
1141 
1142 #define TYPE_OF_TPMA_X509_KEY_USAGE UINT32
1143 #define TPMA_X509_KEY_USAGE_TO_UINT32(a)     (*((UINT32 *)&(a)))
1144 #define UINT32_TO_TPMA_X509_KEY_USAGE(a)     (*((TPMA_X509_KEY_USAGE *)&(a)))
1145 #define TPMA_X509_KEY_USAGE_TO_BYTE_ARRAY(i, a)                                    \
1146             UINT32_TO_BYTE_ARRAY((TPMA_X509_KEY_USAGE_TO_UINT32(i)), (a))
1147 #define BYTE_ARRAY_TO_TPMA_X509_KEY_USAGE(i, a)                                    \
1148             {UINT32 x = BYTE_ARRAY_TO_UINT32(a);                                   \
1149              i = UINT32_TO_TPMA_X509_KEY_USAGE(x);                                 \
1150              }
1151 #if USE_BIT_FIELD_STRUCTURES
1152 typedef struct TPMA_X509_KEY_USAGE {                // Table 2:39
1153     unsigned    Reserved_bits_at_0   : 23;
1154     unsigned    decipherOnly         : 1;
1155     unsigned    encipherOnly         : 1;
1156     unsigned    cRLSign              : 1;
1157     unsigned    keyCertSign          : 1;
1158     unsigned    keyAgreement         : 1;
1159     unsigned    dataEncipherment     : 1;
1160     unsigned    keyEncipherment      : 1;
1161     unsigned    nonrepudiation       : 1;
1162     unsigned    digitalSignature     : 1;
1163 } TPMA_X509_KEY_USAGE;                              /* Bits */
1164 // This is the initializer for a TPMA_X509_KEY_USAGE structure
1165 #define TPMA_X509_KEY_USAGE_INITIALIZER(                                           \
1166              bits_at_0,        decipheronly,     encipheronly,                     \
1167              crlsign,          keycertsign,      keyagreement,                     \
1168              dataencipherment, keyencipherment,  nonrepudiation,                   \
1169              digitalsignature)                                                     \
1170             {bits_at_0,        decipheronly,     encipheronly,                     \
1171              crlsign,          keycertsign,      keyagreement,                     \
1172              dataencipherment, keyencipherment,  nonrepudiation,                   \
1173              digitalsignature}
1174 #else // USE_BIT_FIELD_STRUCTURES
1175 // This implements Table 2:39 TPMA_X509_KEY_USAGE using bit masking
1176 typedef UINT32                                  TPMA_X509_KEY_USAGE;
1177 #define TYPE_OF_TPMA_X509_KEY_USAGE             UINT32
1178 #define TPMA_X509_KEY_USAGE_decipherOnly        ((TPMA_X509_KEY_USAGE)1 << 23)
1179 #define TPMA_X509_KEY_USAGE_encipherOnly        ((TPMA_X509_KEY_USAGE)1 << 24)
1180 #define TPMA_X509_KEY_USAGE_cRLSign             ((TPMA_X509_KEY_USAGE)1 << 25)
1181 #define TPMA_X509_KEY_USAGE_keyCertSign         ((TPMA_X509_KEY_USAGE)1 << 26)
1182 #define TPMA_X509_KEY_USAGE_keyAgreement        ((TPMA_X509_KEY_USAGE)1 << 27)
1183 #define TPMA_X509_KEY_USAGE_dataEncipherment    ((TPMA_X509_KEY_USAGE)1 << 28)
1184 #define TPMA_X509_KEY_USAGE_keyEncipherment     ((TPMA_X509_KEY_USAGE)1 << 29)
1185 #define TPMA_X509_KEY_USAGE_nonrepudiation      ((TPMA_X509_KEY_USAGE)1 << 30)
1186 #define TPMA_X509_KEY_USAGE_digitalSignature    ((TPMA_X509_KEY_USAGE)1 << 31)
1187 //  This is the initializer for a TPMA_X509_KEY_USAGE bit array.
1188 #define TPMA_X509_KEY_USAGE_INITIALIZER(                                           \
1189              bits_at_0,        decipheronly,     encipheronly,                     \
1190              crlsign,          keycertsign,      keyagreement,                     \
1191              dataencipherment, keyencipherment,  nonrepudiation,                   \
1192              digitalsignature)                                                     \
1193     (TPMA_X509_KEY_USAGE)(                                                         \
1194              (decipheronly << 23)     + (encipheronly << 24)     +                 \
1195              (crlsign << 25)          + (keycertsign << 26)      +                 \
1196              (keyagreement << 27)     + (dataencipherment << 28) +                 \
1197              (keyencipherment << 29)  + (nonrepudiation << 30)   +                 \
1198              (digitalsignature << 31))
1199 #endif // USE_BIT_FIELD_STRUCTURES
1200 
1201 #define TYPE_OF_TPMA_ACT    UINT32
1202 #define TPMA_ACT_TO_UINT32(a)    (*((UINT32 *)&(a)))
1203 #define UINT32_TO_TPMA_ACT(a)    (*((TPMA_ACT *)&(a)))
1204 #define TPMA_ACT_TO_BYTE_ARRAY(i, a)                                               \
1205             UINT32_TO_BYTE_ARRAY((TPMA_ACT_TO_UINT32(i)), (a))
1206 #define BYTE_ARRAY_TO_TPMA_ACT(i, a)                                               \
1207             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_ACT(x); }
1208 #if USE_BIT_FIELD_STRUCTURES
1209 typedef struct TPMA_ACT {                           // Table 2:40
1210     unsigned    signaled             : 1;
1211     unsigned    preserveSignaled     : 1;
1212     unsigned    Reserved_bits_at_2   : 30;
1213 } TPMA_ACT;                                         /* Bits */
1214 // This is the initializer for a TPMA_ACT structure
1215 #define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)                \
1216             {signaled, preservesignaled, bits_at_2}
1217 #else // USE_BIT_FIELD_STRUCTURES
1218 // This implements Table 2:40 TPMA_ACT using bit masking
1219 typedef UINT32                      TPMA_ACT;
1220 #define TYPE_OF_TPMA_ACT            UINT32
1221 #define TPMA_ACT_signaled           ((TPMA_ACT)1 << 0)
1222 #define TPMA_ACT_preserveSignaled   ((TPMA_ACT)1 << 1)
1223 //  This is the initializer for a TPMA_ACT bit array.
1224 #define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)                \
1225     (TPMA_ACT)(                                                                    \
1226              (signaled << 0) + (preservesignaled << 1))
1227 #endif // USE_BIT_FIELD_STRUCTURES
1228 
1229 typedef BYTE                TPMI_YES_NO;            // Table 2:41  /* Interface */
1230 
1231 typedef TPM_HANDLE          TPMI_DH_OBJECT;         // Table 2:42  /* Interface */
1232 
1233 typedef TPM_HANDLE          TPMI_DH_PARENT;         // Table 2:43  /* Interface */
1234 
1235 typedef TPM_HANDLE          TPMI_DH_PERSISTENT;     // Table 2:44  /* Interface */
1236 
1237 typedef TPM_HANDLE          TPMI_DH_ENTITY;         // Table 2:45  /* Interface */
1238 
1239 typedef TPM_HANDLE          TPMI_DH_PCR;            // Table 2:46  /* Interface */
1240 
1241 typedef TPM_HANDLE          TPMI_SH_AUTH_SESSION;   // Table 2:47  /* Interface */
1242 
1243 typedef TPM_HANDLE          TPMI_SH_HMAC;           // Table 2:48  /* Interface */
1244 
1245 typedef TPM_HANDLE          TPMI_SH_POLICY;         // Table 2:49  /* Interface */
1246 
1247 typedef TPM_HANDLE          TPMI_DH_CONTEXT;        // Table 2:50  /* Interface */
1248 
1249 typedef TPM_HANDLE          TPMI_DH_SAVED;          // Table 2:51  /* Interface */
1250 
1251 typedef TPM_HANDLE          TPMI_RH_HIERARCHY;      // Table 2:52  /* Interface */
1252 
1253 typedef TPM_HANDLE          TPMI_RH_ENABLES;        // Table 2:53  /* Interface */
1254 
1255 typedef TPM_HANDLE          TPMI_RH_HIERARCHY_AUTH; // Table 2:54  /* Interface */
1256 
1257 typedef TPM_HANDLE          TPMI_RH_HIERARCHY_POLICY;
1258 
1259 typedef TPM_HANDLE          TPMI_RH_PLATFORM;       // Table 2:56  /* Interface */
1260 
1261 typedef TPM_HANDLE          TPMI_RH_OWNER;          // Table 2:57  /* Interface */
1262 
1263 typedef TPM_HANDLE          TPMI_RH_ENDORSEMENT;    // Table 2:58  /* Interface */
1264 
1265 typedef TPM_HANDLE          TPMI_RH_PROVISION;      // Table 2:59  /* Interface */
1266 
1267 typedef TPM_HANDLE          TPMI_RH_CLEAR;          // Table 2:60  /* Interface */
1268 
1269 typedef TPM_HANDLE          TPMI_RH_NV_AUTH;        // Table 2:61  /* Interface */
1270 
1271 typedef TPM_HANDLE          TPMI_RH_LOCKOUT;        // Table 2:62  /* Interface */
1272 
1273 typedef TPM_HANDLE          TPMI_RH_NV_INDEX;       // Table 2:63  /* Interface */
1274 
1275 typedef TPM_HANDLE          TPMI_RH_AC;             // Table 2:64  /* Interface */
1276 
1277 typedef TPM_HANDLE          TPMI_RH_ACT;            // Table 2:65  /* Interface */
1278 
1279 typedef TPM_ALG_ID          TPMI_ALG_HASH;          // Table 2:66  /* Interface */
1280 
1281 typedef TPM_ALG_ID          TPMI_ALG_ASYM;          // Table 2:67  /* Interface */
1282 
1283 typedef TPM_ALG_ID          TPMI_ALG_SYM;           // Table 2:68  /* Interface */
1284 
1285 typedef TPM_ALG_ID          TPMI_ALG_SYM_OBJECT;    // Table 2:69  /* Interface */
1286 
1287 typedef TPM_ALG_ID          TPMI_ALG_SYM_MODE;      // Table 2:70  /* Interface */
1288 
1289 typedef TPM_ALG_ID          TPMI_ALG_KDF;           // Table 2:71  /* Interface */
1290 
1291 typedef TPM_ALG_ID          TPMI_ALG_SIG_SCHEME;    // Table 2:72  /* Interface */
1292 
1293 typedef TPM_ALG_ID          TPMI_ECC_KEY_EXCHANGE;  // Table 2:73  /* Interface */
1294 
1295 typedef TPM_ST              TPMI_ST_COMMAND_TAG;    // Table 2:74  /* Interface */
1296 
1297 typedef TPM_ALG_ID          TPMI_ALG_MAC_SCHEME;    // Table 2:75  /* Interface */
1298 
1299 typedef TPM_ALG_ID          TPMI_ALG_CIPHER_MODE;   // Table 2:76  /* Interface */
1300 
1301 typedef BYTE                TPMS_EMPTY;             // Table 2:77
1302 
1303 typedef struct {                                    // Table 2:78
1304     TPM_ALG_ID              alg;
1305     TPMA_ALGORITHM          attributes;
1306 } TPMS_ALGORITHM_DESCRIPTION;                       /* Structure */
1307 
1308 typedef union {                                     // Table 2:79
1309 #if ALG_SHA1
1310     BYTE                    sha1[SHA1_DIGEST_SIZE];
1311 #endif // ALG_SHA1
1312 #if ALG_SHA256
1313     BYTE                    sha256[SHA256_DIGEST_SIZE];
1314 #endif // ALG_SHA256
1315 #if ALG_SHA384
1316     BYTE                    sha384[SHA384_DIGEST_SIZE];
1317 #endif // ALG_SHA384
1318 #if ALG_SHA512
1319     BYTE                    sha512[SHA512_DIGEST_SIZE];
1320 #endif // ALG_SHA512
1321 #if ALG_SM3_256
1322     BYTE                    sm3_256[SM3_256_DIGEST_SIZE];
1323 #endif // ALG_SM3_256
1324 #if ALG_SHA3_256
1325     BYTE                    sha3_256[SHA3_256_DIGEST_SIZE];
1326 #endif // ALG_SHA3_256
1327 #if ALG_SHA3_384
1328     BYTE                    sha3_384[SHA3_384_DIGEST_SIZE];
1329 #endif // ALG_SHA3_384
1330 #if ALG_SHA3_512
1331     BYTE                    sha3_512[SHA3_512_DIGEST_SIZE];
1332 #endif // ALG_SHA3_512
1333 } TPMU_HA;                                          /* Structure */
1334 
1335 typedef struct {                                    // Table 2:80
1336     TPMI_ALG_HASH           hashAlg;
1337     TPMU_HA                 digest;
1338 } TPMT_HA;                                          /* Structure */
1339 
1340 typedef union {                                     // Table 2:81
1341     struct {
1342         UINT16              size;
1343         BYTE                buffer[sizeof(TPMU_HA)];
1344     }            t;
1345     TPM2B        b;
1346 } TPM2B_DIGEST;                                     /* Structure */
1347 
1348 typedef union {                                     // Table 2:82
1349     struct {
1350         UINT16              size;
1351         BYTE                buffer[sizeof(TPMT_HA)];
1352     }            t;
1353     TPM2B        b;
1354 } TPM2B_DATA;                                       /* Structure */
1355 
1356 // Table 2:83 - Definition of Types for TPM2B_NONCE
1357 typedef TPM2B_DIGEST        TPM2B_NONCE;
1358 
1359 // Table 2:84 - Definition of Types for TPM2B_AUTH
1360 typedef TPM2B_DIGEST        TPM2B_AUTH;
1361 
1362 // Table 2:85 - Definition of Types for TPM2B_OPERAND
1363 typedef TPM2B_DIGEST        TPM2B_OPERAND;
1364 
1365 typedef union {                                     // Table 2:86
1366     struct {
1367         UINT16              size;
1368         BYTE                buffer[1024];
1369     }            t;
1370     TPM2B        b;
1371 } TPM2B_EVENT;                                      /* Structure */
1372 
1373 typedef union {                                     // Table 2:87
1374     struct {
1375         UINT16              size;
1376         BYTE                buffer[MAX_DIGEST_BUFFER];
1377     }            t;
1378     TPM2B        b;
1379 } TPM2B_MAX_BUFFER;                                 /* Structure */
1380 
1381 typedef union {                                     // Table 2:88
1382     struct {
1383         UINT16              size;
1384         BYTE                buffer[MAX_NV_BUFFER_SIZE];
1385     }            t;
1386     TPM2B        b;
1387 } TPM2B_MAX_NV_BUFFER;                              /* Structure */
1388 
1389 typedef union {                                     // Table 2:89
1390     struct {
1391         UINT16              size;
1392         BYTE                buffer[sizeof(UINT64)];
1393     }            t;
1394     TPM2B        b;
1395 } TPM2B_TIMEOUT;                                    /* Structure */
1396 
1397 typedef union {                                     // Table 2:90
1398     struct {
1399         UINT16              size;
1400         BYTE                buffer[MAX_SYM_BLOCK_SIZE];
1401     }            t;
1402     TPM2B        b;
1403 } TPM2B_IV;                                         /* Structure */
1404 
1405 typedef union {                                     // Table 2:91
1406     TPMT_HA                 digest;
1407     TPM_HANDLE              handle;
1408 } TPMU_NAME;                                        /* Structure */
1409 
1410 typedef union {                                     // Table 2:92
1411     struct {
1412         UINT16              size;
1413         BYTE                name[sizeof(TPMU_NAME)];
1414     }            t;
1415     TPM2B        b;
1416 } TPM2B_NAME;                                       /* Structure */
1417 
1418 typedef struct {                                    // Table 2:93
1419     UINT8                   sizeofSelect;
1420     BYTE                    pcrSelect[PCR_SELECT_MAX];
1421 } TPMS_PCR_SELECT;                                  /* Structure */
1422 
1423 typedef struct {                                    // Table 2:94
1424     TPMI_ALG_HASH           hash;
1425     UINT8                   sizeofSelect;
1426     BYTE                    pcrSelect[PCR_SELECT_MAX];
1427 } TPMS_PCR_SELECTION;                               /* Structure */
1428 
1429 typedef struct {                                    // Table 2:97
1430     TPM_ST                  tag;
1431     TPMI_RH_HIERARCHY       hierarchy;
1432     TPM2B_DIGEST            digest;
1433 } TPMT_TK_CREATION;                                 /* Structure */
1434 
1435 typedef struct {                                    // Table 2:98
1436     TPM_ST                  tag;
1437     TPMI_RH_HIERARCHY       hierarchy;
1438     TPM2B_DIGEST            digest;
1439 } TPMT_TK_VERIFIED;                                 /* Structure */
1440 
1441 typedef struct {                                    // Table 2:99
1442     TPM_ST                  tag;
1443     TPMI_RH_HIERARCHY       hierarchy;
1444     TPM2B_DIGEST            digest;
1445 } TPMT_TK_AUTH;                                     /* Structure */
1446 
1447 typedef struct {                                    // Table 2:100
1448     TPM_ST                  tag;
1449     TPMI_RH_HIERARCHY       hierarchy;
1450     TPM2B_DIGEST            digest;
1451 } TPMT_TK_HASHCHECK;                                /* Structure */
1452 
1453 typedef struct {                                    // Table 2:101
1454     TPM_ALG_ID              alg;
1455     TPMA_ALGORITHM          algProperties;
1456 } TPMS_ALG_PROPERTY;                                /* Structure */
1457 
1458 typedef struct {                                    // Table 2:102
1459     TPM_PT                  property;
1460     UINT32                  value;
1461 } TPMS_TAGGED_PROPERTY;                             /* Structure */
1462 
1463 typedef struct {                                    // Table 2:103
1464     TPM_PT_PCR              tag;
1465     UINT8                   sizeofSelect;
1466     BYTE                    pcrSelect[PCR_SELECT_MAX];
1467 } TPMS_TAGGED_PCR_SELECT;                           /* Structure */
1468 
1469 typedef struct {                                    // Table 2:104
1470     TPM_HANDLE              handle;
1471     TPMT_HA                 policyHash;
1472 } TPMS_TAGGED_POLICY;                               /* Structure */
1473 
1474 typedef struct {                                    // Table 2:105
1475     TPM_HANDLE              handle;
1476     UINT32                  timeout;
1477     TPMA_ACT                attributes;
1478 } TPMS_ACT_DATA;                                    /* Structure */
1479 
1480 typedef struct {                                    // Table 2:106
1481     UINT32                  count;
1482     TPM_CC                  commandCodes[MAX_CAP_CC];
1483 } TPML_CC;                                          /* Structure */
1484 
1485 typedef struct {                                    // Table 2:107
1486     UINT32                  count;
1487     TPMA_CC                 commandAttributes[MAX_CAP_CC];
1488 } TPML_CCA;                                         /* Structure */
1489 
1490 typedef struct {                                    // Table 2:108
1491     UINT32                  count;
1492     TPM_ALG_ID              algorithms[MAX_ALG_LIST_SIZE];
1493 } TPML_ALG;                                         /* Structure */
1494 
1495 typedef struct {                                    // Table 2:109
1496     UINT32                  count;
1497     TPM_HANDLE              handle[MAX_CAP_HANDLES];
1498 } TPML_HANDLE;                                      /* Structure */
1499 
1500 typedef struct {                                    // Table 2:110
1501     UINT32                  count;
1502     TPM2B_DIGEST            digests[8];
1503 } TPML_DIGEST;                                      /* Structure */
1504 
1505 typedef struct {                                    // Table 2:111
1506     UINT32                  count;
1507     TPMT_HA                 digests[HASH_COUNT];
1508 } TPML_DIGEST_VALUES;                               /* Structure */
1509 
1510 typedef struct {                                    // Table 2:112
1511     UINT32                  count;
1512     TPMS_PCR_SELECTION      pcrSelections[HASH_COUNT];
1513 } TPML_PCR_SELECTION;                               /* Structure */
1514 
1515 typedef struct {                                    // Table 2:113
1516     UINT32                  count;
1517     TPMS_ALG_PROPERTY       algProperties[MAX_CAP_ALGS];
1518 } TPML_ALG_PROPERTY;                                /* Structure */
1519 
1520 typedef struct {                                    // Table 2:114
1521     UINT32                      count;
1522     TPMS_TAGGED_PROPERTY        tpmProperty[MAX_TPM_PROPERTIES];
1523 } TPML_TAGGED_TPM_PROPERTY;                         /* Structure */
1524 
1525 typedef struct {                                    // Table 2:115
1526     UINT32                      count;
1527     TPMS_TAGGED_PCR_SELECT      pcrProperty[MAX_PCR_PROPERTIES];
1528 } TPML_TAGGED_PCR_PROPERTY;                         /* Structure */
1529 
1530 typedef struct {                                    // Table 2:116
1531     UINT32                  count;
1532     TPM_ECC_CURVE           eccCurves[MAX_ECC_CURVES];
1533 } TPML_ECC_CURVE;                                   /* Structure */
1534 
1535 typedef struct {                                    // Table 2:117
1536     UINT32                  count;
1537     TPMS_TAGGED_POLICY      policies[MAX_TAGGED_POLICIES];
1538 } TPML_TAGGED_POLICY;                               /* Structure */
1539 
1540 typedef struct {                                    // Table 2:118
1541     UINT32                  count;
1542     TPMS_ACT_DATA           actData[MAX_ACT_DATA];
1543 } TPML_ACT_DATA;                                    /* Structure */
1544 
1545 typedef union {                                     // Table 2:119
1546     TPML_ALG_PROPERTY               algorithms;
1547     TPML_HANDLE                     handles;
1548     TPML_CCA                        command;
1549     TPML_CC                         ppCommands;
1550     TPML_CC                         auditCommands;
1551     TPML_PCR_SELECTION              assignedPCR;
1552     TPML_TAGGED_TPM_PROPERTY        tpmProperties;
1553     TPML_TAGGED_PCR_PROPERTY        pcrProperties;
1554 #if ALG_ECC
1555     TPML_ECC_CURVE                  eccCurves;
1556 #endif // ALG_ECC
1557     TPML_TAGGED_POLICY              authPolicies;
1558     TPML_ACT_DATA                   actData;
1559 } TPMU_CAPABILITIES;                                /* Structure */
1560 
1561 typedef struct {                                    // Table 2:120
1562     TPM_CAP                 capability;
1563     TPMU_CAPABILITIES       data;
1564 } TPMS_CAPABILITY_DATA;                             /* Structure */
1565 
1566 typedef struct {                                    // Table 2:121
1567     UINT64                  clock;
1568     UINT32                  resetCount;
1569     UINT32                  restartCount;
1570     TPMI_YES_NO             safe;
1571 } TPMS_CLOCK_INFO;                                  /* Structure */
1572 
1573 typedef struct {                                    // Table 2:122
1574     UINT64                  time;
1575     TPMS_CLOCK_INFO         clockInfo;
1576 } TPMS_TIME_INFO;                                   /* Structure */
1577 
1578 typedef struct {                                    // Table 2:123
1579     TPMS_TIME_INFO          time;
1580     UINT64                  firmwareVersion;
1581 } TPMS_TIME_ATTEST_INFO;                            /* Structure */
1582 
1583 typedef struct {                                    // Table 2:124
1584     TPM2B_NAME              name;
1585     TPM2B_NAME              qualifiedName;
1586 } TPMS_CERTIFY_INFO;                                /* Structure */
1587 
1588 typedef struct {                                    // Table 2:125
1589     TPML_PCR_SELECTION      pcrSelect;
1590     TPM2B_DIGEST            pcrDigest;
1591 } TPMS_QUOTE_INFO;                                  /* Structure */
1592 
1593 typedef struct {                                    // Table 2:126
1594     UINT64                  auditCounter;
1595     TPM_ALG_ID              digestAlg;
1596     TPM2B_DIGEST            auditDigest;
1597     TPM2B_DIGEST            commandDigest;
1598 } TPMS_COMMAND_AUDIT_INFO;                          /* Structure */
1599 
1600 typedef struct {                                    // Table 2:127
1601     TPMI_YES_NO             exclusiveSession;
1602     TPM2B_DIGEST            sessionDigest;
1603 } TPMS_SESSION_AUDIT_INFO;                          /* Structure */
1604 
1605 typedef struct {                                    // Table 2:128
1606     TPM2B_NAME              objectName;
1607     TPM2B_DIGEST            creationHash;
1608 } TPMS_CREATION_INFO;                               /* Structure */
1609 
1610 typedef struct {                                    // Table 2:129
1611     TPM2B_NAME                  indexName;
1612     UINT16                      offset;
1613     TPM2B_MAX_NV_BUFFER         nvContents;
1614 } TPMS_NV_CERTIFY_INFO;                             /* Structure */
1615 
1616 typedef struct {                                    // Table 2:130
1617     TPM2B_NAME              indexName;
1618     TPM2B_DIGEST            nvDigest;
1619 } TPMS_NV_DIGEST_CERTIFY_INFO;                      /* Structure */
1620 
1621 typedef TPM_ST              TPMI_ST_ATTEST;         // Table 2:131  /* Interface */
1622 
1623 typedef union {                                             // Table 2:132
1624     TPMS_CERTIFY_INFO                   certify;
1625     TPMS_CREATION_INFO                  creation;
1626     TPMS_QUOTE_INFO                     quote;
1627     TPMS_COMMAND_AUDIT_INFO             commandAudit;
1628     TPMS_SESSION_AUDIT_INFO             sessionAudit;
1629     TPMS_TIME_ATTEST_INFO               time;
1630     TPMS_NV_CERTIFY_INFO                nv;
1631     TPMS_NV_DIGEST_CERTIFY_INFO         nvDigest;
1632 } TPMU_ATTEST;                                              /* Structure */
1633 
1634 typedef struct {                                    // Table 2:133
1635     TPM_CONSTANTS32         magic;
1636     TPMI_ST_ATTEST          type;
1637     TPM2B_NAME              qualifiedSigner;
1638     TPM2B_DATA              extraData;
1639     TPMS_CLOCK_INFO         clockInfo;
1640     UINT64                  firmwareVersion;
1641     TPMU_ATTEST             attested;
1642 } TPMS_ATTEST;                                      /* Structure */
1643 
1644 typedef union {                                     // Table 2:134
1645     struct {
1646         UINT16              size;
1647         BYTE                attestationData[sizeof(TPMS_ATTEST)];
1648     }            t;
1649     TPM2B        b;
1650 } TPM2B_ATTEST;                                     /* Structure */
1651 
1652 typedef struct {                                    // Table 2:135
1653     TPMI_SH_AUTH_SESSION        sessionHandle;
1654     TPM2B_NONCE                 nonce;
1655     TPMA_SESSION                sessionAttributes;
1656     TPM2B_AUTH                  hmac;
1657 } TPMS_AUTH_COMMAND;                                /* Structure */
1658 
1659 typedef struct {                                    // Table 2:136
1660     TPM2B_NONCE             nonce;
1661     TPMA_SESSION            sessionAttributes;
1662     TPM2B_AUTH              hmac;
1663 } TPMS_AUTH_RESPONSE;                               /* Structure */
1664 
1665 typedef TPM_KEY_BITS        TPMI_TDES_KEY_BITS;     // Table 2:137  /* Interface */
1666 
1667 typedef TPM_KEY_BITS        TPMI_AES_KEY_BITS;      // Table 2:137  /* Interface */
1668 
1669 typedef TPM_KEY_BITS        TPMI_SM4_KEY_BITS;      // Table 2:137  /* Interface */
1670 
1671 typedef TPM_KEY_BITS        TPMI_CAMELLIA_KEY_BITS; // Table 2:137  /* Interface */
1672 
1673 typedef union {                                     // Table 2:138
1674 #if ALG_TDES
1675     TPMI_TDES_KEY_BITS          tdes;
1676 #endif // ALG_TDES
1677 #if ALG_AES
1678     TPMI_AES_KEY_BITS           aes;
1679 #endif // ALG_AES
1680 #if ALG_SM4
1681     TPMI_SM4_KEY_BITS           sm4;
1682 #endif // ALG_SM4
1683 #if ALG_CAMELLIA
1684     TPMI_CAMELLIA_KEY_BITS      camellia;
1685 #endif // ALG_CAMELLIA
1686     TPM_KEY_BITS                sym;
1687 #if ALG_XOR
1688     TPMI_ALG_HASH               xor;
1689 #endif // ALG_XOR
1690 } TPMU_SYM_KEY_BITS;                                /* Structure */
1691 
1692 typedef union {                                     // Table 2:139
1693 #if ALG_TDES
1694     TPMI_ALG_SYM_MODE       tdes;
1695 #endif // ALG_TDES
1696 #if ALG_AES
1697     TPMI_ALG_SYM_MODE       aes;
1698 #endif // ALG_AES
1699 #if ALG_SM4
1700     TPMI_ALG_SYM_MODE       sm4;
1701 #endif // ALG_SM4
1702 #if ALG_CAMELLIA
1703     TPMI_ALG_SYM_MODE       camellia;
1704 #endif // ALG_CAMELLIA
1705     TPMI_ALG_SYM_MODE       sym;
1706 } TPMU_SYM_MODE;                                    /* Structure */
1707 
1708 typedef struct {                                    // Table 2:141
1709     TPMI_ALG_SYM            algorithm;
1710     TPMU_SYM_KEY_BITS       keyBits;
1711     TPMU_SYM_MODE           mode;
1712 } TPMT_SYM_DEF;                                     /* Structure */
1713 
1714 typedef struct {                                    // Table 2:142
1715     TPMI_ALG_SYM_OBJECT         algorithm;
1716     TPMU_SYM_KEY_BITS           keyBits;
1717     TPMU_SYM_MODE               mode;
1718 } TPMT_SYM_DEF_OBJECT;                              /* Structure */
1719 
1720 typedef union {                                     // Table 2:143
1721     struct {
1722         UINT16              size;
1723         BYTE                buffer[MAX_SYM_KEY_BYTES];
1724     }            t;
1725     TPM2B        b;
1726 } TPM2B_SYM_KEY;                                    /* Structure */
1727 
1728 typedef struct {                                    // Table 2:144
1729     TPMT_SYM_DEF_OBJECT         sym;
1730 } TPMS_SYMCIPHER_PARMS;                             /* Structure */
1731 
1732 typedef union {                                     // Table 2:145
1733     struct {
1734         UINT16              size;
1735         BYTE                buffer[LABEL_MAX_BUFFER];
1736     }            t;
1737     TPM2B        b;
1738 } TPM2B_LABEL;                                      /* Structure */
1739 
1740 typedef struct {                                    // Table 2:146
1741     TPM2B_LABEL             label;
1742     TPM2B_LABEL             context;
1743 } TPMS_DERIVE;                                      /* Structure */
1744 
1745 typedef union {                                     // Table 2:147
1746     struct {
1747         UINT16              size;
1748         BYTE                buffer[sizeof(TPMS_DERIVE)];
1749     }            t;
1750     TPM2B        b;
1751 } TPM2B_DERIVE;                                     /* Structure */
1752 
1753 typedef union {                                     // Table 2:148
1754     BYTE                    create[MAX_SYM_DATA];
1755     TPMS_DERIVE             derive;
1756 } TPMU_SENSITIVE_CREATE;                            /* Structure */
1757 
1758 typedef union {                                     // Table 2:149
1759     struct {
1760         UINT16              size;
1761         BYTE                buffer[sizeof(TPMU_SENSITIVE_CREATE)];
1762     }            t;
1763     TPM2B        b;
1764 } TPM2B_SENSITIVE_DATA;                             /* Structure */
1765 
1766 typedef struct {                                    // Table 2:150
1767     TPM2B_AUTH                  userAuth;
1768     TPM2B_SENSITIVE_DATA        data;
1769 } TPMS_SENSITIVE_CREATE;                            /* Structure */
1770 
1771 typedef struct {                                    // Table 2:151
1772     UINT16                      size;
1773     TPMS_SENSITIVE_CREATE       sensitive;
1774 } TPM2B_SENSITIVE_CREATE;                           /* Structure */
1775 
1776 typedef struct {                                    // Table 2:152
1777     TPMI_ALG_HASH           hashAlg;
1778 } TPMS_SCHEME_HASH;                                 /* Structure */
1779 
1780 typedef struct {                                    // Table 2:153
1781     TPMI_ALG_HASH           hashAlg;
1782     UINT16                  count;
1783 } TPMS_SCHEME_ECDAA;                                /* Structure */
1784 
1785 typedef TPM_ALG_ID          TPMI_ALG_KEYEDHASH_SCHEME;
1786 
1787 // Table 2:155 - Definition of Types for HMAC_SIG_SCHEME
1788 typedef TPMS_SCHEME_HASH    TPMS_SCHEME_HMAC;
1789 
1790 typedef struct {                                    // Table 2:156
1791     TPMI_ALG_HASH           hashAlg;
1792     TPMI_ALG_KDF            kdf;
1793 } TPMS_SCHEME_XOR;                                  /* Structure */
1794 
1795 typedef union {                                     // Table 2:157
1796 #if ALG_HMAC
1797     TPMS_SCHEME_HMAC        hmac;
1798 #endif // ALG_HMAC
1799 #if ALG_XOR
1800     TPMS_SCHEME_XOR         xor;
1801 #endif // ALG_XOR
1802 } TPMU_SCHEME_KEYEDHASH;                            /* Structure */
1803 
1804 typedef struct {                                    // Table 2:158
1805     TPMI_ALG_KEYEDHASH_SCHEME       scheme;
1806     TPMU_SCHEME_KEYEDHASH           details;
1807 } TPMT_KEYEDHASH_SCHEME;                            /* Structure */
1808 
1809 // Table 2:159 - Definition of Types for RSA Signature Schemes
1810 typedef TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_RSASSA;
1811 typedef TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_RSAPSS;
1812 
1813 // Table 2:160 - Definition of Types for ECC Signature Schemes
1814 typedef TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_ECDSA;
1815 typedef TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_SM2;
1816 typedef TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_ECSCHNORR;
1817 typedef TPMS_SCHEME_ECDAA   TPMS_SIG_SCHEME_ECDAA;
1818 
1819 typedef union {                                     // Table 2:161
1820 #if ALG_ECC
1821     TPMS_SIG_SCHEME_ECDAA           ecdaa;
1822 #endif // ALG_ECC
1823 #if ALG_RSASSA
1824     TPMS_SIG_SCHEME_RSASSA          rsassa;
1825 #endif // ALG_RSASSA
1826 #if ALG_RSAPSS
1827     TPMS_SIG_SCHEME_RSAPSS          rsapss;
1828 #endif // ALG_RSAPSS
1829 #if ALG_ECDSA
1830     TPMS_SIG_SCHEME_ECDSA           ecdsa;
1831 #endif // ALG_ECDSA
1832 #if ALG_SM2
1833     TPMS_SIG_SCHEME_SM2             sm2;
1834 #endif // ALG_SM2
1835 #if ALG_ECSCHNORR
1836     TPMS_SIG_SCHEME_ECSCHNORR       ecschnorr;
1837 #endif // ALG_ECSCHNORR
1838 #if ALG_HMAC
1839     TPMS_SCHEME_HMAC                hmac;
1840 #endif // ALG_HMAC
1841     TPMS_SCHEME_HASH                any;
1842 } TPMU_SIG_SCHEME;                                  /* Structure */
1843 
1844 typedef struct {                                    // Table 2:162
1845     TPMI_ALG_SIG_SCHEME         scheme;
1846     TPMU_SIG_SCHEME             details;
1847 } TPMT_SIG_SCHEME;                                  /* Structure */
1848 
1849 // Table 2:163 - Definition of Types for Encryption Schemes
1850 typedef TPMS_SCHEME_HASH    TPMS_ENC_SCHEME_OAEP;
1851 typedef TPMS_EMPTY          TPMS_ENC_SCHEME_RSAES;
1852 
1853 // Table 2:164 - Definition of Types for ECC Key Exchange
1854 typedef TPMS_SCHEME_HASH    TPMS_KEY_SCHEME_ECDH;
1855 typedef TPMS_SCHEME_HASH    TPMS_KEY_SCHEME_ECMQV;
1856 
1857 // Table 2:165 - Definition of Types for KDF Schemes
1858 typedef TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_MGF1;
1859 typedef TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF1_SP800_56A;
1860 typedef TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF2;
1861 typedef TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF1_SP800_108;
1862 
1863 typedef union {                                             // Table 2:166
1864 #if ALG_MGF1
1865     TPMS_KDF_SCHEME_MGF1                mgf1;
1866 #endif // ALG_MGF1
1867 #if ALG_KDF1_SP800_56A
1868     TPMS_KDF_SCHEME_KDF1_SP800_56A      kdf1_sp800_56a;
1869 #endif // ALG_KDF1_SP800_56A
1870 #if ALG_KDF2
1871     TPMS_KDF_SCHEME_KDF2                kdf2;
1872 #endif // ALG_KDF2
1873 #if ALG_KDF1_SP800_108
1874     TPMS_KDF_SCHEME_KDF1_SP800_108      kdf1_sp800_108;
1875 #endif // ALG_KDF1_SP800_108
1876     TPMS_SCHEME_HASH                    anyKdf;
1877 } TPMU_KDF_SCHEME;                                          /* Structure */
1878 
1879 typedef struct {                                    // Table 2:167
1880     TPMI_ALG_KDF            scheme;
1881     TPMU_KDF_SCHEME         details;
1882 } TPMT_KDF_SCHEME;                                  /* Structure */
1883 
1884 typedef TPM_ALG_ID          TPMI_ALG_ASYM_SCHEME;   // Table 2:168  /* Interface */
1885 
1886 typedef union {                                     // Table 2:169
1887 #if ALG_ECDH
1888     TPMS_KEY_SCHEME_ECDH            ecdh;
1889 #endif // ALG_ECDH
1890 #if ALG_ECMQV
1891     TPMS_KEY_SCHEME_ECMQV           ecmqv;
1892 #endif // ALG_ECMQV
1893 #if ALG_ECC
1894     TPMS_SIG_SCHEME_ECDAA           ecdaa;
1895 #endif // ALG_ECC
1896 #if ALG_RSASSA
1897     TPMS_SIG_SCHEME_RSASSA          rsassa;
1898 #endif // ALG_RSASSA
1899 #if ALG_RSAPSS
1900     TPMS_SIG_SCHEME_RSAPSS          rsapss;
1901 #endif // ALG_RSAPSS
1902 #if ALG_ECDSA
1903     TPMS_SIG_SCHEME_ECDSA           ecdsa;
1904 #endif // ALG_ECDSA
1905 #if ALG_SM2
1906     TPMS_SIG_SCHEME_SM2             sm2;
1907 #endif // ALG_SM2
1908 #if ALG_ECSCHNORR
1909     TPMS_SIG_SCHEME_ECSCHNORR       ecschnorr;
1910 #endif // ALG_ECSCHNORR
1911 #if ALG_RSAES
1912     TPMS_ENC_SCHEME_RSAES           rsaes;
1913 #endif // ALG_RSAES
1914 #if ALG_OAEP
1915     TPMS_ENC_SCHEME_OAEP            oaep;
1916 #endif // ALG_OAEP
1917     TPMS_SCHEME_HASH                anySig;
1918 } TPMU_ASYM_SCHEME;                                 /* Structure */
1919 
1920 typedef struct {                                    // Table 2:170
1921     TPMI_ALG_ASYM_SCHEME        scheme;
1922     TPMU_ASYM_SCHEME            details;
1923 } TPMT_ASYM_SCHEME;                                 /* Structure */
1924 
1925 typedef TPM_ALG_ID          TPMI_ALG_RSA_SCHEME;    // Table 2:171  /* Interface */
1926 
1927 typedef struct {                                    // Table 2:172
1928     TPMI_ALG_RSA_SCHEME         scheme;
1929     TPMU_ASYM_SCHEME            details;
1930 } TPMT_RSA_SCHEME;                                  /* Structure */
1931 
1932 typedef TPM_ALG_ID          TPMI_ALG_RSA_DECRYPT;   // Table 2:173  /* Interface */
1933 
1934 typedef struct {                                    // Table 2:174
1935     TPMI_ALG_RSA_DECRYPT        scheme;
1936     TPMU_ASYM_SCHEME            details;
1937 } TPMT_RSA_DECRYPT;                                 /* Structure */
1938 
1939 typedef union {                                     // Table 2:175
1940     struct {
1941         UINT16              size;
1942         BYTE                buffer[MAX_RSA_KEY_BYTES];
1943     }            t;
1944     TPM2B        b;
1945 } TPM2B_PUBLIC_KEY_RSA;                             /* Structure */
1946 
1947 typedef TPM_KEY_BITS        TPMI_RSA_KEY_BITS;      // Table 2:176  /* Interface */
1948 
1949 typedef union {                                     // Table 2:177
1950     struct {
1951         UINT16              size;
1952         BYTE                buffer[RSA_PRIVATE_SIZE];
1953     }            t;
1954     TPM2B        b;
1955 } TPM2B_PRIVATE_KEY_RSA;                            /* Structure */
1956 
1957 typedef union {                                     // Table 2:178
1958     struct {
1959         UINT16              size;
1960         BYTE                buffer[MAX_ECC_KEY_BYTES];
1961     }            t;
1962     TPM2B        b;
1963 } TPM2B_ECC_PARAMETER;                              /* Structure */
1964 
1965 typedef struct {                                    // Table 2:179
1966     TPM2B_ECC_PARAMETER         x;
1967     TPM2B_ECC_PARAMETER         y;
1968 } TPMS_ECC_POINT;                                   /* Structure */
1969 
1970 typedef struct {                                    // Table 2:180
1971     UINT16                  size;
1972     TPMS_ECC_POINT          point;
1973 } TPM2B_ECC_POINT;                                  /* Structure */
1974 
1975 typedef TPM_ALG_ID          TPMI_ALG_ECC_SCHEME;    // Table 2:181  /* Interface */
1976 
1977 typedef TPM_ECC_CURVE       TPMI_ECC_CURVE;         // Table 2:182  /* Interface */
1978 
1979 typedef struct {                                    // Table 2:183
1980     TPMI_ALG_ECC_SCHEME         scheme;
1981     TPMU_ASYM_SCHEME            details;
1982 } TPMT_ECC_SCHEME;                                  /* Structure */
1983 
1984 typedef struct {                                    // Table 2:184
1985     TPM_ECC_CURVE               curveID;
1986     UINT16                      keySize;
1987     TPMT_KDF_SCHEME             kdf;
1988     TPMT_ECC_SCHEME             sign;
1989     TPM2B_ECC_PARAMETER         p;
1990     TPM2B_ECC_PARAMETER         a;
1991     TPM2B_ECC_PARAMETER         b;
1992     TPM2B_ECC_PARAMETER         gX;
1993     TPM2B_ECC_PARAMETER         gY;
1994     TPM2B_ECC_PARAMETER         n;
1995     TPM2B_ECC_PARAMETER         h;
1996 } TPMS_ALGORITHM_DETAIL_ECC;                        /* Structure */
1997 
1998 typedef struct {                                    // Table 2:185
1999     TPMI_ALG_HASH               hash;
2000     TPM2B_PUBLIC_KEY_RSA        sig;
2001 } TPMS_SIGNATURE_RSA;                               /* Structure */
2002 
2003 // Table 2:186 - Definition of Types for Signature
2004 typedef TPMS_SIGNATURE_RSA  TPMS_SIGNATURE_RSASSA;
2005 typedef TPMS_SIGNATURE_RSA  TPMS_SIGNATURE_RSAPSS;
2006 
2007 typedef struct {                                    // Table 2:187
2008     TPMI_ALG_HASH               hash;
2009     TPM2B_ECC_PARAMETER         signatureR;
2010     TPM2B_ECC_PARAMETER         signatureS;
2011 } TPMS_SIGNATURE_ECC;                               /* Structure */
2012 
2013 // Table 2:188 - Definition of Types for TPMS_SIGNATURE_ECC
2014 typedef TPMS_SIGNATURE_ECC  TPMS_SIGNATURE_ECDAA;
2015 typedef TPMS_SIGNATURE_ECC  TPMS_SIGNATURE_ECDSA;
2016 typedef TPMS_SIGNATURE_ECC  TPMS_SIGNATURE_SM2;
2017 typedef TPMS_SIGNATURE_ECC  TPMS_SIGNATURE_ECSCHNORR;
2018 
2019 typedef union {                                     // Table 2:189
2020 #if ALG_ECC
2021     TPMS_SIGNATURE_ECDAA            ecdaa;
2022 #endif // ALG_ECC
2023 #if ALG_RSA
2024     TPMS_SIGNATURE_RSASSA           rsassa;
2025 #endif // ALG_RSA
2026 #if ALG_RSA
2027     TPMS_SIGNATURE_RSAPSS           rsapss;
2028 #endif // ALG_RSA
2029 #if ALG_ECC
2030     TPMS_SIGNATURE_ECDSA            ecdsa;
2031 #endif // ALG_ECC
2032 #if ALG_ECC
2033     TPMS_SIGNATURE_SM2              sm2;
2034 #endif // ALG_ECC
2035 #if ALG_ECC
2036     TPMS_SIGNATURE_ECSCHNORR        ecschnorr;
2037 #endif // ALG_ECC
2038 #if ALG_HMAC
2039     TPMT_HA                         hmac;
2040 #endif // ALG_HMAC
2041     TPMS_SCHEME_HASH                any;
2042 } TPMU_SIGNATURE;                                   /* Structure */
2043 
2044 typedef struct {                                    // Table 2:190
2045     TPMI_ALG_SIG_SCHEME         sigAlg;
2046     TPMU_SIGNATURE              signature;
2047 } TPMT_SIGNATURE;                                   /* Structure */
2048 
2049 typedef union {                                     // Table 2:191
2050 #if ALG_ECC
2051     BYTE                    ecc[sizeof(TPMS_ECC_POINT)];
2052 #endif // ALG_ECC
2053 #if ALG_RSA
2054     BYTE                    rsa[MAX_RSA_KEY_BYTES];
2055 #endif // ALG_RSA
2056 #if ALG_SYMCIPHER
2057     BYTE                    symmetric[sizeof(TPM2B_DIGEST)];
2058 #endif // ALG_SYMCIPHER
2059 #if ALG_KEYEDHASH
2060     BYTE                    keyedHash[sizeof(TPM2B_DIGEST)];
2061 #endif // ALG_KEYEDHASH
2062 } TPMU_ENCRYPTED_SECRET;                            /* Structure */
2063 
2064 typedef union {                                     // Table 2:192
2065     struct {
2066         UINT16              size;
2067         BYTE                secret[sizeof(TPMU_ENCRYPTED_SECRET)];
2068     }            t;
2069     TPM2B        b;
2070 } TPM2B_ENCRYPTED_SECRET;                           /* Structure */
2071 
2072 typedef TPM_ALG_ID          TPMI_ALG_PUBLIC;        // Table 2:193  /* Interface */
2073 
2074 typedef union {                                     // Table 2:194
2075 #if ALG_KEYEDHASH
2076     TPM2B_DIGEST                keyedHash;
2077 #endif // ALG_KEYEDHASH
2078 #if ALG_SYMCIPHER
2079     TPM2B_DIGEST                sym;
2080 #endif // ALG_SYMCIPHER
2081 #if ALG_RSA
2082     TPM2B_PUBLIC_KEY_RSA        rsa;
2083 #endif // ALG_RSA
2084 #if ALG_ECC
2085     TPMS_ECC_POINT              ecc;
2086 #endif // ALG_ECC
2087     TPMS_DERIVE                 derive;
2088 } TPMU_PUBLIC_ID;                                   /* Structure */
2089 
2090 typedef struct {                                    // Table 2:195
2091     TPMT_KEYEDHASH_SCHEME       scheme;
2092 } TPMS_KEYEDHASH_PARMS;                             /* Structure */
2093 
2094 typedef struct {                                    // Table 2:196
2095     TPMT_SYM_DEF_OBJECT         symmetric;
2096     TPMT_ASYM_SCHEME            scheme;
2097 } TPMS_ASYM_PARMS;                                  /* Structure */
2098 
2099 typedef struct {                                    // Table 2:197
2100     TPMT_SYM_DEF_OBJECT         symmetric;
2101     TPMT_RSA_SCHEME             scheme;
2102     TPMI_RSA_KEY_BITS           keyBits;
2103     UINT32                      exponent;
2104 } TPMS_RSA_PARMS;                                   /* Structure */
2105 
2106 typedef struct {                                    // Table 2:198
2107     TPMT_SYM_DEF_OBJECT         symmetric;
2108     TPMT_ECC_SCHEME             scheme;
2109     TPMI_ECC_CURVE              curveID;
2110     TPMT_KDF_SCHEME             kdf;
2111 } TPMS_ECC_PARMS;                                   /* Structure */
2112 
2113 typedef union {                                     // Table 2:199
2114 #if ALG_KEYEDHASH
2115     TPMS_KEYEDHASH_PARMS        keyedHashDetail;
2116 #endif // ALG_KEYEDHASH
2117 #if ALG_SYMCIPHER
2118     TPMS_SYMCIPHER_PARMS        symDetail;
2119 #endif // ALG_SYMCIPHER
2120 #if ALG_RSA
2121     TPMS_RSA_PARMS              rsaDetail;
2122 #endif // ALG_RSA
2123 #if ALG_ECC
2124     TPMS_ECC_PARMS              eccDetail;
2125 #endif // ALG_ECC
2126     TPMS_ASYM_PARMS             asymDetail;
2127 } TPMU_PUBLIC_PARMS;                                /* Structure */
2128 
2129 typedef struct {                                    // Table 2:200
2130     TPMI_ALG_PUBLIC         type;
2131     TPMU_PUBLIC_PARMS       parameters;
2132 } TPMT_PUBLIC_PARMS;                                /* Structure */
2133 
2134 typedef struct {                                    // Table 2:201
2135     TPMI_ALG_PUBLIC         type;
2136     TPMI_ALG_HASH           nameAlg;
2137     TPMA_OBJECT             objectAttributes;
2138     TPM2B_DIGEST            authPolicy;
2139     TPMU_PUBLIC_PARMS       parameters;
2140     TPMU_PUBLIC_ID          unique;
2141 } TPMT_PUBLIC;                                      /* Structure */
2142 
2143 typedef struct {                                    // Table 2:202
2144     UINT16                  size;
2145     TPMT_PUBLIC             publicArea;
2146 } TPM2B_PUBLIC;                                     /* Structure */
2147 
2148 typedef union {                                     // Table 2:203
2149     struct {
2150         UINT16              size;
2151         BYTE                buffer[sizeof(TPMT_PUBLIC)];
2152     }            t;
2153     TPM2B        b;
2154 } TPM2B_TEMPLATE;                                   /* Structure */
2155 
2156 typedef union {                                     // Table 2:204
2157     struct {
2158         UINT16              size;
2159         BYTE                buffer[PRIVATE_VENDOR_SPECIFIC_BYTES];
2160     }            t;
2161     TPM2B        b;
2162 } TPM2B_PRIVATE_VENDOR_SPECIFIC;                    /* Structure */
2163 
2164 typedef union {                                     // Table 2:205
2165 #if ALG_RSA
2166     TPM2B_PRIVATE_KEY_RSA               rsa;
2167 #endif // ALG_RSA
2168 #if ALG_ECC
2169     TPM2B_ECC_PARAMETER                 ecc;
2170 #endif // ALG_ECC
2171 #if ALG_KEYEDHASH
2172     TPM2B_SENSITIVE_DATA                bits;
2173 #endif // ALG_KEYEDHASH
2174 #if ALG_SYMCIPHER
2175     TPM2B_SYM_KEY                       sym;
2176 #endif // ALG_SYMCIPHER
2177     TPM2B_PRIVATE_VENDOR_SPECIFIC       any;
2178 } TPMU_SENSITIVE_COMPOSITE;                         /* Structure */
2179 
2180 typedef struct {                                    // Table 2:206
2181     TPMI_ALG_PUBLIC                 sensitiveType;
2182     TPM2B_AUTH                      authValue;
2183     TPM2B_DIGEST                    seedValue;
2184     TPMU_SENSITIVE_COMPOSITE        sensitive;
2185 } TPMT_SENSITIVE;                                   /* Structure */
2186 
2187 typedef struct {                                    // Table 2:207
2188     UINT16                  size;
2189     TPMT_SENSITIVE          sensitiveArea;
2190 } TPM2B_SENSITIVE;                                  /* Structure */
2191 
2192 typedef struct {                                    // Table 2:208
2193     TPM2B_DIGEST            integrityOuter;
2194     TPM2B_DIGEST            integrityInner;
2195     TPM2B_SENSITIVE         sensitive;
2196 } _PRIVATE;                                         /* Structure */
2197 
2198 typedef union {                                     // Table 2:209
2199     struct {
2200         UINT16              size;
2201         BYTE                buffer[sizeof(_PRIVATE)];
2202     }            t;
2203     TPM2B        b;
2204 } TPM2B_PRIVATE;                                    /* Structure */
2205 
2206 typedef struct {                                    // Table 2:210
2207     TPM2B_DIGEST            integrityHMAC;
2208     TPM2B_DIGEST            encIdentity;
2209 } TPMS_ID_OBJECT;                                   /* Structure */
2210 
2211 typedef union {                                     // Table 2:211
2212     struct {
2213         UINT16              size;
2214         BYTE                credential[sizeof(TPMS_ID_OBJECT)];
2215     }            t;
2216     TPM2B        b;
2217 } TPM2B_ID_OBJECT;                                  /* Structure */
2218 
2219 #define TYPE_OF_TPM_NV_INDEX    UINT32
2220 #define TPM_NV_INDEX_TO_UINT32(a)    (*((UINT32 *)&(a)))
2221 #define UINT32_TO_TPM_NV_INDEX(a)    (*((TPM_NV_INDEX *)&(a)))
2222 #define TPM_NV_INDEX_TO_BYTE_ARRAY(i, a)                                           \
2223             UINT32_TO_BYTE_ARRAY((TPM_NV_INDEX_TO_UINT32(i)), (a))
2224 #define BYTE_ARRAY_TO_TPM_NV_INDEX(i, a)                                           \
2225             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPM_NV_INDEX(x); }
2226 #if USE_BIT_FIELD_STRUCTURES
2227 typedef struct TPM_NV_INDEX {                       // Table 2:212
2228     unsigned    index                : 24;
2229     unsigned    RH_NV                : 8;
2230 } TPM_NV_INDEX;                                     /* Bits */
2231 // This is the initializer for a TPM_NV_INDEX structure
2232 #define TPM_NV_INDEX_INITIALIZER(index, rh_nv) {index, rh_nv}
2233 #else // USE_BIT_FIELD_STRUCTURES
2234 // This implements Table 2:212 TPM_NV_INDEX using bit masking
2235 typedef UINT32                      TPM_NV_INDEX;
2236 #define TYPE_OF_TPM_NV_INDEX        UINT32
2237 #define TPM_NV_INDEX_index_SHIFT    0
2238 #define TPM_NV_INDEX_index          ((TPM_NV_INDEX)0xffffff << 0)
2239 #define TPM_NV_INDEX_RH_NV_SHIFT    24
2240 #define TPM_NV_INDEX_RH_NV          ((TPM_NV_INDEX)0xff << 24)
2241 //  This is the initializer for a TPM_NV_INDEX bit array.
2242 #define TPM_NV_INDEX_INITIALIZER(index, rh_nv)                                     \
2243     (TPM_NV_INDEX)(                                                                \
2244              (index << 0) + (rh_nv << 24))
2245 #endif // USE_BIT_FIELD_STRUCTURES
2246 
2247 // Table 2:213 - Definition of TPM_NT Constants
2248 typedef UINT32              TPM_NT;
2249 #define TYPE_OF_TPM_NT      UINT32
2250 #define TPM_NT_ORDINARY     (TPM_NT)(0x0)
2251 #define TPM_NT_COUNTER      (TPM_NT)(0x1)
2252 #define TPM_NT_BITS         (TPM_NT)(0x2)
2253 #define TPM_NT_EXTEND       (TPM_NT)(0x4)
2254 #define TPM_NT_PIN_FAIL     (TPM_NT)(0x8)
2255 #define TPM_NT_PIN_PASS     (TPM_NT)(0x9)
2256 
2257 typedef struct {                                    // Table 2:214
2258     UINT32                  pinCount;
2259     UINT32                  pinLimit;
2260 } TPMS_NV_PIN_COUNTER_PARAMETERS;                   /* Structure */
2261 
2262 #define TYPE_OF_TPMA_NV     UINT32
2263 #define TPMA_NV_TO_UINT32(a)     (*((UINT32 *)&(a)))
2264 #define UINT32_TO_TPMA_NV(a)     (*((TPMA_NV *)&(a)))
2265 #define TPMA_NV_TO_BYTE_ARRAY(i, a)                                                \
2266             UINT32_TO_BYTE_ARRAY((TPMA_NV_TO_UINT32(i)), (a))
2267 #define BYTE_ARRAY_TO_TPMA_NV(i, a)                                                \
2268             { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_NV(x); }
2269 #if USE_BIT_FIELD_STRUCTURES
2270 typedef struct TPMA_NV {                            // Table 2:215
2271     unsigned    PPWRITE              : 1;
2272     unsigned    OWNERWRITE           : 1;
2273     unsigned    AUTHWRITE            : 1;
2274     unsigned    POLICYWRITE          : 1;
2275     unsigned    TPM_NT               : 4;
2276     unsigned    Reserved_bits_at_8   : 2;
2277     unsigned    POLICY_DELETE        : 1;
2278     unsigned    WRITELOCKED          : 1;
2279     unsigned    WRITEALL             : 1;
2280     unsigned    WRITEDEFINE          : 1;
2281     unsigned    WRITE_STCLEAR        : 1;
2282     unsigned    GLOBALLOCK           : 1;
2283     unsigned    PPREAD               : 1;
2284     unsigned    OWNERREAD            : 1;
2285     unsigned    AUTHREAD             : 1;
2286     unsigned    POLICYREAD           : 1;
2287     unsigned    Reserved_bits_at_20  : 5;
2288     unsigned    NO_DA                : 1;
2289     unsigned    ORDERLY              : 1;
2290     unsigned    CLEAR_STCLEAR        : 1;
2291     unsigned    READLOCKED           : 1;
2292     unsigned    WRITTEN              : 1;
2293     unsigned    PLATFORMCREATE       : 1;
2294     unsigned    READ_STCLEAR         : 1;
2295 } TPMA_NV;                                          /* Bits */
2296 // This is the initializer for a TPMA_NV structure
2297 #define TPMA_NV_INITIALIZER(                                                       \
2298              ppwrite,        ownerwrite,     authwrite,      policywrite,          \
2299              tpm_nt,         bits_at_8,      policy_delete,  writelocked,          \
2300              writeall,       writedefine,    write_stclear,  globallock,           \
2301              ppread,         ownerread,      authread,       policyread,           \
2302              bits_at_20,     no_da,          orderly,        clear_stclear,        \
2303              readlocked,     written,        platformcreate, read_stclear)         \
2304             {ppwrite,        ownerwrite,     authwrite,      policywrite,          \
2305              tpm_nt,         bits_at_8,      policy_delete,  writelocked,          \
2306              writeall,       writedefine,    write_stclear,  globallock,           \
2307              ppread,         ownerread,      authread,       policyread,           \
2308              bits_at_20,     no_da,          orderly,        clear_stclear,        \
2309              readlocked,     written,        platformcreate, read_stclear}
2310 #else // USE_BIT_FIELD_STRUCTURES
2311 // This implements Table 2:215 TPMA_NV using bit masking
2312 typedef UINT32                  TPMA_NV;
2313 #define TYPE_OF_TPMA_NV         UINT32
2314 #define TPMA_NV_PPWRITE         ((TPMA_NV)1 << 0)
2315 #define TPMA_NV_OWNERWRITE      ((TPMA_NV)1 << 1)
2316 #define TPMA_NV_AUTHWRITE       ((TPMA_NV)1 << 2)
2317 #define TPMA_NV_POLICYWRITE     ((TPMA_NV)1 << 3)
2318 #define TPMA_NV_TPM_NT_SHIFT    4
2319 #define TPMA_NV_TPM_NT          ((TPMA_NV)0xf << 4)
2320 #define TPMA_NV_POLICY_DELETE   ((TPMA_NV)1 << 10)
2321 #define TPMA_NV_WRITELOCKED     ((TPMA_NV)1 << 11)
2322 #define TPMA_NV_WRITEALL        ((TPMA_NV)1 << 12)
2323 #define TPMA_NV_WRITEDEFINE     ((TPMA_NV)1 << 13)
2324 #define TPMA_NV_WRITE_STCLEAR   ((TPMA_NV)1 << 14)
2325 #define TPMA_NV_GLOBALLOCK      ((TPMA_NV)1 << 15)
2326 #define TPMA_NV_PPREAD          ((TPMA_NV)1 << 16)
2327 #define TPMA_NV_OWNERREAD       ((TPMA_NV)1 << 17)
2328 #define TPMA_NV_AUTHREAD        ((TPMA_NV)1 << 18)
2329 #define TPMA_NV_POLICYREAD      ((TPMA_NV)1 << 19)
2330 #define TPMA_NV_NO_DA           ((TPMA_NV)1 << 25)
2331 #define TPMA_NV_ORDERLY         ((TPMA_NV)1 << 26)
2332 #define TPMA_NV_CLEAR_STCLEAR   ((TPMA_NV)1 << 27)
2333 #define TPMA_NV_READLOCKED      ((TPMA_NV)1 << 28)
2334 #define TPMA_NV_WRITTEN         ((TPMA_NV)1 << 29)
2335 #define TPMA_NV_PLATFORMCREATE  ((TPMA_NV)1 << 30)
2336 #define TPMA_NV_READ_STCLEAR    ((TPMA_NV)1 << 31)
2337 //  This is the initializer for a TPMA_NV bit array.
2338 #define TPMA_NV_INITIALIZER(                                                       \
2339              ppwrite,        ownerwrite,     authwrite,      policywrite,          \
2340              tpm_nt,         bits_at_8,      policy_delete,  writelocked,          \
2341              writeall,       writedefine,    write_stclear,  globallock,           \
2342              ppread,         ownerread,      authread,       policyread,           \
2343              bits_at_20,     no_da,          orderly,        clear_stclear,        \
2344              readlocked,     written,        platformcreate, read_stclear)         \
2345     (TPMA_NV)(                                                                     \
2346              (ppwrite << 0)         + (ownerwrite << 1)      +                     \
2347              (authwrite << 2)       + (policywrite << 3)     +                     \
2348              (tpm_nt << 4)          + (policy_delete << 10)  +                     \
2349              (writelocked << 11)    + (writeall << 12)       +                     \
2350              (writedefine << 13)    + (write_stclear << 14)  +                     \
2351              (globallock << 15)     + (ppread << 16)         +                     \
2352              (ownerread << 17)      + (authread << 18)       +                     \
2353              (policyread << 19)     + (no_da << 25)          +                     \
2354              (orderly << 26)        + (clear_stclear << 27)  +                     \
2355              (readlocked << 28)     + (written << 29)        +                     \
2356              (platformcreate << 30) + (read_stclear << 31))
2357 #endif // USE_BIT_FIELD_STRUCTURES
2358 
2359 typedef struct {                                    // Table 2:216
2360     TPMI_RH_NV_INDEX        nvIndex;
2361     TPMI_ALG_HASH           nameAlg;
2362     TPMA_NV                 attributes;
2363     TPM2B_DIGEST            authPolicy;
2364     UINT16                  dataSize;
2365 } TPMS_NV_PUBLIC;                                   /* Structure */
2366 
2367 typedef struct {                                    // Table 2:217
2368     UINT16                  size;
2369     TPMS_NV_PUBLIC          nvPublic;
2370 } TPM2B_NV_PUBLIC;                                  /* Structure */
2371 
2372 typedef union {                                     // Table 2:218
2373     struct {
2374         UINT16              size;
2375         BYTE                buffer[MAX_CONTEXT_SIZE];
2376     }            t;
2377     TPM2B        b;
2378 } TPM2B_CONTEXT_SENSITIVE;                          /* Structure */
2379 
2380 typedef struct {                                    // Table 2:219
2381     TPM2B_DIGEST                    integrity;
2382     TPM2B_CONTEXT_SENSITIVE         encrypted;
2383 } TPMS_CONTEXT_DATA;                                /* Structure */
2384 
2385 typedef union {                                     // Table 2:220
2386     struct {
2387         UINT16              size;
2388         BYTE                buffer[sizeof(TPMS_CONTEXT_DATA)];
2389     }            t;
2390     TPM2B        b;
2391 } TPM2B_CONTEXT_DATA;                               /* Structure */
2392 
2393 typedef struct {                                    // Table 2:221
2394     UINT64                  sequence;
2395     TPMI_DH_SAVED           savedHandle;
2396     TPMI_RH_HIERARCHY       hierarchy;
2397     TPM2B_CONTEXT_DATA      contextBlob;
2398 } TPMS_CONTEXT;                                     /* Structure */
2399 
2400 typedef struct {                                    // Table 2:223
2401     TPML_PCR_SELECTION      pcrSelect;
2402     TPM2B_DIGEST            pcrDigest;
2403     TPMA_LOCALITY           locality;
2404     TPM_ALG_ID              parentNameAlg;
2405     TPM2B_NAME              parentName;
2406     TPM2B_NAME              parentQualifiedName;
2407     TPM2B_DATA              outsideInfo;
2408 } TPMS_CREATION_DATA;                               /* Structure */
2409 
2410 typedef struct {                                    // Table 2:224
2411     UINT16                  size;
2412     TPMS_CREATION_DATA      creationData;
2413 } TPM2B_CREATION_DATA;                              /* Structure */
2414 
2415 // Table 2:225 - Definition of TPM_AT Constants
2416 typedef UINT32              TPM_AT;
2417 #define TYPE_OF_TPM_AT      UINT32
2418 #define TPM_AT_ANY          (TPM_AT)(0x00000000)
2419 #define TPM_AT_ERROR        (TPM_AT)(0x00000001)
2420 #define TPM_AT_PV1          (TPM_AT)(0x00000002)
2421 #define TPM_AT_VEND         (TPM_AT)(0x80000000)
2422 
2423 // Table 2:226 - Definition of TPM_AE Constants
2424 typedef UINT32              TPM_AE;
2425 #define TYPE_OF_TPM_AE      UINT32
2426 #define TPM_AE_NONE         (TPM_AE)(0x00000000)
2427 
2428 typedef struct {                                    // Table 2:227
2429     TPM_AT                  tag;
2430     UINT32                  data;
2431 } TPMS_AC_OUTPUT;                                   /* Structure */
2432 
2433 typedef struct {                                    // Table 2:228
2434     UINT32                  count;
2435     TPMS_AC_OUTPUT          acCapabilities[MAX_AC_CAPABILITIES];
2436 } TPML_AC_CAPABILITIES;                             /* Structure */
2437 
2438 
2439 
2440 #endif // _TPM_TYPES_H_
2441