1 /** @file
2   TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103)
3   See http://trustedcomputinggroup.org for latest specification updates
4 
5   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6   SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8 
9 
10 #ifndef _TPM12_H_
11 #define _TPM12_H_
12 
13 ///
14 /// The start of TPM return codes
15 ///
16 #define TPM_BASE                    0
17 
18 //
19 // All structures MUST be packed on a byte boundary.
20 //
21 
22 #pragma pack (1)
23 
24 //
25 // Part 2, section 2.2.3: Helper redefinitions
26 //
27 ///
28 /// Indicates the conditions where it is required that authorization be presented
29 ///
30 typedef UINT8                       TPM_AUTH_DATA_USAGE;
31 ///
32 /// The information as to what the payload is in an encrypted structure
33 ///
34 typedef UINT8                       TPM_PAYLOAD_TYPE;
35 ///
36 /// The version info breakdown
37 ///
38 typedef UINT8                       TPM_VERSION_BYTE;
39 ///
40 /// The state of the dictionary attack mitigation logic
41 ///
42 typedef UINT8                       TPM_DA_STATE;
43 ///
44 /// The request or response authorization type
45 ///
46 typedef UINT16                      TPM_TAG;
47 ///
48 /// The protocol in use
49 ///
50 typedef UINT16                      TPM_PROTOCOL_ID;
51 ///
52 /// Indicates the start state
53 ///
54 typedef UINT16                      TPM_STARTUP_TYPE;
55 ///
56 /// The definition of the encryption scheme
57 ///
58 typedef UINT16                      TPM_ENC_SCHEME;
59 ///
60 /// The definition of the signature scheme
61 ///
62 typedef UINT16                      TPM_SIG_SCHEME;
63 ///
64 /// The definition of the migration scheme
65 ///
66 typedef UINT16                      TPM_MIGRATE_SCHEME;
67 ///
68 /// Sets the state of the physical presence mechanism
69 ///
70 typedef UINT16                      TPM_PHYSICAL_PRESENCE;
71 ///
72 /// Indicates the types of entity that are supported by the TPM
73 ///
74 typedef UINT16                      TPM_ENTITY_TYPE;
75 ///
76 /// Indicates the permitted usage of the key
77 ///
78 typedef UINT16                      TPM_KEY_USAGE;
79 ///
80 /// The type of asymmetric encrypted structure in use by the endorsement key
81 ///
82 typedef UINT16                      TPM_EK_TYPE;
83 ///
84 /// The tag for the structure
85 ///
86 typedef UINT16                      TPM_STRUCTURE_TAG;
87 ///
88 /// The platform specific spec to which the information relates to
89 ///
90 typedef UINT16                      TPM_PLATFORM_SPECIFIC;
91 ///
92 /// The command ordinal
93 ///
94 typedef UINT32                      TPM_COMMAND_CODE;
95 ///
96 /// Identifies a TPM capability area
97 ///
98 typedef UINT32                      TPM_CAPABILITY_AREA;
99 ///
100 /// Indicates information regarding a key
101 ///
102 typedef UINT32                      TPM_KEY_FLAGS;
103 ///
104 /// Indicates the type of algorithm
105 ///
106 typedef UINT32                      TPM_ALGORITHM_ID;
107 ///
108 /// The locality modifier
109 ///
110 typedef UINT32                      TPM_MODIFIER_INDICATOR;
111 ///
112 /// The actual number of a counter
113 ///
114 typedef UINT32                      TPM_ACTUAL_COUNT;
115 ///
116 /// Attributes that define what options are in use for a transport session
117 ///
118 typedef UINT32                      TPM_TRANSPORT_ATTRIBUTES;
119 ///
120 /// Handle to an authorization session
121 ///
122 typedef UINT32                      TPM_AUTHHANDLE;
123 ///
124 /// Index to a DIR register
125 ///
126 typedef UINT32                      TPM_DIRINDEX;
127 ///
128 /// The area where a key is held assigned by the TPM
129 ///
130 typedef UINT32                      TPM_KEY_HANDLE;
131 ///
132 /// Index to a PCR register
133 ///
134 typedef UINT32                      TPM_PCRINDEX;
135 ///
136 /// The return code from a function
137 ///
138 typedef UINT32                      TPM_RESULT;
139 ///
140 /// The types of resources that a TPM may have using internal resources
141 ///
142 typedef UINT32                      TPM_RESOURCE_TYPE;
143 ///
144 /// Allows for controlling of the key when loaded and how to handle TPM_Startup issues
145 ///
146 typedef UINT32                      TPM_KEY_CONTROL;
147 ///
148 /// The index into the NV storage area
149 ///
150 typedef UINT32                      TPM_NV_INDEX;
151 ///
152 /// The family ID. Family IDs are automatically assigned a sequence number by the TPM.
153 /// A trusted process can set the FamilyID value in an individual row to NULL, which
154 /// invalidates that row. The family ID resets to NULL on each change of TPM Owner.
155 ///
156 typedef UINT32                      TPM_FAMILY_ID;
157 ///
158 /// IA value used as a label for the most recent verification of this family. Set to zero when not in use.
159 ///
160 typedef UINT32                      TPM_FAMILY_VERIFICATION;
161 ///
162 /// How the TPM handles var
163 ///
164 typedef UINT32                      TPM_STARTUP_EFFECTS;
165 ///
166 /// The mode of a symmetric encryption
167 ///
168 typedef UINT32                      TPM_SYM_MODE;
169 ///
170 /// The family flags
171 ///
172 typedef UINT32                      TPM_FAMILY_FLAGS;
173 ///
174 /// The index value for the delegate NV table
175 ///
176 typedef UINT32                      TPM_DELEGATE_INDEX;
177 ///
178 /// The restrictions placed on delegation of CMK commands
179 ///
180 typedef UINT32                      TPM_CMK_DELEGATE;
181 ///
182 /// The ID value of a monotonic counter
183 ///
184 typedef UINT32                      TPM_COUNT_ID;
185 ///
186 /// A command to execute
187 ///
188 typedef UINT32                      TPM_REDIT_COMMAND;
189 ///
190 /// A transport session handle
191 ///
192 typedef UINT32                      TPM_TRANSHANDLE;
193 ///
194 /// A generic handle could be key, transport etc
195 ///
196 typedef UINT32                      TPM_HANDLE;
197 ///
198 /// What operation is happening
199 ///
200 typedef UINT32                      TPM_FAMILY_OPERATION;
201 
202 //
203 // Part 2, section 2.2.4: Vendor specific
204 // The following defines allow for the quick specification of a
205 // vendor specific item.
206 //
207 #define TPM_Vendor_Specific32       ((UINT32) 0x00000400)
208 #define TPM_Vendor_Specific8        ((UINT8) 0x80)
209 
210 //
211 // Part 2, section 3.1: TPM_STRUCTURE_TAG
212 //
213 #define TPM_TAG_CONTEXTBLOB         ((TPM_STRUCTURE_TAG) 0x0001)
214 #define TPM_TAG_CONTEXT_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0002)
215 #define TPM_TAG_CONTEXTPOINTER      ((TPM_STRUCTURE_TAG) 0x0003)
216 #define TPM_TAG_CONTEXTLIST         ((TPM_STRUCTURE_TAG) 0x0004)
217 #define TPM_TAG_SIGNINFO            ((TPM_STRUCTURE_TAG) 0x0005)
218 #define TPM_TAG_PCR_INFO_LONG       ((TPM_STRUCTURE_TAG) 0x0006)
219 #define TPM_TAG_PERSISTENT_FLAGS    ((TPM_STRUCTURE_TAG) 0x0007)
220 #define TPM_TAG_VOLATILE_FLAGS      ((TPM_STRUCTURE_TAG) 0x0008)
221 #define TPM_TAG_PERSISTENT_DATA     ((TPM_STRUCTURE_TAG) 0x0009)
222 #define TPM_TAG_VOLATILE_DATA       ((TPM_STRUCTURE_TAG) 0x000A)
223 #define TPM_TAG_SV_DATA             ((TPM_STRUCTURE_TAG) 0x000B)
224 #define TPM_TAG_EK_BLOB             ((TPM_STRUCTURE_TAG) 0x000C)
225 #define TPM_TAG_EK_BLOB_AUTH        ((TPM_STRUCTURE_TAG) 0x000D)
226 #define TPM_TAG_COUNTER_VALUE       ((TPM_STRUCTURE_TAG) 0x000E)
227 #define TPM_TAG_TRANSPORT_INTERNAL  ((TPM_STRUCTURE_TAG) 0x000F)
228 #define TPM_TAG_TRANSPORT_LOG_IN    ((TPM_STRUCTURE_TAG) 0x0010)
229 #define TPM_TAG_TRANSPORT_LOG_OUT   ((TPM_STRUCTURE_TAG) 0x0011)
230 #define TPM_TAG_AUDIT_EVENT_IN      ((TPM_STRUCTURE_TAG) 0x0012)
231 #define TPM_TAG_AUDIT_EVENT_OUT     ((TPM_STRUCTURE_TAG) 0x0013)
232 #define TPM_TAG_CURRENT_TICKS       ((TPM_STRUCTURE_TAG) 0x0014)
233 #define TPM_TAG_KEY                 ((TPM_STRUCTURE_TAG) 0x0015)
234 #define TPM_TAG_STORED_DATA12       ((TPM_STRUCTURE_TAG) 0x0016)
235 #define TPM_TAG_NV_ATTRIBUTES       ((TPM_STRUCTURE_TAG) 0x0017)
236 #define TPM_TAG_NV_DATA_PUBLIC      ((TPM_STRUCTURE_TAG) 0x0018)
237 #define TPM_TAG_NV_DATA_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0019)
238 #define TPM_TAG_DELEGATIONS         ((TPM_STRUCTURE_TAG) 0x001A)
239 #define TPM_TAG_DELEGATE_PUBLIC     ((TPM_STRUCTURE_TAG) 0x001B)
240 #define TPM_TAG_DELEGATE_TABLE_ROW  ((TPM_STRUCTURE_TAG) 0x001C)
241 #define TPM_TAG_TRANSPORT_AUTH      ((TPM_STRUCTURE_TAG) 0x001D)
242 #define TPM_TAG_TRANSPORT_PUBLIC    ((TPM_STRUCTURE_TAG) 0x001E)
243 #define TPM_TAG_PERMANENT_FLAGS     ((TPM_STRUCTURE_TAG) 0x001F)
244 #define TPM_TAG_STCLEAR_FLAGS       ((TPM_STRUCTURE_TAG) 0x0020)
245 #define TPM_TAG_STANY_FLAGS         ((TPM_STRUCTURE_TAG) 0x0021)
246 #define TPM_TAG_PERMANENT_DATA      ((TPM_STRUCTURE_TAG) 0x0022)
247 #define TPM_TAG_STCLEAR_DATA        ((TPM_STRUCTURE_TAG) 0x0023)
248 #define TPM_TAG_STANY_DATA          ((TPM_STRUCTURE_TAG) 0x0024)
249 #define TPM_TAG_FAMILY_TABLE_ENTRY  ((TPM_STRUCTURE_TAG) 0x0025)
250 #define TPM_TAG_DELEGATE_SENSITIVE  ((TPM_STRUCTURE_TAG) 0x0026)
251 #define TPM_TAG_DELG_KEY_BLOB       ((TPM_STRUCTURE_TAG) 0x0027)
252 #define TPM_TAG_KEY12               ((TPM_STRUCTURE_TAG) 0x0028)
253 #define TPM_TAG_CERTIFY_INFO2       ((TPM_STRUCTURE_TAG) 0x0029)
254 #define TPM_TAG_DELEGATE_OWNER_BLOB ((TPM_STRUCTURE_TAG) 0x002A)
255 #define TPM_TAG_EK_BLOB_ACTIVATE    ((TPM_STRUCTURE_TAG) 0x002B)
256 #define TPM_TAG_DAA_BLOB            ((TPM_STRUCTURE_TAG) 0x002C)
257 #define TPM_TAG_DAA_CONTEXT         ((TPM_STRUCTURE_TAG) 0x002D)
258 #define TPM_TAG_DAA_ENFORCE         ((TPM_STRUCTURE_TAG) 0x002E)
259 #define TPM_TAG_DAA_ISSUER          ((TPM_STRUCTURE_TAG) 0x002F)
260 #define TPM_TAG_CAP_VERSION_INFO    ((TPM_STRUCTURE_TAG) 0x0030)
261 #define TPM_TAG_DAA_SENSITIVE       ((TPM_STRUCTURE_TAG) 0x0031)
262 #define TPM_TAG_DAA_TPM             ((TPM_STRUCTURE_TAG) 0x0032)
263 #define TPM_TAG_CMK_MIGAUTH         ((TPM_STRUCTURE_TAG) 0x0033)
264 #define TPM_TAG_CMK_SIGTICKET       ((TPM_STRUCTURE_TAG) 0x0034)
265 #define TPM_TAG_CMK_MA_APPROVAL     ((TPM_STRUCTURE_TAG) 0x0035)
266 #define TPM_TAG_QUOTE_INFO2         ((TPM_STRUCTURE_TAG) 0x0036)
267 #define TPM_TAG_DA_INFO             ((TPM_STRUCTURE_TAG) 0x0037)
268 #define TPM_TAG_DA_LIMITED          ((TPM_STRUCTURE_TAG) 0x0038)
269 #define TPM_TAG_DA_ACTION_TYPE      ((TPM_STRUCTURE_TAG) 0x0039)
270 
271 //
272 // Part 2, section 4: TPM Types
273 //
274 
275 //
276 // Part 2, section 4.1: TPM_RESOURCE_TYPE
277 //
278 #define TPM_RT_KEY                  ((TPM_RESOURCE_TYPE) 0x00000001) ///< The handle is a key handle and is the result of a LoadKey type operation
279 #define TPM_RT_AUTH                 ((TPM_RESOURCE_TYPE) 0x00000002) ///< The handle is an authorization handle. Auth handles come from TPM_OIAP, TPM_OSAP and TPM_DSAP
280 #define TPM_RT_HASH                 ((TPM_RESOURCE_TYPE) 0x00000003) ///< Reserved for hashes
281 #define TPM_RT_TRANS                ((TPM_RESOURCE_TYPE) 0x00000004) ///< The handle is for a transport session. Transport handles come from TPM_EstablishTransport
282 #define TPM_RT_CONTEXT              ((TPM_RESOURCE_TYPE) 0x00000005) ///< Resource wrapped and held outside the TPM using the context save/restore commands
283 #define TPM_RT_COUNTER              ((TPM_RESOURCE_TYPE) 0x00000006) ///< Reserved for counters
284 #define TPM_RT_DELEGATE             ((TPM_RESOURCE_TYPE) 0x00000007) ///< The handle is for a delegate row. These are the internal rows held in NV storage by the TPM
285 #define TPM_RT_DAA_TPM              ((TPM_RESOURCE_TYPE) 0x00000008) ///< The value is a DAA TPM specific blob
286 #define TPM_RT_DAA_V0               ((TPM_RESOURCE_TYPE) 0x00000009) ///< The value is a DAA V0 parameter
287 #define TPM_RT_DAA_V1               ((TPM_RESOURCE_TYPE) 0x0000000A) ///< The value is a DAA V1 parameter
288 
289 //
290 // Part 2, section 4.2: TPM_PAYLOAD_TYPE
291 //
292 #define TPM_PT_ASYM                 ((TPM_PAYLOAD_TYPE) 0x01) ///< The entity is an asymmetric key
293 #define TPM_PT_BIND                 ((TPM_PAYLOAD_TYPE) 0x02) ///< The entity is bound data
294 #define TPM_PT_MIGRATE              ((TPM_PAYLOAD_TYPE) 0x03) ///< The entity is a migration blob
295 #define TPM_PT_MAINT                ((TPM_PAYLOAD_TYPE) 0x04) ///< The entity is a maintenance blob
296 #define TPM_PT_SEAL                 ((TPM_PAYLOAD_TYPE) 0x05) ///< The entity is sealed data
297 #define TPM_PT_MIGRATE_RESTRICTED   ((TPM_PAYLOAD_TYPE) 0x06) ///< The entity is a restricted-migration asymmetric key
298 #define TPM_PT_MIGRATE_EXTERNAL     ((TPM_PAYLOAD_TYPE) 0x07) ///< The entity is a external migratable key
299 #define TPM_PT_CMK_MIGRATE          ((TPM_PAYLOAD_TYPE) 0x08) ///< The entity is a CMK migratable blob
300 #define TPM_PT_VENDOR_SPECIFIC      ((TPM_PAYLOAD_TYPE) 0x80) ///< 0x80 - 0xFF Vendor specific payloads
301 
302 //
303 // Part 2, section 4.3: TPM_ENTITY_TYPE
304 //
305 #define TPM_ET_KEYHANDLE            ((UINT16) 0x0001) ///< The entity is a keyHandle or key
306 #define TPM_ET_OWNER                ((UINT16) 0x0002) ///< The entity is the TPM Owner
307 #define TPM_ET_DATA                 ((UINT16) 0x0003) ///< The entity is some data
308 #define TPM_ET_SRK                  ((UINT16) 0x0004) ///< The entity is the SRK
309 #define TPM_ET_KEY                  ((UINT16) 0x0005) ///< The entity is a key or keyHandle
310 #define TPM_ET_REVOKE               ((UINT16) 0x0006) ///< The entity is the RevokeTrust value
311 #define TPM_ET_DEL_OWNER_BLOB       ((UINT16) 0x0007) ///< The entity is a delegate owner blob
312 #define TPM_ET_DEL_ROW              ((UINT16) 0x0008) ///< The entity is a delegate row
313 #define TPM_ET_DEL_KEY_BLOB         ((UINT16) 0x0009) ///< The entity is a delegate key blob
314 #define TPM_ET_COUNTER              ((UINT16) 0x000A) ///< The entity is a counter
315 #define TPM_ET_NV                   ((UINT16) 0x000B) ///< The entity is a NV index
316 #define TPM_ET_OPERATOR             ((UINT16) 0x000C) ///< The entity is the operator
317 #define TPM_ET_RESERVED_HANDLE      ((UINT16) 0x0040) ///< Reserved. This value avoids collisions with the handle MSB setting.
318 //
319 // TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable
320 //
321 #define TPM_ET_XOR                  ((UINT16) 0x0000) ///< ADIP encryption scheme: XOR
322 #define TPM_ET_AES128               ((UINT16) 0x0006) ///< ADIP encryption scheme: AES 128 bits
323 
324 //
325 // Part 2, section 4.4.1: Reserved Key Handles
326 //
327 #define TPM_KH_SRK                  ((TPM_KEY_HANDLE) 0x40000000) ///< The handle points to the SRK
328 #define TPM_KH_OWNER                ((TPM_KEY_HANDLE) 0x40000001) ///< The handle points to the TPM Owner
329 #define TPM_KH_REVOKE               ((TPM_KEY_HANDLE) 0x40000002) ///< The handle points to the RevokeTrust value
330 #define TPM_KH_TRANSPORT            ((TPM_KEY_HANDLE) 0x40000003) ///< The handle points to the EstablishTransport static authorization
331 #define TPM_KH_OPERATOR             ((TPM_KEY_HANDLE) 0x40000004) ///< The handle points to the Operator auth
332 #define TPM_KH_ADMIN                ((TPM_KEY_HANDLE) 0x40000005) ///< The handle points to the delegation administration auth
333 #define TPM_KH_EK                   ((TPM_KEY_HANDLE) 0x40000006) ///< The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub
334 
335 //
336 // Part 2, section 4.5: TPM_STARTUP_TYPE
337 //
338 #define TPM_ST_CLEAR                ((TPM_STARTUP_TYPE) 0x0001) ///< The TPM is starting up from a clean state
339 #define TPM_ST_STATE                ((TPM_STARTUP_TYPE) 0x0002) ///< The TPM is starting up from a saved state
340 #define TPM_ST_DEACTIVATED          ((TPM_STARTUP_TYPE) 0x0003) ///< The TPM is to startup and set the deactivated flag to TRUE
341 
342 //
343 // Part 2, section 4.6: TPM_STATUP_EFFECTS
344 // The table makeup is still an open issue.
345 //
346 
347 //
348 // Part 2, section 4.7: TPM_PROTOCOL_ID
349 //
350 #define TPM_PID_OIAP                ((TPM_PROTOCOL_ID) 0x0001) ///< The OIAP protocol.
351 #define TPM_PID_OSAP                ((TPM_PROTOCOL_ID) 0x0002) ///< The OSAP protocol.
352 #define TPM_PID_ADIP                ((TPM_PROTOCOL_ID) 0x0003) ///< The ADIP protocol.
353 #define TPM_PID_ADCP                ((TPM_PROTOCOL_ID) 0x0004) ///< The ADCP protocol.
354 #define TPM_PID_OWNER               ((TPM_PROTOCOL_ID) 0x0005) ///< The protocol for taking ownership of a TPM.
355 #define TPM_PID_DSAP                ((TPM_PROTOCOL_ID) 0x0006) ///< The DSAP protocol
356 #define TPM_PID_TRANSPORT           ((TPM_PROTOCOL_ID) 0x0007) ///< The transport protocol
357 
358 //
359 // Part 2, section 4.8: TPM_ALGORITHM_ID
360 //   The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC,
361 //   TPM_ALG_MGF1
362 //
363 #define TPM_ALG_RSA                 ((TPM_ALGORITHM_ID) 0x00000001) ///< The RSA algorithm.
364 #define TPM_ALG_DES                 ((TPM_ALGORITHM_ID) 0x00000002) ///< The DES algorithm
365 #define TPM_ALG_3DES                ((TPM_ALGORITHM_ID) 0x00000003) ///< The 3DES algorithm in EDE mode
366 #define TPM_ALG_SHA                 ((TPM_ALGORITHM_ID) 0x00000004) ///< The SHA1 algorithm
367 #define TPM_ALG_HMAC                ((TPM_ALGORITHM_ID) 0x00000005) ///< The RFC 2104 HMAC algorithm
368 #define TPM_ALG_AES128              ((TPM_ALGORITHM_ID) 0x00000006) ///< The AES algorithm, key size 128
369 #define TPM_ALG_MGF1                ((TPM_ALGORITHM_ID) 0x00000007) ///< The XOR algorithm using MGF1 to create a string the size of the encrypted block
370 #define TPM_ALG_AES192              ((TPM_ALGORITHM_ID) 0x00000008) ///< AES, key size 192
371 #define TPM_ALG_AES256              ((TPM_ALGORITHM_ID) 0x00000009) ///< AES, key size 256
372 #define TPM_ALG_XOR                 ((TPM_ALGORITHM_ID) 0x0000000A) ///< XOR using the rolling nonces
373 
374 //
375 // Part 2, section 4.9: TPM_PHYSICAL_PRESENCE
376 //
377 #define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((TPM_PHYSICAL_PRESENCE) 0x0200) ///< Sets the physicalPresenceHWEnable to FALSE
378 #define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((TPM_PHYSICAL_PRESENCE) 0x0100) ///< Sets the physicalPresenceCMDEnable to FALSE
379 #define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) ///< Sets the physicalPresenceLifetimeLock to TRUE
380 #define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((TPM_PHYSICAL_PRESENCE) 0x0040) ///< Sets the physicalPresenceHWEnable to TRUE
381 #define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((TPM_PHYSICAL_PRESENCE) 0x0020) ///< Sets the physicalPresenceCMDEnable to TRUE
382 #define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((TPM_PHYSICAL_PRESENCE) 0x0010) ///< Sets PhysicalPresence = FALSE
383 #define TPM_PHYSICAL_PRESENCE_PRESENT       ((TPM_PHYSICAL_PRESENCE) 0x0008) ///< Sets PhysicalPresence = TRUE
384 #define TPM_PHYSICAL_PRESENCE_LOCK          ((TPM_PHYSICAL_PRESENCE) 0x0004) ///< Sets PhysicalPresenceLock = TRUE
385 
386 //
387 // Part 2, section 4.10: TPM_MIGRATE_SCHEME
388 //
389 #define TPM_MS_MIGRATE                      ((TPM_MIGRATE_SCHEME) 0x0001) ///< A public key that can be used with all TPM migration commands other than 'ReWrap' mode.
390 #define TPM_MS_REWRAP                       ((TPM_MIGRATE_SCHEME) 0x0002) ///< A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob.
391 #define TPM_MS_MAINT                        ((TPM_MIGRATE_SCHEME) 0x0003) ///< A public key that can be used for the Maintenance commands
392 #define TPM_MS_RESTRICT_MIGRATE             ((TPM_MIGRATE_SCHEME) 0x0004) ///< The key is to be migrated to a Migration Authority.
393 #define TPM_MS_RESTRICT_APPROVE_DOUBLE      ((TPM_MIGRATE_SCHEME) 0x0005) ///< The key is to be migrated to an entity approved by a Migration Authority using double wrapping
394 
395 //
396 // Part 2, section 4.11: TPM_EK_TYPE
397 //
398 #define TPM_EK_TYPE_ACTIVATE        ((TPM_EK_TYPE) 0x0001) ///< The blob MUST be TPM_EK_BLOB_ACTIVATE
399 #define TPM_EK_TYPE_AUTH            ((TPM_EK_TYPE) 0x0002) ///< The blob MUST be TPM_EK_BLOB_AUTH
400 
401 //
402 // Part 2, section 4.12: TPM_PLATFORM_SPECIFIC
403 //
404 #define TPM_PS_PC_11                ((TPM_PLATFORM_SPECIFIC) 0x0001) ///< PC Specific version 1.1
405 #define TPM_PS_PC_12                ((TPM_PLATFORM_SPECIFIC) 0x0002) ///< PC Specific version 1.2
406 #define TPM_PS_PDA_12               ((TPM_PLATFORM_SPECIFIC) 0x0003) ///< PDA Specific version 1.2
407 #define TPM_PS_Server_12            ((TPM_PLATFORM_SPECIFIC) 0x0004) ///< Server Specific version 1.2
408 #define TPM_PS_Mobile_12            ((TPM_PLATFORM_SPECIFIC) 0x0005) ///< Mobil Specific version 1.2
409 
410 //
411 // Part 2, section 5: Basic Structures
412 //
413 
414 ///
415 /// Part 2, section 5.1: TPM_STRUCT_VER
416 ///
417 typedef struct tdTPM_STRUCT_VER {
418   UINT8                             major;
419   UINT8                             minor;
420   UINT8                             revMajor;
421   UINT8                             revMinor;
422 } TPM_STRUCT_VER;
423 
424 ///
425 /// Part 2, section 5.3: TPM_VERSION
426 ///
427 typedef struct tdTPM_VERSION {
428   TPM_VERSION_BYTE                  major;
429   TPM_VERSION_BYTE                  minor;
430   UINT8                             revMajor;
431   UINT8                             revMinor;
432 } TPM_VERSION;
433 
434 
435 #define TPM_SHA1_160_HASH_LEN       0x14
436 #define TPM_SHA1BASED_NONCE_LEN     TPM_SHA1_160_HASH_LEN
437 
438 ///
439 /// Part 2, section 5.4: TPM_DIGEST
440 ///
441 typedef struct tdTPM_DIGEST{
442   UINT8                             digest[TPM_SHA1_160_HASH_LEN];
443 } TPM_DIGEST;
444 
445 ///
446 /// This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity
447 ///
448 typedef TPM_DIGEST                  TPM_CHOSENID_HASH;
449 ///
450 /// This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to
451 ///
452 typedef TPM_DIGEST                  TPM_COMPOSITE_HASH;
453 ///
454 /// This SHALL be the value of a DIR register
455 ///
456 typedef TPM_DIGEST                  TPM_DIRVALUE;
457 
458 typedef TPM_DIGEST                  TPM_HMAC;
459 ///
460 /// The value inside of the PCR
461 ///
462 typedef TPM_DIGEST                  TPM_PCRVALUE;
463 ///
464 /// This SHALL be the value of the current internal audit state
465 ///
466 typedef TPM_DIGEST                  TPM_AUDITDIGEST;
467 
468 ///
469 /// Part 2, section 5.5: TPM_NONCE
470 ///
471 typedef struct tdTPM_NONCE{
472   UINT8                             nonce[20];
473 } TPM_NONCE;
474 
475 ///
476 /// This SHALL be a random value generated by a TPM immediately after the EK is installed
477 /// in that TPM, whenever an EK is installed in that TPM
478 ///
479 typedef TPM_NONCE                  TPM_DAA_TPM_SEED;
480 ///
481 /// This SHALL be a random value
482 ///
483 typedef TPM_NONCE                  TPM_DAA_CONTEXT_SEED;
484 
485 //
486 // Part 2, section 5.6: TPM_AUTHDATA
487 //
488 ///
489 /// The AuthData data is the information that is saved or passed to provide proof of ownership
490 /// 296 of an entity
491 ///
492 typedef UINT8                       tdTPM_AUTHDATA[20];
493 
494 typedef tdTPM_AUTHDATA              TPM_AUTHDATA;
495 ///
496 /// A secret plaintext value used in the authorization process
497 ///
498 typedef TPM_AUTHDATA                TPM_SECRET;
499 ///
500 /// A ciphertext (encrypted) version of AuthData data. The encryption mechanism depends on the context
501 ///
502 typedef TPM_AUTHDATA                TPM_ENCAUTH;
503 
504 ///
505 /// Part 2, section 5.7: TPM_KEY_HANDLE_LIST
506 /// Size of handle is loaded * sizeof(TPM_KEY_HANDLE)
507 ///
508 typedef struct tdTPM_KEY_HANDLE_LIST {
509   UINT16                            loaded;
510   TPM_KEY_HANDLE                    handle[1];
511 } TPM_KEY_HANDLE_LIST;
512 
513 //
514 // Part 2, section 5.8: TPM_KEY_USAGE values
515 //
516 ///
517 /// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be
518 /// used for signing operations, only. This means that it MUST be a leaf of the
519 /// Protected Storage key hierarchy.
520 ///
521 #define TPM_KEY_SIGNING             ((UINT16) 0x0010)
522 ///
523 /// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap
524 /// and unwrap other keys in the Protected Storage hierarchy
525 ///
526 #define TPM_KEY_STORAGE             ((UINT16) 0x0011)
527 ///
528 /// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for
529 /// operations that require a TPM identity, only.
530 ///
531 #define TPM_KEY_IDENTITY            ((UINT16) 0x0012)
532 ///
533 /// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during
534 /// the ChangeAuthAsym process, only.
535 ///
536 #define TPM_KEY_AUTHCHANGE          ((UINT16) 0x0013)
537 ///
538 /// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and
539 /// TPM_Unbind operations only.
540 ///
541 #define TPM_KEY_BIND                ((UINT16) 0x0014)
542 ///
543 /// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding
544 /// operations. The key MAY be used for both signing and binding operations.
545 /// The TPM_KEY_LEGACY key type is to allow for use by applications where both
546 /// signing and encryption operations occur with the same key. The use of this
547 /// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a
548 /// key in use for TPM_MigrateKey
549 ///
550 #define TPM_KEY_LEGACY              ((UINT16) 0x0015)
551 ///
552 /// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey
553 ///
554 #define TPM_KEY_MIGRATE             ((UINT16) 0x0016)
555 
556 //
557 // Part 2, section 5.8.1: Mandatory Key Usage Schemes
558 //
559 
560 #define TPM_ES_NONE                 ((TPM_ENC_SCHEME) 0x0001)
561 #define TPM_ES_RSAESPKCSv15         ((TPM_ENC_SCHEME) 0x0002)
562 #define TPM_ES_RSAESOAEP_SHA1_MGF1  ((TPM_ENC_SCHEME) 0x0003)
563 #define TPM_ES_SYM_CNT              ((TPM_ENC_SCHEME) 0x0004)  ///< rev94 defined
564 #define TPM_ES_SYM_CTR              ((TPM_ENC_SCHEME) 0x0004)
565 #define TPM_ES_SYM_OFB              ((TPM_ENC_SCHEME) 0x0005)
566 
567 #define TPM_SS_NONE                 ((TPM_SIG_SCHEME) 0x0001)
568 #define TPM_SS_RSASSAPKCS1v15_SHA1  ((TPM_SIG_SCHEME) 0x0002)
569 #define TPM_SS_RSASSAPKCS1v15_DER   ((TPM_SIG_SCHEME) 0x0003)
570 #define TPM_SS_RSASSAPKCS1v15_INFO  ((TPM_SIG_SCHEME) 0x0004)
571 
572 //
573 // Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
574 //
575 #define TPM_AUTH_NEVER              ((TPM_AUTH_DATA_USAGE) 0x00)
576 #define TPM_AUTH_ALWAYS             ((TPM_AUTH_DATA_USAGE) 0x01)
577 #define TPM_AUTH_PRIV_USE_ONLY      ((TPM_AUTH_DATA_USAGE) 0x03)
578 
579 ///
580 /// Part 2, section 5.10: TPM_KEY_FLAGS
581 ///
582 typedef enum tdTPM_KEY_FLAGS {
583   redirection                       = 0x00000001,
584   migratable                        = 0x00000002,
585   isVolatile                        = 0x00000004,
586   pcrIgnoredOnRead                  = 0x00000008,
587   migrateAuthority                  = 0x00000010
588 } TPM_KEY_FLAGS_BITS;
589 
590 ///
591 /// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
592 ///
593 typedef struct tdTPM_CHANGEAUTH_VALIDATE {
594   TPM_SECRET                        newAuthSecret;
595   TPM_NONCE                         n1;
596 } TPM_CHANGEAUTH_VALIDATE;
597 
598 ///
599 /// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
600 ///   decalared after section 10 to catch declaration of TPM_PUBKEY
601 ///
602 /// Part 2 section 10.1: TPM_KEY_PARMS
603 ///   [size_is(parmSize)] BYTE* parms;
604 ///
605 typedef struct tdTPM_KEY_PARMS {
606   TPM_ALGORITHM_ID                  algorithmID;
607   TPM_ENC_SCHEME                    encScheme;
608   TPM_SIG_SCHEME                    sigScheme;
609   UINT32                            parmSize;
610   UINT8                             *parms;
611 } TPM_KEY_PARMS;
612 
613 ///
614 /// Part 2, section 10.4: TPM_STORE_PUBKEY
615 ///
616 typedef struct tdTPM_STORE_PUBKEY {
617   UINT32                            keyLength;
618   UINT8                             key[1];
619 } TPM_STORE_PUBKEY;
620 
621 ///
622 /// Part 2, section 10.5: TPM_PUBKEY
623 ///
624 typedef struct tdTPM_PUBKEY{
625   TPM_KEY_PARMS                     algorithmParms;
626   TPM_STORE_PUBKEY                  pubKey;
627 } TPM_PUBKEY;
628 
629 ///
630 /// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
631 ///
632 typedef struct tdTPM_MIGRATIONKEYAUTH{
633   TPM_PUBKEY                        migrationKey;
634   TPM_MIGRATE_SCHEME                migrationScheme;
635   TPM_DIGEST                        digest;
636 } TPM_MIGRATIONKEYAUTH;
637 
638 ///
639 /// Part 2, section 5.13: TPM_COUNTER_VALUE
640 ///
641 typedef struct tdTPM_COUNTER_VALUE{
642   TPM_STRUCTURE_TAG                 tag;
643   UINT8                             label[4];
644   TPM_ACTUAL_COUNT                  counter;
645 } TPM_COUNTER_VALUE;
646 
647 ///
648 /// Part 2, section 5.14: TPM_SIGN_INFO
649 ///   Size of data indicated by dataLen
650 ///
651 typedef struct tdTPM_SIGN_INFO {
652   TPM_STRUCTURE_TAG                 tag;
653   UINT8                             fixed[4];
654   TPM_NONCE                         replay;
655   UINT32                            dataLen;
656   UINT8                             *data;
657 } TPM_SIGN_INFO;
658 
659 ///
660 /// Part 2, section 5.15: TPM_MSA_COMPOSITE
661 ///   Number of migAuthDigest indicated by MSAlist
662 ///
663 typedef struct tdTPM_MSA_COMPOSITE {
664   UINT32                            MSAlist;
665   TPM_DIGEST                        migAuthDigest[1];
666 } TPM_MSA_COMPOSITE;
667 
668 ///
669 /// Part 2, section 5.16: TPM_CMK_AUTH
670 ///
671 typedef struct tdTPM_CMK_AUTH{
672   TPM_DIGEST                        migrationAuthorityDigest;
673   TPM_DIGEST                        destinationKeyDigest;
674   TPM_DIGEST                        sourceKeyDigest;
675 } TPM_CMK_AUTH;
676 
677 //
678 // Part 2, section 5.17: TPM_CMK_DELEGATE
679 //
680 #define TPM_CMK_DELEGATE_SIGNING    ((TPM_CMK_DELEGATE) BIT31)
681 #define TPM_CMK_DELEGATE_STORAGE    ((TPM_CMK_DELEGATE) BIT30)
682 #define TPM_CMK_DELEGATE_BIND       ((TPM_CMK_DELEGATE) BIT29)
683 #define TPM_CMK_DELEGATE_LEGACY     ((TPM_CMK_DELEGATE) BIT28)
684 #define TPM_CMK_DELEGATE_MIGRATE    ((TPM_CMK_DELEGATE) BIT27)
685 
686 ///
687 /// Part 2, section 5.18: TPM_SELECT_SIZE
688 ///
689 typedef struct tdTPM_SELECT_SIZE {
690   UINT8                             major;
691   UINT8                             minor;
692   UINT16                            reqSize;
693 } TPM_SELECT_SIZE;
694 
695 ///
696 /// Part 2, section 5,19: TPM_CMK_MIGAUTH
697 ///
698 typedef struct tdTPM_CMK_MIGAUTH{
699   TPM_STRUCTURE_TAG                 tag;
700   TPM_DIGEST                        msaDigest;
701   TPM_DIGEST                        pubKeyDigest;
702 } TPM_CMK_MIGAUTH;
703 
704 ///
705 /// Part 2, section 5.20: TPM_CMK_SIGTICKET
706 ///
707 typedef struct tdTPM_CMK_SIGTICKET{
708   TPM_STRUCTURE_TAG                 tag;
709   TPM_DIGEST                        verKeyDigest;
710   TPM_DIGEST                        signedData;
711 } TPM_CMK_SIGTICKET;
712 
713 ///
714 /// Part 2, section 5.21: TPM_CMK_MA_APPROVAL
715 ///
716 typedef struct tdTPM_CMK_MA_APPROVAL{
717   TPM_STRUCTURE_TAG                 tag;
718   TPM_DIGEST                        migrationAuthorityDigest;
719 } TPM_CMK_MA_APPROVAL;
720 
721 //
722 // Part 2, section 6: Command Tags
723 //
724 #define TPM_TAG_RQU_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C1)
725 #define TPM_TAG_RQU_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C2)
726 #define TPM_TAG_RQU_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C3)
727 #define TPM_TAG_RSP_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C4)
728 #define TPM_TAG_RSP_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C5)
729 #define TPM_TAG_RSP_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C6)
730 
731 ///
732 /// Part 2, section 7.1: TPM_PERMANENT_FLAGS
733 ///
734 typedef struct tdTPM_PERMANENT_FLAGS{
735   TPM_STRUCTURE_TAG                 tag;
736   BOOLEAN                           disable;
737   BOOLEAN                           ownership;
738   BOOLEAN                           deactivated;
739   BOOLEAN                           readPubek;
740   BOOLEAN                           disableOwnerClear;
741   BOOLEAN                           allowMaintenance;
742   BOOLEAN                           physicalPresenceLifetimeLock;
743   BOOLEAN                           physicalPresenceHWEnable;
744   BOOLEAN                           physicalPresenceCMDEnable;
745   BOOLEAN                           CEKPUsed;
746   BOOLEAN                           TPMpost;
747   BOOLEAN                           TPMpostLock;
748   BOOLEAN                           FIPS;
749   BOOLEAN                           operator;
750   BOOLEAN                           enableRevokeEK;
751   BOOLEAN                           nvLocked;
752   BOOLEAN                           readSRKPub;
753   BOOLEAN                           tpmEstablished;
754   BOOLEAN                           maintenanceDone;
755   BOOLEAN                           disableFullDALogicInfo;
756 } TPM_PERMANENT_FLAGS;
757 
758 //
759 // Part 2, section 7.1.1: Flag Restrictions (of TPM_PERMANENT_FLAGS)
760 //
761 #define TPM_PF_DISABLE                      ((TPM_CAPABILITY_AREA) 1)
762 #define TPM_PF_OWNERSHIP                    ((TPM_CAPABILITY_AREA) 2)
763 #define TPM_PF_DEACTIVATED                  ((TPM_CAPABILITY_AREA) 3)
764 #define TPM_PF_READPUBEK                    ((TPM_CAPABILITY_AREA) 4)
765 #define TPM_PF_DISABLEOWNERCLEAR            ((TPM_CAPABILITY_AREA) 5)
766 #define TPM_PF_ALLOWMAINTENANCE             ((TPM_CAPABILITY_AREA) 6)
767 #define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((TPM_CAPABILITY_AREA) 7)
768 #define TPM_PF_PHYSICALPRESENCEHWENABLE     ((TPM_CAPABILITY_AREA) 8)
769 #define TPM_PF_PHYSICALPRESENCECMDENABLE    ((TPM_CAPABILITY_AREA) 9)
770 #define TPM_PF_CEKPUSED                     ((TPM_CAPABILITY_AREA) 10)
771 #define TPM_PF_TPMPOST                      ((TPM_CAPABILITY_AREA) 11)
772 #define TPM_PF_TPMPOSTLOCK                  ((TPM_CAPABILITY_AREA) 12)
773 #define TPM_PF_FIPS                         ((TPM_CAPABILITY_AREA) 13)
774 #define TPM_PF_OPERATOR                     ((TPM_CAPABILITY_AREA) 14)
775 #define TPM_PF_ENABLEREVOKEEK               ((TPM_CAPABILITY_AREA) 15)
776 #define TPM_PF_NV_LOCKED                    ((TPM_CAPABILITY_AREA) 16)
777 #define TPM_PF_READSRKPUB                   ((TPM_CAPABILITY_AREA) 17)
778 #define TPM_PF_TPMESTABLISHED               ((TPM_CAPABILITY_AREA) 18)
779 #define TPM_PF_MAINTENANCEDONE              ((TPM_CAPABILITY_AREA) 19)
780 #define TPM_PF_DISABLEFULLDALOGICINFO       ((TPM_CAPABILITY_AREA) 20)
781 
782 ///
783 /// Part 2, section 7.2: TPM_STCLEAR_FLAGS
784 ///
785 typedef struct tdTPM_STCLEAR_FLAGS{
786   TPM_STRUCTURE_TAG                 tag;
787   BOOLEAN                           deactivated;
788   BOOLEAN                           disableForceClear;
789   BOOLEAN                           physicalPresence;
790   BOOLEAN                           physicalPresenceLock;
791   BOOLEAN                           bGlobalLock;
792 } TPM_STCLEAR_FLAGS;
793 
794 //
795 // Part 2, section 7.2.1: Flag Restrictions (of TPM_STCLEAR_FLAGS)
796 //
797 #define TPM_SF_DEACTIVATED          ((TPM_CAPABILITY_AREA) 1)
798 #define TPM_SF_DISABLEFORCECLEAR    ((TPM_CAPABILITY_AREA) 2)
799 #define TPM_SF_PHYSICALPRESENCE     ((TPM_CAPABILITY_AREA) 3)
800 #define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4)
801 #define TPM_SF_BGLOBALLOCK          ((TPM_CAPABILITY_AREA) 5)
802 
803 ///
804 /// Part 2, section 7.3: TPM_STANY_FLAGS
805 ///
806 typedef struct tdTPM_STANY_FLAGS{
807   TPM_STRUCTURE_TAG                 tag;
808   BOOLEAN                           postInitialise;
809   TPM_MODIFIER_INDICATOR            localityModifier;
810   BOOLEAN                           transportExclusive;
811   BOOLEAN                           TOSPresent;
812 } TPM_STANY_FLAGS;
813 
814 //
815 // Part 2, section 7.3.1: Flag Restrictions (of TPM_STANY_FLAGS)
816 //
817 #define TPM_AF_POSTINITIALISE       ((TPM_CAPABILITY_AREA) 1)
818 #define TPM_AF_LOCALITYMODIFIER     ((TPM_CAPABILITY_AREA) 2)
819 #define TPM_AF_TRANSPORTEXCLUSIVE   ((TPM_CAPABILITY_AREA) 3)
820 #define TPM_AF_TOSPRESENT           ((TPM_CAPABILITY_AREA) 4)
821 
822 //
823 // All those structures defined in section 7.4, 7.5, 7.6 are not normative and
824 // thus no definitions here
825 //
826 // Part 2, section 7.4: TPM_PERMANENT_DATA
827 //
828 #define TPM_MIN_COUNTERS            4   ///< the minimum number of counters is 4
829 #define TPM_DELEGATE_KEY            TPM_KEY
830 #define TPM_NUM_PCR                 16
831 #define TPM_MAX_NV_WRITE_NOOWNER    64
832 
833 //
834 // Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability
835 //
836 #define TPM_PD_REVMAJOR               ((TPM_CAPABILITY_AREA) 1)
837 #define TPM_PD_REVMINOR               ((TPM_CAPABILITY_AREA) 2)
838 #define TPM_PD_TPMPROOF               ((TPM_CAPABILITY_AREA) 3)
839 #define TPM_PD_OWNERAUTH              ((TPM_CAPABILITY_AREA) 4)
840 #define TPM_PD_OPERATORAUTH           ((TPM_CAPABILITY_AREA) 5)
841 #define TPM_PD_MANUMAINTPUB           ((TPM_CAPABILITY_AREA) 6)
842 #define TPM_PD_ENDORSEMENTKEY         ((TPM_CAPABILITY_AREA) 7)
843 #define TPM_PD_SRK                    ((TPM_CAPABILITY_AREA) 8)
844 #define TPM_PD_DELEGATEKEY            ((TPM_CAPABILITY_AREA) 9)
845 #define TPM_PD_CONTEXTKEY             ((TPM_CAPABILITY_AREA) 10)
846 #define TPM_PD_AUDITMONOTONICCOUNTER  ((TPM_CAPABILITY_AREA) 11)
847 #define TPM_PD_MONOTONICCOUNTER       ((TPM_CAPABILITY_AREA) 12)
848 #define TPM_PD_PCRATTRIB              ((TPM_CAPABILITY_AREA) 13)
849 #define TPM_PD_ORDINALAUDITSTATUS     ((TPM_CAPABILITY_AREA) 14)
850 #define TPM_PD_AUTHDIR                ((TPM_CAPABILITY_AREA) 15)
851 #define TPM_PD_RNGSTATE               ((TPM_CAPABILITY_AREA) 16)
852 #define TPM_PD_FAMILYTABLE            ((TPM_CAPABILITY_AREA) 17)
853 #define TPM_DELEGATETABLE             ((TPM_CAPABILITY_AREA) 18)
854 #define TPM_PD_EKRESET                ((TPM_CAPABILITY_AREA) 19)
855 #define TPM_PD_MAXNVBUFSIZE           ((TPM_CAPABILITY_AREA) 20)
856 #define TPM_PD_LASTFAMILYID           ((TPM_CAPABILITY_AREA) 21)
857 #define TPM_PD_NOOWNERNVWRITE         ((TPM_CAPABILITY_AREA) 22)
858 #define TPM_PD_RESTRICTDELEGATE       ((TPM_CAPABILITY_AREA) 23)
859 #define TPM_PD_TPMDAASEED             ((TPM_CAPABILITY_AREA) 24)
860 #define TPM_PD_DAAPROOF               ((TPM_CAPABILITY_AREA) 25)
861 
862 ///
863 /// Part 2, section 7.5: TPM_STCLEAR_DATA
864 ///   available inside TPM only
865 ///
866  typedef struct tdTPM_STCLEAR_DATA{
867    TPM_STRUCTURE_TAG                  tag;
868    TPM_NONCE                          contextNonceKey;
869    TPM_COUNT_ID                       countID;
870    UINT32                             ownerReference;
871    BOOLEAN                            disableResetLock;
872    TPM_PCRVALUE                       PCR[TPM_NUM_PCR];
873    UINT32                             deferredPhysicalPresence;
874  }TPM_STCLEAR_DATA;
875 
876 //
877 // Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability
878 //
879 #define TPM_SD_CONTEXTNONCEKEY            ((TPM_CAPABILITY_AREA)0x00000001)
880 #define TPM_SD_COUNTID                    ((TPM_CAPABILITY_AREA)0x00000002)
881 #define TPM_SD_OWNERREFERENCE             ((TPM_CAPABILITY_AREA)0x00000003)
882 #define TPM_SD_DISABLERESETLOCK           ((TPM_CAPABILITY_AREA)0x00000004)
883 #define TPM_SD_PCR                        ((TPM_CAPABILITY_AREA)0x00000005)
884 #define TPM_SD_DEFERREDPHYSICALPRESENCE   ((TPM_CAPABILITY_AREA)0x00000006)
885 
886 //
887 // Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability
888 //
889 #define TPM_AD_CONTEXTNONCESESSION        ((TPM_CAPABILITY_AREA) 1)
890 #define TPM_AD_AUDITDIGEST                ((TPM_CAPABILITY_AREA) 2)
891 #define TPM_AD_CURRENTTICKS               ((TPM_CAPABILITY_AREA) 3)
892 #define TPM_AD_CONTEXTCOUNT               ((TPM_CAPABILITY_AREA) 4)
893 #define TPM_AD_CONTEXTLIST                ((TPM_CAPABILITY_AREA) 5)
894 #define TPM_AD_SESSIONS                   ((TPM_CAPABILITY_AREA) 6)
895 
896 //
897 // Part 2, section 8: PCR Structures
898 //
899 
900 ///
901 /// Part 2, section 8.1: TPM_PCR_SELECTION
902 ///   Size of pcrSelect[] indicated by sizeOfSelect
903 ///
904 typedef struct tdTPM_PCR_SELECTION {
905   UINT16                            sizeOfSelect;
906   UINT8                             pcrSelect[1];
907 } TPM_PCR_SELECTION;
908 
909 ///
910 /// Part 2, section 8.2: TPM_PCR_COMPOSITE
911 ///   Size of pcrValue[] indicated by valueSize
912 ///
913 typedef struct tdTPM_PCR_COMPOSITE {
914   TPM_PCR_SELECTION                 select;
915   UINT32                            valueSize;
916   TPM_PCRVALUE                      pcrValue[1];
917 } TPM_PCR_COMPOSITE;
918 
919 ///
920 /// Part 2, section 8.3: TPM_PCR_INFO
921 ///
922 typedef struct tdTPM_PCR_INFO {
923   TPM_PCR_SELECTION                 pcrSelection;
924   TPM_COMPOSITE_HASH                digestAtRelease;
925   TPM_COMPOSITE_HASH                digestAtCreation;
926 } TPM_PCR_INFO;
927 
928 ///
929 /// Part 2, section 8.6: TPM_LOCALITY_SELECTION
930 ///
931 typedef UINT8                       TPM_LOCALITY_SELECTION;
932 
933 #define TPM_LOC_FOUR                ((UINT8) 0x10)
934 #define TPM_LOC_THREE               ((UINT8) 0x08)
935 #define TPM_LOC_TWO                 ((UINT8) 0x04)
936 #define TPM_LOC_ONE                 ((UINT8) 0x02)
937 #define TPM_LOC_ZERO                ((UINT8) 0x01)
938 
939 ///
940 /// Part 2, section 8.4: TPM_PCR_INFO_LONG
941 ///
942 typedef struct tdTPM_PCR_INFO_LONG {
943   TPM_STRUCTURE_TAG                 tag;
944   TPM_LOCALITY_SELECTION            localityAtCreation;
945   TPM_LOCALITY_SELECTION            localityAtRelease;
946   TPM_PCR_SELECTION                 creationPCRSelection;
947   TPM_PCR_SELECTION                 releasePCRSelection;
948   TPM_COMPOSITE_HASH                digestAtCreation;
949   TPM_COMPOSITE_HASH                digestAtRelease;
950 } TPM_PCR_INFO_LONG;
951 
952 ///
953 /// Part 2, section 8.5: TPM_PCR_INFO_SHORT
954 ///
955 typedef struct tdTPM_PCR_INFO_SHORT{
956   TPM_PCR_SELECTION                 pcrSelection;
957   TPM_LOCALITY_SELECTION            localityAtRelease;
958   TPM_COMPOSITE_HASH                digestAtRelease;
959 } TPM_PCR_INFO_SHORT;
960 
961 ///
962 /// Part 2, section 8.8: TPM_PCR_ATTRIBUTES
963 ///
964 typedef struct tdTPM_PCR_ATTRIBUTES{
965   BOOLEAN                           pcrReset;
966   TPM_LOCALITY_SELECTION            pcrExtendLocal;
967   TPM_LOCALITY_SELECTION            pcrResetLocal;
968 } TPM_PCR_ATTRIBUTES;
969 
970 //
971 // Part 2, section 9: Storage Structures
972 //
973 
974 ///
975 /// Part 2, section 9.1: TPM_STORED_DATA
976 ///   [size_is(sealInfoSize)] BYTE* sealInfo;
977 ///   [size_is(encDataSize)] BYTE* encData;
978 ///
979 typedef struct tdTPM_STORED_DATA {
980   TPM_STRUCT_VER                    ver;
981   UINT32                            sealInfoSize;
982   UINT8                             *sealInfo;
983   UINT32                            encDataSize;
984   UINT8                             *encData;
985 } TPM_STORED_DATA;
986 
987 ///
988 /// Part 2, section 9.2: TPM_STORED_DATA12
989 ///   [size_is(sealInfoSize)] BYTE* sealInfo;
990 ///   [size_is(encDataSize)] BYTE* encData;
991 ///
992 typedef struct tdTPM_STORED_DATA12 {
993   TPM_STRUCTURE_TAG                 tag;
994   TPM_ENTITY_TYPE                   et;
995   UINT32                            sealInfoSize;
996   UINT8                             *sealInfo;
997   UINT32                            encDataSize;
998   UINT8                             *encData;
999 } TPM_STORED_DATA12;
1000 
1001 ///
1002 /// Part 2, section 9.3: TPM_SEALED_DATA
1003 ///   [size_is(dataSize)] BYTE* data;
1004 ///
1005 typedef struct tdTPM_SEALED_DATA {
1006   TPM_PAYLOAD_TYPE                  payload;
1007   TPM_SECRET                        authData;
1008   TPM_NONCE                         tpmProof;
1009   TPM_DIGEST                        storedDigest;
1010   UINT32                            dataSize;
1011   UINT8                             *data;
1012 } TPM_SEALED_DATA;
1013 
1014 ///
1015 /// Part 2, section 9.4: TPM_SYMMETRIC_KEY
1016 ///   [size_is(size)] BYTE* data;
1017 ///
1018 typedef struct tdTPM_SYMMETRIC_KEY {
1019   TPM_ALGORITHM_ID                  algId;
1020   TPM_ENC_SCHEME                    encScheme;
1021   UINT16                            dataSize;
1022   UINT8                             *data;
1023 } TPM_SYMMETRIC_KEY;
1024 
1025 ///
1026 /// Part 2, section 9.5: TPM_BOUND_DATA
1027 ///
1028 typedef struct tdTPM_BOUND_DATA {
1029   TPM_STRUCT_VER                    ver;
1030   TPM_PAYLOAD_TYPE                  payload;
1031   UINT8                             payloadData[1];
1032 } TPM_BOUND_DATA;
1033 
1034 //
1035 // Part 2 section 10: TPM_KEY complex
1036 //
1037 
1038 //
1039 // Section 10.1, 10.4, and 10.5 have been defined previously
1040 //
1041 
1042 ///
1043 /// Part 2, section 10.2: TPM_KEY
1044 ///   [size_is(encDataSize)] BYTE* encData;
1045 ///
1046 typedef struct tdTPM_KEY{
1047   TPM_STRUCT_VER                    ver;
1048   TPM_KEY_USAGE                     keyUsage;
1049   TPM_KEY_FLAGS                     keyFlags;
1050   TPM_AUTH_DATA_USAGE               authDataUsage;
1051   TPM_KEY_PARMS                     algorithmParms;
1052   UINT32                            PCRInfoSize;
1053   UINT8                             *PCRInfo;
1054   TPM_STORE_PUBKEY                  pubKey;
1055   UINT32                            encDataSize;
1056   UINT8                             *encData;
1057 } TPM_KEY;
1058 
1059 ///
1060 /// Part 2, section 10.3: TPM_KEY12
1061 ///   [size_is(encDataSize)] BYTE* encData;
1062 ///
1063 typedef struct tdTPM_KEY12{
1064   TPM_STRUCTURE_TAG                 tag;
1065   UINT16                            fill;
1066   TPM_KEY_USAGE                     keyUsage;
1067   TPM_KEY_FLAGS                     keyFlags;
1068   TPM_AUTH_DATA_USAGE               authDataUsage;
1069   TPM_KEY_PARMS                     algorithmParms;
1070   UINT32                            PCRInfoSize;
1071   UINT8                             *PCRInfo;
1072   TPM_STORE_PUBKEY                  pubKey;
1073   UINT32                            encDataSize;
1074   UINT8                             *encData;
1075 } TPM_KEY12;
1076 
1077 ///
1078 /// Part 2, section 10.7: TPM_STORE_PRIVKEY
1079 ///   [size_is(keyLength)] BYTE* key;
1080 ///
1081 typedef struct tdTPM_STORE_PRIVKEY {
1082   UINT32                            keyLength;
1083   UINT8                             *key;
1084 } TPM_STORE_PRIVKEY;
1085 
1086 ///
1087 /// Part 2, section 10.6: TPM_STORE_ASYMKEY
1088 ///
1089 typedef struct tdTPM_STORE_ASYMKEY {                // pos len total
1090   TPM_PAYLOAD_TYPE                  payload;        // 0    1   1
1091   TPM_SECRET                        usageAuth;      // 1    20  21
1092   TPM_SECRET                        migrationAuth;  // 21   20  41
1093   TPM_DIGEST                        pubDataDigest;  // 41   20  61
1094   TPM_STORE_PRIVKEY                 privKey;        // 61 132-151 193-214
1095 } TPM_STORE_ASYMKEY;
1096 
1097 ///
1098 /// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY
1099 ///   [size_is(partPrivKeyLen)] BYTE* partPrivKey;
1100 ///
1101 typedef struct tdTPM_MIGRATE_ASYMKEY {              // pos  len  total
1102   TPM_PAYLOAD_TYPE                  payload;        //   0    1       1
1103   TPM_SECRET                        usageAuth;      //   1   20      21
1104   TPM_DIGEST                        pubDataDigest;  //  21   20      41
1105   UINT32                            partPrivKeyLen; //  41    4      45
1106   UINT8                             *partPrivKey;   //  45 112-127 157-172
1107 } TPM_MIGRATE_ASYMKEY;
1108 
1109 ///
1110 /// Part 2, section 10.9: TPM_KEY_CONTROL
1111 ///
1112 #define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001)
1113 
1114 //
1115 // Part 2, section 11: Signed Structures
1116 //
1117 
1118 ///
1119 /// Part 2, section 11.1: TPM_CERTIFY_INFO Structure
1120 ///
1121 typedef struct tdTPM_CERTIFY_INFO {
1122   TPM_STRUCT_VER                  version;
1123   TPM_KEY_USAGE                   keyUsage;
1124   TPM_KEY_FLAGS                   keyFlags;
1125   TPM_AUTH_DATA_USAGE             authDataUsage;
1126   TPM_KEY_PARMS                   algorithmParms;
1127   TPM_DIGEST                      pubkeyDigest;
1128   TPM_NONCE                       data;
1129   BOOLEAN                         parentPCRStatus;
1130   UINT32                          PCRInfoSize;
1131   UINT8                           *PCRInfo;
1132 } TPM_CERTIFY_INFO;
1133 
1134 ///
1135 /// Part 2, section 11.2: TPM_CERTIFY_INFO2 Structure
1136 ///
1137 typedef struct tdTPM_CERTIFY_INFO2 {
1138   TPM_STRUCTURE_TAG               tag;
1139   UINT8                           fill;
1140   TPM_PAYLOAD_TYPE                payloadType;
1141   TPM_KEY_USAGE                   keyUsage;
1142   TPM_KEY_FLAGS                   keyFlags;
1143   TPM_AUTH_DATA_USAGE             authDataUsage;
1144   TPM_KEY_PARMS                   algorithmParms;
1145   TPM_DIGEST                      pubkeyDigest;
1146   TPM_NONCE                       data;
1147   BOOLEAN                         parentPCRStatus;
1148   UINT32                          PCRInfoSize;
1149   UINT8                           *PCRInfo;
1150   UINT32                          migrationAuthoritySize;
1151   UINT8                           *migrationAuthority;
1152 } TPM_CERTIFY_INFO2;
1153 
1154 ///
1155 /// Part 2, section 11.3 TPM_QUOTE_INFO Structure
1156 ///
1157 typedef struct tdTPM_QUOTE_INFO {
1158   TPM_STRUCT_VER                  version;
1159   UINT8                           fixed[4];
1160   TPM_COMPOSITE_HASH              digestValue;
1161   TPM_NONCE                       externalData;
1162 } TPM_QUOTE_INFO;
1163 
1164 ///
1165 /// Part 2, section 11.4 TPM_QUOTE_INFO2 Structure
1166 ///
1167 typedef struct tdTPM_QUOTE_INFO2 {
1168   TPM_STRUCTURE_TAG               tag;
1169   UINT8                           fixed[4];
1170   TPM_NONCE                       externalData;
1171   TPM_PCR_INFO_SHORT              infoShort;
1172 } TPM_QUOTE_INFO2;
1173 
1174 //
1175 // Part 2, section 12: Identity Structures
1176 //
1177 
1178 ///
1179 /// Part 2, section 12.1 TPM_EK_BLOB
1180 ///
1181 typedef struct tdTPM_EK_BLOB {
1182   TPM_STRUCTURE_TAG               tag;
1183   TPM_EK_TYPE                     ekType;
1184   UINT32                          blobSize;
1185   UINT8                           *blob;
1186 } TPM_EK_BLOB;
1187 
1188 ///
1189 /// Part 2, section 12.2 TPM_EK_BLOB_ACTIVATE
1190 ///
1191 typedef struct tdTPM_EK_BLOB_ACTIVATE {
1192   TPM_STRUCTURE_TAG               tag;
1193   TPM_SYMMETRIC_KEY               sessionKey;
1194   TPM_DIGEST                      idDigest;
1195   TPM_PCR_INFO_SHORT              pcrInfo;
1196 } TPM_EK_BLOB_ACTIVATE;
1197 
1198 ///
1199 /// Part 2, section 12.3 TPM_EK_BLOB_AUTH
1200 ///
1201 typedef struct tdTPM_EK_BLOB_AUTH {
1202   TPM_STRUCTURE_TAG               tag;
1203   TPM_SECRET                      authValue;
1204 } TPM_EK_BLOB_AUTH;
1205 
1206 
1207 ///
1208 /// Part 2, section 12.5 TPM_IDENTITY_CONTENTS
1209 ///
1210 typedef struct tdTPM_IDENTITY_CONTENTS {
1211   TPM_STRUCT_VER                  ver;
1212   UINT32                          ordinal;
1213   TPM_CHOSENID_HASH               labelPrivCADigest;
1214   TPM_PUBKEY                      identityPubKey;
1215 } TPM_IDENTITY_CONTENTS;
1216 
1217 ///
1218 /// Part 2, section 12.6 TPM_IDENTITY_REQ
1219 ///
1220 typedef struct tdTPM_IDENTITY_REQ {
1221   UINT32                          asymSize;
1222   UINT32                          symSize;
1223   TPM_KEY_PARMS                   asymAlgorithm;
1224   TPM_KEY_PARMS                   symAlgorithm;
1225   UINT8                           *asymBlob;
1226   UINT8                           *symBlob;
1227 } TPM_IDENTITY_REQ;
1228 
1229 ///
1230 /// Part 2, section 12.7 TPM_IDENTITY_PROOF
1231 ///
1232 typedef struct tdTPM_IDENTITY_PROOF {
1233   TPM_STRUCT_VER                  ver;
1234   UINT32                          labelSize;
1235   UINT32                          identityBindingSize;
1236   UINT32                          endorsementSize;
1237   UINT32                          platformSize;
1238   UINT32                          conformanceSize;
1239   TPM_PUBKEY                      identityKey;
1240   UINT8                           *labelArea;
1241   UINT8                           *identityBinding;
1242   UINT8                           *endorsementCredential;
1243   UINT8                           *platformCredential;
1244   UINT8                           *conformanceCredential;
1245 } TPM_IDENTITY_PROOF;
1246 
1247 ///
1248 /// Part 2, section 12.8 TPM_ASYM_CA_CONTENTS
1249 ///
1250 typedef struct tdTPM_ASYM_CA_CONTENTS {
1251   TPM_SYMMETRIC_KEY               sessionKey;
1252   TPM_DIGEST                      idDigest;
1253 } TPM_ASYM_CA_CONTENTS;
1254 
1255 ///
1256 /// Part 2, section 12.9 TPM_SYM_CA_ATTESTATION
1257 ///
1258 typedef struct tdTPM_SYM_CA_ATTESTATION {
1259   UINT32                          credSize;
1260   TPM_KEY_PARMS                   algorithm;
1261   UINT8                           *credential;
1262 } TPM_SYM_CA_ATTESTATION;
1263 
1264 ///
1265 /// Part 2, section 15: Tick Structures
1266 ///   Placed here out of order because definitions are used in section 13.
1267 ///
1268 typedef struct tdTPM_CURRENT_TICKS {
1269   TPM_STRUCTURE_TAG                 tag;
1270   UINT64                            currentTicks;
1271   UINT16                            tickRate;
1272   TPM_NONCE                         tickNonce;
1273 } TPM_CURRENT_TICKS;
1274 
1275 ///
1276 /// Part 2, section 13: Transport structures
1277 ///
1278 
1279 ///
1280 /// Part 2, section 13.1: TPM _TRANSPORT_PUBLIC
1281 ///
1282 typedef struct tdTPM_TRANSPORT_PUBLIC {
1283   TPM_STRUCTURE_TAG               tag;
1284   TPM_TRANSPORT_ATTRIBUTES        transAttributes;
1285   TPM_ALGORITHM_ID                algId;
1286   TPM_ENC_SCHEME                  encScheme;
1287 } TPM_TRANSPORT_PUBLIC;
1288 
1289 //
1290 // Part 2, section 13.1.1 TPM_TRANSPORT_ATTRIBUTES Definitions
1291 //
1292 #define TPM_TRANSPORT_ENCRYPT       ((UINT32)BIT0)
1293 #define TPM_TRANSPORT_LOG           ((UINT32)BIT1)
1294 #define TPM_TRANSPORT_EXCLUSIVE     ((UINT32)BIT2)
1295 
1296 ///
1297 /// Part 2, section 13.2 TPM_TRANSPORT_INTERNAL
1298 ///
1299 typedef struct tdTPM_TRANSPORT_INTERNAL {
1300   TPM_STRUCTURE_TAG               tag;
1301   TPM_AUTHDATA                    authData;
1302   TPM_TRANSPORT_PUBLIC            transPublic;
1303   TPM_TRANSHANDLE                 transHandle;
1304   TPM_NONCE                       transNonceEven;
1305   TPM_DIGEST                      transDigest;
1306 } TPM_TRANSPORT_INTERNAL;
1307 
1308 ///
1309 /// Part 2, section 13.3 TPM_TRANSPORT_LOG_IN structure
1310 ///
1311 typedef struct tdTPM_TRANSPORT_LOG_IN {
1312   TPM_STRUCTURE_TAG               tag;
1313   TPM_DIGEST                      parameters;
1314   TPM_DIGEST                      pubKeyHash;
1315 } TPM_TRANSPORT_LOG_IN;
1316 
1317 ///
1318 /// Part 2, section 13.4 TPM_TRANSPORT_LOG_OUT structure
1319 ///
1320 typedef struct tdTPM_TRANSPORT_LOG_OUT {
1321   TPM_STRUCTURE_TAG               tag;
1322   TPM_CURRENT_TICKS               currentTicks;
1323   TPM_DIGEST                      parameters;
1324   TPM_MODIFIER_INDICATOR          locality;
1325 } TPM_TRANSPORT_LOG_OUT;
1326 
1327 ///
1328 /// Part 2, section 13.5 TPM_TRANSPORT_AUTH structure
1329 ///
1330 typedef struct tdTPM_TRANSPORT_AUTH {
1331   TPM_STRUCTURE_TAG               tag;
1332   TPM_AUTHDATA                    authData;
1333 } TPM_TRANSPORT_AUTH;
1334 
1335 //
1336 // Part 2, section 14: Audit Structures
1337 //
1338 
1339 ///
1340 /// Part 2, section 14.1 TPM_AUDIT_EVENT_IN structure
1341 ///
1342 typedef struct tdTPM_AUDIT_EVENT_IN {
1343   TPM_STRUCTURE_TAG               tag;
1344   TPM_DIGEST                      inputParms;
1345   TPM_COUNTER_VALUE               auditCount;
1346 } TPM_AUDIT_EVENT_IN;
1347 
1348 ///
1349 /// Part 2, section 14.2 TPM_AUDIT_EVENT_OUT structure
1350 ///
1351 typedef struct tdTPM_AUDIT_EVENT_OUT {
1352   TPM_STRUCTURE_TAG               tag;
1353   TPM_COMMAND_CODE                ordinal;
1354   TPM_DIGEST                      outputParms;
1355   TPM_COUNTER_VALUE               auditCount;
1356   TPM_RESULT                      returnCode;
1357 } TPM_AUDIT_EVENT_OUT;
1358 
1359 //
1360 // Part 2, section 16: Return Codes
1361 //
1362 
1363 #define TPM_VENDOR_ERROR            TPM_Vendor_Specific32
1364 #define TPM_NON_FATAL               0x00000800
1365 
1366 #define TPM_SUCCESS                 ((TPM_RESULT) TPM_BASE)
1367 #define TPM_AUTHFAIL                ((TPM_RESULT) (TPM_BASE + 1))
1368 #define TPM_BADINDEX                ((TPM_RESULT) (TPM_BASE + 2))
1369 #define TPM_BAD_PARAMETER           ((TPM_RESULT) (TPM_BASE + 3))
1370 #define TPM_AUDITFAILURE            ((TPM_RESULT) (TPM_BASE + 4))
1371 #define TPM_CLEAR_DISABLED          ((TPM_RESULT) (TPM_BASE + 5))
1372 #define TPM_DEACTIVATED             ((TPM_RESULT) (TPM_BASE + 6))
1373 #define TPM_DISABLED                ((TPM_RESULT) (TPM_BASE + 7))
1374 #define TPM_DISABLED_CMD            ((TPM_RESULT) (TPM_BASE + 8))
1375 #define TPM_FAIL                    ((TPM_RESULT) (TPM_BASE + 9))
1376 #define TPM_BAD_ORDINAL             ((TPM_RESULT) (TPM_BASE + 10))
1377 #define TPM_INSTALL_DISABLED        ((TPM_RESULT) (TPM_BASE + 11))
1378 #define TPM_INVALID_KEYHANDLE       ((TPM_RESULT) (TPM_BASE + 12))
1379 #define TPM_KEYNOTFOUND             ((TPM_RESULT) (TPM_BASE + 13))
1380 #define TPM_INAPPROPRIATE_ENC       ((TPM_RESULT) (TPM_BASE + 14))
1381 #define TPM_MIGRATEFAIL             ((TPM_RESULT) (TPM_BASE + 15))
1382 #define TPM_INVALID_PCR_INFO        ((TPM_RESULT) (TPM_BASE + 16))
1383 #define TPM_NOSPACE                 ((TPM_RESULT) (TPM_BASE + 17))
1384 #define TPM_NOSRK                   ((TPM_RESULT) (TPM_BASE + 18))
1385 #define TPM_NOTSEALED_BLOB          ((TPM_RESULT) (TPM_BASE + 19))
1386 #define TPM_OWNER_SET               ((TPM_RESULT) (TPM_BASE + 20))
1387 #define TPM_RESOURCES               ((TPM_RESULT) (TPM_BASE + 21))
1388 #define TPM_SHORTRANDOM             ((TPM_RESULT) (TPM_BASE + 22))
1389 #define TPM_SIZE                    ((TPM_RESULT) (TPM_BASE + 23))
1390 #define TPM_WRONGPCRVAL             ((TPM_RESULT) (TPM_BASE + 24))
1391 #define TPM_BAD_PARAM_SIZE          ((TPM_RESULT) (TPM_BASE + 25))
1392 #define TPM_SHA_THREAD              ((TPM_RESULT) (TPM_BASE + 26))
1393 #define TPM_SHA_ERROR               ((TPM_RESULT) (TPM_BASE + 27))
1394 #define TPM_FAILEDSELFTEST          ((TPM_RESULT) (TPM_BASE + 28))
1395 #define TPM_AUTH2FAIL               ((TPM_RESULT) (TPM_BASE + 29))
1396 #define TPM_BADTAG                  ((TPM_RESULT) (TPM_BASE + 30))
1397 #define TPM_IOERROR                 ((TPM_RESULT) (TPM_BASE + 31))
1398 #define TPM_ENCRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 32))
1399 #define TPM_DECRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 33))
1400 #define TPM_INVALID_AUTHHANDLE      ((TPM_RESULT) (TPM_BASE + 34))
1401 #define TPM_NO_ENDORSEMENT          ((TPM_RESULT) (TPM_BASE + 35))
1402 #define TPM_INVALID_KEYUSAGE        ((TPM_RESULT) (TPM_BASE + 36))
1403 #define TPM_WRONG_ENTITYTYPE        ((TPM_RESULT) (TPM_BASE + 37))
1404 #define TPM_INVALID_POSTINIT        ((TPM_RESULT) (TPM_BASE + 38))
1405 #define TPM_INAPPROPRIATE_SIG       ((TPM_RESULT) (TPM_BASE + 39))
1406 #define TPM_BAD_KEY_PROPERTY        ((TPM_RESULT) (TPM_BASE + 40))
1407 #define TPM_BAD_MIGRATION           ((TPM_RESULT) (TPM_BASE + 41))
1408 #define TPM_BAD_SCHEME              ((TPM_RESULT) (TPM_BASE + 42))
1409 #define TPM_BAD_DATASIZE            ((TPM_RESULT) (TPM_BASE + 43))
1410 #define TPM_BAD_MODE                ((TPM_RESULT) (TPM_BASE + 44))
1411 #define TPM_BAD_PRESENCE            ((TPM_RESULT) (TPM_BASE + 45))
1412 #define TPM_BAD_VERSION             ((TPM_RESULT) (TPM_BASE + 46))
1413 #define TPM_NO_WRAP_TRANSPORT       ((TPM_RESULT) (TPM_BASE + 47))
1414 #define TPM_AUDITFAIL_UNSUCCESSFUL  ((TPM_RESULT) (TPM_BASE + 48))
1415 #define TPM_AUDITFAIL_SUCCESSFUL    ((TPM_RESULT) (TPM_BASE + 49))
1416 #define TPM_NOTRESETABLE            ((TPM_RESULT) (TPM_BASE + 50))
1417 #define TPM_NOTLOCAL                ((TPM_RESULT) (TPM_BASE + 51))
1418 #define TPM_BAD_TYPE                ((TPM_RESULT) (TPM_BASE + 52))
1419 #define TPM_INVALID_RESOURCE        ((TPM_RESULT) (TPM_BASE + 53))
1420 #define TPM_NOTFIPS                 ((TPM_RESULT) (TPM_BASE + 54))
1421 #define TPM_INVALID_FAMILY          ((TPM_RESULT) (TPM_BASE + 55))
1422 #define TPM_NO_NV_PERMISSION        ((TPM_RESULT) (TPM_BASE + 56))
1423 #define TPM_REQUIRES_SIGN           ((TPM_RESULT) (TPM_BASE + 57))
1424 #define TPM_KEY_NOTSUPPORTED        ((TPM_RESULT) (TPM_BASE + 58))
1425 #define TPM_AUTH_CONFLICT           ((TPM_RESULT) (TPM_BASE + 59))
1426 #define TPM_AREA_LOCKED             ((TPM_RESULT) (TPM_BASE + 60))
1427 #define TPM_BAD_LOCALITY            ((TPM_RESULT) (TPM_BASE + 61))
1428 #define TPM_READ_ONLY               ((TPM_RESULT) (TPM_BASE + 62))
1429 #define TPM_PER_NOWRITE             ((TPM_RESULT) (TPM_BASE + 63))
1430 #define TPM_FAMILYCOUNT             ((TPM_RESULT) (TPM_BASE + 64))
1431 #define TPM_WRITE_LOCKED            ((TPM_RESULT) (TPM_BASE + 65))
1432 #define TPM_BAD_ATTRIBUTES          ((TPM_RESULT) (TPM_BASE + 66))
1433 #define TPM_INVALID_STRUCTURE       ((TPM_RESULT) (TPM_BASE + 67))
1434 #define TPM_KEY_OWNER_CONTROL       ((TPM_RESULT) (TPM_BASE + 68))
1435 #define TPM_BAD_COUNTER             ((TPM_RESULT) (TPM_BASE + 69))
1436 #define TPM_NOT_FULLWRITE           ((TPM_RESULT) (TPM_BASE + 70))
1437 #define TPM_CONTEXT_GAP             ((TPM_RESULT) (TPM_BASE + 71))
1438 #define TPM_MAXNVWRITES             ((TPM_RESULT) (TPM_BASE + 72))
1439 #define TPM_NOOPERATOR              ((TPM_RESULT) (TPM_BASE + 73))
1440 #define TPM_RESOURCEMISSING         ((TPM_RESULT) (TPM_BASE + 74))
1441 #define TPM_DELEGATE_LOCK           ((TPM_RESULT) (TPM_BASE + 75))
1442 #define TPM_DELEGATE_FAMILY         ((TPM_RESULT) (TPM_BASE + 76))
1443 #define TPM_DELEGATE_ADMIN          ((TPM_RESULT) (TPM_BASE + 77))
1444 #define TPM_TRANSPORT_NOTEXCLUSIVE  ((TPM_RESULT) (TPM_BASE + 78))
1445 #define TPM_OWNER_CONTROL           ((TPM_RESULT) (TPM_BASE + 79))
1446 #define TPM_DAA_RESOURCES           ((TPM_RESULT) (TPM_BASE + 80))
1447 #define TPM_DAA_INPUT_DATA0         ((TPM_RESULT) (TPM_BASE + 81))
1448 #define TPM_DAA_INPUT_DATA1         ((TPM_RESULT) (TPM_BASE + 82))
1449 #define TPM_DAA_ISSUER_SETTINGS     ((TPM_RESULT) (TPM_BASE + 83))
1450 #define TPM_DAA_TPM_SETTINGS        ((TPM_RESULT) (TPM_BASE + 84))
1451 #define TPM_DAA_STAGE               ((TPM_RESULT) (TPM_BASE + 85))
1452 #define TPM_DAA_ISSUER_VALIDITY     ((TPM_RESULT) (TPM_BASE + 86))
1453 #define TPM_DAA_WRONG_W             ((TPM_RESULT) (TPM_BASE + 87))
1454 #define TPM_BAD_HANDLE              ((TPM_RESULT) (TPM_BASE + 88))
1455 #define TPM_BAD_DELEGATE            ((TPM_RESULT) (TPM_BASE + 89))
1456 #define TPM_BADCONTEXT              ((TPM_RESULT) (TPM_BASE + 90))
1457 #define TPM_TOOMANYCONTEXTS         ((TPM_RESULT) (TPM_BASE + 91))
1458 #define TPM_MA_TICKET_SIGNATURE     ((TPM_RESULT) (TPM_BASE + 92))
1459 #define TPM_MA_DESTINATION          ((TPM_RESULT) (TPM_BASE + 93))
1460 #define TPM_MA_SOURCE               ((TPM_RESULT) (TPM_BASE + 94))
1461 #define TPM_MA_AUTHORITY            ((TPM_RESULT) (TPM_BASE + 95))
1462 #define TPM_PERMANENTEK             ((TPM_RESULT) (TPM_BASE + 97))
1463 #define TPM_BAD_SIGNATURE           ((TPM_RESULT) (TPM_BASE + 98))
1464 #define TPM_NOCONTEXTSPACE          ((TPM_RESULT) (TPM_BASE + 99))
1465 
1466 #define TPM_RETRY                   ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL))
1467 #define TPM_NEEDS_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 1))
1468 #define TPM_DOING_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 2))
1469 #define TPM_DEFEND_LOCK_RUNNING     ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 3))
1470 
1471 //
1472 // Part 2, section 17: Ordinals
1473 //
1474 // Ordinals are 32 bit values. The upper byte contains values that serve as
1475 // flag indicators, the next byte contains values indicating what committee
1476 // designated the ordinal, and the final two bytes contain the Command
1477 // Ordinal Index.
1478 //      3                   2                   1
1479 //    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1480 //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1481 //   |P|C|V| Reserved| Purview |     Command Ordinal Index           |
1482 //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1483 //
1484 //  Where:
1485 //
1486 //    * P is Protected/Unprotected command. When 0 the command is a Protected
1487 //      command, when 1 the command is an Unprotected command.
1488 //
1489 //    * C is Non-Connection/Connection related command. When 0 this command
1490 //      passes through to either the protected (TPM) or unprotected (TSS)
1491 //      components.
1492 //
1493 //    * V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the
1494 //      command is vendor defined.
1495 //
1496 //    * All reserved area bits are set to 0.
1497 //
1498 
1499 #define TPM_ORD_ActivateIdentity                  ((TPM_COMMAND_CODE) 0x0000007A)
1500 #define TPM_ORD_AuthorizeMigrationKey             ((TPM_COMMAND_CODE) 0x0000002B)
1501 #define TPM_ORD_CertifyKey                        ((TPM_COMMAND_CODE) 0x00000032)
1502 #define TPM_ORD_CertifyKey2                       ((TPM_COMMAND_CODE) 0x00000033)
1503 #define TPM_ORD_CertifySelfTest                   ((TPM_COMMAND_CODE) 0x00000052)
1504 #define TPM_ORD_ChangeAuth                        ((TPM_COMMAND_CODE) 0x0000000C)
1505 #define TPM_ORD_ChangeAuthAsymFinish              ((TPM_COMMAND_CODE) 0x0000000F)
1506 #define TPM_ORD_ChangeAuthAsymStart               ((TPM_COMMAND_CODE) 0x0000000E)
1507 #define TPM_ORD_ChangeAuthOwner                   ((TPM_COMMAND_CODE) 0x00000010)
1508 #define TPM_ORD_CMK_ApproveMA                     ((TPM_COMMAND_CODE) 0x0000001D)
1509 #define TPM_ORD_CMK_ConvertMigration              ((TPM_COMMAND_CODE) 0x00000024)
1510 #define TPM_ORD_CMK_CreateBlob                    ((TPM_COMMAND_CODE) 0x0000001B)
1511 #define TPM_ORD_CMK_CreateKey                     ((TPM_COMMAND_CODE) 0x00000013)
1512 #define TPM_ORD_CMK_CreateTicket                  ((TPM_COMMAND_CODE) 0x00000012)
1513 #define TPM_ORD_CMK_SetRestrictions               ((TPM_COMMAND_CODE) 0x0000001C)
1514 #define TPM_ORD_ContinueSelfTest                  ((TPM_COMMAND_CODE) 0x00000053)
1515 #define TPM_ORD_ConvertMigrationBlob              ((TPM_COMMAND_CODE) 0x0000002A)
1516 #define TPM_ORD_CreateCounter                     ((TPM_COMMAND_CODE) 0x000000DC)
1517 #define TPM_ORD_CreateEndorsementKeyPair          ((TPM_COMMAND_CODE) 0x00000078)
1518 #define TPM_ORD_CreateMaintenanceArchive          ((TPM_COMMAND_CODE) 0x0000002C)
1519 #define TPM_ORD_CreateMigrationBlob               ((TPM_COMMAND_CODE) 0x00000028)
1520 #define TPM_ORD_CreateRevocableEK                 ((TPM_COMMAND_CODE) 0x0000007F)
1521 #define TPM_ORD_CreateWrapKey                     ((TPM_COMMAND_CODE) 0x0000001F)
1522 #define TPM_ORD_DAA_JOIN                          ((TPM_COMMAND_CODE) 0x00000029)
1523 #define TPM_ORD_DAA_SIGN                          ((TPM_COMMAND_CODE) 0x00000031)
1524 #define TPM_ORD_Delegate_CreateKeyDelegation      ((TPM_COMMAND_CODE) 0x000000D4)
1525 #define TPM_ORD_Delegate_CreateOwnerDelegation    ((TPM_COMMAND_CODE) 0x000000D5)
1526 #define TPM_ORD_Delegate_LoadOwnerDelegation      ((TPM_COMMAND_CODE) 0x000000D8)
1527 #define TPM_ORD_Delegate_Manage                   ((TPM_COMMAND_CODE) 0x000000D2)
1528 #define TPM_ORD_Delegate_ReadTable                ((TPM_COMMAND_CODE) 0x000000DB)
1529 #define TPM_ORD_Delegate_UpdateVerification       ((TPM_COMMAND_CODE) 0x000000D1)
1530 #define TPM_ORD_Delegate_VerifyDelegation         ((TPM_COMMAND_CODE) 0x000000D6)
1531 #define TPM_ORD_DirRead                           ((TPM_COMMAND_CODE) 0x0000001A)
1532 #define TPM_ORD_DirWriteAuth                      ((TPM_COMMAND_CODE) 0x00000019)
1533 #define TPM_ORD_DisableForceClear                 ((TPM_COMMAND_CODE) 0x0000005E)
1534 #define TPM_ORD_DisableOwnerClear                 ((TPM_COMMAND_CODE) 0x0000005C)
1535 #define TPM_ORD_DisablePubekRead                  ((TPM_COMMAND_CODE) 0x0000007E)
1536 #define TPM_ORD_DSAP                              ((TPM_COMMAND_CODE) 0x00000011)
1537 #define TPM_ORD_EstablishTransport                ((TPM_COMMAND_CODE) 0x000000E6)
1538 #define TPM_ORD_EvictKey                          ((TPM_COMMAND_CODE) 0x00000022)
1539 #define TPM_ORD_ExecuteTransport                  ((TPM_COMMAND_CODE) 0x000000E7)
1540 #define TPM_ORD_Extend                            ((TPM_COMMAND_CODE) 0x00000014)
1541 #define TPM_ORD_FieldUpgrade                      ((TPM_COMMAND_CODE) 0x000000AA)
1542 #define TPM_ORD_FlushSpecific                     ((TPM_COMMAND_CODE) 0x000000BA)
1543 #define TPM_ORD_ForceClear                        ((TPM_COMMAND_CODE) 0x0000005D)
1544 #define TPM_ORD_GetAuditDigest                    ((TPM_COMMAND_CODE) 0x00000085)
1545 #define TPM_ORD_GetAuditDigestSigned              ((TPM_COMMAND_CODE) 0x00000086)
1546 #define TPM_ORD_GetAuditEvent                     ((TPM_COMMAND_CODE) 0x00000082)
1547 #define TPM_ORD_GetAuditEventSigned               ((TPM_COMMAND_CODE) 0x00000083)
1548 #define TPM_ORD_GetCapability                     ((TPM_COMMAND_CODE) 0x00000065)
1549 #define TPM_ORD_GetCapabilityOwner                ((TPM_COMMAND_CODE) 0x00000066)
1550 #define TPM_ORD_GetCapabilitySigned               ((TPM_COMMAND_CODE) 0x00000064)
1551 #define TPM_ORD_GetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008C)
1552 #define TPM_ORD_GetPubKey                         ((TPM_COMMAND_CODE) 0x00000021)
1553 #define TPM_ORD_GetRandom                         ((TPM_COMMAND_CODE) 0x00000046)
1554 #define TPM_ORD_GetTestResult                     ((TPM_COMMAND_CODE) 0x00000054)
1555 #define TPM_ORD_GetTicks                          ((TPM_COMMAND_CODE) 0x000000F1)
1556 #define TPM_ORD_IncrementCounter                  ((TPM_COMMAND_CODE) 0x000000DD)
1557 #define TPM_ORD_Init                              ((TPM_COMMAND_CODE) 0x00000097)
1558 #define TPM_ORD_KeyControlOwner                   ((TPM_COMMAND_CODE) 0x00000023)
1559 #define TPM_ORD_KillMaintenanceFeature            ((TPM_COMMAND_CODE) 0x0000002E)
1560 #define TPM_ORD_LoadAuthContext                   ((TPM_COMMAND_CODE) 0x000000B7)
1561 #define TPM_ORD_LoadContext                       ((TPM_COMMAND_CODE) 0x000000B9)
1562 #define TPM_ORD_LoadKey                           ((TPM_COMMAND_CODE) 0x00000020)
1563 #define TPM_ORD_LoadKey2                          ((TPM_COMMAND_CODE) 0x00000041)
1564 #define TPM_ORD_LoadKeyContext                    ((TPM_COMMAND_CODE) 0x000000B5)
1565 #define TPM_ORD_LoadMaintenanceArchive            ((TPM_COMMAND_CODE) 0x0000002D)
1566 #define TPM_ORD_LoadManuMaintPub                  ((TPM_COMMAND_CODE) 0x0000002F)
1567 #define TPM_ORD_MakeIdentity                      ((TPM_COMMAND_CODE) 0x00000079)
1568 #define TPM_ORD_MigrateKey                        ((TPM_COMMAND_CODE) 0x00000025)
1569 #define TPM_ORD_NV_DefineSpace                    ((TPM_COMMAND_CODE) 0x000000CC)
1570 #define TPM_ORD_NV_ReadValue                      ((TPM_COMMAND_CODE) 0x000000CF)
1571 #define TPM_ORD_NV_ReadValueAuth                  ((TPM_COMMAND_CODE) 0x000000D0)
1572 #define TPM_ORD_NV_WriteValue                     ((TPM_COMMAND_CODE) 0x000000CD)
1573 #define TPM_ORD_NV_WriteValueAuth                 ((TPM_COMMAND_CODE) 0x000000CE)
1574 #define TPM_ORD_OIAP                              ((TPM_COMMAND_CODE) 0x0000000A)
1575 #define TPM_ORD_OSAP                              ((TPM_COMMAND_CODE) 0x0000000B)
1576 #define TPM_ORD_OwnerClear                        ((TPM_COMMAND_CODE) 0x0000005B)
1577 #define TPM_ORD_OwnerReadInternalPub              ((TPM_COMMAND_CODE) 0x00000081)
1578 #define TPM_ORD_OwnerReadPubek                    ((TPM_COMMAND_CODE) 0x0000007D)
1579 #define TPM_ORD_OwnerSetDisable                   ((TPM_COMMAND_CODE) 0x0000006E)
1580 #define TPM_ORD_PCR_Reset                         ((TPM_COMMAND_CODE) 0x000000C8)
1581 #define TPM_ORD_PcrRead                           ((TPM_COMMAND_CODE) 0x00000015)
1582 #define TPM_ORD_PhysicalDisable                   ((TPM_COMMAND_CODE) 0x00000070)
1583 #define TPM_ORD_PhysicalEnable                    ((TPM_COMMAND_CODE) 0x0000006F)
1584 #define TPM_ORD_PhysicalSetDeactivated            ((TPM_COMMAND_CODE) 0x00000072)
1585 #define TPM_ORD_Quote                             ((TPM_COMMAND_CODE) 0x00000016)
1586 #define TPM_ORD_Quote2                            ((TPM_COMMAND_CODE) 0x0000003E)
1587 #define TPM_ORD_ReadCounter                       ((TPM_COMMAND_CODE) 0x000000DE)
1588 #define TPM_ORD_ReadManuMaintPub                  ((TPM_COMMAND_CODE) 0x00000030)
1589 #define TPM_ORD_ReadPubek                         ((TPM_COMMAND_CODE) 0x0000007C)
1590 #define TPM_ORD_ReleaseCounter                    ((TPM_COMMAND_CODE) 0x000000DF)
1591 #define TPM_ORD_ReleaseCounterOwner               ((TPM_COMMAND_CODE) 0x000000E0)
1592 #define TPM_ORD_ReleaseTransportSigned            ((TPM_COMMAND_CODE) 0x000000E8)
1593 #define TPM_ORD_Reset                             ((TPM_COMMAND_CODE) 0x0000005A)
1594 #define TPM_ORD_ResetLockValue                    ((TPM_COMMAND_CODE) 0x00000040)
1595 #define TPM_ORD_RevokeTrust                       ((TPM_COMMAND_CODE) 0x00000080)
1596 #define TPM_ORD_SaveAuthContext                   ((TPM_COMMAND_CODE) 0x000000B6)
1597 #define TPM_ORD_SaveContext                       ((TPM_COMMAND_CODE) 0x000000B8)
1598 #define TPM_ORD_SaveKeyContext                    ((TPM_COMMAND_CODE) 0x000000B4)
1599 #define TPM_ORD_SaveState                         ((TPM_COMMAND_CODE) 0x00000098)
1600 #define TPM_ORD_Seal                              ((TPM_COMMAND_CODE) 0x00000017)
1601 #define TPM_ORD_Sealx                             ((TPM_COMMAND_CODE) 0x0000003D)
1602 #define TPM_ORD_SelfTestFull                      ((TPM_COMMAND_CODE) 0x00000050)
1603 #define TPM_ORD_SetCapability                     ((TPM_COMMAND_CODE) 0x0000003F)
1604 #define TPM_ORD_SetOperatorAuth                   ((TPM_COMMAND_CODE) 0x00000074)
1605 #define TPM_ORD_SetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008D)
1606 #define TPM_ORD_SetOwnerInstall                   ((TPM_COMMAND_CODE) 0x00000071)
1607 #define TPM_ORD_SetOwnerPointer                   ((TPM_COMMAND_CODE) 0x00000075)
1608 #define TPM_ORD_SetRedirection                    ((TPM_COMMAND_CODE) 0x0000009A)
1609 #define TPM_ORD_SetTempDeactivated                ((TPM_COMMAND_CODE) 0x00000073)
1610 #define TPM_ORD_SHA1Complete                      ((TPM_COMMAND_CODE) 0x000000A2)
1611 #define TPM_ORD_SHA1CompleteExtend                ((TPM_COMMAND_CODE) 0x000000A3)
1612 #define TPM_ORD_SHA1Start                         ((TPM_COMMAND_CODE) 0x000000A0)
1613 #define TPM_ORD_SHA1Update                        ((TPM_COMMAND_CODE) 0x000000A1)
1614 #define TPM_ORD_Sign                              ((TPM_COMMAND_CODE) 0x0000003C)
1615 #define TPM_ORD_Startup                           ((TPM_COMMAND_CODE) 0x00000099)
1616 #define TPM_ORD_StirRandom                        ((TPM_COMMAND_CODE) 0x00000047)
1617 #define TPM_ORD_TakeOwnership                     ((TPM_COMMAND_CODE) 0x0000000D)
1618 #define TPM_ORD_Terminate_Handle                  ((TPM_COMMAND_CODE) 0x00000096)
1619 #define TPM_ORD_TickStampBlob                     ((TPM_COMMAND_CODE) 0x000000F2)
1620 #define TPM_ORD_UnBind                            ((TPM_COMMAND_CODE) 0x0000001E)
1621 #define TPM_ORD_Unseal                            ((TPM_COMMAND_CODE) 0x00000018)
1622 #define TSC_ORD_PhysicalPresence                  ((TPM_COMMAND_CODE) 0x4000000A)
1623 #define TSC_ORD_ResetEstablishmentBit             ((TPM_COMMAND_CODE) 0x4000000B)
1624 
1625 //
1626 // Part 2, section 18: Context structures
1627 //
1628 
1629 ///
1630 /// Part 2, section 18.1: TPM_CONTEXT_BLOB
1631 ///
1632 typedef struct tdTPM_CONTEXT_BLOB {
1633   TPM_STRUCTURE_TAG               tag;
1634   TPM_RESOURCE_TYPE               resourceType;
1635   TPM_HANDLE                      handle;
1636   UINT8                           label[16];
1637   UINT32                          contextCount;
1638   TPM_DIGEST                      integrityDigest;
1639   UINT32                          additionalSize;
1640   UINT8                           *additionalData;
1641   UINT32                          sensitiveSize;
1642   UINT8                           *sensitiveData;
1643 } TPM_CONTEXT_BLOB;
1644 
1645 ///
1646 /// Part 2, section 18.2 TPM_CONTEXT_SENSITIVE
1647 ///
1648 typedef struct tdTPM_CONTEXT_SENSITIVE {
1649   TPM_STRUCTURE_TAG               tag;
1650   TPM_NONCE                       contextNonce;
1651   UINT32                          internalSize;
1652   UINT8                           *internalData;
1653 } TPM_CONTEXT_SENSITIVE;
1654 
1655 //
1656 // Part 2, section 19: NV Structures
1657 //
1658 
1659 //
1660 // Part 2, section 19.1.1: Required TPM_NV_INDEX values
1661 //
1662 #define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)
1663 #define TPM_NV_INDEX0                  ((UINT32)0x00000000)
1664 #define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)
1665 #define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)
1666 #define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)
1667 #define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)
1668 #define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)
1669 //
1670 // Part 2, section 19.1.2: Reserved Index values
1671 //
1672 #define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)
1673 #define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)
1674 #define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)
1675 #define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)
1676 #define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)
1677 #define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)
1678 
1679 ///
1680 /// Part 2, section 19.2: TPM_NV_ATTRIBUTES
1681 ///
1682 typedef struct tdTPM_NV_ATTRIBUTES {
1683   TPM_STRUCTURE_TAG               tag;
1684   UINT32                          attributes;
1685 } TPM_NV_ATTRIBUTES;
1686 
1687 #define TPM_NV_PER_READ_STCLEAR        (BIT31)
1688 #define TPM_NV_PER_AUTHREAD            (BIT18)
1689 #define TPM_NV_PER_OWNERREAD           (BIT17)
1690 #define TPM_NV_PER_PPREAD              (BIT16)
1691 #define TPM_NV_PER_GLOBALLOCK          (BIT15)
1692 #define TPM_NV_PER_WRITE_STCLEAR       (BIT14)
1693 #define TPM_NV_PER_WRITEDEFINE         (BIT13)
1694 #define TPM_NV_PER_WRITEALL            (BIT12)
1695 #define TPM_NV_PER_AUTHWRITE           (BIT2)
1696 #define TPM_NV_PER_OWNERWRITE          (BIT1)
1697 #define TPM_NV_PER_PPWRITE             (BIT0)
1698 
1699 ///
1700 /// Part 2, section 19.3: TPM_NV_DATA_PUBLIC
1701 ///
1702 typedef struct tdTPM_NV_DATA_PUBLIC {
1703   TPM_STRUCTURE_TAG               tag;
1704   TPM_NV_INDEX                    nvIndex;
1705   TPM_PCR_INFO_SHORT              pcrInfoRead;
1706   TPM_PCR_INFO_SHORT              pcrInfoWrite;
1707   TPM_NV_ATTRIBUTES               permission;
1708   BOOLEAN                         bReadSTClear;
1709   BOOLEAN                         bWriteSTClear;
1710   BOOLEAN                         bWriteDefine;
1711   UINT32                          dataSize;
1712 } TPM_NV_DATA_PUBLIC;
1713 
1714 //
1715 // Part 2, section 20: Delegate Structures
1716 //
1717 
1718 #define TPM_DEL_OWNER_BITS          ((UINT32)0x00000001)
1719 #define TPM_DEL_KEY_BITS            ((UINT32)0x00000002)
1720 ///
1721 /// Part 2, section 20.2: Delegate Definitions
1722 ///
1723 typedef struct tdTPM_DELEGATIONS {
1724   TPM_STRUCTURE_TAG               tag;
1725   UINT32                          delegateType;
1726   UINT32                          per1;
1727   UINT32                          per2;
1728 } TPM_DELEGATIONS;
1729 
1730 //
1731 // Part 2, section 20.2.1: Owner Permission Settings
1732 //
1733 #define TPM_DELEGATE_SetOrdinalAuditStatus          (BIT30)
1734 #define TPM_DELEGATE_DirWriteAuth                   (BIT29)
1735 #define TPM_DELEGATE_CMK_ApproveMA                  (BIT28)
1736 #define TPM_DELEGATE_NV_WriteValue                  (BIT27)
1737 #define TPM_DELEGATE_CMK_CreateTicket               (BIT26)
1738 #define TPM_DELEGATE_NV_ReadValue                   (BIT25)
1739 #define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (BIT24)
1740 #define TPM_DELEGATE_DAA_Join                       (BIT23)
1741 #define TPM_DELEGATE_AuthorizeMigrationKey          (BIT22)
1742 #define TPM_DELEGATE_CreateMaintenanceArchive       (BIT21)
1743 #define TPM_DELEGATE_LoadMaintenanceArchive         (BIT20)
1744 #define TPM_DELEGATE_KillMaintenanceFeature         (BIT19)
1745 #define TPM_DELEGATE_OwnerReadInteralPub            (BIT18)
1746 #define TPM_DELEGATE_ResetLockValue                 (BIT17)
1747 #define TPM_DELEGATE_OwnerClear                     (BIT16)
1748 #define TPM_DELEGATE_DisableOwnerClear              (BIT15)
1749 #define TPM_DELEGATE_NV_DefineSpace                 (BIT14)
1750 #define TPM_DELEGATE_OwnerSetDisable                (BIT13)
1751 #define TPM_DELEGATE_SetCapability                  (BIT12)
1752 #define TPM_DELEGATE_MakeIdentity                   (BIT11)
1753 #define TPM_DELEGATE_ActivateIdentity               (BIT10)
1754 #define TPM_DELEGATE_OwnerReadPubek                 (BIT9)
1755 #define TPM_DELEGATE_DisablePubekRead               (BIT8)
1756 #define TPM_DELEGATE_SetRedirection                 (BIT7)
1757 #define TPM_DELEGATE_FieldUpgrade                   (BIT6)
1758 #define TPM_DELEGATE_Delegate_UpdateVerification    (BIT5)
1759 #define TPM_DELEGATE_CreateCounter                  (BIT4)
1760 #define TPM_DELEGATE_ReleaseCounterOwner            (BIT3)
1761 #define TPM_DELEGATE_DelegateManage                 (BIT2)
1762 #define TPM_DELEGATE_Delegate_CreateOwnerDelegation (BIT1)
1763 #define TPM_DELEGATE_DAA_Sign                       (BIT0)
1764 
1765 //
1766 // Part 2, section 20.2.3: Key Permission settings
1767 //
1768 #define TPM_KEY_DELEGATE_CMK_ConvertMigration       (BIT28)
1769 #define TPM_KEY_DELEGATE_TickStampBlob              (BIT27)
1770 #define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (BIT26)
1771 #define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (BIT25)
1772 #define TPM_KEY_DELEGATE_CMK_CreateKey              (BIT24)
1773 #define TPM_KEY_DELEGATE_MigrateKey                 (BIT23)
1774 #define TPM_KEY_DELEGATE_LoadKey2                   (BIT22)
1775 #define TPM_KEY_DELEGATE_EstablishTransport         (BIT21)
1776 #define TPM_KEY_DELEGATE_ReleaseTransportSigned     (BIT20)
1777 #define TPM_KEY_DELEGATE_Quote2                     (BIT19)
1778 #define TPM_KEY_DELEGATE_Sealx                      (BIT18)
1779 #define TPM_KEY_DELEGATE_MakeIdentity               (BIT17)
1780 #define TPM_KEY_DELEGATE_ActivateIdentity           (BIT16)
1781 #define TPM_KEY_DELEGATE_GetAuditDigestSigned       (BIT15)
1782 #define TPM_KEY_DELEGATE_Sign                       (BIT14)
1783 #define TPM_KEY_DELEGATE_CertifyKey2                (BIT13)
1784 #define TPM_KEY_DELEGATE_CertifyKey                 (BIT12)
1785 #define TPM_KEY_DELEGATE_CreateWrapKey              (BIT11)
1786 #define TPM_KEY_DELEGATE_CMK_CreateBlob             (BIT10)
1787 #define TPM_KEY_DELEGATE_CreateMigrationBlob        (BIT9)
1788 #define TPM_KEY_DELEGATE_ConvertMigrationBlob       (BIT8)
1789 #define TPM_KEY_DELEGATE_CreateKeyDelegation        (BIT7)
1790 #define TPM_KEY_DELEGATE_ChangeAuth                 (BIT6)
1791 #define TPM_KEY_DELEGATE_GetPubKey                  (BIT5)
1792 #define TPM_KEY_DELEGATE_UnBind                     (BIT4)
1793 #define TPM_KEY_DELEGATE_Quote                      (BIT3)
1794 #define TPM_KEY_DELEGATE_Unseal                     (BIT2)
1795 #define TPM_KEY_DELEGATE_Seal                       (BIT1)
1796 #define TPM_KEY_DELEGATE_LoadKey                    (BIT0)
1797 
1798 //
1799 // Part 2, section 20.3: TPM_FAMILY_FLAGS
1800 //
1801 #define TPM_DELEGATE_ADMIN_LOCK           (BIT1)
1802 #define TPM_FAMFLAG_ENABLE                (BIT0)
1803 
1804 ///
1805 /// Part 2, section 20.4: TPM_FAMILY_LABEL
1806 ///
1807 typedef struct tdTPM_FAMILY_LABEL {
1808   UINT8                           label;
1809 } TPM_FAMILY_LABEL;
1810 
1811 ///
1812 /// Part 2, section 20.5: TPM_FAMILY_TABLE_ENTRY
1813 ///
1814 typedef struct tdTPM_FAMILY_TABLE_ENTRY {
1815   TPM_STRUCTURE_TAG               tag;
1816   TPM_FAMILY_LABEL                label;
1817   TPM_FAMILY_ID                   familyID;
1818   TPM_FAMILY_VERIFICATION         verificationCount;
1819   TPM_FAMILY_FLAGS                flags;
1820 } TPM_FAMILY_TABLE_ENTRY;
1821 
1822 //
1823 // Part 2, section 20.6: TPM_FAMILY_TABLE
1824 //
1825 #define TPM_NUM_FAMILY_TABLE_ENTRY_MIN 8
1826 
1827 typedef struct tdTPM_FAMILY_TABLE{
1828   TPM_FAMILY_TABLE_ENTRY famTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
1829 } TPM_FAMILY_TABLE;
1830 
1831 ///
1832 /// Part 2, section 20.7: TPM_DELEGATE_LABEL
1833 ///
1834 typedef struct tdTPM_DELEGATE_LABEL {
1835   UINT8                           label;
1836 } TPM_DELEGATE_LABEL;
1837 
1838 ///
1839 /// Part 2, section 20.8: TPM_DELEGATE_PUBLIC
1840 ///
1841 typedef struct tdTPM_DELEGATE_PUBLIC {
1842   TPM_STRUCTURE_TAG               tag;
1843   TPM_DELEGATE_LABEL              label;
1844   TPM_PCR_INFO_SHORT              pcrInfo;
1845   TPM_DELEGATIONS                 permissions;
1846   TPM_FAMILY_ID                   familyID;
1847   TPM_FAMILY_VERIFICATION         verificationCount;
1848 } TPM_DELEGATE_PUBLIC;
1849 
1850 ///
1851 /// Part 2, section 20.9: TPM_DELEGATE_TABLE_ROW
1852 ///
1853 typedef struct tdTPM_DELEGATE_TABLE_ROW {
1854   TPM_STRUCTURE_TAG               tag;
1855   TPM_DELEGATE_PUBLIC             pub;
1856   TPM_SECRET                      authValue;
1857 } TPM_DELEGATE_TABLE_ROW;
1858 
1859 //
1860 // Part 2, section 20.10: TPM_DELEGATE_TABLE
1861 //
1862 #define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
1863 
1864 typedef struct tdTPM_DELEGATE_TABLE{
1865   TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
1866 } TPM_DELEGATE_TABLE;
1867 
1868 ///
1869 /// Part 2, section 20.11: TPM_DELEGATE_SENSITIVE
1870 ///
1871 typedef struct tdTPM_DELEGATE_SENSITIVE {
1872   TPM_STRUCTURE_TAG               tag;
1873   TPM_SECRET                      authValue;
1874 } TPM_DELEGATE_SENSITIVE;
1875 
1876 ///
1877 /// Part 2, section 20.12: TPM_DELEGATE_OWNER_BLOB
1878 ///
1879 typedef struct tdTPM_DELEGATE_OWNER_BLOB {
1880   TPM_STRUCTURE_TAG               tag;
1881   TPM_DELEGATE_PUBLIC             pub;
1882   TPM_DIGEST                      integrityDigest;
1883   UINT32                          additionalSize;
1884   UINT8                           *additionalArea;
1885   UINT32                          sensitiveSize;
1886   UINT8                           *sensitiveArea;
1887 } TPM_DELEGATE_OWNER_BLOB;
1888 
1889 ///
1890 /// Part 2, section 20.13: TTPM_DELEGATE_KEY_BLOB
1891 ///
1892 typedef struct tdTPM_DELEGATE_KEY_BLOB {
1893   TPM_STRUCTURE_TAG               tag;
1894   TPM_DELEGATE_PUBLIC             pub;
1895   TPM_DIGEST                      integrityDigest;
1896   TPM_DIGEST                      pubKeyDigest;
1897   UINT32                          additionalSize;
1898   UINT8                           *additionalArea;
1899   UINT32                          sensitiveSize;
1900   UINT8                           *sensitiveArea;
1901 } TPM_DELEGATE_KEY_BLOB;
1902 
1903 //
1904 // Part 2, section 20.14: TPM_FAMILY_OPERATION Values
1905 //
1906 #define TPM_FAMILY_CREATE                 ((UINT32)0x00000001)
1907 #define TPM_FAMILY_ENABLE                 ((UINT32)0x00000002)
1908 #define TPM_FAMILY_ADMIN                  ((UINT32)0x00000003)
1909 #define TPM_FAMILY_INVALIDATE             ((UINT32)0x00000004)
1910 
1911 //
1912 // Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability
1913 //
1914 #define TPM_CAP_ORD                     ((TPM_CAPABILITY_AREA) 0x00000001)
1915 #define TPM_CAP_ALG                     ((TPM_CAPABILITY_AREA) 0x00000002)
1916 #define TPM_CAP_PID                     ((TPM_CAPABILITY_AREA) 0x00000003)
1917 #define TPM_CAP_FLAG                    ((TPM_CAPABILITY_AREA) 0x00000004)
1918 #define TPM_CAP_PROPERTY                ((TPM_CAPABILITY_AREA) 0x00000005)
1919 #define TPM_CAP_VERSION                 ((TPM_CAPABILITY_AREA) 0x00000006)
1920 #define TPM_CAP_KEY_HANDLE              ((TPM_CAPABILITY_AREA) 0x00000007)
1921 #define TPM_CAP_CHECK_LOADED            ((TPM_CAPABILITY_AREA) 0x00000008)
1922 #define TPM_CAP_SYM_MODE                ((TPM_CAPABILITY_AREA) 0x00000009)
1923 #define TPM_CAP_KEY_STATUS              ((TPM_CAPABILITY_AREA) 0x0000000C)
1924 #define TPM_CAP_NV_LIST                 ((TPM_CAPABILITY_AREA) 0x0000000D)
1925 #define TPM_CAP_MFR                     ((TPM_CAPABILITY_AREA) 0x00000010)
1926 #define TPM_CAP_NV_INDEX                ((TPM_CAPABILITY_AREA) 0x00000011)
1927 #define TPM_CAP_TRANS_ALG               ((TPM_CAPABILITY_AREA) 0x00000012)
1928 #define TPM_CAP_HANDLE                  ((TPM_CAPABILITY_AREA) 0x00000014)
1929 #define TPM_CAP_TRANS_ES                ((TPM_CAPABILITY_AREA) 0x00000015)
1930 #define TPM_CAP_AUTH_ENCRYPT            ((TPM_CAPABILITY_AREA) 0x00000017)
1931 #define TPM_CAP_SELECT_SIZE             ((TPM_CAPABILITY_AREA) 0x00000018)
1932 #define TPM_CAP_VERSION_VAL             ((TPM_CAPABILITY_AREA) 0x0000001A)
1933 
1934 #define TPM_CAP_FLAG_PERMANENT          ((TPM_CAPABILITY_AREA) 0x00000108)
1935 #define TPM_CAP_FLAG_VOLATILE           ((TPM_CAPABILITY_AREA) 0x00000109)
1936 
1937 //
1938 // Part 2, section 21.2: CAP_PROPERTY Subcap values for GetCapability
1939 //
1940 #define TPM_CAP_PROP_PCR                ((TPM_CAPABILITY_AREA) 0x00000101)
1941 #define TPM_CAP_PROP_DIR                ((TPM_CAPABILITY_AREA) 0x00000102)
1942 #define TPM_CAP_PROP_MANUFACTURER       ((TPM_CAPABILITY_AREA) 0x00000103)
1943 #define TPM_CAP_PROP_KEYS               ((TPM_CAPABILITY_AREA) 0x00000104)
1944 #define TPM_CAP_PROP_MIN_COUNTER        ((TPM_CAPABILITY_AREA) 0x00000107)
1945 #define TPM_CAP_PROP_AUTHSESS           ((TPM_CAPABILITY_AREA) 0x0000010A)
1946 #define TPM_CAP_PROP_TRANSESS           ((TPM_CAPABILITY_AREA) 0x0000010B)
1947 #define TPM_CAP_PROP_COUNTERS           ((TPM_CAPABILITY_AREA) 0x0000010C)
1948 #define TPM_CAP_PROP_MAX_AUTHSESS       ((TPM_CAPABILITY_AREA) 0x0000010D)
1949 #define TPM_CAP_PROP_MAX_TRANSESS       ((TPM_CAPABILITY_AREA) 0x0000010E)
1950 #define TPM_CAP_PROP_MAX_COUNTERS       ((TPM_CAPABILITY_AREA) 0x0000010F)
1951 #define TPM_CAP_PROP_MAX_KEYS           ((TPM_CAPABILITY_AREA) 0x00000110)
1952 #define TPM_CAP_PROP_OWNER              ((TPM_CAPABILITY_AREA) 0x00000111)
1953 #define TPM_CAP_PROP_CONTEXT            ((TPM_CAPABILITY_AREA) 0x00000112)
1954 #define TPM_CAP_PROP_MAX_CONTEXT        ((TPM_CAPABILITY_AREA) 0x00000113)
1955 #define TPM_CAP_PROP_FAMILYROWS         ((TPM_CAPABILITY_AREA) 0x00000114)
1956 #define TPM_CAP_PROP_TIS_TIMEOUT        ((TPM_CAPABILITY_AREA) 0x00000115)
1957 #define TPM_CAP_PROP_STARTUP_EFFECT     ((TPM_CAPABILITY_AREA) 0x00000116)
1958 #define TPM_CAP_PROP_DELEGATE_ROW       ((TPM_CAPABILITY_AREA) 0x00000117)
1959 #define TPM_CAP_PROP_DAA_MAX            ((TPM_CAPABILITY_AREA) 0x00000119)
1960 #define CAP_PROP_SESSION_DAA            ((TPM_CAPABILITY_AREA) 0x0000011A)
1961 #define TPM_CAP_PROP_CONTEXT_DIST       ((TPM_CAPABILITY_AREA) 0x0000011B)
1962 #define TPM_CAP_PROP_DAA_INTERRUPT      ((TPM_CAPABILITY_AREA) 0x0000011C)
1963 #define TPM_CAP_PROP_SESSIONS           ((TPM_CAPABILITY_AREA) 0x0000011D)
1964 #define TPM_CAP_PROP_MAX_SESSIONS       ((TPM_CAPABILITY_AREA) 0x0000011E)
1965 #define TPM_CAP_PROP_CMK_RESTRICTION    ((TPM_CAPABILITY_AREA) 0x0000011F)
1966 #define TPM_CAP_PROP_DURATION           ((TPM_CAPABILITY_AREA) 0x00000120)
1967 #define TPM_CAP_PROP_ACTIVE_COUNTER     ((TPM_CAPABILITY_AREA) 0x00000122)
1968 #define TPM_CAP_PROP_MAX_NV_AVAILABLE   ((TPM_CAPABILITY_AREA) 0x00000123)
1969 #define TPM_CAP_PROP_INPUT_BUFFER       ((TPM_CAPABILITY_AREA) 0x00000124)
1970 
1971 //
1972 // Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability
1973 //
1974 #define TPM_SET_PERM_FLAGS              ((TPM_CAPABILITY_AREA) 0x00000001)
1975 #define TPM_SET_PERM_DATA               ((TPM_CAPABILITY_AREA) 0x00000002)
1976 #define TPM_SET_STCLEAR_FLAGS           ((TPM_CAPABILITY_AREA) 0x00000003)
1977 #define TPM_SET_STCLEAR_DATA            ((TPM_CAPABILITY_AREA) 0x00000004)
1978 #define TPM_SET_STANY_FLAGS             ((TPM_CAPABILITY_AREA) 0x00000005)
1979 #define TPM_SET_STANY_DATA              ((TPM_CAPABILITY_AREA) 0x00000006)
1980 
1981 ///
1982 /// Part 2, section 21.6: TPM_CAP_VERSION_INFO
1983 ///   [size_is(vendorSpecificSize)] BYTE* vendorSpecific;
1984 ///
1985 typedef struct tdTPM_CAP_VERSION_INFO {
1986   TPM_STRUCTURE_TAG                 tag;
1987   TPM_VERSION                       version;
1988   UINT16                            specLevel;
1989   UINT8                             errataRev;
1990   UINT8                             tpmVendorID[4];
1991   UINT16                            vendorSpecificSize;
1992   UINT8                             *vendorSpecific;
1993 } TPM_CAP_VERSION_INFO;
1994 
1995 ///
1996 /// Part 2, section 21.10: TPM_DA_ACTION_TYPE
1997 ///
1998 typedef struct tdTPM_DA_ACTION_TYPE {
1999   TPM_STRUCTURE_TAG                 tag;
2000   UINT32                            actions;
2001 } TPM_DA_ACTION_TYPE;
2002 
2003 #define TPM_DA_ACTION_FAILURE_MODE     (((UINT32)1)<<3)
2004 #define TPM_DA_ACTION_DEACTIVATE       (((UINT32)1)<<2)
2005 #define TPM_DA_ACTION_DISABLE          (((UINT32)1)<<1)
2006 #define TPM_DA_ACTION_TIMEOUT          (((UINT32)1)<<0)
2007 
2008 ///
2009 /// Part 2, section 21.7: TPM_DA_INFO
2010 ///
2011 typedef struct tdTPM_DA_INFO {
2012   TPM_STRUCTURE_TAG                 tag;
2013   TPM_DA_STATE                      state;
2014   UINT16                            currentCount;
2015   UINT16                            thresholdCount;
2016   TPM_DA_ACTION_TYPE                actionAtThreshold;
2017   UINT32                            actionDependValue;
2018   UINT32                            vendorDataSize;
2019   UINT8                             *vendorData;
2020 } TPM_DA_INFO;
2021 
2022 ///
2023 /// Part 2, section 21.8: TPM_DA_INFO_LIMITED
2024 ///
2025 typedef struct tdTPM_DA_INFO_LIMITED {
2026   TPM_STRUCTURE_TAG                 tag;
2027   TPM_DA_STATE                      state;
2028   TPM_DA_ACTION_TYPE                actionAtThreshold;
2029   UINT32                            vendorDataSize;
2030   UINT8                             *vendorData;
2031 } TPM_DA_INFO_LIMITED;
2032 
2033 //
2034 // Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability
2035 //
2036 #define TPM_DA_STATE_INACTIVE          ((UINT8)0x00)
2037 #define TPM_DA_STATE_ACTIVE            ((UINT8)0x01)
2038 
2039 //
2040 // Part 2, section 22: DAA Structures
2041 //
2042 
2043 //
2044 // Part 2, section 22.1: Size definitions
2045 //
2046 #define TPM_DAA_SIZE_r0                (43)
2047 #define TPM_DAA_SIZE_r1                (43)
2048 #define TPM_DAA_SIZE_r2                (128)
2049 #define TPM_DAA_SIZE_r3                (168)
2050 #define TPM_DAA_SIZE_r4                (219)
2051 #define TPM_DAA_SIZE_NT                (20)
2052 #define TPM_DAA_SIZE_v0                (128)
2053 #define TPM_DAA_SIZE_v1                (192)
2054 #define TPM_DAA_SIZE_NE                (256)
2055 #define TPM_DAA_SIZE_w                 (256)
2056 #define TPM_DAA_SIZE_issuerModulus     (256)
2057 //
2058 // Part 2, section 22.2: Constant definitions
2059 //
2060 #define TPM_DAA_power0                 (104)
2061 #define TPM_DAA_power1                 (1024)
2062 
2063 ///
2064 /// Part 2, section 22.3: TPM_DAA_ISSUER
2065 ///
2066 typedef struct tdTPM_DAA_ISSUER {
2067   TPM_STRUCTURE_TAG               tag;
2068   TPM_DIGEST                      DAA_digest_R0;
2069   TPM_DIGEST                      DAA_digest_R1;
2070   TPM_DIGEST                      DAA_digest_S0;
2071   TPM_DIGEST                      DAA_digest_S1;
2072   TPM_DIGEST                      DAA_digest_n;
2073   TPM_DIGEST                      DAA_digest_gamma;
2074   UINT8                           DAA_generic_q[26];
2075 } TPM_DAA_ISSUER;
2076 
2077 ///
2078 /// Part 2, section 22.4: TPM_DAA_TPM
2079 ///
2080 typedef struct tdTPM_DAA_TPM {
2081   TPM_STRUCTURE_TAG               tag;
2082   TPM_DIGEST                      DAA_digestIssuer;
2083   TPM_DIGEST                      DAA_digest_v0;
2084   TPM_DIGEST                      DAA_digest_v1;
2085   TPM_DIGEST                      DAA_rekey;
2086   UINT32                          DAA_count;
2087 } TPM_DAA_TPM;
2088 
2089 ///
2090 /// Part 2, section 22.5: TPM_DAA_CONTEXT
2091 ///
2092 typedef struct tdTPM_DAA_CONTEXT {
2093   TPM_STRUCTURE_TAG               tag;
2094   TPM_DIGEST                      DAA_digestContext;
2095   TPM_DIGEST                      DAA_digest;
2096   TPM_DAA_CONTEXT_SEED            DAA_contextSeed;
2097   UINT8                           DAA_scratch[256];
2098   UINT8                           DAA_stage;
2099 } TPM_DAA_CONTEXT;
2100 
2101 ///
2102 /// Part 2, section 22.6: TPM_DAA_JOINDATA
2103 ///
2104 typedef struct tdTPM_DAA_JOINDATA {
2105   UINT8                           DAA_join_u0[128];
2106   UINT8                           DAA_join_u1[138];
2107   TPM_DIGEST                      DAA_digest_n0;
2108 } TPM_DAA_JOINDATA;
2109 
2110 ///
2111 /// Part 2, section 22.8: TPM_DAA_BLOB
2112 ///
2113 typedef struct tdTPM_DAA_BLOB {
2114   TPM_STRUCTURE_TAG               tag;
2115   TPM_RESOURCE_TYPE               resourceType;
2116   UINT8                           label[16];
2117   TPM_DIGEST                      blobIntegrity;
2118   UINT32                          additionalSize;
2119   UINT8                           *additionalData;
2120   UINT32                          sensitiveSize;
2121   UINT8                           *sensitiveData;
2122 } TPM_DAA_BLOB;
2123 
2124 ///
2125 /// Part 2, section 22.9: TPM_DAA_SENSITIVE
2126 ///
2127 typedef struct tdTPM_DAA_SENSITIVE {
2128   TPM_STRUCTURE_TAG               tag;
2129   UINT32                          internalSize;
2130   UINT8                           *internalData;
2131 } TPM_DAA_SENSITIVE;
2132 
2133 
2134 //
2135 // Part 2, section 23: Redirection
2136 //
2137 
2138 ///
2139 /// Part 2 section 23.1: TPM_REDIR_COMMAND
2140 /// This section defines exactly one value but does not
2141 /// give it a name. The definition of TPM_SetRedirection in Part3
2142 /// refers to exactly one name but does not give its value. We join
2143 /// them here.
2144 ///
2145 #define TPM_REDIR_GPIO              (0x00000001)
2146 
2147 ///
2148 /// TPM Command Headers defined in Part 3
2149 ///
2150 typedef struct tdTPM_RQU_COMMAND_HDR {
2151   TPM_STRUCTURE_TAG                 tag;
2152   UINT32                            paramSize;
2153   TPM_COMMAND_CODE                  ordinal;
2154 } TPM_RQU_COMMAND_HDR;
2155 
2156 ///
2157 /// TPM Response Headers defined in Part 3
2158 ///
2159 typedef struct tdTPM_RSP_COMMAND_HDR {
2160   TPM_STRUCTURE_TAG                 tag;
2161   UINT32                            paramSize;
2162   TPM_RESULT                        returnCode;
2163 } TPM_RSP_COMMAND_HDR;
2164 
2165 #pragma pack ()
2166 
2167 #endif
2168