1 /*++
2  *
3  * TPM structures extracted from the TPM specification 1.2,
4  * Part 2 (Structures), rev 85.
5  *
6  * Errata:
7  *
8  * *) The individual bits of TPM_STARTUP_EFFECTS were not given names in
9  * the TPM spec so they are not defined in tpm.h.
10  *
11  * *) A few typedefs not present in the TPM 1.2 specification have been
12  * added. This was generally done when the TPM 1.2 spec defined a set of
13  * related values (either bitmasks or enumeration values) but did not
14  * define an associated type to hold these values. The typedefs have been
15  * added and structure fields that were to hold those values have been
16  * switched from generic UINT* types to the more specific types. This was
17  * done to highlight exactly where those #defined values were to be used.
18  * The types that have been added are:
19  *   TPM_NV_PER_ATTRIBUTES
20  *   TPM_DELEGATE_TYPE
21  *
22  * *) The layout of bitfields within a structure are compiler-dependent
23  * and the use of structure bitfields has been avoided where possible. In
24  * cases where a value is a collection of independent bits the type is
25  * given a name (typedeffed to UINT16 or UINT32 as appropriate) and masks
26  * are #defined to access the individual bits. This is not possible for
27  * TPM_VERSION_BYTE because the fields are 4-bit values. A best attempt
28  * has been made to make this compiler independent but it has only been
29  * checked on GCC and Visual C++ on little-endian machines.
30  *
31  * *) The TPM_DELEGATIONS per1 and per2 fields field are a bitmask but
32  * are defined as a UINT32 because the bitfields have different meaning
33  * based on the type of delegation blob.
34  *
35  * *) The definitions of TPM_PERMANENT_DATA, TPM_STCLEAR_DATA,
36  * TPM_STANY_DATA, and TPM_DELEGATE_TABLE_ROW are commented out. These
37  * structures are internal to the TPM and are not directly accessible by
38  * external software so this should not be a problem.
39  *
40  * *) The definitions of TPM_FAMILY_TABLE and TPM_DELEGATE_TABLE are
41  * commented out because they are variable length arrays internal to the
42  * TPM. As above they are not directly accessible by external software
43  * so this should not be a problem.
44  */
45 
46 #ifndef __TPM_H__
47 #define __TPM_H__
48 
49 #ifdef __midl
50 #define SIZEIS(x)  [size_is(x)]
51 #else
52 #define SIZEIS(x)
53 #endif
54 
55 #include <tss/platform.h>
56 
57 //-------------------------------------------------------------------
58 // Part 2, section 2.1: Basic data types
59 typedef BYTE   TPM_BOOL;
60 #ifndef FALSE
61 #define FALSE  0x00
62 #define TRUE   0x01
63 #endif /* ifndef FALSE */
64 
65 //-------------------------------------------------------------------
66 // Part 2, section 2.3: Helper Redefinitions
67 //   Many of the helper redefinitions appear later in this file
68 //   so that they are declared next to the list of valid values
69 //   they may hold.
70 typedef BYTE TPM_LOCALITY_MODIFIER;
71 typedef UINT32 TPM_COMMAND_CODE;                            /* 1.1b */
72 typedef UINT32 TPM_COUNT_ID;
73 typedef UINT32 TPM_REDIT_COMMAND;
74 typedef UINT32 TPM_HANDLE;
75 typedef UINT32 TPM_AUTHHANDLE;
76 typedef UINT32 TPM_TRANSHANDLE;
77 typedef UINT32 TPM_KEYHANDLE;
78 typedef UINT32 TPM_DIRINDEX;
79 typedef UINT32 TPM_PCRINDEX;
80 typedef UINT32 TPM_RESULT;
81 typedef UINT32 TPM_MODIFIER_INDICATOR;
82 
83 
84 
85 //-------------------------------------------------------------------
86 // Part 2, section 2.2.4: Vendor Specific
87 #define TPM_Vendor_Specific32  0x00000400
88 #define TPM_Vendor_Specific8   0x80
89 
90 
91 //-------------------------------------------------------------------
92 // Part 2, section 3: Structure Tags
93 typedef UINT16  TPM_STRUCTURE_TAG;
94 #define TPM_TAG_CONTEXTBLOB            ((UINT16)0x0001)
95 #define TPM_TAG_CONTEXT_SENSITIVE      ((UINT16)0x0002)
96 #define TPM_TAG_CONTEXTPOINTER         ((UINT16)0x0003)
97 #define TPM_TAG_CONTEXTLIST            ((UINT16)0x0004)
98 #define TPM_TAG_SIGNINFO               ((UINT16)0x0005)
99 #define TPM_TAG_PCR_INFO_LONG          ((UINT16)0x0006)
100 #define TPM_TAG_PERSISTENT_FLAGS       ((UINT16)0x0007)
101 #define TPM_TAG_VOLATILE_FLAGS         ((UINT16)0x0008)
102 #define TPM_TAG_PERSISTENT_DATA        ((UINT16)0x0009)
103 #define TPM_TAG_VOLATILE_DATA          ((UINT16)0x000a)
104 #define TPM_TAG_SV_DATA                ((UINT16)0x000b)
105 #define TPM_TAG_EK_BLOB                ((UINT16)0x000c)
106 #define TPM_TAG_EK_BLOB_AUTH           ((UINT16)0x000d)
107 #define TPM_TAG_COUNTER_VALUE          ((UINT16)0x000e)
108 #define TPM_TAG_TRANSPORT_INTERNAL     ((UINT16)0x000f)
109 #define TPM_TAG_TRANSPORT_LOG_IN       ((UINT16)0x0010)
110 #define TPM_TAG_TRANSPORT_LOG_OUT      ((UINT16)0x0011)
111 #define TPM_TAG_AUDIT_EVENT_IN         ((UINT16)0x0012)
112 #define TPM_TAG_AUDIT_EVENT_OUT        ((UINT16)0x0013)
113 #define TPM_TAG_CURRENT_TICKS          ((UINT16)0x0014)
114 #define TPM_TAG_KEY                    ((UINT16)0x0015)
115 #define TPM_TAG_STORED_DATA12          ((UINT16)0x0016)
116 #define TPM_TAG_NV_ATTRIBUTES          ((UINT16)0x0017)
117 #define TPM_TAG_NV_DATA_PUBLIC         ((UINT16)0x0018)
118 #define TPM_TAG_NV_DATA_SENSITIVE      ((UINT16)0x0019)
119 #define TPM_TAG_DELEGATIONS            ((UINT16)0x001a)
120 #define TPM_TAG_DELEGATE_PUBLIC        ((UINT16)0x001b)
121 #define TPM_TAG_DELEGATE_TABLE_ROW     ((UINT16)0x001c)
122 #define TPM_TAG_TRANSPORT_AUTH         ((UINT16)0x001d)
123 #define TPM_TAG_TRANSPORT_PUBLIC       ((UINT16)0x001e)
124 #define TPM_TAG_PERMANENT_FLAGS        ((UINT16)0x001f)
125 #define TPM_TAG_STCLEAR_FLAGS          ((UINT16)0x0020)
126 #define TPM_TAG_STANY_FLAGS            ((UINT16)0x0021)
127 #define TPM_TAG_PERMANENT_DATA         ((UINT16)0x0022)
128 #define TPM_TAG_STCLEAR_DATA           ((UINT16)0x0023)
129 #define TPM_TAG_STANY_DATA             ((UINT16)0x0024)
130 #define TPM_TAG_FAMILY_TABLE_ENTRY     ((UINT16)0x0025)
131 #define TPM_TAG_DELEGATE_SENSITIVE     ((UINT16)0x0026)
132 #define TPM_TAG_DELG_KEY_BLOB          ((UINT16)0x0027)
133 #define TPM_TAG_KEY12                  ((UINT16)0x0028)
134 #define TPM_TAG_CERTIFY_INFO2          ((UINT16)0x0029)
135 #define TPM_TAG_DELEGATE_OWNER_BLOB    ((UINT16)0x002a)
136 #define TPM_TAG_EK_BLOB_ACTIVATE       ((UINT16)0x002b)
137 #define TPM_TAG_DAA_BLOB               ((UINT16)0x002c)
138 #define TPM_TAG_DAA_CONTEXT            ((UINT16)0x002d)
139 #define TPM_TAG_DAA_ENFORCE            ((UINT16)0x002e)
140 #define TPM_TAG_DAA_ISSUER             ((UINT16)0x002f)
141 #define TPM_TAG_CAP_VERSION_INFO       ((UINT16)0x0030)
142 #define TPM_TAG_DAA_SENSITIVE          ((UINT16)0x0031)
143 #define TPM_TAG_DAA_TPM                ((UINT16)0x0032)
144 #define TPM_TAG_CMK_MIGAUTH            ((UINT16)0x0033)
145 #define TPM_TAG_CMK_SIGTICKET          ((UINT16)0x0034)
146 #define TPM_TAG_CMK_MA_APPROVAL        ((UINT16)0x0035)
147 #define TPM_TAG_QUOTE_INFO2            ((UINT16)0x0036)
148 #define TPM_TAG_DA_INFO                ((UINT16)0x0037)
149 #define TPM_TAG_DA_INFO_LIMITED        ((UINT16)0x0038)
150 #define TPM_TAG_DA_ACTION_TYPE         ((UINT16)0x0039)
151 
152 
153 //-------------------------------------------------------------------
154 // Part 2, section 4: Types
155 typedef UINT32 TPM_RESOURCE_TYPE;
156 #define TPM_RT_KEY                     ((UINT32)0x00000001)
157 #define TPM_RT_AUTH                    ((UINT32)0x00000002)
158 #define TPM_RT_HASH                    ((UINT32)0x00000003)
159 #define TPM_RT_TRANS                   ((UINT32)0x00000004)
160 #define TPM_RT_CONTEXT                 ((UINT32)0x00000005)
161 #define TPM_RT_COUNTER                 ((UINT32)0x00000006)
162 #define TPM_RT_DELEGATE                ((UINT32)0x00000007)
163 #define TPM_RT_DAA_TPM                 ((UINT32)0x00000008)
164 #define TPM_RT_DAA_V0                  ((UINT32)0x00000009)
165 #define TPM_RT_DAA_V1                  ((UINT32)0x0000000a)
166 
167 
168 typedef BYTE TPM_PAYLOAD_TYPE;                              /* 1.1b */
169 #define TPM_PT_ASYM                    ((BYTE)0x01)         /* 1.1b */
170 #define TPM_PT_BIND                    ((BYTE)0x02)         /* 1.1b */
171 #define TPM_PT_MIGRATE                 ((BYTE)0x03)         /* 1.1b */
172 #define TPM_PT_MAINT                   ((BYTE)0x04)         /* 1.1b */
173 #define TPM_PT_SEAL                    ((BYTE)0x05)         /* 1.1b */
174 #define TPM_PT_MIGRATE_RESTRICTED      ((BYTE)0x06)
175 #define TPM_PT_MIGRATE_EXTERNAL        ((BYTE)0x07)
176 #define TPM_PT_CMK_MIGRATE             ((BYTE)0x08)
177 
178 
179 typedef UINT16 TPM_ENTITY_TYPE;                             /* 1.1b */
180 #define TPM_ET_KEYHANDLE               ((UINT16)0x0001)     /* 1.1b */
181 #define TPM_ET_OWNER                   ((UINT16)0x0002)     /* 1.1b */
182 #define TPM_ET_DATA                    ((UINT16)0x0003)     /* 1.1b */
183 #define TPM_ET_SRK                     ((UINT16)0x0004)     /* 1.1b */
184 #define TPM_ET_KEY                     ((UINT16)0x0005)     /* 1.1b */
185 #define TPM_ET_REVOKE                  ((UINT16)0x0006)
186 #define TPM_ET_DEL_OWNER_BLOB          ((UINT16)0x0007)
187 #define TPM_ET_DEL_ROW                 ((UINT16)0x0008)
188 #define TPM_ET_DEL_KEY_BLOB            ((UINT16)0x0009)
189 #define TPM_ET_COUNTER                 ((UINT16)0x000a)
190 #define TPM_ET_NV                      ((UINT16)0x000b)
191 #define TPM_ET_OPERATOR                ((UINT16)0x000c)
192 #define TPM_ET_RESERVED_HANDLE         ((UINT16)0x0040)
193 
194 /* The following values may be ORed into the MSB of the TPM_ENTITY_TYPE
195  * to indicate particular encryption scheme
196  */
197 #define TPM_ET_XOR                     ((BYTE)0x00)
198 #define TPM_ET_AES                     ((BYTE)0x06)
199 
200 typedef UINT32 TPM_KEY_HANDLE;                              /* 1.1b */
201 #define TPM_KH_SRK                     ((UINT32)0x40000000)
202 #define TPM_KH_OWNER                   ((UINT32)0x40000001)
203 #define TPM_KH_REVOKE                  ((UINT32)0x40000002)
204 #define TPM_KH_TRANSPORT               ((UINT32)0x40000003)
205 #define TPM_KH_OPERATOR                ((UINT32)0x40000004)
206 #define TPM_KH_ADMIN                   ((UINT32)0x40000005)
207 #define TPM_KH_EK                      ((UINT32)0x40000006)
208 /* 1.1b used different names, but the same values */
209 #define TPM_KEYHND_SRK                 (TPM_KH_SRK)        /* 1.1b */
210 #define TPM_KEYHND_OWNER               (TPM_KH_OWNER)      /* 1.1b */
211 
212 
213 typedef UINT16 TPM_STARTUP_TYPE;                            /* 1.1b */
214 #define TPM_ST_CLEAR                   ((UINT16)0x0001)     /* 1.1b */
215 #define TPM_ST_STATE                   ((UINT16)0x0002)     /* 1.1b */
216 #define TPM_ST_DEACTIVATED             ((UINT16)0x0003)     /* 1.1b */
217 
218 
219 //typedef UINT32 TPM_STARTUP_EFFECTS;
220 // 32-bit mask, see spec for meaning. Names not currently defined.
221 // bits 0-8 have meaning
222 
223 typedef UINT16 TPM_PROTOCOL_ID;                             /* 1.1b */
224 #define TPM_PID_OIAP                   ((UINT16)0x0001)     /* 1.1b */
225 #define TPM_PID_OSAP                   ((UINT16)0x0002)     /* 1.1b */
226 #define TPM_PID_ADIP                   ((UINT16)0x0003)     /* 1.1b */
227 #define TPM_PID_ADCP                   ((UINT16)0x0004)     /* 1.1b */
228 #define TPM_PID_OWNER                  ((UINT16)0x0005)     /* 1.1b */
229 #define TPM_PID_DSAP                   ((UINT16)0x0006)
230 #define TPM_PID_TRANSPORT              ((UINT16)0x0007)
231 
232 
233 // Note in 1.2 rev 104, DES and 3DES are eliminated
234 typedef UINT32 TPM_ALGORITHM_ID;                            /* 1.1b */
235 #define TPM_ALG_RSA                    ((UINT32)0x00000001) /* 1.1b */
236 #define TPM_ALG_DES                    ((UINT32)0x00000002) /* 1.1b */
237 #define TPM_ALG_3DES                   ((UINT32)0x00000003) /* 1.1b */
238 #define TPM_ALG_SHA                    ((UINT32)0x00000004) /* 1.1b */
239 #define TPM_ALG_HMAC                   ((UINT32)0x00000005) /* 1.1b */
240 #define TPM_ALG_AES                    ((UINT32)0x00000006) /* 1.1b */
241 #define TPM_ALG_AES128                 (TPM_ALG_AES)
242 #define TPM_ALG_MGF1                   ((UINT32)0x00000007)
243 #define TPM_ALG_AES192                 ((UINT32)0x00000008)
244 #define TPM_ALG_AES256                 ((UINT32)0x00000009)
245 #define TPM_ALG_XOR                    ((UINT32)0x0000000a)
246 
247 
248 typedef UINT16 TPM_PHYSICAL_PRESENCE;                        /* 1.1b */
249 #define TPM_PHYSICAL_PRESENCE_LOCK          ((UINT16)0x0004) /* 1.1b */
250 #define TPM_PHYSICAL_PRESENCE_PRESENT       ((UINT16)0x0008) /* 1.1b */
251 #define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((UINT16)0x0010) /* 1.1b */
252 #define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((UINT16)0x0020) /* 1.1b */
253 #define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((UINT16)0x0040) /* 1.1b */
254 #define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((UINT16)0x0080) /* 1.1b */
255 #define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((UINT16)0x0100)
256 #define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((UINT16)0x0200)
257 
258 
259 typedef UINT16 TPM_MIGRATE_SCHEME;                          /* 1.1b */
260 #define TPM_MS_MIGRATE                   ((UINT16)0x0001)   /* 1.1b */
261 #define TPM_MS_REWRAP                    ((UINT16)0x0002)   /* 1.1b */
262 #define TPM_MS_MAINT                     ((UINT16)0x0003)   /* 1.1b */
263 #define TPM_MS_RESTRICT_MIGRATE          ((UINT16)0x0004)
264 #define TPM_MS_RESTRICT_APPROVE_DOUBLE   ((UINT16)0x0005)
265 
266 
267 typedef UINT16 TPM_EK_TYPE;
268 #define TPM_EK_TYPE_ACTIVATE           ((UINT16)0x0001)
269 #define TPM_EK_TYPE_AUTH               ((UINT16)0x0002)
270 
271 
272 typedef UINT16 TPM_PLATFORM_SPECIFIC;
273 #define TPM_PS_PC_11                   ((UINT16)0x0001)
274 #define TPM_PS_PC_12                   ((UINT16)0x0002)
275 #define TPM_PS_PDA_12                  ((UINT16)0x0003)
276 #define TPM_PS_Server_12               ((UINT16)0x0004)
277 #define TPM_PS_Mobile_12               ((UINT16)0x0005)
278 
279 //-------------------------------------------------------------------
280 // Part 2, section 5: Basic Structures
281 
282 typedef struct tdTPM_STRUCT_VER
283 {
284     BYTE   major;
285     BYTE   minor;
286     BYTE   revMajor;
287     BYTE   revMinor;
288 } TPM_STRUCT_VER;
289 
290 typedef struct tdTPM_VERSION_BYTE
291 {
292     // This needs to be made compiler-independent.
293     int leastSigVer : 4; // least significant 4 bits
294     int mostSigVer  : 4; // most significant 4 bits
295 } TPM_VERSION_BYTE;
296 
297 typedef struct tdTPM_VERSION
298 {
299     BYTE   major;      // Should really be a TPM_VERSION_BYTE
300     BYTE   minor;      // Should really be a TPM_VERSION_BYTE
301     BYTE   revMajor;
302     BYTE   revMinor;
303 } TPM_VERSION;
304 
305 
306 // Put this in the right place:
307 // byte size definition for 160 bit SHA1 hash value
308 #define TPM_SHA1_160_HASH_LEN    0x14
309 #define TPM_SHA1BASED_NONCE_LEN  TPM_SHA1_160_HASH_LEN
310 
311 typedef struct tdTPM_DIGEST
312 {
313     BYTE  digest[TPM_SHA1_160_HASH_LEN];
314 } TPM_DIGEST;
315 
316 typedef TPM_DIGEST TPM_CHOSENID_HASH;
317 typedef TPM_DIGEST TPM_COMPOSITE_HASH;
318 typedef TPM_DIGEST TPM_DIRVALUE;
319 typedef TPM_DIGEST TPM_HMAC;
320 typedef TPM_DIGEST TPM_PCRVALUE;
321 typedef TPM_DIGEST TPM_AUDITDIGEST;
322 
323 typedef struct tdTPM_NONCE                                  /* 1.1b */
324 {
325     BYTE  nonce[TPM_SHA1BASED_NONCE_LEN];
326 } TPM_NONCE;
327 
328 typedef TPM_NONCE TPM_DAA_TPM_SEED;
329 typedef TPM_NONCE TPM_DAA_CONTEXT_SEED;
330 
331 typedef struct tdTPM_AUTHDATA                               /* 1.1b */
332 {
333     BYTE  authdata[TPM_SHA1_160_HASH_LEN];
334 } TPM_AUTHDATA;
335 
336 typedef TPM_AUTHDATA TPM_SECRET;
337 typedef TPM_AUTHDATA TPM_ENCAUTH;
338 
339 
340 typedef struct tdTPM_KEY_HANDLE_LIST                        /* 1.1b */
341 {
342     UINT16              loaded;
343     SIZEIS(loaded)
344         TPM_KEY_HANDLE *handle;
345 } TPM_KEY_HANDLE_LIST;
346 
347 
348 //-------------------------------------------------------------------
349 // Part 2, section 5.8: Key usage values
350 
351 typedef UINT16 TPM_KEY_USAGE;                               /* 1.1b */
352 #define TPM_KEY_SIGNING                ((UINT16)0x0010)     /* 1.1b */
353 #define TPM_KEY_STORAGE                ((UINT16)0x0011)     /* 1.1b */
354 #define TPM_KEY_IDENTITY               ((UINT16)0x0012)     /* 1.1b */
355 #define TPM_KEY_AUTHCHANGE             ((UINT16)0x0013)     /* 1.1b */
356 #define TPM_KEY_BIND                   ((UINT16)0x0014)     /* 1.1b */
357 #define TPM_KEY_LEGACY                 ((UINT16)0x0015)     /* 1.1b */
358 #define TPM_KEY_MIGRATE                ((UINT16)0x0016)
359 
360 typedef UINT16 TPM_SIG_SCHEME;                              /* 1.1b */
361 #define TPM_SS_NONE                    ((UINT16)0x0001)     /* 1.1b */
362 #define TPM_SS_RSASSAPKCS1v15_SHA1     ((UINT16)0x0002)     /* 1.1b */
363 #define TPM_SS_RSASSAPKCS1v15_DER      ((UINT16)0x0003)     /* 1.1b */
364 #define TPM_SS_RSASSAPKCS1v15_INFO     ((UINT16)0x0004)
365 
366 typedef UINT16 TPM_ENC_SCHEME;                              /* 1.1b */
367 #define TPM_ES_NONE                    ((UINT16)0x0001)     /* 1.1b */
368 #define TPM_ES_RSAESPKCSv15            ((UINT16)0x0002)     /* 1.1b */
369 #define TPM_ES_RSAESOAEP_SHA1_MGF1     ((UINT16)0x0003)     /* 1.1b */
370 #define TPM_ES_SYM_CNT                 ((UINT16)0x0004)
371 #define TPM_ES_SYM_CTR                 TPM_ES_SYM_CNT
372 #define TPM_ES_SYM_OFB                 ((UINT16)0x0005)
373 #define TPM_ES_SYM_CBC_PKCS5PAD        ((UINT16)0x00ff)
374 
375 //-------------------------------------------------------------------
376 // Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
377 
378 typedef BYTE TPM_AUTH_DATA_USAGE;                           /* 1.1b */
379 #define TPM_AUTH_NEVER                 ((BYTE)0x00)         /* 1.1b */
380 #define TPM_AUTH_ALWAYS                ((BYTE)0x01)         /* 1.1b */
381 #define TPM_AUTH_PRIV_USE_ONLY         ((BYTE)0x11)
382 
383 
384 //-------------------------------------------------------------------
385 // Part 2, section 5.10: TPM_KEY_FLAGS flags
386 
387 typedef UINT32 TPM_KEY_FLAGS;                               /* 1.1b */
388 #define TPM_REDIRECTION                ((UINT32)0x00000001) /* 1.1b */
389 #define TPM_MIGRATABLE                 ((UINT32)0x00000002) /* 1.1b */
390 #define TPM_VOLATILE                   ((UINT32)0x00000004) /* 1.1b */
391 #define TPM_PCRIGNOREDONREAD           ((UINT32)0x00000008)
392 #define TPM_MIGRATEAUTHORITY           ((UINT32)0x00000010)
393 
394 
395 //-------------------------------------------------------------------
396 // Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
397 
398 typedef struct tdTPM_CHANGEAUTH_VALIDATE
399 {
400     TPM_SECRET newAuthSecret;
401     TPM_NONCE  n1;
402 } TPM_CHANGEAUTH_VALIDATE;
403 
404 //-------------------------------------------------------------------
405 // Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
406 // declared after section 10 to catch declaration of TPM_PUBKEY
407 
408 //-------------------------------------------------------------------
409 // Part 2, section 5.13: TPM_COUNTER_VALUE;
410 
411 typedef UINT32 TPM_ACTUAL_COUNT;
412 typedef struct tdTPM_COUNTER_VALUE
413 {
414     TPM_STRUCTURE_TAG tag;
415     BYTE              label[4];
416     TPM_ACTUAL_COUNT  counter;
417 } TPM_COUNTER_VALUE;
418 
419 //-------------------------------------------------------------------
420 // Part 2, section 5.14: TPM_SIGN_INFO structure
421 
422 typedef struct tdTPM_SIGN_INFO
423 {
424     TPM_STRUCTURE_TAG tag;
425     BYTE              fixed[4];
426     TPM_NONCE         replay;
427     UINT32            dataLen;
428     SIZEIS(dataLen)
429         BYTE         *data;
430 } TPM_SIGN_INFO;
431 
432 //-------------------------------------------------------------------
433 // Part 2, section 5.15: TPM_MSA_COMPOSITE
434 
435 typedef struct tdTPM_MSA_COMPOSITE
436 {
437     UINT32          MSAlist;
438     SIZEIS(MSAlist)
439         TPM_DIGEST *migAuthDigest;
440 } TPM_MSA_COMPOSITE;
441 
442 //-------------------------------------------------------------------
443 // Part 2, section 5.16: TPM_CMK_AUTH
444 
445 typedef struct tdTPM_CMK_AUTH
446 {
447     TPM_DIGEST migrationAuthorityDigest;
448     TPM_DIGEST destinationKeyDigest;
449     TPM_DIGEST sourceKeyDigest;
450 } TPM_CMK_AUTH;
451 
452 //-------------------------------------------------------------------
453 // Part 2, section 5.17: TPM_CMK_DELEGATE
454 
455 typedef UINT32 TPM_CMK_DELEGATE;
456 #define TPM_CMK_DELEGATE_SIGNING       (((UINT32)1)<<31)
457 #define TPM_CMK_DELEGATE_STORAGE       (((UINT32)1)<<30)
458 #define TPM_CMK_DELEGATE_BIND          (((UINT32)1)<<29)
459 #define TPM_CMK_DELEGATE_LEGACY        (((UINT32)1)<<28)
460 #define TPM_CMK_DELEGATE_MIGRATE       (((UINT32)1)<<27)
461 
462 //-------------------------------------------------------------------
463 // Part 2, section 5.18: TPM_SELECT_SIZE
464 
465 typedef struct tdTPM_SELECT_SIZE
466 {
467     BYTE   major;
468     BYTE   minor;
469     UINT16 reqSize;
470 } TPM_SELECT_SIZE;
471 
472 //-------------------------------------------------------------------
473 // Part 2, section 5.19: TPM_CMK_MIGAUTH
474 
475 typedef struct tdTPM_CMK_MIGAUTH
476 {
477     TPM_STRUCTURE_TAG tag;
478     TPM_DIGEST        msaDigest;
479     TPM_DIGEST        pubKeyDigest;
480 } TPM_CMK_MIGAUTH;
481 
482 //-------------------------------------------------------------------
483 // Part 2, section 5.20: TPM_CMK_SIGTICKET
484 
485 typedef struct tdTPM_CMK_SIGTICKET
486 {
487     TPM_STRUCTURE_TAG tag;
488     TPM_DIGEST        verKeyDigest;
489     TPM_DIGEST        signedData;
490 } TPM_CMK_SIGTICKET;
491 
492 //-------------------------------------------------------------------
493 // Part 2, section 5.21: TPM_CMK_MA_APPROVAL
494 
495 typedef struct tdTPM_CMK_MA_APPROVAL
496 {
497     TPM_STRUCTURE_TAG tag;
498     TPM_DIGEST        migrationAuthorityDigest;
499 } TPM_CMK_MA_APPROVAL;
500 
501 
502 //-------------------------------------------------------------------
503 // Part 2, section 6: Command Tags
504 
505 typedef UINT16 TPM_TAG;                                     /* 1.1b */
506 #define TPM_TAG_RQU_COMMAND            ((UINT16)0x00c1)
507 #define TPM_TAG_RQU_AUTH1_COMMAND      ((UINT16)0x00c2)
508 #define TPM_TAG_RQU_AUTH2_COMMAND      ((UINT16)0x00c3)
509 #define TPM_TAG_RSP_COMMAND            ((UINT16)0x00c4)
510 #define TPM_TAG_RSP_AUTH1_COMMAND      ((UINT16)0x00c5)
511 #define TPM_TAG_RSP_AUTH2_COMMAND      ((UINT16)0x00c6)
512 
513 
514 //-------------------------------------------------------------------
515 // Part 2, section 7.1: TPM_PERMANENT_FLAGS
516 
517 typedef struct tdTPM_PERMANENT_FLAGS
518 {
519     TPM_STRUCTURE_TAG tag;
520     TSS_BOOL disable;
521     TSS_BOOL ownership;
522     TSS_BOOL deactivated;
523     TSS_BOOL readPubek;
524     TSS_BOOL disableOwnerClear;
525     TSS_BOOL allowMaintenance;
526     TSS_BOOL physicalPresenceLifetimeLock;
527     TSS_BOOL physicalPresenceHWEnable;
528     TSS_BOOL physicalPresenceCMDEnable;
529     TSS_BOOL CEKPUsed;
530     TSS_BOOL TPMpost;
531     TSS_BOOL TPMpostLock;
532     TSS_BOOL FIPS;
533     TSS_BOOL Operator;
534     TSS_BOOL enableRevokeEK;
535     TSS_BOOL nvLocked;
536     TSS_BOOL readSRKPub;
537     TSS_BOOL tpmEstablished;
538     TSS_BOOL maintenanceDone;
539     TSS_BOOL disableFullDALogicInfo;
540 } TPM_PERMANENT_FLAGS;
541 
542 #define TPM_PF_DISABLE                      ((UINT32)0x00000001)
543 #define TPM_PF_OWNERSHIP                    ((UINT32)0x00000002)
544 #define TPM_PF_DEACTIVATED                  ((UINT32)0x00000003)
545 #define TPM_PF_READPUBEK                    ((UINT32)0x00000004)
546 #define TPM_PF_DISABLEOWNERCLEAR            ((UINT32)0x00000005)
547 #define TPM_PF_ALLOWMAINTENANCE             ((UINT32)0x00000006)
548 #define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((UINT32)0x00000007)
549 #define TPM_PF_PHYSICALPRESENCEHWENABLE     ((UINT32)0x00000008)
550 #define TPM_PF_PHYSICALPRESENCECMDENABLE    ((UINT32)0x00000009)
551 #define TPM_PF_CEKPUSED                     ((UINT32)0x0000000A)
552 #define TPM_PF_TPMPOST                      ((UINT32)0x0000000B)
553 #define TPM_PF_TPMPOSTLOCK                  ((UINT32)0x0000000C)
554 #define TPM_PF_FIPS                         ((UINT32)0x0000000D)
555 #define TPM_PF_OPERATOR                     ((UINT32)0x0000000E)
556 #define TPM_PF_ENABLEREVOKEEK               ((UINT32)0x0000000F)
557 #define TPM_PF_NV_LOCKED                    ((UINT32)0x00000010)
558 #define TPM_PF_READSRKPUB                   ((UINT32)0x00000011)
559 #define TPM_PF_RESETESTABLISHMENTBIT        ((UINT32)0x00000012)
560 #define TPM_PF_MAINTENANCEDONE              ((UINT32)0x00000013)
561 #define TPM_PF_DISABLEFULLDALOGICINFO       ((UINT32)0x00000014)
562 
563 
564 //-------------------------------------------------------------------
565 // Part 2, section 7.2: TPM_STCLEAR_FLAGS
566 
567 typedef struct tdTPM_STCLEAR_FLAGS
568 {
569     TPM_STRUCTURE_TAG tag;
570     TSS_BOOL          deactivated;
571     TSS_BOOL          disableForceClear;
572     TSS_BOOL          physicalPresence;
573     TSS_BOOL          physicalPresenceLock;
574     TSS_BOOL          bGlobalLock;
575 } TPM_STCLEAR_FLAGS;
576 
577 #define TPM_SF_DEACTIVATED             ((UINT32)0x00000001)
578 #define TPM_SF_DISABLEFORCECLEAR       ((UINT32)0x00000002)
579 #define TPM_SF_PHYSICALPRESENCE        ((UINT32)0x00000003)
580 #define TPM_SF_PHYSICALPRESENCELOCK    ((UINT32)0x00000004)
581 #define TPM_SF_GLOBALLOCK              ((UINT32)0x00000005)
582 
583 
584 //-------------------------------------------------------------------
585 // Part 2, section 7.3: TPM_STANY_FLAGS
586 
587 typedef struct tdTPM_STANY_FLAGS
588 {
589     TPM_STRUCTURE_TAG      tag;
590     TSS_BOOL               postInitialise;
591     TPM_MODIFIER_INDICATOR localityModifier;
592     TSS_BOOL               transportExclusive;
593     TSS_BOOL               TOSPresent;
594 } TPM_STANY_FLAGS;
595 
596 #define TPM_AF_POSTINITIALIZE          ((UINT32)0x00000001)
597 #define TPM_AF_LOCALITYMODIFIER        ((UINT32)0x00000002)
598 #define TPM_AF_TRANSPORTEXCLUSIVE      ((UINT32)0x00000003)
599 #define TPM_AF_TOSPRESENT              ((UINT32)0x00000004)
600 
601 
602 //-------------------------------------------------------------------
603 // Part 2, section 7.4: TPM_PERMANENT_DATA
604 // available inside TPM only
605 //
606 //#define TPM_MIN_COUNTERS          4
607 //#define TPM_NUM_PCR              16
608 //#define TPM_MAX_NV_WRITE_NOOWNER 64
609 //
610 //typedef struct tdTPM_PERMANENT_DATA
611 //{
612 //    TPM_STRUCTURE_TAG  tag;
613 //    BYTE               revMajor;
614 //    BYTE               revMinor;
615 //    TPM_NONCE          tpmProof;
616 //    TPM_NONCE          ekReset;
617 //    TPM_SECRET         ownerAuth;
618 //    TPM_SECRET         operatorAuth;
619 //    TPM_DIRVALUE       authDIR[1];
620 //    TPM_PUBKEY         manuMaintPub;
621 //    TPM_KEY            endorsementKey;
622 //    TPM_KEY            srk;
623 //    TPM_KEY            contextKey;
624 //    TPM_KEY            delegateKey;
625 //    TPM_COUNTER_VALUE  auditMonotonicCounter;
626 //    TPM_COUNTER_VALUE  monitonicCounter[TPM_MIN_COUNTERS];
627 //    TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR];
628 //    BYTE               ordinalAuditStatus[];
629 //    BYTE              *rngState;
630 //    TPM_FAMILY_TABLE   familyTable;
631 //    TPM_DELEGATE_TABLE delegateTable;
632 //    UINT32             maxNVBufSize;
633 //    UINT32             lastFamilyID;
634 //    UINT32             noOwnerNVWrite;
635 //    TPM_CMK_DELEGATE   restrictDelegate;
636 //    TPM_DAA_TPM_SEED   tpmDAASeed;
637 //    TPM_NONCE          daaProof;
638 //    TPM_NONCE          daaBlobKey;
639 //} TPM_PERMANENT_DATA;
640 
641 
642 //-------------------------------------------------------------------
643 // Part 2, section 7.5: TPM_STCLEAR_DATA
644 // available inside TPM only
645 //
646 //typedef struct tdTPM_STCLEAR_DATA
647 //{
648 //    TPM_STRUCTURE_TAG tag;
649 //    TPM_NONCE         contextNonceKey;
650 //    TPM_COUNT_ID      countID;
651 //    UINT32            ownerReference;
652 //    TPM_BOOL          disableResetLock;
653 //    TPM_PCRVALUE      PCR[TPM_NUM_PCR];
654 //    UINT32            deferredPhysicalPresence;
655 //} TPM_STCLEAR_DATA;
656 
657 
658 
659 //-------------------------------------------------------------------
660 // Part 2, section 7.5: TPM_STANY_DATA
661 // available inside TPM only
662 //
663 //typedef struct tdTPM_STANY_DATA
664 //{
665 //    TPM_STRUCTURE_TAG tag;
666 //    TPM_NONCE         contextNonceSession;
667 //    TPM_DIGEST        auditDigest;
668 //    TPM_CURRENT_TICKS currentTicks;
669 //    UINT32            contextCount;
670 //    UINT32            contextList[TPM_MIN_SESSION_LIST];
671 //    TPM_SESSION_DATA  sessions[TPM_MIN_SESSIONS];
672 //    // The following appear in section 22.6 but not in 7.5
673 //    TPM_DAA_ISSUER    DAA_issuerSettings;
674 //    TPM_DAA_TPM       DAA_tpmSpecific;
675 //    TPM_DAA_CONTEXT   DAA_session;
676 //    TPM_DAA_JOINDATA  DAA_joinSession;
677 //} TPM_STANY_DATA;
678 
679 
680 
681 //-------------------------------------------------------------------
682 // Part 2, section 8: PCR Structures
683 
684 typedef BYTE  TPM_LOCALITY_SELECTION;
685 #define TPM_LOC_FOUR                   (((UINT32)1)<<4)
686 #define TPM_LOC_THREE                  (((UINT32)1)<<3)
687 #define TPM_LOC_TWO                    (((UINT32)1)<<2)
688 #define TPM_LOC_ONE                    (((UINT32)1)<<1)
689 #define TPM_LOC_ZERO                   (((UINT32)1)<<0)
690 
691 typedef struct tdTPM_PCR_SELECTION                          /* 1.1b */
692 {
693     UINT16    sizeOfSelect;
694     SIZEIS(sizeOfSelect)
695         BYTE *pcrSelect;
696 } TPM_PCR_SELECTION;
697 
698 typedef struct tdTPM_PCR_COMPOSITE                          /* 1.1b */
699 {
700     TPM_PCR_SELECTION select;
701     UINT32            valueSize;
702     SIZEIS(valueSize)
703         TPM_PCRVALUE *pcrValue;
704 } TPM_PCR_COMPOSITE;
705 
706 typedef struct tdTPM_PCR_INFO                               /* 1.1b */
707 {
708     TPM_PCR_SELECTION  pcrSelection;
709     TPM_COMPOSITE_HASH digestAtRelease;
710     TPM_COMPOSITE_HASH digestAtCreation;
711 }  TPM_PCR_INFO;
712 
713 typedef struct tdTPM_PCR_INFO_LONG
714 {
715     TPM_STRUCTURE_TAG      tag;
716     TPM_LOCALITY_SELECTION localityAtCreation;
717     TPM_LOCALITY_SELECTION localityAtRelease;
718     TPM_PCR_SELECTION      creationPCRSelection;
719     TPM_PCR_SELECTION      releasePCRSelection;
720     TPM_COMPOSITE_HASH     digestAtCreation;
721     TPM_COMPOSITE_HASH     digestAtRelease;
722 }  TPM_PCR_INFO_LONG;
723 
724 typedef struct tdTPM_PCR_INFO_SHORT
725 {
726     TPM_PCR_SELECTION      pcrSelection;
727     TPM_LOCALITY_SELECTION localityAtRelease;
728     TPM_COMPOSITE_HASH     digestAtRelease;
729 }  TPM_PCR_INFO_SHORT;
730 
731 typedef struct tdTPM_PCR_ATTRIBUTES
732 {
733     BYTE                   pcrReset;
734     TPM_LOCALITY_SELECTION pcrExtendLocal;
735     TPM_LOCALITY_SELECTION pcrResetLocal;
736 } TPM_PCR_ATTRIBUTES;
737 
738 
739 
740 //-------------------------------------------------------------------
741 // Part 2, section 9:
742 
743 typedef struct tdTPM_STORED_DATA                            /* 1.1b */
744 {
745     TPM_STRUCT_VER ver;
746     UINT32         sealInfoSize;
747     SIZEIS(sealInfoSize)
748         BYTE      *sealInfo;
749     UINT32         encDataSize;
750     SIZEIS(encDataSize)
751         BYTE      *encData;
752 } TPM_STORED_DATA;
753 
754 typedef struct tdTPM_STORED_DATA12
755 {
756     TPM_STRUCTURE_TAG tag;
757     TPM_ENTITY_TYPE   et;
758     UINT32            sealInfoSize;
759     SIZEIS(sealInfoSize)
760         BYTE         *sealInfo;
761     UINT32            encDataSize;
762     SIZEIS(encDataSize)
763         BYTE         *encData;
764 } TPM_STORED_DATA12;
765 
766 typedef struct tdTPM_SEALED_DATA                            /* 1.1b */
767 {
768     TPM_PAYLOAD_TYPE  payload;
769     TPM_SECRET        authData;
770     TPM_NONCE         tpmProof;
771     TPM_DIGEST        storedDigest;
772     UINT32            dataSize;
773     SIZEIS(dataSize)
774         BYTE         *data;
775 } TPM_SEALED_DATA;
776 
777 typedef struct tdTPM_SYMMETRIC_KEY                          /* 1.1b */
778 {
779     TPM_ALGORITHM_ID  algId;
780     TPM_ENC_SCHEME    encScheme;
781     UINT16            size;
782     SIZEIS(size)
783         BYTE         *data;
784 } TPM_SYMMETRIC_KEY;
785 
786 typedef struct tdTPM_BOUND_DATA
787 {
788     TPM_STRUCT_VER   ver;
789     TPM_PAYLOAD_TYPE payload;
790     BYTE            *payloadData; // length is implied
791 } TPM_BOUND_DATA;
792 
793 
794 //-------------------------------------------------------------------
795 // Part 2, section 10: TPM_KEY complex
796 
797 typedef struct tdTPM_KEY_PARMS                              /* 1.1b */
798 {
799     TPM_ALGORITHM_ID  algorithmID;
800     TPM_ENC_SCHEME    encScheme;
801     TPM_SIG_SCHEME    sigScheme;
802     UINT32            parmSize;
803     SIZEIS(parmSize)
804         BYTE         *parms;
805 } TPM_KEY_PARMS;
806 
807 typedef struct tdTPM_RSA_KEY_PARMS                          /* 1.1b */
808 {
809     UINT32    keyLength;
810     UINT32    numPrimes;
811     UINT32    exponentSize;
812     SIZEIS(exponentSize)
813         BYTE *exponent;
814 } TPM_RSA_KEY_PARMS;
815 
816 typedef struct tdTPM_SYMMETRIC_KEY_PARMS
817 {
818     UINT32 keyLength;
819     UINT32 blockSize;
820     UINT32 ivSize;
821     SIZEIS(ivSize)
822         BYTE *IV;
823 } TPM_SYMMETRIC_KEY_PARMS;
824 
825 typedef struct tdTPM_STORE_PUBKEY                           /* 1.1b */
826 {
827     UINT32    keyLength;
828     SIZEIS(keyLength)
829         BYTE *key;
830 } TPM_STORE_PUBKEY;
831 
832 typedef struct tdTPM_PUBKEY                                 /* 1.1b */
833 {
834     TPM_KEY_PARMS     algorithmParms;
835     TPM_STORE_PUBKEY  pubKey;
836 } TPM_PUBKEY;
837 
838 typedef struct tdTPM_STORE_PRIVKEY                          /* 1.1b */
839 {
840     UINT32    keyLength;
841     SIZEIS(keyLength)
842         BYTE *key;
843 } TPM_STORE_PRIVKEY;
844 
845 typedef struct tdTPM_STORE_ASYMKEY                          /* 1.1b */
846 {
847     TPM_PAYLOAD_TYPE  payload;
848     TPM_SECRET        usageAuth;
849     TPM_SECRET        migrationAuth;
850     TPM_DIGEST        pubDataDigest;
851     TPM_STORE_PRIVKEY privKey;
852 } TPM_STORE_ASYMKEY;
853 
854 typedef struct tdTPM_KEY                                    /* 1.1b */
855 {
856     TPM_STRUCT_VER      ver;
857     TPM_KEY_USAGE       keyUsage;
858     TPM_KEY_FLAGS       keyFlags;
859     TPM_AUTH_DATA_USAGE authDataUsage;
860     TPM_KEY_PARMS       algorithmParms;
861     UINT32              PCRInfoSize;
862     SIZEIS(PCRInfoSize)
863         BYTE           *PCRInfo;
864     TPM_STORE_PUBKEY    pubKey;
865     UINT32              encSize;
866     SIZEIS(encSize)
867         BYTE           *encData;
868 } TPM_KEY;
869 
870 typedef struct tdTPM_KEY12
871 {
872     TPM_STRUCTURE_TAG   tag;
873     UINT16              fill;
874     TPM_KEY_USAGE       keyUsage;
875     TPM_KEY_FLAGS       keyFlags;
876     TPM_AUTH_DATA_USAGE authDataUsage;
877     TPM_KEY_PARMS       algorithmParms;
878     UINT32              PCRInfoSize;
879     SIZEIS(PCRInfoSize)
880        BYTE            *PCRInfo;
881     TPM_STORE_PUBKEY    pubKey;
882     UINT32              encSize;
883     SIZEIS(encSize)
884        BYTE            *encData;
885 } TPM_KEY12;
886 
887 typedef struct tdTPM_MIGRATE_ASYMKEY
888 {
889     TPM_PAYLOAD_TYPE payload;
890     TPM_SECRET       usageAuth;
891     TPM_DIGEST       pubDataDigest;
892     UINT32           partPrivKeyLen;
893     SIZEIS(partPrivKeyLen)
894         BYTE        *partPrivKey;
895 } TPM_MIGRATE_ASYMKEY;
896 
897 
898 typedef UINT32 TPM_KEY_CONTROL;
899 #define TPM_KEY_CONTROL_OWNER_EVICT    ((UINT32)0x00000001)
900 
901 
902 //-------------------------------------------------------------------
903 // Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
904 
905 typedef struct tdTPM_MIGRATIONKEYAUTH                       /* 1.1b */
906 {
907     TPM_PUBKEY         migrationKey;
908     TPM_MIGRATE_SCHEME migrationScheme;
909     TPM_DIGEST         digest;
910 } TPM_MIGRATIONKEYAUTH;
911 
912 
913 //-------------------------------------------------------------------
914 // Part 2, section 11: Signed Structures
915 
916 typedef struct tdTPM_CERTIFY_INFO                           /* 1.1b */
917 {
918     TPM_STRUCT_VER      version;
919     TPM_KEY_USAGE       keyUsage;
920     TPM_KEY_FLAGS       keyFlags;
921     TPM_AUTH_DATA_USAGE authDataUsage;
922     TPM_KEY_PARMS       algorithmParms;
923     TPM_DIGEST          pubkeyDigest;
924     TPM_NONCE           data;
925     TPM_BOOL            parentPCRStatus;
926     UINT32              PCRInfoSize;
927     SIZEIS(PCRInfoSize)
928         BYTE           *PCRInfo;
929 } TPM_CERTIFY_INFO;
930 
931 typedef struct tdTPM_CERTIFY_INFO2
932 {
933     TPM_STRUCTURE_TAG   tag;
934     BYTE                fill;
935     TPM_PAYLOAD_TYPE    payloadType;
936     TPM_KEY_USAGE       keyUsage;
937     TPM_KEY_FLAGS       keyFlags;
938     TPM_AUTH_DATA_USAGE authDataUsage;
939     TPM_KEY_PARMS       algorithmParms;
940     TPM_DIGEST          pubkeyDigest;
941     TPM_NONCE           data;
942     TPM_BOOL            parentPCRStatus;
943     UINT32              PCRInfoSize;
944     SIZEIS(PCRInfoSize)
945         BYTE           *PCRInfo;
946     UINT32              migrationAuthoritySize;
947     SIZEIS(migrationAuthoritySize)
948         BYTE           *migrationAuthority;
949 } TPM_CERTIFY_INFO2;
950 
951 typedef struct tdTPM_QUOTE_INFO                             /* 1.1b */
952 {
953     TPM_STRUCT_VER     version;
954     BYTE               fixed[4];
955     TPM_COMPOSITE_HASH compositeHash; /* in 1.2 TPM spec, named digestValue */
956     TPM_NONCE          externalData;
957 } TPM_QUOTE_INFO;
958 
959 typedef struct tdTPM_QUOTE_INFO2
960 {
961     TPM_STRUCTURE_TAG  tag;
962     BYTE               fixed[4];
963     TPM_NONCE          externalData;
964     TPM_PCR_INFO_SHORT infoShort;
965 } TPM_QUOTE_INFO2;
966 
967 
968 
969 //-------------------------------------------------------------------
970 // Part 2, section 12: Identity Structures
971 
972 
973 typedef struct tdTPM_EK_BLOB
974 {
975     TPM_STRUCTURE_TAG tag;
976     TPM_EK_TYPE       ekType;
977     UINT32            blobSize;
978     SIZEIS(blobSize)
979         BYTE         *blob;
980 } TPM_EK_BLOB;
981 
982 typedef struct tdTPM_EK_BLOB_ACTIVATE
983 {
984     TPM_STRUCTURE_TAG  tag;
985     TPM_SYMMETRIC_KEY  sessionKey;
986     TPM_DIGEST         idDigest;
987     TPM_PCR_INFO_SHORT pcrInfo;
988 } TPM_EK_BLOB_ACTIVATE;
989 
990 typedef struct tdTPM_EK_BLOB_AUTH
991 {
992     TPM_STRUCTURE_TAG tag;
993     TPM_SECRET        authValue;
994 } TPM_EK_BLOB_AUTH;
995 
996 
997 typedef struct tdTPM_IDENTITY_CONTENTS
998 {
999     TPM_STRUCT_VER    ver;
1000     UINT32            ordinal;
1001     TPM_CHOSENID_HASH labelPrivCADigest;
1002     TPM_PUBKEY        identityPubKey;
1003 } TPM_IDENTITY_CONTENTS;
1004 
1005 typedef struct tdTPM_IDENTITY_REQ                           /* 1.1b */
1006 {
1007     UINT32         asymSize;
1008     UINT32         symSize;
1009     TPM_KEY_PARMS  asymAlgorithm;
1010     TPM_KEY_PARMS  symAlgorithm;
1011     SIZEIS(asymSize)
1012         BYTE      *asymBlob;
1013     SIZEIS(symSize)
1014         BYTE      *symBlob;
1015 } TPM_IDENTITY_REQ;
1016 
1017 typedef struct tdTPM_IDENTITY_PROOF                         /* 1.1b */
1018 {
1019     TPM_STRUCT_VER  ver;
1020     UINT32          labelSize;
1021     UINT32          identityBindingSize;
1022     UINT32          endorsementSize;
1023     UINT32          platformSize;
1024     UINT32          conformanceSize;
1025     TPM_PUBKEY      identityKey;
1026     SIZEIS(labelSize)
1027       BYTE         *labelArea;
1028     SIZEIS(identityBindingSize)
1029       BYTE         *identityBinding;
1030     SIZEIS(endorsementSize)
1031       BYTE         *endorsementCredential;
1032     SIZEIS(platformSize)
1033       BYTE         *platformCredential;
1034     SIZEIS(conformanceSize)
1035       BYTE         *conformanceCredential;
1036 } TPM_IDENTITY_PROOF;
1037 
1038 typedef struct tdTPM_ASYM_CA_CONTENTS                       /* 1.1b */
1039 {
1040     TPM_SYMMETRIC_KEY sessionKey;
1041     TPM_DIGEST        idDigest;
1042 } TPM_ASYM_CA_CONTENTS;
1043 
1044 typedef struct tdTPM_SYM_CA_ATTESTATION
1045 {
1046     UINT32         credSize;
1047     TPM_KEY_PARMS  algorithm;
1048     SIZEIS(credSize)
1049         BYTE      *credential;
1050 } TPM_SYM_CA_ATTESTATION;
1051 
1052 
1053 
1054 //-------------------------------------------------------------------
1055 // Part 2, section 15: Tick Structures
1056 // Placed here out of order because definitions are used in section 13.
1057 
1058 typedef struct tdTPM_CURRENT_TICKS
1059 {
1060     TPM_STRUCTURE_TAG tag;
1061     UINT64            currentTicks;
1062     UINT16            tickRate;
1063     TPM_NONCE         tickNonce;
1064 } TPM_CURRENT_TICKS;
1065 
1066 
1067 
1068 //-------------------------------------------------------------------
1069 // Part 2, section 13: Transport structures
1070 
1071 typedef UINT32 TPM_TRANSPORT_ATTRIBUTES;
1072 #define TPM_TRANSPORT_ENCRYPT          ((UINT32)0x00000001)
1073 #define TPM_TRANSPORT_LOG              ((UINT32)0x00000002)
1074 #define TPM_TRANSPORT_EXCLUSIVE        ((UINT32)0x00000004)
1075 
1076 typedef struct tdTPM_TRANSPORT_PUBLIC
1077 {
1078     TPM_STRUCTURE_TAG        tag;
1079     TPM_TRANSPORT_ATTRIBUTES transAttributes;
1080     TPM_ALGORITHM_ID         algId;
1081     TPM_ENC_SCHEME           encScheme;
1082 } TPM_TRANSPORT_PUBLIC;
1083 
1084 typedef struct tdTPM_TRANSPORT_INTERNAL
1085 {
1086     TPM_STRUCTURE_TAG    tag;
1087     TPM_AUTHDATA         authData;
1088     TPM_TRANSPORT_PUBLIC transPublic;
1089     TPM_TRANSHANDLE      transHandle;
1090     TPM_NONCE            transNonceEven;
1091     TPM_DIGEST           transDigest;
1092 } TPM_TRANSPORT_INTERNAL;
1093 
1094 typedef struct tdTPM_TRANSPORT_LOG_IN
1095 {
1096     TPM_STRUCTURE_TAG tag;
1097     TPM_DIGEST        parameters;
1098     TPM_DIGEST        pubKeyHash;
1099 } TPM_TRANSPORT_LOG_IN;
1100 
1101 typedef struct tdTPM_TRANSPORT_LOG_OUT
1102 {
1103     TPM_STRUCTURE_TAG      tag;
1104     TPM_CURRENT_TICKS      currentTicks;
1105     TPM_DIGEST             parameters;
1106     TPM_MODIFIER_INDICATOR locality;
1107 } TPM_TRANSPORT_LOG_OUT;
1108 
1109 typedef struct tdTPM_TRANSPORT_AUTH
1110 {
1111     TPM_STRUCTURE_TAG tag;
1112     TPM_AUTHDATA      authData;
1113 } TPM_TRANSPORT_AUTH;
1114 
1115 
1116 
1117 //-------------------------------------------------------------------
1118 // Part 2, section 14: Audit Structures
1119 
1120 typedef struct tdTPM_AUDIT_EVENT_IN
1121 {
1122     TPM_STRUCTURE_TAG tag;
1123     TPM_DIGEST        inputParms;
1124     TPM_COUNTER_VALUE auditCount;
1125 } TPM_AUDIT_EVENT_IN;
1126 
1127 typedef struct tdTPM_AUDIT_EVENT_OUT
1128 {
1129     TPM_STRUCTURE_TAG tag;
1130     TPM_COMMAND_CODE  ordinal;
1131     TPM_DIGEST        outputParms;
1132     TPM_COUNTER_VALUE auditCount;
1133     TPM_RESULT        returnCode;
1134 } TPM_AUDIT_EVENT_OUT;
1135 
1136 
1137 
1138 //-------------------------------------------------------------------
1139 // Part 2, section 16: Return codes
1140 
1141 #include <tss/tpm_error.h>
1142 
1143 
1144 //-------------------------------------------------------------------
1145 // Part 2, section 17: Ordinals
1146 
1147 #include <tss/tpm_ordinal.h>
1148 
1149 //-------------------------------------------------------------------
1150 // Part 2, section 18: Context structures
1151 
1152 typedef struct tdTPM_CONTEXT_BLOB
1153 {
1154     TPM_STRUCTURE_TAG  tag;
1155     TPM_RESOURCE_TYPE  resourceType;
1156     TPM_HANDLE         handle;
1157     BYTE               label[16];
1158     UINT32             contextCount;
1159     TPM_DIGEST         integrityDigest;
1160     UINT32             additionalSize;
1161     SIZEIS(additionalSize)
1162         BYTE          *additionalData;
1163     UINT32             sensitiveSize;
1164     SIZEIS(sensitiveSize)
1165         BYTE          *sensitiveData;
1166 } TPM_CONTEXT_BLOB;
1167 
1168 typedef struct tdTPM_CONTEXT_SENSITIVE
1169 {
1170     TPM_STRUCTURE_TAG tag;
1171     TPM_NONCE         contextNonce;
1172     UINT32            internalSize;
1173     SIZEIS(internalSize)
1174         BYTE         *internalData;
1175 } TPM_CONTEXT_SENSITIVE;
1176 
1177 //-------------------------------------------------------------------
1178 // Part 2, section 19: NV Structures
1179 
1180 typedef UINT32 TPM_NV_INDEX;
1181 #define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)
1182 #define TPM_NV_INDEX0                  ((UINT32)0x00000000)
1183 #define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)
1184 // The reserved index values MAY have their D bit set by the
1185 // TPM vendor to permanently reserve the index in the TPM.
1186 // e.g. the typical EK certificate would have the D bit set
1187 // so the actual address would be 1000f000
1188 #define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)
1189 #define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)
1190 #define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)
1191 #define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)
1192 // The following define ranges of reserved indices.
1193 #define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)
1194 #define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)
1195 #define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)
1196 #define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)
1197 #define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)
1198 #define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)
1199 
1200 
1201 typedef UINT32 TPM_NV_PER_ATTRIBUTES;
1202 #define TPM_NV_PER_READ_STCLEAR        (((UINT32)1)<<31)
1203 #define TPM_NV_PER_AUTHREAD            (((UINT32)1)<<18)
1204 #define TPM_NV_PER_OWNERREAD           (((UINT32)1)<<17)
1205 #define TPM_NV_PER_PPREAD              (((UINT32)1)<<16)
1206 #define TPM_NV_PER_GLOBALLOCK          (((UINT32)1)<<15)
1207 #define TPM_NV_PER_WRITE_STCLEAR       (((UINT32)1)<<14)
1208 #define TPM_NV_PER_WRITEDEFINE         (((UINT32)1)<<13)
1209 #define TPM_NV_PER_WRITEALL            (((UINT32)1)<<12)
1210 #define TPM_NV_PER_AUTHWRITE           (((UINT32)1)<<2)
1211 #define TPM_NV_PER_OWNERWRITE          (((UINT32)1)<<1)
1212 #define TPM_NV_PER_PPWRITE             (((UINT32)1)<<0)
1213 
1214 typedef struct tdTPM_NV_ATTRIBUTES
1215 {
1216     TPM_STRUCTURE_TAG     tag;
1217     TPM_NV_PER_ATTRIBUTES attributes;
1218 } TPM_NV_ATTRIBUTES;
1219 
1220 
1221 typedef struct tdTPM_NV_DATA_PUBLIC
1222 {
1223     TPM_STRUCTURE_TAG  tag;
1224     TPM_NV_INDEX       nvIndex;
1225     TPM_PCR_INFO_SHORT pcrInfoRead;
1226     TPM_PCR_INFO_SHORT pcrInfoWrite;
1227     TPM_NV_ATTRIBUTES  permission;
1228     TPM_BOOL           bReadSTClear;
1229     TPM_BOOL           bWriteSTClear;
1230     TPM_BOOL           bWriteDefine;
1231     UINT32             dataSize;
1232 } TPM_NV_DATA_PUBLIC;
1233 
1234 
1235 #if 0
1236 // Internal to TPM:
1237 typedef struct tdTPM_NV_DATA_SENSITIVE
1238 {
1239     TPM_STRUCTURE_TAG  tag;
1240     TPM_NV_DATA_PUBLIC pubInfo;
1241     TPM_AUTHDATA       authValue;
1242     SIZEIS(pubInfo.dataSize)
1243         BYTE          *data;
1244 } TPM_NV_DATA_SENSITIVE;
1245 #endif
1246 
1247 
1248 //-------------------------------------------------------------------
1249 // Part 2, section 20: Delegation
1250 
1251 //-------------------------------------------------------------------
1252 // Part 2, section 20.3: Owner Permissions Settings for per1 bits
1253 #define TPM_DELEGATE_SetOrdinalAuditStatus          (((UINT32)1)<<30)
1254 #define TPM_DELEGATE_DirWriteAuth                   (((UINT32)1)<<29)
1255 #define TPM_DELEGATE_CMK_ApproveMA                  (((UINT32)1)<<28)
1256 #define TPM_DELEGATE_NV_WriteValue                  (((UINT32)1)<<27)
1257 #define TPM_DELEGATE_CMK_CreateTicket               (((UINT32)1)<<26)
1258 #define TPM_DELEGATE_NV_ReadValue                   (((UINT32)1)<<25)
1259 #define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (((UINT32)1)<<24)
1260 #define TPM_DELEGATE_DAA_Join                       (((UINT32)1)<<23)
1261 #define TPM_DELEGATE_AuthorizeMigrationKey          (((UINT32)1)<<22)
1262 #define TPM_DELEGATE_CreateMaintenanceArchive       (((UINT32)1)<<21)
1263 #define TPM_DELEGATE_LoadMaintenanceArchive         (((UINT32)1)<<20)
1264 #define TPM_DELEGATE_KillMaintenanceFeature         (((UINT32)1)<<19)
1265 #define TPM_DELEGATE_OwnerReadInternalPub           (((UINT32)1)<<18)
1266 #define TPM_DELEGATE_ResetLockValue                 (((UINT32)1)<<17)
1267 #define TPM_DELEGATE_OwnerClear                     (((UINT32)1)<<16)
1268 #define TPM_DELEGATE_DisableOwnerClear              (((UINT32)1)<<15)
1269 #define TPM_DELEGATE_NV_DefineSpace                 (((UINT32)1)<<14)
1270 #define TPM_DELEGATE_OwnerSetDisable                (((UINT32)1)<<13)
1271 #define TPM_DELEGATE_SetCapability                  (((UINT32)1)<<12)
1272 #define TPM_DELEGATE_MakeIdentity                   (((UINT32)1)<<11)
1273 #define TPM_DELEGATE_ActivateIdentity               (((UINT32)1)<<10)
1274 #define TPM_DELEGATE_OwnerReadPubek                 (((UINT32)1)<<9)
1275 #define TPM_DELEGATE_DisablePubekRead               (((UINT32)1)<<8)
1276 #define TPM_DELEGATE_SetRedirection                 (((UINT32)1)<<7)
1277 #define TPM_DELEGATE_FieldUpgrade                   (((UINT32)1)<<6)
1278 #define TPM_DELEGATE_Delegate_UpdateVerification    (((UINT32)1)<<5)
1279 #define TPM_DELEGATE_CreateCounter                  (((UINT32)1)<<4)
1280 #define TPM_DELEGATE_ReleaseCounterOwner            (((UINT32)1)<<3)
1281 #define TPM_DELEGATE_DelegateManage                 (((UINT32)1)<<2)
1282 #define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1)
1283 #define TPM_DELEGATE_DAA_Sign                       (((UINT32)1)<<0)
1284 
1285 //-------------------------------------------------------------------
1286 // Part 2, section 20.3: Key Permissions Settings for per1 bits
1287 #define TPM_KEY_DELEGATE_CMK_ConvertMigration       (((UINT32)1)<<28)
1288 #define TPM_KEY_DELEGATE_TickStampBlob              (((UINT32)1)<<27)
1289 #define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (((UINT32)1)<<26)
1290 #define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (((UINT32)1)<<25)
1291 #define TPM_KEY_DELEGATE_CMK_CreateKey              (((UINT32)1)<<24)
1292 #define TPM_KEY_DELEGATE_MigrateKey                 (((UINT32)1)<<23)
1293 #define TPM_KEY_DELEGATE_LoadKey2                   (((UINT32)1)<<22)
1294 #define TPM_KEY_DELEGATE_EstablishTransport         (((UINT32)1)<<21)
1295 #define TPM_KEY_DELEGATE_ReleaseTransportSigned     (((UINT32)1)<<20)
1296 #define TPM_KEY_DELEGATE_Quote2                     (((UINT32)1)<<19)
1297 #define TPM_KEY_DELEGATE_Sealx                      (((UINT32)1)<<18)
1298 #define TPM_KEY_DELEGATE_MakeIdentity               (((UINT32)1)<<17)
1299 #define TPM_KEY_DELEGATE_ActivateIdentity           (((UINT32)1)<<16)
1300 #define TPM_KEY_DELEGATE_GetAuditDigestSigned       (((UINT32)1)<<15)
1301 #define TPM_KEY_DELEGATE_Sign                       (((UINT32)1)<<14)
1302 #define TPM_KEY_DELEGATE_CertifyKey2                (((UINT32)1)<<13)
1303 #define TPM_KEY_DELEGATE_CertifyKey                 (((UINT32)1)<<12)
1304 #define TPM_KEY_DELEGATE_CreateWrapKey              (((UINT32)1)<<11)
1305 #define TPM_KEY_DELEGATE_CMK_CreateBlob             (((UINT32)1)<<10)
1306 #define TPM_KEY_DELEGATE_CreateMigrationBlob        (((UINT32)1)<<9)
1307 #define TPM_KEY_DELEGATE_ConvertMigrationBlob       (((UINT32)1)<<8)
1308 #define TPM_KEY_DELEGATE_CreateKeyDelegation        (((UINT32)1)<<7)
1309 #define TPM_KEY_DELEGATE_ChangeAuth                 (((UINT32)1)<<6)
1310 #define TPM_KEY_DELEGATE_GetPubKey                  (((UINT32)1)<<5)
1311 #define TPM_KEY_DELEGATE_UnBind                     (((UINT32)1)<<4)
1312 #define TPM_KEY_DELEGATE_Quote                      (((UINT32)1)<<3)
1313 #define TPM_KEY_DELEGATE_Unseal                     (((UINT32)1)<<2)
1314 #define TPM_KEY_DELEGATE_Seal                       (((UINT32)1)<<1)
1315 #define TPM_KEY_DELEGATE_LoadKey                    (((UINT32)1)<<0)
1316 
1317 typedef UINT32 TPM_FAMILY_VERIFICATION;
1318 
1319 typedef UINT32 TPM_FAMILY_ID;
1320 
1321 typedef UINT32 TPM_DELEGATE_INDEX;
1322 
1323 typedef UINT32 TPM_FAMILY_OPERATION;
1324 #define TPM_FAMILY_CREATE              ((UINT32)0x00000001)
1325 #define TPM_FAMILY_ENABLE              ((UINT32)0x00000002)
1326 #define TPM_FAMILY_ADMIN               ((UINT32)0x00000003)
1327 #define TPM_FAMILY_INVALIDATE          ((UINT32)0x00000004)
1328 
1329 typedef UINT32 TPM_FAMILY_FLAGS;
1330 #define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK   (((UINT32)1)<<1)
1331 #define TPM_FAMFLAG_ENABLE                (((UINT32)1)<<0)
1332 
1333 typedef struct tdTPM_FAMILY_LABEL
1334 {
1335     BYTE label;
1336 } TPM_FAMILY_LABEL;
1337 
1338 typedef struct tdTPM_FAMILY_TABLE_ENTRY
1339 {
1340     TPM_STRUCTURE_TAG       tag;
1341     TPM_FAMILY_LABEL        label;
1342     TPM_FAMILY_ID           familyID;
1343     TPM_FAMILY_VERIFICATION verificationCount;
1344     TPM_FAMILY_FLAGS        flags;
1345 } TPM_FAMILY_TABLE_ENTRY;
1346 
1347 
1348 #define TPM_FAMILY_TABLE_ENTRY_MIN 8
1349 //typedef struct tdTPM_FAMILY_TABLE
1350 //{
1351 //    TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
1352 //} TPM_FAMILY_TABLE;
1353 
1354 
1355 typedef struct tdTPM_DELEGATE_LABEL
1356 {
1357     BYTE label;
1358 } TPM_DELEGATE_LABEL;
1359 
1360 
1361 typedef UINT32 TPM_DELEGATE_TYPE;
1362 #define TPM_DEL_OWNER_BITS             ((UINT32)0x00000001)
1363 #define TPM_DEL_KEY_BITS               ((UINT32)0x00000002)
1364 
1365 typedef struct tdTPM_DELEGATIONS
1366 {
1367     TPM_STRUCTURE_TAG tag;
1368     TPM_DELEGATE_TYPE delegateType;
1369     UINT32            per1;
1370     UINT32            per2;
1371 } TPM_DELEGATIONS;
1372 
1373 typedef struct tdTPM_DELEGATE_PUBLIC
1374 {
1375     TPM_STRUCTURE_TAG       tag;
1376     TPM_DELEGATE_LABEL      label;
1377     TPM_PCR_INFO_SHORT      pcrInfo;
1378     TPM_DELEGATIONS         permissions;
1379     TPM_FAMILY_ID           familyID;
1380     TPM_FAMILY_VERIFICATION verificationCount;
1381 } TPM_DELEGATE_PUBLIC;
1382 
1383 typedef struct tdTPM_DELEGATE_TABLE_ROW
1384 {
1385     TPM_STRUCTURE_TAG   tag;
1386     TPM_DELEGATE_PUBLIC pub;
1387     TPM_SECRET          authValue;
1388 } TPM_DELEGATE_TABLE_ROW;
1389 
1390 
1391 #define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
1392 //typedef struct tdTPM_DELEGATE_TABLE
1393 //{
1394 //    TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
1395 //} TPM_DELEGATE_TABLE;
1396 
1397 typedef struct tdTPM_DELEGATE_SENSITIVE
1398 {
1399     TPM_STRUCTURE_TAG tag;
1400     TPM_SECRET        authValue;
1401 } TPM_DELEGATE_SENSITIVE;
1402 
1403 typedef struct tdTPM_DELEGATE_OWNER_BLOB
1404 {
1405     TPM_STRUCTURE_TAG   tag;
1406     TPM_DELEGATE_PUBLIC pub;
1407     TPM_DIGEST          integrityDigest;
1408     UINT32              additionalSize;
1409     SIZEIS(additionalSize)
1410         BYTE           *additionalArea;
1411     UINT32              sensitiveSize;
1412     SIZEIS(sensitiveSize)
1413         BYTE           *sensitiveArea;
1414 } TPM_DELEGATE_OWNER_BLOB;
1415 
1416 typedef struct tdTPM_DELEGATE_KEY_BLOB
1417 {
1418     TPM_STRUCTURE_TAG   tag;
1419     TPM_DELEGATE_PUBLIC pub;
1420     TPM_DIGEST          integrityDigest;
1421     TPM_DIGEST          pubKeyDigest;
1422     UINT32              additionalSize;
1423     SIZEIS(additionalSize)
1424         BYTE           *additionalArea;
1425     UINT32              sensitiveSize;
1426     SIZEIS(sensitiveSize)
1427         BYTE           *sensitiveArea;
1428 } TPM_DELEGATE_KEY_BLOB;
1429 
1430 
1431 //-------------------------------------------------------------------
1432 // Part 2, section 21.1: TPM_CAPABILITY_AREA
1433 
1434 typedef UINT32 TPM_CAPABILITY_AREA;                         /* 1.1b */
1435 #define TPM_CAP_ORD                    ((UINT32)0x00000001) /* 1.1b */
1436 #define TPM_CAP_ALG                    ((UINT32)0x00000002) /* 1.1b */
1437 #define TPM_CAP_PID                    ((UINT32)0x00000003) /* 1.1b */
1438 #define TPM_CAP_FLAG                   ((UINT32)0x00000004) /* 1.1b */
1439 #define TPM_CAP_PROPERTY               ((UINT32)0x00000005) /* 1.1b */
1440 #define TPM_CAP_VERSION                ((UINT32)0x00000006) /* 1.1b */
1441 #define TPM_CAP_KEY_HANDLE             ((UINT32)0x00000007) /* 1.1b */
1442 #define TPM_CAP_CHECK_LOADED           ((UINT32)0x00000008) /* 1.1b */
1443 #define TPM_CAP_SYM_MODE               ((UINT32)0x00000009)
1444 #define TPM_CAP_KEY_STATUS             ((UINT32)0x0000000C)
1445 #define TPM_CAP_NV_LIST                ((UINT32)0x0000000D)
1446 #define TPM_CAP_MFR                    ((UINT32)0x00000010)
1447 #define TPM_CAP_NV_INDEX               ((UINT32)0x00000011)
1448 #define TPM_CAP_TRANS_ALG              ((UINT32)0x00000012)
1449 #define TPM_CAP_HANDLE                 ((UINT32)0x00000014)
1450 #define TPM_CAP_TRANS_ES               ((UINT32)0x00000015)
1451 #define TPM_CAP_AUTH_ENCRYPT           ((UINT32)0x00000017)
1452 #define TPM_CAP_SELECT_SIZE            ((UINT32)0x00000018)
1453 #define TPM_CAP_DA_LOGIC               ((UINT32)0x00000019)
1454 #define TPM_CAP_VERSION_VAL            ((UINT32)0x0000001A)
1455 
1456 // Part 2, section 21.1: Subcap values for CAP_FLAG
1457 #define TPM_CAP_FLAG_PERMANENT         ((UINT32)0x00000108)
1458 #define TPM_CAP_FLAG_VOLATILE          ((UINT32)0x00000109)
1459 
1460 //-------------------------------------------------------------------
1461 // Part 2, section 21.2: Subcap values for CAP_PROPERTY
1462 
1463 #define TPM_CAP_PROP_PCR               ((UINT32)0x00000101) /* 1.1b */
1464 #define TPM_CAP_PROP_DIR               ((UINT32)0x00000102) /* 1.1b */
1465 #define TPM_CAP_PROP_MANUFACTURER      ((UINT32)0x00000103) /* 1.1b */
1466 #define TPM_CAP_PROP_KEYS              ((UINT32)0x00000104)
1467 #define TPM_CAP_PROP_SLOTS             (TPM_CAP_PROP_KEYS)
1468 #define TPM_CAP_PROP_MIN_COUNTER       ((UINT32)0x00000107)
1469 #define TPM_CAP_PROP_AUTHSESS          ((UINT32)0x0000010A)
1470 #define TPM_CAP_PROP_TRANSSESS         ((UINT32)0x0000010B)
1471 #define TPM_CAP_PROP_COUNTERS          ((UINT32)0x0000010C)
1472 #define TPM_CAP_PROP_MAX_AUTHSESS      ((UINT32)0x0000010D)
1473 #define TPM_CAP_PROP_MAX_TRANSSESS     ((UINT32)0x0000010E)
1474 #define TPM_CAP_PROP_MAX_COUNTERS      ((UINT32)0x0000010F)
1475 #define TPM_CAP_PROP_MAX_KEYS          ((UINT32)0x00000110)
1476 #define TPM_CAP_PROP_OWNER             ((UINT32)0x00000111)
1477 #define TPM_CAP_PROP_CONTEXT           ((UINT32)0x00000112)
1478 #define TPM_CAP_PROP_MAX_CONTEXT       ((UINT32)0x00000113)
1479 #define TPM_CAP_PROP_FAMILYROWS        ((UINT32)0x00000114)
1480 #define TPM_CAP_PROP_TIS_TIMEOUT       ((UINT32)0x00000115)
1481 #define TPM_CAP_PROP_STARTUP_EFFECT    ((UINT32)0x00000116)
1482 #define TPM_CAP_PROP_DELEGATE_ROW      ((UINT32)0x00000117)
1483 #define TPM_CAP_PROP_MAX_DAASESS       ((UINT32)0x00000119)
1484 #define TPM_CAP_PROP_DAA_MAX           TPM_CAP_PROP_MAX_DAASESS
1485 #define TPM_CAP_PROP_DAASESS           ((UINT32)0x0000011A)
1486 #define TPM_CAP_PROP_SESSION_DAA       TPM_CAP_PROP_DAASESS
1487 #define TPM_CAP_PROP_CONTEXT_DIST      ((UINT32)0x0000011B)
1488 #define TPM_CAP_PROP_DAA_INTERRUPT     ((UINT32)0x0000011C)
1489 #define TPM_CAP_PROP_SESSIONS          ((UINT32)0x0000011D)
1490 #define TPM_CAP_PROP_MAX_SESSIONS      ((UINT32)0x0000011E)
1491 #define TPM_CAP_PROP_CMK_RESTRICTION   ((UINT32)0x0000011F)
1492 #define TPM_CAP_PROP_DURATION          ((UINT32)0x00000120)
1493 #define TPM_CAP_PROP_ACTIVE_COUNTER    ((UINT32)0x00000122)
1494 #define TPM_CAP_PROP_NV_AVAILABLE      ((UINT32)0x00000123)
1495 #define TPM_CAP_PROP_INPUT_BUFFER      ((UINT32)0x00000124)
1496 
1497 
1498 // Part 2, section 21.4: SetCapability Values
1499 #define TPM_SET_PERM_FLAGS             ((UINT32)0x00000001)
1500 #define TPM_SET_PERM_DATA              ((UINT32)0x00000002)
1501 #define TPM_SET_STCLEAR_FLAGS          ((UINT32)0x00000003)
1502 #define TPM_SET_STCLEAR_DATA           ((UINT32)0x00000004)
1503 #define TPM_SET_STANY_FLAGS            ((UINT32)0x00000005)
1504 #define TPM_SET_STANY_DATA             ((UINT32)0x00000006)
1505 #define TPM_SET_VENDOR                 ((UINT32)0x00000007)
1506 
1507 
1508 // Part 2, section 21.6: TPM_CAP_VERSION_INFO
1509 typedef struct tdTPM_CAP_VERSION_INFO
1510 {
1511     TPM_STRUCTURE_TAG tag;
1512     TPM_VERSION       version;
1513     UINT16            specLevel;
1514     BYTE              errataRev;
1515     BYTE              tpmVendorID[4];
1516     UINT16            vendorSpecificSize;
1517     SIZEIS(vendorSpecificSize)
1518         BYTE         *vendorSpecific;
1519 } TPM_CAP_VERSION_INFO;
1520 
1521 
1522 // Part 2, section 21.9: TPM_DA_STATE
1523 // out of order to make it available for structure definitions
1524 typedef BYTE TPM_DA_STATE;
1525 #define TPM_DA_STATE_INACTIVE          (0x00)
1526 #define TPM_DA_STATE_ACTIVE            (0x01)
1527 
1528 // Part 2, section 21.10: TPM_DA_ACTION_TYPE
1529 typedef struct tdTPM_DA_ACTION_TYPE
1530 {
1531     TPM_STRUCTURE_TAG tag;
1532     UINT32            actions;
1533 } TPM_DA_ACTION_TYPE;
1534 #define TPM_DA_ACTION_TIMEOUT          ((UINT32)0x00000001)
1535 #define TPM_DA_ACTION_DISABLE          ((UINT32)0x00000002)
1536 #define TPM_DA_ACTION_DEACTIVATE       ((UINT32)0x00000004)
1537 #define TPM_DA_ACTION_FAILURE_MODE     ((UINT32)0x00000008)
1538 
1539 // Part 2, section 21.7: TPM_DA_INFO
1540 typedef struct tdTPM_DA_INFO
1541 {
1542     TPM_STRUCTURE_TAG  tag;
1543     TPM_DA_STATE       state;
1544     UINT16             currentCount;
1545     UINT16             threshholdCount;
1546     TPM_DA_ACTION_TYPE actionAtThreshold;
1547     UINT32             actionDependValue;
1548     UINT32             vendorDataSize;
1549     SIZEIS(vendorDataSize)
1550         BYTE          *vendorData;
1551 } TPM_DA_INFO;
1552 
1553 // Part 2, section 21.8: TPM_DA_INFO_LIMITED
1554 typedef struct tdTPM_DA_INFO_LIMITED
1555 {
1556     TPM_STRUCTURE_TAG  tag;
1557     TPM_DA_STATE       state;
1558     TPM_DA_ACTION_TYPE actionAtThreshold;
1559     UINT32             vendorDataSize;
1560     SIZEIS(vendorDataSize)
1561         BYTE          *vendorData;
1562 } TPM_DA_INFO_LIMITED;
1563 
1564 
1565 
1566 //-------------------------------------------------------------------
1567 // Part 2, section 22: DAA Structures
1568 
1569 #define TPM_DAA_SIZE_r0                (43)
1570 #define TPM_DAA_SIZE_r1                (43)
1571 #define TPM_DAA_SIZE_r2                (128)
1572 #define TPM_DAA_SIZE_r3                (168)
1573 #define TPM_DAA_SIZE_r4                (219)
1574 #define TPM_DAA_SIZE_NT                (20)
1575 #define TPM_DAA_SIZE_v0                (128)
1576 #define TPM_DAA_SIZE_v1                (192)
1577 #define TPM_DAA_SIZE_NE                (256)
1578 #define TPM_DAA_SIZE_w                 (256)
1579 #define TPM_DAA_SIZE_issuerModulus     (256)
1580 #define TPM_DAA_power0                 (104)
1581 #define TPM_DAA_power1                 (1024)
1582 
1583 typedef struct tdTPM_DAA_ISSUER
1584 {
1585     TPM_STRUCTURE_TAG tag;
1586     TPM_DIGEST        DAA_digest_R0;
1587     TPM_DIGEST        DAA_digest_R1;
1588     TPM_DIGEST        DAA_digest_S0;
1589     TPM_DIGEST        DAA_digest_S1;
1590     TPM_DIGEST        DAA_digest_n;
1591     TPM_DIGEST        DAA_digest_gamma;
1592     BYTE              DAA_generic_q[26];
1593 } TPM_DAA_ISSUER;
1594 
1595 
1596 typedef struct tdTPM_DAA_TPM
1597 {
1598     TPM_STRUCTURE_TAG tag;
1599     TPM_DIGEST        DAA_digestIssuer;
1600     TPM_DIGEST        DAA_digest_v0;
1601     TPM_DIGEST        DAA_digest_v1;
1602     TPM_DIGEST        DAA_rekey;
1603     UINT32            DAA_count;
1604 } TPM_DAA_TPM;
1605 
1606 typedef struct tdTPM_DAA_CONTEXT
1607 {
1608     TPM_STRUCTURE_TAG    tag;
1609     TPM_DIGEST           DAA_digestContext;
1610     TPM_DIGEST           DAA_digest;
1611     TPM_DAA_CONTEXT_SEED DAA_contextSeed;
1612     BYTE                 DAA_scratch[256];
1613     BYTE                 DAA_stage;
1614 } TPM_DAA_CONTEXT;
1615 
1616 typedef struct tdTPM_DAA_JOINDATA
1617 {
1618     BYTE       DAA_join_u0[128];
1619     BYTE       DAA_join_u1[138];
1620     TPM_DIGEST DAA_digest_n0;
1621 } TPM_DAA_JOINDATA;
1622 
1623 typedef struct tdTPM_DAA_BLOB
1624 {
1625     TPM_STRUCTURE_TAG tag;
1626     TPM_RESOURCE_TYPE resourceType;
1627     BYTE              label[16];
1628     TPM_DIGEST        blobIntegrity;
1629     UINT32            additionalSize;
1630     SIZEIS(additionalSize)
1631         BYTE         *additionalData;
1632     UINT32            sensitiveSize;
1633     SIZEIS(sensitiveSize)
1634         BYTE         *sensitiveData;
1635 } TPM_DAA_BLOB;
1636 
1637 typedef struct tdTPM_DAA_SENSITIVE
1638 {
1639     TPM_STRUCTURE_TAG tag;
1640     UINT32            internalSize;
1641     SIZEIS(internalSize)
1642         BYTE         *internalData;
1643 } TPM_DAA_SENSITIVE;
1644 
1645 
1646 
1647 //-------------------------------------------------------------------
1648 // Part 2, section 23: Redirection
1649 
1650 // This section of the TPM spec defines exactly one value but does not
1651 // give it a name. The definition of TPM_SetRedirection in Part3
1652 // refers to exactly one name but does not give its value. We join
1653 // them here.
1654 #define TPM_REDIR_GPIO              (0x00000001)
1655 
1656 
1657 //-------------------------------------------------------------------
1658 // Part 2, section 24.6: TPM_SYM_MODE
1659 //    Deprecated by TPM 1.2 spec
1660 
1661 typedef UINT32 TPM_SYM_MODE;
1662 #define TPM_SYM_MODE_ECB            (0x00000001)
1663 #define TPM_SYM_MODE_CBC            (0x00000002)
1664 #define TPM_SYM_MODE_CFB            (0x00000003)
1665 
1666 #endif // __TPM_H__
1667 
1668