iPXE
Tpm12.h
Go to the documentation of this file.
00001 /** @file
00002   TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103)
00003   See http://trustedcomputinggroup.org for latest specification updates
00004 
00005   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00006   This program and the accompanying materials
00007   are licensed and made available under the terms and conditions of the BSD License
00008   which accompanies this distribution.  The full text of the license may be found at
00009   http://opensource.org/licenses/bsd-license.php
00010 
00011   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00013 **/
00014 
00015 
00016 #ifndef _TPM12_H_
00017 #define _TPM12_H_
00018 
00019 FILE_LICENCE ( BSD3 );
00020 
00021 ///
00022 /// The start of TPM return codes
00023 ///
00024 #define TPM_BASE                    0
00025 
00026 //
00027 // All structures MUST be packed on a byte boundary.
00028 //
00029 
00030 #pragma pack (1)
00031 
00032 //
00033 // Part 2, section 2.2.3: Helper redefinitions
00034 //
00035 ///
00036 /// Indicates the conditions where it is required that authorization be presented
00037 ///
00038 typedef UINT8                       TPM_AUTH_DATA_USAGE;
00039 ///
00040 /// The information as to what the payload is in an encrypted structure
00041 ///
00042 typedef UINT8                       TPM_PAYLOAD_TYPE;
00043 ///
00044 /// The version info breakdown
00045 ///
00046 typedef UINT8                       TPM_VERSION_BYTE;
00047 ///
00048 /// The state of the dictionary attack mitigation logic
00049 ///
00050 typedef UINT8                       TPM_DA_STATE;
00051 ///
00052 /// The request or response authorization type
00053 ///
00054 typedef UINT16                      TPM_TAG;
00055 ///
00056 /// The protocol in use
00057 ///
00058 typedef UINT16                      TPM_PROTOCOL_ID;
00059 ///
00060 /// Indicates the start state
00061 ///
00062 typedef UINT16                      TPM_STARTUP_TYPE;
00063 ///
00064 /// The definition of the encryption scheme
00065 ///
00066 typedef UINT16                      TPM_ENC_SCHEME;
00067 ///
00068 /// The definition of the signature scheme
00069 ///
00070 typedef UINT16                      TPM_SIG_SCHEME;
00071 ///
00072 /// The definition of the migration scheme
00073 ///
00074 typedef UINT16                      TPM_MIGRATE_SCHEME;
00075 ///
00076 /// Sets the state of the physical presence mechanism
00077 ///
00078 typedef UINT16                      TPM_PHYSICAL_PRESENCE;
00079 ///
00080 /// Indicates the types of entity that are supported by the TPM
00081 ///
00082 typedef UINT16                      TPM_ENTITY_TYPE;
00083 ///
00084 /// Indicates the permitted usage of the key
00085 ///
00086 typedef UINT16                      TPM_KEY_USAGE;
00087 ///
00088 /// The type of asymmetric encrypted structure in use by the endorsement key
00089 ///
00090 typedef UINT16                      TPM_EK_TYPE;
00091 ///
00092 /// The tag for the structure
00093 ///
00094 typedef UINT16                      TPM_STRUCTURE_TAG;
00095 ///
00096 /// The platform specific spec to which the information relates to
00097 ///
00098 typedef UINT16                      TPM_PLATFORM_SPECIFIC;
00099 ///
00100 /// The command ordinal
00101 ///
00102 typedef UINT32                      TPM_COMMAND_CODE;
00103 ///
00104 /// Identifies a TPM capability area
00105 ///
00106 typedef UINT32                      TPM_CAPABILITY_AREA;
00107 ///
00108 /// Indicates information regarding a key
00109 ///
00110 typedef UINT32                      TPM_KEY_FLAGS;
00111 ///
00112 /// Indicates the type of algorithm
00113 ///
00114 typedef UINT32                      TPM_ALGORITHM_ID;
00115 ///
00116 /// The locality modifier
00117 ///
00118 typedef UINT32                      TPM_MODIFIER_INDICATOR;
00119 ///
00120 /// The actual number of a counter
00121 ///
00122 typedef UINT32                      TPM_ACTUAL_COUNT;
00123 ///
00124 /// Attributes that define what options are in use for a transport session
00125 ///
00126 typedef UINT32                      TPM_TRANSPORT_ATTRIBUTES;
00127 ///
00128 /// Handle to an authorization session
00129 ///
00130 typedef UINT32                      TPM_AUTHHANDLE;
00131 ///
00132 /// Index to a DIR register
00133 ///
00134 typedef UINT32                      TPM_DIRINDEX;
00135 ///
00136 /// The area where a key is held assigned by the TPM
00137 ///
00138 typedef UINT32                      TPM_KEY_HANDLE;
00139 ///
00140 /// Index to a PCR register
00141 ///
00142 typedef UINT32                      TPM_PCRINDEX;
00143 ///
00144 /// The return code from a function
00145 ///
00146 typedef UINT32                      TPM_RESULT;
00147 ///
00148 /// The types of resources that a TPM may have using internal resources
00149 ///
00150 typedef UINT32                      TPM_RESOURCE_TYPE;
00151 ///
00152 /// Allows for controlling of the key when loaded and how to handle TPM_Startup issues
00153 ///
00154 typedef UINT32                      TPM_KEY_CONTROL;
00155 ///
00156 /// The index into the NV storage area
00157 ///
00158 typedef UINT32                      TPM_NV_INDEX;
00159 ///
00160 /// The family ID. Family IDs are automatically assigned a sequence number by the TPM.
00161 /// A trusted process can set the FamilyID value in an individual row to NULL, which
00162 /// invalidates that row. The family ID resets to NULL on each change of TPM Owner.
00163 ///
00164 typedef UINT32                      TPM_FAMILY_ID;
00165 ///
00166 /// IA value used as a label for the most recent verification of this family. Set to zero when not in use.
00167 ///
00168 typedef UINT32                      TPM_FAMILY_VERIFICATION;
00169 ///
00170 /// How the TPM handles var
00171 ///
00172 typedef UINT32                      TPM_STARTUP_EFFECTS;
00173 ///
00174 /// The mode of a symmetric encryption
00175 ///
00176 typedef UINT32                      TPM_SYM_MODE;
00177 ///
00178 /// The family flags
00179 ///
00180 typedef UINT32                      TPM_FAMILY_FLAGS;
00181 ///
00182 /// The index value for the delegate NV table
00183 ///
00184 typedef UINT32                      TPM_DELEGATE_INDEX;
00185 ///
00186 /// The restrictions placed on delegation of CMK commands
00187 ///
00188 typedef UINT32                      TPM_CMK_DELEGATE;
00189 ///
00190 /// The ID value of a monotonic counter
00191 ///
00192 typedef UINT32                      TPM_COUNT_ID;
00193 ///
00194 /// A command to execute
00195 ///
00196 typedef UINT32                      TPM_REDIT_COMMAND;
00197 ///
00198 /// A transport session handle
00199 ///
00200 typedef UINT32                      TPM_TRANSHANDLE;
00201 ///
00202 /// A generic handle could be key, transport etc
00203 ///
00204 typedef UINT32                      TPM_HANDLE;
00205 ///
00206 /// What operation is happening
00207 ///
00208 typedef UINT32                      TPM_FAMILY_OPERATION;
00209 
00210 //
00211 // Part 2, section 2.2.4: Vendor specific
00212 // The following defines allow for the quick specification of a
00213 // vendor specific item.
00214 //
00215 #define TPM_Vendor_Specific32       ((UINT32) 0x00000400)
00216 #define TPM_Vendor_Specific8        ((UINT8) 0x80)
00217 
00218 //
00219 // Part 2, section 3.1: TPM_STRUCTURE_TAG
00220 //
00221 #define TPM_TAG_CONTEXTBLOB         ((TPM_STRUCTURE_TAG) 0x0001)
00222 #define TPM_TAG_CONTEXT_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0002)
00223 #define TPM_TAG_CONTEXTPOINTER      ((TPM_STRUCTURE_TAG) 0x0003)
00224 #define TPM_TAG_CONTEXTLIST         ((TPM_STRUCTURE_TAG) 0x0004)
00225 #define TPM_TAG_SIGNINFO            ((TPM_STRUCTURE_TAG) 0x0005)
00226 #define TPM_TAG_PCR_INFO_LONG       ((TPM_STRUCTURE_TAG) 0x0006)
00227 #define TPM_TAG_PERSISTENT_FLAGS    ((TPM_STRUCTURE_TAG) 0x0007)
00228 #define TPM_TAG_VOLATILE_FLAGS      ((TPM_STRUCTURE_TAG) 0x0008)
00229 #define TPM_TAG_PERSISTENT_DATA     ((TPM_STRUCTURE_TAG) 0x0009)
00230 #define TPM_TAG_VOLATILE_DATA       ((TPM_STRUCTURE_TAG) 0x000A)
00231 #define TPM_TAG_SV_DATA             ((TPM_STRUCTURE_TAG) 0x000B)
00232 #define TPM_TAG_EK_BLOB             ((TPM_STRUCTURE_TAG) 0x000C)
00233 #define TPM_TAG_EK_BLOB_AUTH        ((TPM_STRUCTURE_TAG) 0x000D)
00234 #define TPM_TAG_COUNTER_VALUE       ((TPM_STRUCTURE_TAG) 0x000E)
00235 #define TPM_TAG_TRANSPORT_INTERNAL  ((TPM_STRUCTURE_TAG) 0x000F)
00236 #define TPM_TAG_TRANSPORT_LOG_IN    ((TPM_STRUCTURE_TAG) 0x0010)
00237 #define TPM_TAG_TRANSPORT_LOG_OUT   ((TPM_STRUCTURE_TAG) 0x0011)
00238 #define TPM_TAG_AUDIT_EVENT_IN      ((TPM_STRUCTURE_TAG) 0x0012)
00239 #define TPM_TAG_AUDIT_EVENT_OUT     ((TPM_STRUCTURE_TAG) 0x0013)
00240 #define TPM_TAG_CURRENT_TICKS       ((TPM_STRUCTURE_TAG) 0x0014)
00241 #define TPM_TAG_KEY                 ((TPM_STRUCTURE_TAG) 0x0015)
00242 #define TPM_TAG_STORED_DATA12       ((TPM_STRUCTURE_TAG) 0x0016)
00243 #define TPM_TAG_NV_ATTRIBUTES       ((TPM_STRUCTURE_TAG) 0x0017)
00244 #define TPM_TAG_NV_DATA_PUBLIC      ((TPM_STRUCTURE_TAG) 0x0018)
00245 #define TPM_TAG_NV_DATA_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0019)
00246 #define TPM_TAG_DELEGATIONS         ((TPM_STRUCTURE_TAG) 0x001A)
00247 #define TPM_TAG_DELEGATE_PUBLIC     ((TPM_STRUCTURE_TAG) 0x001B)
00248 #define TPM_TAG_DELEGATE_TABLE_ROW  ((TPM_STRUCTURE_TAG) 0x001C)
00249 #define TPM_TAG_TRANSPORT_AUTH      ((TPM_STRUCTURE_TAG) 0x001D)
00250 #define TPM_TAG_TRANSPORT_PUBLIC    ((TPM_STRUCTURE_TAG) 0x001E)
00251 #define TPM_TAG_PERMANENT_FLAGS     ((TPM_STRUCTURE_TAG) 0x001F)
00252 #define TPM_TAG_STCLEAR_FLAGS       ((TPM_STRUCTURE_TAG) 0x0020)
00253 #define TPM_TAG_STANY_FLAGS         ((TPM_STRUCTURE_TAG) 0x0021)
00254 #define TPM_TAG_PERMANENT_DATA      ((TPM_STRUCTURE_TAG) 0x0022)
00255 #define TPM_TAG_STCLEAR_DATA        ((TPM_STRUCTURE_TAG) 0x0023)
00256 #define TPM_TAG_STANY_DATA          ((TPM_STRUCTURE_TAG) 0x0024)
00257 #define TPM_TAG_FAMILY_TABLE_ENTRY  ((TPM_STRUCTURE_TAG) 0x0025)
00258 #define TPM_TAG_DELEGATE_SENSITIVE  ((TPM_STRUCTURE_TAG) 0x0026)
00259 #define TPM_TAG_DELG_KEY_BLOB       ((TPM_STRUCTURE_TAG) 0x0027)
00260 #define TPM_TAG_KEY12               ((TPM_STRUCTURE_TAG) 0x0028)
00261 #define TPM_TAG_CERTIFY_INFO2       ((TPM_STRUCTURE_TAG) 0x0029)
00262 #define TPM_TAG_DELEGATE_OWNER_BLOB ((TPM_STRUCTURE_TAG) 0x002A)
00263 #define TPM_TAG_EK_BLOB_ACTIVATE    ((TPM_STRUCTURE_TAG) 0x002B)
00264 #define TPM_TAG_DAA_BLOB            ((TPM_STRUCTURE_TAG) 0x002C)
00265 #define TPM_TAG_DAA_CONTEXT         ((TPM_STRUCTURE_TAG) 0x002D)
00266 #define TPM_TAG_DAA_ENFORCE         ((TPM_STRUCTURE_TAG) 0x002E)
00267 #define TPM_TAG_DAA_ISSUER          ((TPM_STRUCTURE_TAG) 0x002F)
00268 #define TPM_TAG_CAP_VERSION_INFO    ((TPM_STRUCTURE_TAG) 0x0030)
00269 #define TPM_TAG_DAA_SENSITIVE       ((TPM_STRUCTURE_TAG) 0x0031)
00270 #define TPM_TAG_DAA_TPM             ((TPM_STRUCTURE_TAG) 0x0032)
00271 #define TPM_TAG_CMK_MIGAUTH         ((TPM_STRUCTURE_TAG) 0x0033)
00272 #define TPM_TAG_CMK_SIGTICKET       ((TPM_STRUCTURE_TAG) 0x0034)
00273 #define TPM_TAG_CMK_MA_APPROVAL     ((TPM_STRUCTURE_TAG) 0x0035)
00274 #define TPM_TAG_QUOTE_INFO2         ((TPM_STRUCTURE_TAG) 0x0036)
00275 #define TPM_TAG_DA_INFO             ((TPM_STRUCTURE_TAG) 0x0037)
00276 #define TPM_TAG_DA_LIMITED          ((TPM_STRUCTURE_TAG) 0x0038)
00277 #define TPM_TAG_DA_ACTION_TYPE      ((TPM_STRUCTURE_TAG) 0x0039)
00278 
00279 //
00280 // Part 2, section 4: TPM Types
00281 //
00282 
00283 //
00284 // Part 2, section 4.1: TPM_RESOURCE_TYPE
00285 //
00286 #define TPM_RT_KEY                  ((TPM_RESOURCE_TYPE) 0x00000001) ///< The handle is a key handle and is the result of a LoadKey type operation
00287 #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
00288 #define TPM_RT_HASH                 ((TPM_RESOURCE_TYPE) 0x00000003) ///< Reserved for hashes
00289 #define TPM_RT_TRANS                ((TPM_RESOURCE_TYPE) 0x00000004) ///< The handle is for a transport session. Transport handles come from TPM_EstablishTransport
00290 #define TPM_RT_CONTEXT              ((TPM_RESOURCE_TYPE) 0x00000005) ///< Resource wrapped and held outside the TPM using the context save/restore commands
00291 #define TPM_RT_COUNTER              ((TPM_RESOURCE_TYPE) 0x00000006) ///< Reserved for counters
00292 #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
00293 #define TPM_RT_DAA_TPM              ((TPM_RESOURCE_TYPE) 0x00000008) ///< The value is a DAA TPM specific blob
00294 #define TPM_RT_DAA_V0               ((TPM_RESOURCE_TYPE) 0x00000009) ///< The value is a DAA V0 parameter
00295 #define TPM_RT_DAA_V1               ((TPM_RESOURCE_TYPE) 0x0000000A) ///< The value is a DAA V1 parameter
00296 
00297 //
00298 // Part 2, section 4.2: TPM_PAYLOAD_TYPE
00299 //
00300 #define TPM_PT_ASYM                 ((TPM_PAYLOAD_TYPE) 0x01) ///< The entity is an asymmetric key
00301 #define TPM_PT_BIND                 ((TPM_PAYLOAD_TYPE) 0x02) ///< The entity is bound data
00302 #define TPM_PT_MIGRATE              ((TPM_PAYLOAD_TYPE) 0x03) ///< The entity is a migration blob
00303 #define TPM_PT_MAINT                ((TPM_PAYLOAD_TYPE) 0x04) ///< The entity is a maintenance blob
00304 #define TPM_PT_SEAL                 ((TPM_PAYLOAD_TYPE) 0x05) ///< The entity is sealed data
00305 #define TPM_PT_MIGRATE_RESTRICTED   ((TPM_PAYLOAD_TYPE) 0x06) ///< The entity is a restricted-migration asymmetric key
00306 #define TPM_PT_MIGRATE_EXTERNAL     ((TPM_PAYLOAD_TYPE) 0x07) ///< The entity is a external migratable key
00307 #define TPM_PT_CMK_MIGRATE          ((TPM_PAYLOAD_TYPE) 0x08) ///< The entity is a CMK migratable blob
00308 #define TPM_PT_VENDOR_SPECIFIC      ((TPM_PAYLOAD_TYPE) 0x80) ///< 0x80 - 0xFF Vendor specific payloads
00309 
00310 //
00311 // Part 2, section 4.3: TPM_ENTITY_TYPE
00312 //
00313 #define TPM_ET_KEYHANDLE            ((UINT16) 0x0001) ///< The entity is a keyHandle or key
00314 #define TPM_ET_OWNER                ((UINT16) 0x0002) ///< The entity is the TPM Owner
00315 #define TPM_ET_DATA                 ((UINT16) 0x0003) ///< The entity is some data
00316 #define TPM_ET_SRK                  ((UINT16) 0x0004) ///< The entity is the SRK
00317 #define TPM_ET_KEY                  ((UINT16) 0x0005) ///< The entity is a key or keyHandle
00318 #define TPM_ET_REVOKE               ((UINT16) 0x0006) ///< The entity is the RevokeTrust value
00319 #define TPM_ET_DEL_OWNER_BLOB       ((UINT16) 0x0007) ///< The entity is a delegate owner blob
00320 #define TPM_ET_DEL_ROW              ((UINT16) 0x0008) ///< The entity is a delegate row
00321 #define TPM_ET_DEL_KEY_BLOB         ((UINT16) 0x0009) ///< The entity is a delegate key blob
00322 #define TPM_ET_COUNTER              ((UINT16) 0x000A) ///< The entity is a counter
00323 #define TPM_ET_NV                   ((UINT16) 0x000B) ///< The entity is a NV index
00324 #define TPM_ET_OPERATOR             ((UINT16) 0x000C) ///< The entity is the operator
00325 #define TPM_ET_RESERVED_HANDLE      ((UINT16) 0x0040) ///< Reserved. This value avoids collisions with the handle MSB setting.
00326 //
00327 // TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable
00328 //
00329 #define TPM_ET_XOR                  ((UINT16) 0x0000) ///< ADIP encryption scheme: XOR
00330 #define TPM_ET_AES128               ((UINT16) 0x0006) ///< ADIP encryption scheme: AES 128 bits
00331 
00332 //
00333 // Part 2, section 4.4.1: Reserved Key Handles
00334 //
00335 #define TPM_KH_SRK                  ((TPM_KEY_HANDLE) 0x40000000) ///< The handle points to the SRK
00336 #define TPM_KH_OWNER                ((TPM_KEY_HANDLE) 0x40000001) ///< The handle points to the TPM Owner
00337 #define TPM_KH_REVOKE               ((TPM_KEY_HANDLE) 0x40000002) ///< The handle points to the RevokeTrust value
00338 #define TPM_KH_TRANSPORT            ((TPM_KEY_HANDLE) 0x40000003) ///< The handle points to the EstablishTransport static authorization
00339 #define TPM_KH_OPERATOR             ((TPM_KEY_HANDLE) 0x40000004) ///< The handle points to the Operator auth
00340 #define TPM_KH_ADMIN                ((TPM_KEY_HANDLE) 0x40000005) ///< The handle points to the delegation administration auth
00341 #define TPM_KH_EK                   ((TPM_KEY_HANDLE) 0x40000006) ///< The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub
00342 
00343 //
00344 // Part 2, section 4.5: TPM_STARTUP_TYPE
00345 //
00346 #define TPM_ST_CLEAR                ((TPM_STARTUP_TYPE) 0x0001) ///< The TPM is starting up from a clean state
00347 #define TPM_ST_STATE                ((TPM_STARTUP_TYPE) 0x0002) ///< The TPM is starting up from a saved state
00348 #define TPM_ST_DEACTIVATED          ((TPM_STARTUP_TYPE) 0x0003) ///< The TPM is to startup and set the deactivated flag to TRUE
00349 
00350 //
00351 // Part 2, section 4.6: TPM_STATUP_EFFECTS
00352 // The table makeup is still an open issue.
00353 //
00354 
00355 //
00356 // Part 2, section 4.7: TPM_PROTOCOL_ID
00357 //
00358 #define TPM_PID_OIAP                ((TPM_PROTOCOL_ID) 0x0001) ///< The OIAP protocol.
00359 #define TPM_PID_OSAP                ((TPM_PROTOCOL_ID) 0x0002) ///< The OSAP protocol.
00360 #define TPM_PID_ADIP                ((TPM_PROTOCOL_ID) 0x0003) ///< The ADIP protocol.
00361 #define TPM_PID_ADCP                ((TPM_PROTOCOL_ID) 0x0004) ///< The ADCP protocol.
00362 #define TPM_PID_OWNER               ((TPM_PROTOCOL_ID) 0x0005) ///< The protocol for taking ownership of a TPM.
00363 #define TPM_PID_DSAP                ((TPM_PROTOCOL_ID) 0x0006) ///< The DSAP protocol
00364 #define TPM_PID_TRANSPORT           ((TPM_PROTOCOL_ID) 0x0007) ///< The transport protocol
00365 
00366 //
00367 // Part 2, section 4.8: TPM_ALGORITHM_ID
00368 //   The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC,
00369 //   TPM_ALG_MGF1
00370 //
00371 #define TPM_ALG_RSA                 ((TPM_ALGORITHM_ID) 0x00000001) ///< The RSA algorithm.
00372 #define TPM_ALG_DES                 ((TPM_ALGORITHM_ID) 0x00000002) ///< The DES algorithm
00373 #define TPM_ALG_3DES                ((TPM_ALGORITHM_ID) 0x00000003) ///< The 3DES algorithm in EDE mode
00374 #define TPM_ALG_SHA                 ((TPM_ALGORITHM_ID) 0x00000004) ///< The SHA1 algorithm
00375 #define TPM_ALG_HMAC                ((TPM_ALGORITHM_ID) 0x00000005) ///< The RFC 2104 HMAC algorithm
00376 #define TPM_ALG_AES128              ((TPM_ALGORITHM_ID) 0x00000006) ///< The AES algorithm, key size 128
00377 #define TPM_ALG_MGF1                ((TPM_ALGORITHM_ID) 0x00000007) ///< The XOR algorithm using MGF1 to create a string the size of the encrypted block
00378 #define TPM_ALG_AES192              ((TPM_ALGORITHM_ID) 0x00000008) ///< AES, key size 192
00379 #define TPM_ALG_AES256              ((TPM_ALGORITHM_ID) 0x00000009) ///< AES, key size 256
00380 #define TPM_ALG_XOR                 ((TPM_ALGORITHM_ID) 0x0000000A) ///< XOR using the rolling nonces
00381 
00382 //
00383 // Part 2, section 4.9: TPM_PHYSICAL_PRESENCE
00384 //
00385 #define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((TPM_PHYSICAL_PRESENCE) 0x0200) ///< Sets the physicalPresenceHWEnable to FALSE
00386 #define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((TPM_PHYSICAL_PRESENCE) 0x0100) ///< Sets the physicalPresenceCMDEnable to FALSE
00387 #define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) ///< Sets the physicalPresenceLifetimeLock to TRUE
00388 #define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((TPM_PHYSICAL_PRESENCE) 0x0040) ///< Sets the physicalPresenceHWEnable to TRUE
00389 #define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((TPM_PHYSICAL_PRESENCE) 0x0020) ///< Sets the physicalPresenceCMDEnable to TRUE
00390 #define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((TPM_PHYSICAL_PRESENCE) 0x0010) ///< Sets PhysicalPresence = FALSE
00391 #define TPM_PHYSICAL_PRESENCE_PRESENT       ((TPM_PHYSICAL_PRESENCE) 0x0008) ///< Sets PhysicalPresence = TRUE
00392 #define TPM_PHYSICAL_PRESENCE_LOCK          ((TPM_PHYSICAL_PRESENCE) 0x0004) ///< Sets PhysicalPresenceLock = TRUE
00393 
00394 //
00395 // Part 2, section 4.10: TPM_MIGRATE_SCHEME
00396 //
00397 #define TPM_MS_MIGRATE                      ((TPM_MIGRATE_SCHEME) 0x0001) ///< A public key that can be used with all TPM migration commands other than 'ReWrap' mode.
00398 #define TPM_MS_REWRAP                       ((TPM_MIGRATE_SCHEME) 0x0002) ///< A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob.
00399 #define TPM_MS_MAINT                        ((TPM_MIGRATE_SCHEME) 0x0003) ///< A public key that can be used for the Maintenance commands
00400 #define TPM_MS_RESTRICT_MIGRATE             ((TPM_MIGRATE_SCHEME) 0x0004) ///< The key is to be migrated to a Migration Authority.
00401 #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
00402 
00403 //
00404 // Part 2, section 4.11: TPM_EK_TYPE
00405 //
00406 #define TPM_EK_TYPE_ACTIVATE        ((TPM_EK_TYPE) 0x0001) ///< The blob MUST be TPM_EK_BLOB_ACTIVATE
00407 #define TPM_EK_TYPE_AUTH            ((TPM_EK_TYPE) 0x0002) ///< The blob MUST be TPM_EK_BLOB_AUTH
00408 
00409 //
00410 // Part 2, section 4.12: TPM_PLATFORM_SPECIFIC
00411 //
00412 #define TPM_PS_PC_11                ((TPM_PLATFORM_SPECIFIC) 0x0001) ///< PC Specific version 1.1
00413 #define TPM_PS_PC_12                ((TPM_PLATFORM_SPECIFIC) 0x0002) ///< PC Specific version 1.2
00414 #define TPM_PS_PDA_12               ((TPM_PLATFORM_SPECIFIC) 0x0003) ///< PDA Specific version 1.2
00415 #define TPM_PS_Server_12            ((TPM_PLATFORM_SPECIFIC) 0x0004) ///< Server Specific version 1.2
00416 #define TPM_PS_Mobile_12            ((TPM_PLATFORM_SPECIFIC) 0x0005) ///< Mobil Specific version 1.2
00417 
00418 //
00419 // Part 2, section 5: Basic Structures
00420 //
00421 
00422 ///
00423 /// Part 2, section 5.1: TPM_STRUCT_VER
00424 ///
00425 typedef struct tdTPM_STRUCT_VER {
00426   UINT8                             major;
00427   UINT8                             minor;
00428   UINT8                             revMajor;
00429   UINT8                             revMinor;
00430 } TPM_STRUCT_VER;
00431 
00432 ///
00433 /// Part 2, section 5.3: TPM_VERSION
00434 ///
00435 typedef struct tdTPM_VERSION {
00436   TPM_VERSION_BYTE                  major;
00437   TPM_VERSION_BYTE                  minor;
00438   UINT8                             revMajor;
00439   UINT8                             revMinor;
00440 } TPM_VERSION;
00441 
00442 
00443 #define TPM_SHA1_160_HASH_LEN       0x14
00444 #define TPM_SHA1BASED_NONCE_LEN     TPM_SHA1_160_HASH_LEN
00445 
00446 ///
00447 /// Part 2, section 5.4: TPM_DIGEST
00448 ///
00449 typedef struct tdTPM_DIGEST{
00450   UINT8                             digest[TPM_SHA1_160_HASH_LEN];
00451 } TPM_DIGEST;
00452 
00453 ///
00454 /// This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity
00455 ///
00456 typedef TPM_DIGEST                  TPM_CHOSENID_HASH;
00457 ///
00458 /// This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to
00459 ///
00460 typedef TPM_DIGEST                  TPM_COMPOSITE_HASH;
00461 ///
00462 /// This SHALL be the value of a DIR register
00463 ///
00464 typedef TPM_DIGEST                  TPM_DIRVALUE;
00465 
00466 typedef TPM_DIGEST                  TPM_HMAC;
00467 ///
00468 /// The value inside of the PCR
00469 ///
00470 typedef TPM_DIGEST                  TPM_PCRVALUE;
00471 ///
00472 /// This SHALL be the value of the current internal audit state
00473 ///
00474 typedef TPM_DIGEST                  TPM_AUDITDIGEST;
00475 
00476 ///
00477 /// Part 2, section 5.5: TPM_NONCE
00478 ///
00479 typedef struct tdTPM_NONCE{
00480   UINT8                             nonce[20];
00481 } TPM_NONCE;
00482 
00483 ///
00484 /// This SHALL be a random value generated by a TPM immediately after the EK is installed
00485 /// in that TPM, whenever an EK is installed in that TPM
00486 ///
00487 typedef TPM_NONCE                  TPM_DAA_TPM_SEED;
00488 ///
00489 /// This SHALL be a random value
00490 ///
00491 typedef TPM_NONCE                  TPM_DAA_CONTEXT_SEED;
00492 
00493 //
00494 // Part 2, section 5.6: TPM_AUTHDATA
00495 //
00496 ///
00497 /// The AuthData data is the information that is saved or passed to provide proof of ownership
00498 /// 296 of an entity
00499 ///
00500 typedef UINT8                       tdTPM_AUTHDATA[20];
00501 
00502 typedef tdTPM_AUTHDATA              TPM_AUTHDATA;
00503 ///
00504 /// A secret plaintext value used in the authorization process
00505 ///
00506 typedef TPM_AUTHDATA                TPM_SECRET;
00507 ///
00508 /// A ciphertext (encrypted) version of AuthData data. The encryption mechanism depends on the context
00509 ///
00510 typedef TPM_AUTHDATA                TPM_ENCAUTH;
00511 
00512 ///
00513 /// Part 2, section 5.7: TPM_KEY_HANDLE_LIST
00514 /// Size of handle is loaded * sizeof(TPM_KEY_HANDLE)
00515 ///
00516 typedef struct tdTPM_KEY_HANDLE_LIST {
00517   UINT16                            loaded;
00518   TPM_KEY_HANDLE                    handle[1];
00519 } TPM_KEY_HANDLE_LIST;
00520 
00521 //
00522 // Part 2, section 5.8: TPM_KEY_USAGE values
00523 //
00524 ///
00525 /// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be
00526 /// used for signing operations, only. This means that it MUST be a leaf of the
00527 /// Protected Storage key hierarchy.
00528 ///
00529 #define TPM_KEY_SIGNING             ((UINT16) 0x0010)
00530 ///
00531 /// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap
00532 /// and unwrap other keys in the Protected Storage hierarchy
00533 ///
00534 #define TPM_KEY_STORAGE             ((UINT16) 0x0011)
00535 ///
00536 /// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for
00537 /// operations that require a TPM identity, only.
00538 ///
00539 #define TPM_KEY_IDENTITY            ((UINT16) 0x0012)
00540 ///
00541 /// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during
00542 /// the ChangeAuthAsym process, only.
00543 ///
00544 #define TPM_KEY_AUTHCHANGE          ((UINT16) 0x0013)
00545 ///
00546 /// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and
00547 /// TPM_Unbind operations only.
00548 ///
00549 #define TPM_KEY_BIND                ((UINT16) 0x0014)
00550 ///
00551 /// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding
00552 /// operations. The key MAY be used for both signing and binding operations.
00553 /// The TPM_KEY_LEGACY key type is to allow for use by applications where both
00554 /// signing and encryption operations occur with the same key. The use of this
00555 /// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a
00556 /// key in use for TPM_MigrateKey
00557 ///
00558 #define TPM_KEY_LEGACY              ((UINT16) 0x0015)
00559 ///
00560 /// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey
00561 ///
00562 #define TPM_KEY_MIGRATE             ((UINT16) 0x0016)
00563 
00564 //
00565 // Part 2, section 5.8.1: Mandatory Key Usage Schemes
00566 //
00567 
00568 #define TPM_ES_NONE                 ((TPM_ENC_SCHEME) 0x0001)
00569 #define TPM_ES_RSAESPKCSv15         ((TPM_ENC_SCHEME) 0x0002)
00570 #define TPM_ES_RSAESOAEP_SHA1_MGF1  ((TPM_ENC_SCHEME) 0x0003)
00571 #define TPM_ES_SYM_CNT              ((TPM_ENC_SCHEME) 0x0004)  ///< rev94 defined
00572 #define TPM_ES_SYM_CTR              ((TPM_ENC_SCHEME) 0x0004)
00573 #define TPM_ES_SYM_OFB              ((TPM_ENC_SCHEME) 0x0005)
00574 
00575 #define TPM_SS_NONE                 ((TPM_SIG_SCHEME) 0x0001)
00576 #define TPM_SS_RSASSAPKCS1v15_SHA1  ((TPM_SIG_SCHEME) 0x0002)
00577 #define TPM_SS_RSASSAPKCS1v15_DER   ((TPM_SIG_SCHEME) 0x0003)
00578 #define TPM_SS_RSASSAPKCS1v15_INFO  ((TPM_SIG_SCHEME) 0x0004)
00579 
00580 //
00581 // Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
00582 //
00583 #define TPM_AUTH_NEVER              ((TPM_AUTH_DATA_USAGE) 0x00)
00584 #define TPM_AUTH_ALWAYS             ((TPM_AUTH_DATA_USAGE) 0x01)
00585 #define TPM_AUTH_PRIV_USE_ONLY      ((TPM_AUTH_DATA_USAGE) 0x03)
00586 
00587 ///
00588 /// Part 2, section 5.10: TPM_KEY_FLAGS
00589 ///
00590 typedef enum tdTPM_KEY_FLAGS {
00591   redirection                       = 0x00000001,
00592   migratable                        = 0x00000002,
00593   isVolatile                        = 0x00000004,
00594   pcrIgnoredOnRead                  = 0x00000008,
00595   migrateAuthority                  = 0x00000010
00596 } TPM_KEY_FLAGS_BITS;
00597 
00598 ///
00599 /// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
00600 ///
00601 typedef struct tdTPM_CHANGEAUTH_VALIDATE {
00602   TPM_SECRET                        newAuthSecret;
00603   TPM_NONCE                         n1;
00604 } TPM_CHANGEAUTH_VALIDATE;
00605 
00606 ///
00607 /// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
00608 ///   decalared after section 10 to catch declaration of TPM_PUBKEY
00609 ///
00610 /// Part 2 section 10.1: TPM_KEY_PARMS
00611 ///   [size_is(parmSize)] BYTE* parms;
00612 ///
00613 typedef struct tdTPM_KEY_PARMS {
00614   TPM_ALGORITHM_ID                  algorithmID;
00615   TPM_ENC_SCHEME                    encScheme;
00616   TPM_SIG_SCHEME                    sigScheme;
00617   UINT32                            parmSize;
00618   UINT8                             *parms;
00619 } TPM_KEY_PARMS;
00620 
00621 ///
00622 /// Part 2, section 10.4: TPM_STORE_PUBKEY
00623 ///
00624 typedef struct tdTPM_STORE_PUBKEY {
00625   UINT32                            keyLength;
00626   UINT8                             key[1];
00627 } TPM_STORE_PUBKEY;
00628 
00629 ///
00630 /// Part 2, section 10.5: TPM_PUBKEY
00631 ///
00632 typedef struct tdTPM_PUBKEY{
00633   TPM_KEY_PARMS                     algorithmParms;
00634   TPM_STORE_PUBKEY                  pubKey;
00635 } TPM_PUBKEY;
00636 
00637 ///
00638 /// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
00639 ///
00640 typedef struct tdTPM_MIGRATIONKEYAUTH{
00641   TPM_PUBKEY                        migrationKey;
00642   TPM_MIGRATE_SCHEME                migrationScheme;
00643   TPM_DIGEST                        digest;
00644 } TPM_MIGRATIONKEYAUTH;
00645 
00646 ///
00647 /// Part 2, section 5.13: TPM_COUNTER_VALUE
00648 ///
00649 typedef struct tdTPM_COUNTER_VALUE{
00650   TPM_STRUCTURE_TAG                 tag;
00651   UINT8                             label[4];
00652   TPM_ACTUAL_COUNT                  counter;
00653 } TPM_COUNTER_VALUE;
00654 
00655 ///
00656 /// Part 2, section 5.14: TPM_SIGN_INFO
00657 ///   Size of data indicated by dataLen
00658 ///
00659 typedef struct tdTPM_SIGN_INFO {
00660   TPM_STRUCTURE_TAG                 tag;
00661   UINT8                             fixed[4];
00662   TPM_NONCE                         replay;
00663   UINT32                            dataLen;
00664   UINT8                             *data;
00665 } TPM_SIGN_INFO;
00666 
00667 ///
00668 /// Part 2, section 5.15: TPM_MSA_COMPOSITE
00669 ///   Number of migAuthDigest indicated by MSAlist
00670 ///
00671 typedef struct tdTPM_MSA_COMPOSITE {
00672   UINT32                            MSAlist;
00673   TPM_DIGEST                        migAuthDigest[1];
00674 } TPM_MSA_COMPOSITE;
00675 
00676 ///
00677 /// Part 2, section 5.16: TPM_CMK_AUTH
00678 ///
00679 typedef struct tdTPM_CMK_AUTH{
00680   TPM_DIGEST                        migrationAuthorityDigest;
00681   TPM_DIGEST                        destinationKeyDigest;
00682   TPM_DIGEST                        sourceKeyDigest;
00683 } TPM_CMK_AUTH;
00684 
00685 //
00686 // Part 2, section 5.17: TPM_CMK_DELEGATE
00687 //
00688 #define TPM_CMK_DELEGATE_SIGNING    ((TPM_CMK_DELEGATE) BIT31)
00689 #define TPM_CMK_DELEGATE_STORAGE    ((TPM_CMK_DELEGATE) BIT30)
00690 #define TPM_CMK_DELEGATE_BIND       ((TPM_CMK_DELEGATE) BIT29)
00691 #define TPM_CMK_DELEGATE_LEGACY     ((TPM_CMK_DELEGATE) BIT28)
00692 #define TPM_CMK_DELEGATE_MIGRATE    ((TPM_CMK_DELEGATE) BIT27)
00693 
00694 ///
00695 /// Part 2, section 5.18: TPM_SELECT_SIZE
00696 ///
00697 typedef struct tdTPM_SELECT_SIZE {
00698   UINT8                             major;
00699   UINT8                             minor;
00700   UINT16                            reqSize;
00701 } TPM_SELECT_SIZE;
00702 
00703 ///
00704 /// Part 2, section 5,19: TPM_CMK_MIGAUTH
00705 ///
00706 typedef struct tdTPM_CMK_MIGAUTH{
00707   TPM_STRUCTURE_TAG                 tag;
00708   TPM_DIGEST                        msaDigest;
00709   TPM_DIGEST                        pubKeyDigest;
00710 } TPM_CMK_MIGAUTH;
00711 
00712 ///
00713 /// Part 2, section 5.20: TPM_CMK_SIGTICKET
00714 ///
00715 typedef struct tdTPM_CMK_SIGTICKET{
00716   TPM_STRUCTURE_TAG                 tag;
00717   TPM_DIGEST                        verKeyDigest;
00718   TPM_DIGEST                        signedData;
00719 } TPM_CMK_SIGTICKET;
00720 
00721 ///
00722 /// Part 2, section 5.21: TPM_CMK_MA_APPROVAL
00723 ///
00724 typedef struct tdTPM_CMK_MA_APPROVAL{
00725   TPM_STRUCTURE_TAG                 tag;
00726   TPM_DIGEST                        migrationAuthorityDigest;
00727 } TPM_CMK_MA_APPROVAL;
00728 
00729 //
00730 // Part 2, section 6: Command Tags
00731 //
00732 #define TPM_TAG_RQU_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C1)
00733 #define TPM_TAG_RQU_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C2)
00734 #define TPM_TAG_RQU_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C3)
00735 #define TPM_TAG_RSP_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C4)
00736 #define TPM_TAG_RSP_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C5)
00737 #define TPM_TAG_RSP_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C6)
00738 
00739 ///
00740 /// Part 2, section 7.1: TPM_PERMANENT_FLAGS
00741 ///
00742 typedef struct tdTPM_PERMANENT_FLAGS{
00743   TPM_STRUCTURE_TAG                 tag;
00744   BOOLEAN                           disable;
00745   BOOLEAN                           ownership;
00746   BOOLEAN                           deactivated;
00747   BOOLEAN                           readPubek;
00748   BOOLEAN                           disableOwnerClear;
00749   BOOLEAN                           allowMaintenance;
00750   BOOLEAN                           physicalPresenceLifetimeLock;
00751   BOOLEAN                           physicalPresenceHWEnable;
00752   BOOLEAN                           physicalPresenceCMDEnable;
00753   BOOLEAN                           CEKPUsed;
00754   BOOLEAN                           TPMpost;
00755   BOOLEAN                           TPMpostLock;
00756   BOOLEAN                           FIPS;
00757   BOOLEAN                           operator;
00758   BOOLEAN                           enableRevokeEK;
00759   BOOLEAN                           nvLocked;
00760   BOOLEAN                           readSRKPub;
00761   BOOLEAN                           tpmEstablished;
00762   BOOLEAN                           maintenanceDone;
00763   BOOLEAN                           disableFullDALogicInfo;
00764 } TPM_PERMANENT_FLAGS;
00765 
00766 //
00767 // Part 2, section 7.1.1: Flag Restrictions (of TPM_PERMANENT_FLAGS)
00768 //
00769 #define TPM_PF_DISABLE                      ((TPM_CAPABILITY_AREA) 1)
00770 #define TPM_PF_OWNERSHIP                    ((TPM_CAPABILITY_AREA) 2)
00771 #define TPM_PF_DEACTIVATED                  ((TPM_CAPABILITY_AREA) 3)
00772 #define TPM_PF_READPUBEK                    ((TPM_CAPABILITY_AREA) 4)
00773 #define TPM_PF_DISABLEOWNERCLEAR            ((TPM_CAPABILITY_AREA) 5)
00774 #define TPM_PF_ALLOWMAINTENANCE             ((TPM_CAPABILITY_AREA) 6)
00775 #define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((TPM_CAPABILITY_AREA) 7)
00776 #define TPM_PF_PHYSICALPRESENCEHWENABLE     ((TPM_CAPABILITY_AREA) 8)
00777 #define TPM_PF_PHYSICALPRESENCECMDENABLE    ((TPM_CAPABILITY_AREA) 9)
00778 #define TPM_PF_CEKPUSED                     ((TPM_CAPABILITY_AREA) 10)
00779 #define TPM_PF_TPMPOST                      ((TPM_CAPABILITY_AREA) 11)
00780 #define TPM_PF_TPMPOSTLOCK                  ((TPM_CAPABILITY_AREA) 12)
00781 #define TPM_PF_FIPS                         ((TPM_CAPABILITY_AREA) 13)
00782 #define TPM_PF_OPERATOR                     ((TPM_CAPABILITY_AREA) 14)
00783 #define TPM_PF_ENABLEREVOKEEK               ((TPM_CAPABILITY_AREA) 15)
00784 #define TPM_PF_NV_LOCKED                    ((TPM_CAPABILITY_AREA) 16)
00785 #define TPM_PF_READSRKPUB                   ((TPM_CAPABILITY_AREA) 17)
00786 #define TPM_PF_TPMESTABLISHED               ((TPM_CAPABILITY_AREA) 18)
00787 #define TPM_PF_MAINTENANCEDONE              ((TPM_CAPABILITY_AREA) 19)
00788 #define TPM_PF_DISABLEFULLDALOGICINFO       ((TPM_CAPABILITY_AREA) 20)
00789 
00790 ///
00791 /// Part 2, section 7.2: TPM_STCLEAR_FLAGS
00792 ///
00793 typedef struct tdTPM_STCLEAR_FLAGS{
00794   TPM_STRUCTURE_TAG                 tag;
00795   BOOLEAN                           deactivated;
00796   BOOLEAN                           disableForceClear;
00797   BOOLEAN                           physicalPresence;
00798   BOOLEAN                           physicalPresenceLock;
00799   BOOLEAN                           bGlobalLock;
00800 } TPM_STCLEAR_FLAGS;
00801 
00802 //
00803 // Part 2, section 7.2.1: Flag Restrictions (of TPM_STCLEAR_FLAGS)
00804 //
00805 #define TPM_SF_DEACTIVATED          ((TPM_CAPABILITY_AREA) 1)
00806 #define TPM_SF_DISABLEFORCECLEAR    ((TPM_CAPABILITY_AREA) 2)
00807 #define TPM_SF_PHYSICALPRESENCE     ((TPM_CAPABILITY_AREA) 3)
00808 #define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4)
00809 #define TPM_SF_BGLOBALLOCK          ((TPM_CAPABILITY_AREA) 5)
00810 
00811 ///
00812 /// Part 2, section 7.3: TPM_STANY_FLAGS
00813 ///
00814 typedef struct tdTPM_STANY_FLAGS{
00815   TPM_STRUCTURE_TAG                 tag;
00816   BOOLEAN                           postInitialise;
00817   TPM_MODIFIER_INDICATOR            localityModifier;
00818   BOOLEAN                           transportExclusive;
00819   BOOLEAN                           TOSPresent;
00820 } TPM_STANY_FLAGS;
00821 
00822 //
00823 // Part 2, section 7.3.1: Flag Restrictions (of TPM_STANY_FLAGS)
00824 //
00825 #define TPM_AF_POSTINITIALISE       ((TPM_CAPABILITY_AREA) 1)
00826 #define TPM_AF_LOCALITYMODIFIER     ((TPM_CAPABILITY_AREA) 2)
00827 #define TPM_AF_TRANSPORTEXCLUSIVE   ((TPM_CAPABILITY_AREA) 3)
00828 #define TPM_AF_TOSPRESENT           ((TPM_CAPABILITY_AREA) 4)
00829 
00830 //
00831 // All those structures defined in section 7.4, 7.5, 7.6 are not normative and
00832 // thus no definitions here
00833 //
00834 // Part 2, section 7.4: TPM_PERMANENT_DATA
00835 //
00836 #define TPM_MIN_COUNTERS            4   ///< the minimum number of counters is 4
00837 #define TPM_DELEGATE_KEY            TPM_KEY
00838 #define TPM_NUM_PCR                 16
00839 #define TPM_MAX_NV_WRITE_NOOWNER    64
00840 
00841 //
00842 // Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability
00843 //
00844 #define TPM_PD_REVMAJOR               ((TPM_CAPABILITY_AREA) 1)
00845 #define TPM_PD_REVMINOR               ((TPM_CAPABILITY_AREA) 2)
00846 #define TPM_PD_TPMPROOF               ((TPM_CAPABILITY_AREA) 3)
00847 #define TPM_PD_OWNERAUTH              ((TPM_CAPABILITY_AREA) 4)
00848 #define TPM_PD_OPERATORAUTH           ((TPM_CAPABILITY_AREA) 5)
00849 #define TPM_PD_MANUMAINTPUB           ((TPM_CAPABILITY_AREA) 6)
00850 #define TPM_PD_ENDORSEMENTKEY         ((TPM_CAPABILITY_AREA) 7)
00851 #define TPM_PD_SRK                    ((TPM_CAPABILITY_AREA) 8)
00852 #define TPM_PD_DELEGATEKEY            ((TPM_CAPABILITY_AREA) 9)
00853 #define TPM_PD_CONTEXTKEY             ((TPM_CAPABILITY_AREA) 10)
00854 #define TPM_PD_AUDITMONOTONICCOUNTER  ((TPM_CAPABILITY_AREA) 11)
00855 #define TPM_PD_MONOTONICCOUNTER       ((TPM_CAPABILITY_AREA) 12)
00856 #define TPM_PD_PCRATTRIB              ((TPM_CAPABILITY_AREA) 13)
00857 #define TPM_PD_ORDINALAUDITSTATUS     ((TPM_CAPABILITY_AREA) 14)
00858 #define TPM_PD_AUTHDIR                ((TPM_CAPABILITY_AREA) 15)
00859 #define TPM_PD_RNGSTATE               ((TPM_CAPABILITY_AREA) 16)
00860 #define TPM_PD_FAMILYTABLE            ((TPM_CAPABILITY_AREA) 17)
00861 #define TPM_DELEGATETABLE             ((TPM_CAPABILITY_AREA) 18)
00862 #define TPM_PD_EKRESET                ((TPM_CAPABILITY_AREA) 19)
00863 #define TPM_PD_MAXNVBUFSIZE           ((TPM_CAPABILITY_AREA) 20)
00864 #define TPM_PD_LASTFAMILYID           ((TPM_CAPABILITY_AREA) 21)
00865 #define TPM_PD_NOOWNERNVWRITE         ((TPM_CAPABILITY_AREA) 22)
00866 #define TPM_PD_RESTRICTDELEGATE       ((TPM_CAPABILITY_AREA) 23)
00867 #define TPM_PD_TPMDAASEED             ((TPM_CAPABILITY_AREA) 24)
00868 #define TPM_PD_DAAPROOF               ((TPM_CAPABILITY_AREA) 25)
00869 
00870 ///
00871 /// Part 2, section 7.5: TPM_STCLEAR_DATA
00872 ///   available inside TPM only
00873 ///
00874  typedef struct tdTPM_STCLEAR_DATA{
00875    TPM_STRUCTURE_TAG                  tag;
00876    TPM_NONCE                          contextNonceKey;
00877    TPM_COUNT_ID                       countID;
00878    UINT32                             ownerReference;
00879    BOOLEAN                            disableResetLock;
00880    TPM_PCRVALUE                       PCR[TPM_NUM_PCR];
00881    UINT32                             deferredPhysicalPresence;
00882  }TPM_STCLEAR_DATA;
00883 
00884 //
00885 // Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability
00886 //
00887 #define TPM_SD_CONTEXTNONCEKEY            ((TPM_CAPABILITY_AREA)0x00000001)
00888 #define TPM_SD_COUNTID                    ((TPM_CAPABILITY_AREA)0x00000002)
00889 #define TPM_SD_OWNERREFERENCE             ((TPM_CAPABILITY_AREA)0x00000003)
00890 #define TPM_SD_DISABLERESETLOCK           ((TPM_CAPABILITY_AREA)0x00000004)
00891 #define TPM_SD_PCR                        ((TPM_CAPABILITY_AREA)0x00000005)
00892 #define TPM_SD_DEFERREDPHYSICALPRESENCE   ((TPM_CAPABILITY_AREA)0x00000006)
00893 
00894 //
00895 // Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability
00896 //
00897 #define TPM_AD_CONTEXTNONCESESSION        ((TPM_CAPABILITY_AREA) 1)
00898 #define TPM_AD_AUDITDIGEST                ((TPM_CAPABILITY_AREA) 2)
00899 #define TPM_AD_CURRENTTICKS               ((TPM_CAPABILITY_AREA) 3)
00900 #define TPM_AD_CONTEXTCOUNT               ((TPM_CAPABILITY_AREA) 4)
00901 #define TPM_AD_CONTEXTLIST                ((TPM_CAPABILITY_AREA) 5)
00902 #define TPM_AD_SESSIONS                   ((TPM_CAPABILITY_AREA) 6)
00903 
00904 //
00905 // Part 2, section 8: PCR Structures
00906 //
00907 
00908 ///
00909 /// Part 2, section 8.1: TPM_PCR_SELECTION
00910 ///   Size of pcrSelect[] indicated by sizeOfSelect
00911 ///
00912 typedef struct tdTPM_PCR_SELECTION {
00913   UINT16                            sizeOfSelect;
00914   UINT8                             pcrSelect[1];
00915 } TPM_PCR_SELECTION;
00916 
00917 ///
00918 /// Part 2, section 8.2: TPM_PCR_COMPOSITE
00919 ///   Size of pcrValue[] indicated by valueSize
00920 ///
00921 typedef struct tdTPM_PCR_COMPOSITE {
00922   TPM_PCR_SELECTION                 select;
00923   UINT32                            valueSize;
00924   TPM_PCRVALUE                      pcrValue[1];
00925 } TPM_PCR_COMPOSITE;
00926 
00927 ///
00928 /// Part 2, section 8.3: TPM_PCR_INFO
00929 ///
00930 typedef struct tdTPM_PCR_INFO {
00931   TPM_PCR_SELECTION                 pcrSelection;
00932   TPM_COMPOSITE_HASH                digestAtRelease;
00933   TPM_COMPOSITE_HASH                digestAtCreation;
00934 } TPM_PCR_INFO;
00935 
00936 ///
00937 /// Part 2, section 8.6: TPM_LOCALITY_SELECTION
00938 ///
00939 typedef UINT8                       TPM_LOCALITY_SELECTION;
00940 
00941 #define TPM_LOC_FOUR                ((UINT8) 0x10)
00942 #define TPM_LOC_THREE               ((UINT8) 0x08)
00943 #define TPM_LOC_TWO                 ((UINT8) 0x04)
00944 #define TPM_LOC_ONE                 ((UINT8) 0x02)
00945 #define TPM_LOC_ZERO                ((UINT8) 0x01)
00946 
00947 ///
00948 /// Part 2, section 8.4: TPM_PCR_INFO_LONG
00949 ///
00950 typedef struct tdTPM_PCR_INFO_LONG {
00951   TPM_STRUCTURE_TAG                 tag;
00952   TPM_LOCALITY_SELECTION            localityAtCreation;
00953   TPM_LOCALITY_SELECTION            localityAtRelease;
00954   TPM_PCR_SELECTION                 creationPCRSelection;
00955   TPM_PCR_SELECTION                 releasePCRSelection;
00956   TPM_COMPOSITE_HASH                digestAtCreation;
00957   TPM_COMPOSITE_HASH                digestAtRelease;
00958 } TPM_PCR_INFO_LONG;
00959 
00960 ///
00961 /// Part 2, section 8.5: TPM_PCR_INFO_SHORT
00962 ///
00963 typedef struct tdTPM_PCR_INFO_SHORT{
00964   TPM_PCR_SELECTION                 pcrSelection;
00965   TPM_LOCALITY_SELECTION            localityAtRelease;
00966   TPM_COMPOSITE_HASH                digestAtRelease;
00967 } TPM_PCR_INFO_SHORT;
00968 
00969 ///
00970 /// Part 2, section 8.8: TPM_PCR_ATTRIBUTES
00971 ///
00972 typedef struct tdTPM_PCR_ATTRIBUTES{
00973   BOOLEAN                           pcrReset;
00974   TPM_LOCALITY_SELECTION            pcrExtendLocal;
00975   TPM_LOCALITY_SELECTION            pcrResetLocal;
00976 } TPM_PCR_ATTRIBUTES;
00977 
00978 //
00979 // Part 2, section 9: Storage Structures
00980 //
00981 
00982 ///
00983 /// Part 2, section 9.1: TPM_STORED_DATA
00984 ///   [size_is(sealInfoSize)] BYTE* sealInfo;
00985 ///   [size_is(encDataSize)] BYTE* encData;
00986 ///
00987 typedef struct tdTPM_STORED_DATA {
00988   TPM_STRUCT_VER                    ver;
00989   UINT32                            sealInfoSize;
00990   UINT8                             *sealInfo;
00991   UINT32                            encDataSize;
00992   UINT8                             *encData;
00993 } TPM_STORED_DATA;
00994 
00995 ///
00996 /// Part 2, section 9.2: TPM_STORED_DATA12
00997 ///   [size_is(sealInfoSize)] BYTE* sealInfo;
00998 ///   [size_is(encDataSize)] BYTE* encData;
00999 ///
01000 typedef struct tdTPM_STORED_DATA12 {
01001   TPM_STRUCTURE_TAG                 tag;
01002   TPM_ENTITY_TYPE                   et;
01003   UINT32                            sealInfoSize;
01004   UINT8                             *sealInfo;
01005   UINT32                            encDataSize;
01006   UINT8                             *encData;
01007 } TPM_STORED_DATA12;
01008 
01009 ///
01010 /// Part 2, section 9.3: TPM_SEALED_DATA
01011 ///   [size_is(dataSize)] BYTE* data;
01012 ///
01013 typedef struct tdTPM_SEALED_DATA {
01014   TPM_PAYLOAD_TYPE                  payload;
01015   TPM_SECRET                        authData;
01016   TPM_NONCE                         tpmProof;
01017   TPM_DIGEST                        storedDigest;
01018   UINT32                            dataSize;
01019   UINT8                             *data;
01020 } TPM_SEALED_DATA;
01021 
01022 ///
01023 /// Part 2, section 9.4: TPM_SYMMETRIC_KEY
01024 ///   [size_is(size)] BYTE* data;
01025 ///
01026 typedef struct tdTPM_SYMMETRIC_KEY {
01027   TPM_ALGORITHM_ID                  algId;
01028   TPM_ENC_SCHEME                    encScheme;
01029   UINT16                            dataSize;
01030   UINT8                             *data;
01031 } TPM_SYMMETRIC_KEY;
01032 
01033 ///
01034 /// Part 2, section 9.5: TPM_BOUND_DATA
01035 ///
01036 typedef struct tdTPM_BOUND_DATA {
01037   TPM_STRUCT_VER                    ver;
01038   TPM_PAYLOAD_TYPE                  payload;
01039   UINT8                             payloadData[1];
01040 } TPM_BOUND_DATA;
01041 
01042 //
01043 // Part 2 section 10: TPM_KEY complex
01044 //
01045 
01046 //
01047 // Section 10.1, 10.4, and 10.5 have been defined previously
01048 //
01049 
01050 ///
01051 /// Part 2, section 10.2: TPM_KEY
01052 ///   [size_is(encDataSize)] BYTE* encData;
01053 ///
01054 typedef struct tdTPM_KEY{
01055   TPM_STRUCT_VER                    ver;
01056   TPM_KEY_USAGE                     keyUsage;
01057   TPM_KEY_FLAGS                     keyFlags;
01058   TPM_AUTH_DATA_USAGE               authDataUsage;
01059   TPM_KEY_PARMS                     algorithmParms;
01060   UINT32                            PCRInfoSize;
01061   UINT8                             *PCRInfo;
01062   TPM_STORE_PUBKEY                  pubKey;
01063   UINT32                            encDataSize;
01064   UINT8                             *encData;
01065 } TPM_KEY;
01066 
01067 ///
01068 /// Part 2, section 10.3: TPM_KEY12
01069 ///   [size_is(encDataSize)] BYTE* encData;
01070 ///
01071 typedef struct tdTPM_KEY12{
01072   TPM_STRUCTURE_TAG                 tag;
01073   UINT16                            fill;
01074   TPM_KEY_USAGE                     keyUsage;
01075   TPM_KEY_FLAGS                     keyFlags;
01076   TPM_AUTH_DATA_USAGE               authDataUsage;
01077   TPM_KEY_PARMS                     algorithmParms;
01078   UINT32                            PCRInfoSize;
01079   UINT8                             *PCRInfo;
01080   TPM_STORE_PUBKEY                  pubKey;
01081   UINT32                            encDataSize;
01082   UINT8                             *encData;
01083 } TPM_KEY12;
01084 
01085 ///
01086 /// Part 2, section 10.7: TPM_STORE_PRIVKEY
01087 ///   [size_is(keyLength)] BYTE* key;
01088 ///
01089 typedef struct tdTPM_STORE_PRIVKEY {
01090   UINT32                            keyLength;
01091   UINT8                             *key;
01092 } TPM_STORE_PRIVKEY;
01093 
01094 ///
01095 /// Part 2, section 10.6: TPM_STORE_ASYMKEY
01096 ///
01097 typedef struct tdTPM_STORE_ASYMKEY {                // pos len total
01098   TPM_PAYLOAD_TYPE                  payload;        // 0    1   1
01099   TPM_SECRET                        usageAuth;      // 1    20  21
01100   TPM_SECRET                        migrationAuth;  // 21   20  41
01101   TPM_DIGEST                        pubDataDigest;  // 41   20  61
01102   TPM_STORE_PRIVKEY                 privKey;        // 61 132-151 193-214
01103 } TPM_STORE_ASYMKEY;
01104 
01105 ///
01106 /// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY
01107 ///   [size_is(partPrivKeyLen)] BYTE* partPrivKey;
01108 ///
01109 typedef struct tdTPM_MIGRATE_ASYMKEY {              // pos  len  total
01110   TPM_PAYLOAD_TYPE                  payload;        //   0    1       1
01111   TPM_SECRET                        usageAuth;      //   1   20      21
01112   TPM_DIGEST                        pubDataDigest;  //  21   20      41
01113   UINT32                            partPrivKeyLen; //  41    4      45
01114   UINT8                             *partPrivKey;   //  45 112-127 157-172
01115 } TPM_MIGRATE_ASYMKEY;
01116 
01117 ///
01118 /// Part 2, section 10.9: TPM_KEY_CONTROL
01119 ///
01120 #define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001)
01121 
01122 //
01123 // Part 2, section 11: Signed Structures
01124 //
01125 
01126 ///
01127 /// Part 2, section 11.1: TPM_CERTIFY_INFO Structure
01128 ///
01129 typedef struct tdTPM_CERTIFY_INFO {
01130   TPM_STRUCT_VER                  version;
01131   TPM_KEY_USAGE                   keyUsage;
01132   TPM_KEY_FLAGS                   keyFlags;
01133   TPM_AUTH_DATA_USAGE             authDataUsage;
01134   TPM_KEY_PARMS                   algorithmParms;
01135   TPM_DIGEST                      pubkeyDigest;
01136   TPM_NONCE                       data;
01137   BOOLEAN                         parentPCRStatus;
01138   UINT32                          PCRInfoSize;
01139   UINT8                           *PCRInfo;
01140 } TPM_CERTIFY_INFO;
01141 
01142 ///
01143 /// Part 2, section 11.2: TPM_CERTIFY_INFO2 Structure
01144 ///
01145 typedef struct tdTPM_CERTIFY_INFO2 {
01146   TPM_STRUCTURE_TAG               tag;
01147   UINT8                           fill;
01148   TPM_PAYLOAD_TYPE                payloadType;
01149   TPM_KEY_USAGE                   keyUsage;
01150   TPM_KEY_FLAGS                   keyFlags;
01151   TPM_AUTH_DATA_USAGE             authDataUsage;
01152   TPM_KEY_PARMS                   algorithmParms;
01153   TPM_DIGEST                      pubkeyDigest;
01154   TPM_NONCE                       data;
01155   BOOLEAN                         parentPCRStatus;
01156   UINT32                          PCRInfoSize;
01157   UINT8                           *PCRInfo;
01158   UINT32                          migrationAuthoritySize;
01159   UINT8                           *migrationAuthority;
01160 } TPM_CERTIFY_INFO2;
01161 
01162 ///
01163 /// Part 2, section 11.3 TPM_QUOTE_INFO Structure
01164 ///
01165 typedef struct tdTPM_QUOTE_INFO {
01166   TPM_STRUCT_VER                  version;
01167   UINT8                           fixed[4];
01168   TPM_COMPOSITE_HASH              digestValue;
01169   TPM_NONCE                       externalData;
01170 } TPM_QUOTE_INFO;
01171 
01172 ///
01173 /// Part 2, section 11.4 TPM_QUOTE_INFO2 Structure
01174 ///
01175 typedef struct tdTPM_QUOTE_INFO2 {
01176   TPM_STRUCTURE_TAG               tag;
01177   UINT8                           fixed[4];
01178   TPM_NONCE                       externalData;
01179   TPM_PCR_INFO_SHORT              infoShort;
01180 } TPM_QUOTE_INFO2;
01181 
01182 //
01183 // Part 2, section 12: Identity Structures
01184 //
01185 
01186 ///
01187 /// Part 2, section 12.1 TPM_EK_BLOB
01188 ///
01189 typedef struct tdTPM_EK_BLOB {
01190   TPM_STRUCTURE_TAG               tag;
01191   TPM_EK_TYPE                     ekType;
01192   UINT32                          blobSize;
01193   UINT8                           *blob;
01194 } TPM_EK_BLOB;
01195 
01196 ///
01197 /// Part 2, section 12.2 TPM_EK_BLOB_ACTIVATE
01198 ///
01199 typedef struct tdTPM_EK_BLOB_ACTIVATE {
01200   TPM_STRUCTURE_TAG               tag;
01201   TPM_SYMMETRIC_KEY               sessionKey;
01202   TPM_DIGEST                      idDigest;
01203   TPM_PCR_INFO_SHORT              pcrInfo;
01204 } TPM_EK_BLOB_ACTIVATE;
01205 
01206 ///
01207 /// Part 2, section 12.3 TPM_EK_BLOB_AUTH
01208 ///
01209 typedef struct tdTPM_EK_BLOB_AUTH {
01210   TPM_STRUCTURE_TAG               tag;
01211   TPM_SECRET                      authValue;
01212 } TPM_EK_BLOB_AUTH;
01213 
01214 
01215 ///
01216 /// Part 2, section 12.5 TPM_IDENTITY_CONTENTS
01217 ///
01218 typedef struct tdTPM_IDENTITY_CONTENTS {
01219   TPM_STRUCT_VER                  ver;
01220   UINT32                          ordinal;
01221   TPM_CHOSENID_HASH               labelPrivCADigest;
01222   TPM_PUBKEY                      identityPubKey;
01223 } TPM_IDENTITY_CONTENTS;
01224 
01225 ///
01226 /// Part 2, section 12.6 TPM_IDENTITY_REQ
01227 ///
01228 typedef struct tdTPM_IDENTITY_REQ {
01229   UINT32                          asymSize;
01230   UINT32                          symSize;
01231   TPM_KEY_PARMS                   asymAlgorithm;
01232   TPM_KEY_PARMS                   symAlgorithm;
01233   UINT8                           *asymBlob;
01234   UINT8                           *symBlob;
01235 } TPM_IDENTITY_REQ;
01236 
01237 ///
01238 /// Part 2, section 12.7 TPM_IDENTITY_PROOF
01239 ///
01240 typedef struct tdTPM_IDENTITY_PROOF {
01241   TPM_STRUCT_VER                  ver;
01242   UINT32                          labelSize;
01243   UINT32                          identityBindingSize;
01244   UINT32                          endorsementSize;
01245   UINT32                          platformSize;
01246   UINT32                          conformanceSize;
01247   TPM_PUBKEY                      identityKey;
01248   UINT8                           *labelArea;
01249   UINT8                           *identityBinding;
01250   UINT8                           *endorsementCredential;
01251   UINT8                           *platformCredential;
01252   UINT8                           *conformanceCredential;
01253 } TPM_IDENTITY_PROOF;
01254 
01255 ///
01256 /// Part 2, section 12.8 TPM_ASYM_CA_CONTENTS
01257 ///
01258 typedef struct tdTPM_ASYM_CA_CONTENTS {
01259   TPM_SYMMETRIC_KEY               sessionKey;
01260   TPM_DIGEST                      idDigest;
01261 } TPM_ASYM_CA_CONTENTS;
01262 
01263 ///
01264 /// Part 2, section 12.9 TPM_SYM_CA_ATTESTATION
01265 ///
01266 typedef struct tdTPM_SYM_CA_ATTESTATION {
01267   UINT32                          credSize;
01268   TPM_KEY_PARMS                   algorithm;
01269   UINT8                           *credential;
01270 } TPM_SYM_CA_ATTESTATION;
01271 
01272 ///
01273 /// Part 2, section 15: Tick Structures
01274 ///   Placed here out of order because definitions are used in section 13.
01275 ///
01276 typedef struct tdTPM_CURRENT_TICKS {
01277   TPM_STRUCTURE_TAG                 tag;
01278   UINT64                            currentTicks;
01279   UINT16                            tickRate;
01280   TPM_NONCE                         tickNonce;
01281 } TPM_CURRENT_TICKS;
01282 
01283 ///
01284 /// Part 2, section 13: Transport structures
01285 ///
01286 
01287 ///
01288 /// Part 2, section 13.1: TPM _TRANSPORT_PUBLIC
01289 ///
01290 typedef struct tdTPM_TRANSPORT_PUBLIC {
01291   TPM_STRUCTURE_TAG               tag;
01292   TPM_TRANSPORT_ATTRIBUTES        transAttributes;
01293   TPM_ALGORITHM_ID                algId;
01294   TPM_ENC_SCHEME                  encScheme;
01295 } TPM_TRANSPORT_PUBLIC;
01296 
01297 //
01298 // Part 2, section 13.1.1 TPM_TRANSPORT_ATTRIBUTES Definitions
01299 //
01300 #define TPM_TRANSPORT_ENCRYPT       ((UINT32)BIT0)
01301 #define TPM_TRANSPORT_LOG           ((UINT32)BIT1)
01302 #define TPM_TRANSPORT_EXCLUSIVE     ((UINT32)BIT2)
01303 
01304 ///
01305 /// Part 2, section 13.2 TPM_TRANSPORT_INTERNAL
01306 ///
01307 typedef struct tdTPM_TRANSPORT_INTERNAL {
01308   TPM_STRUCTURE_TAG               tag;
01309   TPM_AUTHDATA                    authData;
01310   TPM_TRANSPORT_PUBLIC            transPublic;
01311   TPM_TRANSHANDLE                 transHandle;
01312   TPM_NONCE                       transNonceEven;
01313   TPM_DIGEST                      transDigest;
01314 } TPM_TRANSPORT_INTERNAL;
01315 
01316 ///
01317 /// Part 2, section 13.3 TPM_TRANSPORT_LOG_IN structure
01318 ///
01319 typedef struct tdTPM_TRANSPORT_LOG_IN {
01320   TPM_STRUCTURE_TAG               tag;
01321   TPM_DIGEST                      parameters;
01322   TPM_DIGEST                      pubKeyHash;
01323 } TPM_TRANSPORT_LOG_IN;
01324 
01325 ///
01326 /// Part 2, section 13.4 TPM_TRANSPORT_LOG_OUT structure
01327 ///
01328 typedef struct tdTPM_TRANSPORT_LOG_OUT {
01329   TPM_STRUCTURE_TAG               tag;
01330   TPM_CURRENT_TICKS               currentTicks;
01331   TPM_DIGEST                      parameters;
01332   TPM_MODIFIER_INDICATOR          locality;
01333 } TPM_TRANSPORT_LOG_OUT;
01334 
01335 ///
01336 /// Part 2, section 13.5 TPM_TRANSPORT_AUTH structure
01337 ///
01338 typedef struct tdTPM_TRANSPORT_AUTH {
01339   TPM_STRUCTURE_TAG               tag;
01340   TPM_AUTHDATA                    authData;
01341 } TPM_TRANSPORT_AUTH;
01342 
01343 //
01344 // Part 2, section 14: Audit Structures
01345 //
01346 
01347 ///
01348 /// Part 2, section 14.1 TPM_AUDIT_EVENT_IN structure
01349 ///
01350 typedef struct tdTPM_AUDIT_EVENT_IN {
01351   TPM_STRUCTURE_TAG               tag;
01352   TPM_DIGEST                      inputParms;
01353   TPM_COUNTER_VALUE               auditCount;
01354 } TPM_AUDIT_EVENT_IN;
01355 
01356 ///
01357 /// Part 2, section 14.2 TPM_AUDIT_EVENT_OUT structure
01358 ///
01359 typedef struct tdTPM_AUDIT_EVENT_OUT {
01360   TPM_STRUCTURE_TAG               tag;
01361   TPM_COMMAND_CODE                ordinal;
01362   TPM_DIGEST                      outputParms;
01363   TPM_COUNTER_VALUE               auditCount;
01364   TPM_RESULT                      returnCode;
01365 } TPM_AUDIT_EVENT_OUT;
01366 
01367 //
01368 // Part 2, section 16: Return Codes
01369 //
01370 
01371 #define TPM_VENDOR_ERROR            TPM_Vendor_Specific32
01372 #define TPM_NON_FATAL               0x00000800
01373 
01374 #define TPM_SUCCESS                 ((TPM_RESULT) TPM_BASE)
01375 #define TPM_AUTHFAIL                ((TPM_RESULT) (TPM_BASE + 1))
01376 #define TPM_BADINDEX                ((TPM_RESULT) (TPM_BASE + 2))
01377 #define TPM_BAD_PARAMETER           ((TPM_RESULT) (TPM_BASE + 3))
01378 #define TPM_AUDITFAILURE            ((TPM_RESULT) (TPM_BASE + 4))
01379 #define TPM_CLEAR_DISABLED          ((TPM_RESULT) (TPM_BASE + 5))
01380 #define TPM_DEACTIVATED             ((TPM_RESULT) (TPM_BASE + 6))
01381 #define TPM_DISABLED                ((TPM_RESULT) (TPM_BASE + 7))
01382 #define TPM_DISABLED_CMD            ((TPM_RESULT) (TPM_BASE + 8))
01383 #define TPM_FAIL                    ((TPM_RESULT) (TPM_BASE + 9))
01384 #define TPM_BAD_ORDINAL             ((TPM_RESULT) (TPM_BASE + 10))
01385 #define TPM_INSTALL_DISABLED        ((TPM_RESULT) (TPM_BASE + 11))
01386 #define TPM_INVALID_KEYHANDLE       ((TPM_RESULT) (TPM_BASE + 12))
01387 #define TPM_KEYNOTFOUND             ((TPM_RESULT) (TPM_BASE + 13))
01388 #define TPM_INAPPROPRIATE_ENC       ((TPM_RESULT) (TPM_BASE + 14))
01389 #define TPM_MIGRATEFAIL             ((TPM_RESULT) (TPM_BASE + 15))
01390 #define TPM_INVALID_PCR_INFO        ((TPM_RESULT) (TPM_BASE + 16))
01391 #define TPM_NOSPACE                 ((TPM_RESULT) (TPM_BASE + 17))
01392 #define TPM_NOSRK                   ((TPM_RESULT) (TPM_BASE + 18))
01393 #define TPM_NOTSEALED_BLOB          ((TPM_RESULT) (TPM_BASE + 19))
01394 #define TPM_OWNER_SET               ((TPM_RESULT) (TPM_BASE + 20))
01395 #define TPM_RESOURCES               ((TPM_RESULT) (TPM_BASE + 21))
01396 #define TPM_SHORTRANDOM             ((TPM_RESULT) (TPM_BASE + 22))
01397 #define TPM_SIZE                    ((TPM_RESULT) (TPM_BASE + 23))
01398 #define TPM_WRONGPCRVAL             ((TPM_RESULT) (TPM_BASE + 24))
01399 #define TPM_BAD_PARAM_SIZE          ((TPM_RESULT) (TPM_BASE + 25))
01400 #define TPM_SHA_THREAD              ((TPM_RESULT) (TPM_BASE + 26))
01401 #define TPM_SHA_ERROR               ((TPM_RESULT) (TPM_BASE + 27))
01402 #define TPM_FAILEDSELFTEST          ((TPM_RESULT) (TPM_BASE + 28))
01403 #define TPM_AUTH2FAIL               ((TPM_RESULT) (TPM_BASE + 29))
01404 #define TPM_BADTAG                  ((TPM_RESULT) (TPM_BASE + 30))
01405 #define TPM_IOERROR                 ((TPM_RESULT) (TPM_BASE + 31))
01406 #define TPM_ENCRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 32))
01407 #define TPM_DECRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 33))
01408 #define TPM_INVALID_AUTHHANDLE      ((TPM_RESULT) (TPM_BASE + 34))
01409 #define TPM_NO_ENDORSEMENT          ((TPM_RESULT) (TPM_BASE + 35))
01410 #define TPM_INVALID_KEYUSAGE        ((TPM_RESULT) (TPM_BASE + 36))
01411 #define TPM_WRONG_ENTITYTYPE        ((TPM_RESULT) (TPM_BASE + 37))
01412 #define TPM_INVALID_POSTINIT        ((TPM_RESULT) (TPM_BASE + 38))
01413 #define TPM_INAPPROPRIATE_SIG       ((TPM_RESULT) (TPM_BASE + 39))
01414 #define TPM_BAD_KEY_PROPERTY        ((TPM_RESULT) (TPM_BASE + 40))
01415 #define TPM_BAD_MIGRATION           ((TPM_RESULT) (TPM_BASE + 41))
01416 #define TPM_BAD_SCHEME              ((TPM_RESULT) (TPM_BASE + 42))
01417 #define TPM_BAD_DATASIZE            ((TPM_RESULT) (TPM_BASE + 43))
01418 #define TPM_BAD_MODE                ((TPM_RESULT) (TPM_BASE + 44))
01419 #define TPM_BAD_PRESENCE            ((TPM_RESULT) (TPM_BASE + 45))
01420 #define TPM_BAD_VERSION             ((TPM_RESULT) (TPM_BASE + 46))
01421 #define TPM_NO_WRAP_TRANSPORT       ((TPM_RESULT) (TPM_BASE + 47))
01422 #define TPM_AUDITFAIL_UNSUCCESSFUL  ((TPM_RESULT) (TPM_BASE + 48))
01423 #define TPM_AUDITFAIL_SUCCESSFUL    ((TPM_RESULT) (TPM_BASE + 49))
01424 #define TPM_NOTRESETABLE            ((TPM_RESULT) (TPM_BASE + 50))
01425 #define TPM_NOTLOCAL                ((TPM_RESULT) (TPM_BASE + 51))
01426 #define TPM_BAD_TYPE                ((TPM_RESULT) (TPM_BASE + 52))
01427 #define TPM_INVALID_RESOURCE        ((TPM_RESULT) (TPM_BASE + 53))
01428 #define TPM_NOTFIPS                 ((TPM_RESULT) (TPM_BASE + 54))
01429 #define TPM_INVALID_FAMILY          ((TPM_RESULT) (TPM_BASE + 55))
01430 #define TPM_NO_NV_PERMISSION        ((TPM_RESULT) (TPM_BASE + 56))
01431 #define TPM_REQUIRES_SIGN           ((TPM_RESULT) (TPM_BASE + 57))
01432 #define TPM_KEY_NOTSUPPORTED        ((TPM_RESULT) (TPM_BASE + 58))
01433 #define TPM_AUTH_CONFLICT           ((TPM_RESULT) (TPM_BASE + 59))
01434 #define TPM_AREA_LOCKED             ((TPM_RESULT) (TPM_BASE + 60))
01435 #define TPM_BAD_LOCALITY            ((TPM_RESULT) (TPM_BASE + 61))
01436 #define TPM_READ_ONLY               ((TPM_RESULT) (TPM_BASE + 62))
01437 #define TPM_PER_NOWRITE             ((TPM_RESULT) (TPM_BASE + 63))
01438 #define TPM_FAMILYCOUNT             ((TPM_RESULT) (TPM_BASE + 64))
01439 #define TPM_WRITE_LOCKED            ((TPM_RESULT) (TPM_BASE + 65))
01440 #define TPM_BAD_ATTRIBUTES          ((TPM_RESULT) (TPM_BASE + 66))
01441 #define TPM_INVALID_STRUCTURE       ((TPM_RESULT) (TPM_BASE + 67))
01442 #define TPM_KEY_OWNER_CONTROL       ((TPM_RESULT) (TPM_BASE + 68))
01443 #define TPM_BAD_COUNTER             ((TPM_RESULT) (TPM_BASE + 69))
01444 #define TPM_NOT_FULLWRITE           ((TPM_RESULT) (TPM_BASE + 70))
01445 #define TPM_CONTEXT_GAP             ((TPM_RESULT) (TPM_BASE + 71))
01446 #define TPM_MAXNVWRITES             ((TPM_RESULT) (TPM_BASE + 72))
01447 #define TPM_NOOPERATOR              ((TPM_RESULT) (TPM_BASE + 73))
01448 #define TPM_RESOURCEMISSING         ((TPM_RESULT) (TPM_BASE + 74))
01449 #define TPM_DELEGATE_LOCK           ((TPM_RESULT) (TPM_BASE + 75))
01450 #define TPM_DELEGATE_FAMILY         ((TPM_RESULT) (TPM_BASE + 76))
01451 #define TPM_DELEGATE_ADMIN          ((TPM_RESULT) (TPM_BASE + 77))
01452 #define TPM_TRANSPORT_NOTEXCLUSIVE  ((TPM_RESULT) (TPM_BASE + 78))
01453 #define TPM_OWNER_CONTROL           ((TPM_RESULT) (TPM_BASE + 79))
01454 #define TPM_DAA_RESOURCES           ((TPM_RESULT) (TPM_BASE + 80))
01455 #define TPM_DAA_INPUT_DATA0         ((TPM_RESULT) (TPM_BASE + 81))
01456 #define TPM_DAA_INPUT_DATA1         ((TPM_RESULT) (TPM_BASE + 82))
01457 #define TPM_DAA_ISSUER_SETTINGS     ((TPM_RESULT) (TPM_BASE + 83))
01458 #define TPM_DAA_TPM_SETTINGS        ((TPM_RESULT) (TPM_BASE + 84))
01459 #define TPM_DAA_STAGE               ((TPM_RESULT) (TPM_BASE + 85))
01460 #define TPM_DAA_ISSUER_VALIDITY     ((TPM_RESULT) (TPM_BASE + 86))
01461 #define TPM_DAA_WRONG_W             ((TPM_RESULT) (TPM_BASE + 87))
01462 #define TPM_BAD_HANDLE              ((TPM_RESULT) (TPM_BASE + 88))
01463 #define TPM_BAD_DELEGATE            ((TPM_RESULT) (TPM_BASE + 89))
01464 #define TPM_BADCONTEXT              ((TPM_RESULT) (TPM_BASE + 90))
01465 #define TPM_TOOMANYCONTEXTS         ((TPM_RESULT) (TPM_BASE + 91))
01466 #define TPM_MA_TICKET_SIGNATURE     ((TPM_RESULT) (TPM_BASE + 92))
01467 #define TPM_MA_DESTINATION          ((TPM_RESULT) (TPM_BASE + 93))
01468 #define TPM_MA_SOURCE               ((TPM_RESULT) (TPM_BASE + 94))
01469 #define TPM_MA_AUTHORITY            ((TPM_RESULT) (TPM_BASE + 95))
01470 #define TPM_PERMANENTEK             ((TPM_RESULT) (TPM_BASE + 97))
01471 #define TPM_BAD_SIGNATURE           ((TPM_RESULT) (TPM_BASE + 98))
01472 #define TPM_NOCONTEXTSPACE          ((TPM_RESULT) (TPM_BASE + 99))
01473 
01474 #define TPM_RETRY                   ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL))
01475 #define TPM_NEEDS_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 1))
01476 #define TPM_DOING_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 2))
01477 #define TPM_DEFEND_LOCK_RUNNING     ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 3))
01478 
01479 //
01480 // Part 2, section 17: Ordinals
01481 //
01482 // Ordinals are 32 bit values. The upper byte contains values that serve as
01483 // flag indicators, the next byte contains values indicating what committee
01484 // designated the ordinal, and the final two bytes contain the Command
01485 // Ordinal Index.
01486 //      3                   2                   1
01487 //    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
01488 //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
01489 //   |P|C|V| Reserved| Purview |     Command Ordinal Index           |
01490 //   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
01491 //
01492 //  Where:
01493 //
01494 //    * P is Protected/Unprotected command. When 0 the command is a Protected
01495 //      command, when 1 the command is an Unprotected command.
01496 //
01497 //    * C is Non-Connection/Connection related command. When 0 this command
01498 //      passes through to either the protected (TPM) or unprotected (TSS)
01499 //      components.
01500 //
01501 //    * V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the
01502 //      command is vendor defined.
01503 //
01504 //    * All reserved area bits are set to 0.
01505 //
01506 
01507 #define TPM_ORD_ActivateIdentity                  ((TPM_COMMAND_CODE) 0x0000007A)
01508 #define TPM_ORD_AuthorizeMigrationKey             ((TPM_COMMAND_CODE) 0x0000002B)
01509 #define TPM_ORD_CertifyKey                        ((TPM_COMMAND_CODE) 0x00000032)
01510 #define TPM_ORD_CertifyKey2                       ((TPM_COMMAND_CODE) 0x00000033)
01511 #define TPM_ORD_CertifySelfTest                   ((TPM_COMMAND_CODE) 0x00000052)
01512 #define TPM_ORD_ChangeAuth                        ((TPM_COMMAND_CODE) 0x0000000C)
01513 #define TPM_ORD_ChangeAuthAsymFinish              ((TPM_COMMAND_CODE) 0x0000000F)
01514 #define TPM_ORD_ChangeAuthAsymStart               ((TPM_COMMAND_CODE) 0x0000000E)
01515 #define TPM_ORD_ChangeAuthOwner                   ((TPM_COMMAND_CODE) 0x00000010)
01516 #define TPM_ORD_CMK_ApproveMA                     ((TPM_COMMAND_CODE) 0x0000001D)
01517 #define TPM_ORD_CMK_ConvertMigration              ((TPM_COMMAND_CODE) 0x00000024)
01518 #define TPM_ORD_CMK_CreateBlob                    ((TPM_COMMAND_CODE) 0x0000001B)
01519 #define TPM_ORD_CMK_CreateKey                     ((TPM_COMMAND_CODE) 0x00000013)
01520 #define TPM_ORD_CMK_CreateTicket                  ((TPM_COMMAND_CODE) 0x00000012)
01521 #define TPM_ORD_CMK_SetRestrictions               ((TPM_COMMAND_CODE) 0x0000001C)
01522 #define TPM_ORD_ContinueSelfTest                  ((TPM_COMMAND_CODE) 0x00000053)
01523 #define TPM_ORD_ConvertMigrationBlob              ((TPM_COMMAND_CODE) 0x0000002A)
01524 #define TPM_ORD_CreateCounter                     ((TPM_COMMAND_CODE) 0x000000DC)
01525 #define TPM_ORD_CreateEndorsementKeyPair          ((TPM_COMMAND_CODE) 0x00000078)
01526 #define TPM_ORD_CreateMaintenanceArchive          ((TPM_COMMAND_CODE) 0x0000002C)
01527 #define TPM_ORD_CreateMigrationBlob               ((TPM_COMMAND_CODE) 0x00000028)
01528 #define TPM_ORD_CreateRevocableEK                 ((TPM_COMMAND_CODE) 0x0000007F)
01529 #define TPM_ORD_CreateWrapKey                     ((TPM_COMMAND_CODE) 0x0000001F)
01530 #define TPM_ORD_DAA_JOIN                          ((TPM_COMMAND_CODE) 0x00000029)
01531 #define TPM_ORD_DAA_SIGN                          ((TPM_COMMAND_CODE) 0x00000031)
01532 #define TPM_ORD_Delegate_CreateKeyDelegation      ((TPM_COMMAND_CODE) 0x000000D4)
01533 #define TPM_ORD_Delegate_CreateOwnerDelegation    ((TPM_COMMAND_CODE) 0x000000D5)
01534 #define TPM_ORD_Delegate_LoadOwnerDelegation      ((TPM_COMMAND_CODE) 0x000000D8)
01535 #define TPM_ORD_Delegate_Manage                   ((TPM_COMMAND_CODE) 0x000000D2)
01536 #define TPM_ORD_Delegate_ReadTable                ((TPM_COMMAND_CODE) 0x000000DB)
01537 #define TPM_ORD_Delegate_UpdateVerification       ((TPM_COMMAND_CODE) 0x000000D1)
01538 #define TPM_ORD_Delegate_VerifyDelegation         ((TPM_COMMAND_CODE) 0x000000D6)
01539 #define TPM_ORD_DirRead                           ((TPM_COMMAND_CODE) 0x0000001A)
01540 #define TPM_ORD_DirWriteAuth                      ((TPM_COMMAND_CODE) 0x00000019)
01541 #define TPM_ORD_DisableForceClear                 ((TPM_COMMAND_CODE) 0x0000005E)
01542 #define TPM_ORD_DisableOwnerClear                 ((TPM_COMMAND_CODE) 0x0000005C)
01543 #define TPM_ORD_DisablePubekRead                  ((TPM_COMMAND_CODE) 0x0000007E)
01544 #define TPM_ORD_DSAP                              ((TPM_COMMAND_CODE) 0x00000011)
01545 #define TPM_ORD_EstablishTransport                ((TPM_COMMAND_CODE) 0x000000E6)
01546 #define TPM_ORD_EvictKey                          ((TPM_COMMAND_CODE) 0x00000022)
01547 #define TPM_ORD_ExecuteTransport                  ((TPM_COMMAND_CODE) 0x000000E7)
01548 #define TPM_ORD_Extend                            ((TPM_COMMAND_CODE) 0x00000014)
01549 #define TPM_ORD_FieldUpgrade                      ((TPM_COMMAND_CODE) 0x000000AA)
01550 #define TPM_ORD_FlushSpecific                     ((TPM_COMMAND_CODE) 0x000000BA)
01551 #define TPM_ORD_ForceClear                        ((TPM_COMMAND_CODE) 0x0000005D)
01552 #define TPM_ORD_GetAuditDigest                    ((TPM_COMMAND_CODE) 0x00000085)
01553 #define TPM_ORD_GetAuditDigestSigned              ((TPM_COMMAND_CODE) 0x00000086)
01554 #define TPM_ORD_GetAuditEvent                     ((TPM_COMMAND_CODE) 0x00000082)
01555 #define TPM_ORD_GetAuditEventSigned               ((TPM_COMMAND_CODE) 0x00000083)
01556 #define TPM_ORD_GetCapability                     ((TPM_COMMAND_CODE) 0x00000065)
01557 #define TPM_ORD_GetCapabilityOwner                ((TPM_COMMAND_CODE) 0x00000066)
01558 #define TPM_ORD_GetCapabilitySigned               ((TPM_COMMAND_CODE) 0x00000064)
01559 #define TPM_ORD_GetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008C)
01560 #define TPM_ORD_GetPubKey                         ((TPM_COMMAND_CODE) 0x00000021)
01561 #define TPM_ORD_GetRandom                         ((TPM_COMMAND_CODE) 0x00000046)
01562 #define TPM_ORD_GetTestResult                     ((TPM_COMMAND_CODE) 0x00000054)
01563 #define TPM_ORD_GetTicks                          ((TPM_COMMAND_CODE) 0x000000F1)
01564 #define TPM_ORD_IncrementCounter                  ((TPM_COMMAND_CODE) 0x000000DD)
01565 #define TPM_ORD_Init                              ((TPM_COMMAND_CODE) 0x00000097)
01566 #define TPM_ORD_KeyControlOwner                   ((TPM_COMMAND_CODE) 0x00000023)
01567 #define TPM_ORD_KillMaintenanceFeature            ((TPM_COMMAND_CODE) 0x0000002E)
01568 #define TPM_ORD_LoadAuthContext                   ((TPM_COMMAND_CODE) 0x000000B7)
01569 #define TPM_ORD_LoadContext                       ((TPM_COMMAND_CODE) 0x000000B9)
01570 #define TPM_ORD_LoadKey                           ((TPM_COMMAND_CODE) 0x00000020)
01571 #define TPM_ORD_LoadKey2                          ((TPM_COMMAND_CODE) 0x00000041)
01572 #define TPM_ORD_LoadKeyContext                    ((TPM_COMMAND_CODE) 0x000000B5)
01573 #define TPM_ORD_LoadMaintenanceArchive            ((TPM_COMMAND_CODE) 0x0000002D)
01574 #define TPM_ORD_LoadManuMaintPub                  ((TPM_COMMAND_CODE) 0x0000002F)
01575 #define TPM_ORD_MakeIdentity                      ((TPM_COMMAND_CODE) 0x00000079)
01576 #define TPM_ORD_MigrateKey                        ((TPM_COMMAND_CODE) 0x00000025)
01577 #define TPM_ORD_NV_DefineSpace                    ((TPM_COMMAND_CODE) 0x000000CC)
01578 #define TPM_ORD_NV_ReadValue                      ((TPM_COMMAND_CODE) 0x000000CF)
01579 #define TPM_ORD_NV_ReadValueAuth                  ((TPM_COMMAND_CODE) 0x000000D0)
01580 #define TPM_ORD_NV_WriteValue                     ((TPM_COMMAND_CODE) 0x000000CD)
01581 #define TPM_ORD_NV_WriteValueAuth                 ((TPM_COMMAND_CODE) 0x000000CE)
01582 #define TPM_ORD_OIAP                              ((TPM_COMMAND_CODE) 0x0000000A)
01583 #define TPM_ORD_OSAP                              ((TPM_COMMAND_CODE) 0x0000000B)
01584 #define TPM_ORD_OwnerClear                        ((TPM_COMMAND_CODE) 0x0000005B)
01585 #define TPM_ORD_OwnerReadInternalPub              ((TPM_COMMAND_CODE) 0x00000081)
01586 #define TPM_ORD_OwnerReadPubek                    ((TPM_COMMAND_CODE) 0x0000007D)
01587 #define TPM_ORD_OwnerSetDisable                   ((TPM_COMMAND_CODE) 0x0000006E)
01588 #define TPM_ORD_PCR_Reset                         ((TPM_COMMAND_CODE) 0x000000C8)
01589 #define TPM_ORD_PcrRead                           ((TPM_COMMAND_CODE) 0x00000015)
01590 #define TPM_ORD_PhysicalDisable                   ((TPM_COMMAND_CODE) 0x00000070)
01591 #define TPM_ORD_PhysicalEnable                    ((TPM_COMMAND_CODE) 0x0000006F)
01592 #define TPM_ORD_PhysicalSetDeactivated            ((TPM_COMMAND_CODE) 0x00000072)
01593 #define TPM_ORD_Quote                             ((TPM_COMMAND_CODE) 0x00000016)
01594 #define TPM_ORD_Quote2                            ((TPM_COMMAND_CODE) 0x0000003E)
01595 #define TPM_ORD_ReadCounter                       ((TPM_COMMAND_CODE) 0x000000DE)
01596 #define TPM_ORD_ReadManuMaintPub                  ((TPM_COMMAND_CODE) 0x00000030)
01597 #define TPM_ORD_ReadPubek                         ((TPM_COMMAND_CODE) 0x0000007C)
01598 #define TPM_ORD_ReleaseCounter                    ((TPM_COMMAND_CODE) 0x000000DF)
01599 #define TPM_ORD_ReleaseCounterOwner               ((TPM_COMMAND_CODE) 0x000000E0)
01600 #define TPM_ORD_ReleaseTransportSigned            ((TPM_COMMAND_CODE) 0x000000E8)
01601 #define TPM_ORD_Reset                             ((TPM_COMMAND_CODE) 0x0000005A)
01602 #define TPM_ORD_ResetLockValue                    ((TPM_COMMAND_CODE) 0x00000040)
01603 #define TPM_ORD_RevokeTrust                       ((TPM_COMMAND_CODE) 0x00000080)
01604 #define TPM_ORD_SaveAuthContext                   ((TPM_COMMAND_CODE) 0x000000B6)
01605 #define TPM_ORD_SaveContext                       ((TPM_COMMAND_CODE) 0x000000B8)
01606 #define TPM_ORD_SaveKeyContext                    ((TPM_COMMAND_CODE) 0x000000B4)
01607 #define TPM_ORD_SaveState                         ((TPM_COMMAND_CODE) 0x00000098)
01608 #define TPM_ORD_Seal                              ((TPM_COMMAND_CODE) 0x00000017)
01609 #define TPM_ORD_Sealx                             ((TPM_COMMAND_CODE) 0x0000003D)
01610 #define TPM_ORD_SelfTestFull                      ((TPM_COMMAND_CODE) 0x00000050)
01611 #define TPM_ORD_SetCapability                     ((TPM_COMMAND_CODE) 0x0000003F)
01612 #define TPM_ORD_SetOperatorAuth                   ((TPM_COMMAND_CODE) 0x00000074)
01613 #define TPM_ORD_SetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008D)
01614 #define TPM_ORD_SetOwnerInstall                   ((TPM_COMMAND_CODE) 0x00000071)
01615 #define TPM_ORD_SetOwnerPointer                   ((TPM_COMMAND_CODE) 0x00000075)
01616 #define TPM_ORD_SetRedirection                    ((TPM_COMMAND_CODE) 0x0000009A)
01617 #define TPM_ORD_SetTempDeactivated                ((TPM_COMMAND_CODE) 0x00000073)
01618 #define TPM_ORD_SHA1Complete                      ((TPM_COMMAND_CODE) 0x000000A2)
01619 #define TPM_ORD_SHA1CompleteExtend                ((TPM_COMMAND_CODE) 0x000000A3)
01620 #define TPM_ORD_SHA1Start                         ((TPM_COMMAND_CODE) 0x000000A0)
01621 #define TPM_ORD_SHA1Update                        ((TPM_COMMAND_CODE) 0x000000A1)
01622 #define TPM_ORD_Sign                              ((TPM_COMMAND_CODE) 0x0000003C)
01623 #define TPM_ORD_Startup                           ((TPM_COMMAND_CODE) 0x00000099)
01624 #define TPM_ORD_StirRandom                        ((TPM_COMMAND_CODE) 0x00000047)
01625 #define TPM_ORD_TakeOwnership                     ((TPM_COMMAND_CODE) 0x0000000D)
01626 #define TPM_ORD_Terminate_Handle                  ((TPM_COMMAND_CODE) 0x00000096)
01627 #define TPM_ORD_TickStampBlob                     ((TPM_COMMAND_CODE) 0x000000F2)
01628 #define TPM_ORD_UnBind                            ((TPM_COMMAND_CODE) 0x0000001E)
01629 #define TPM_ORD_Unseal                            ((TPM_COMMAND_CODE) 0x00000018)
01630 #define TSC_ORD_PhysicalPresence                  ((TPM_COMMAND_CODE) 0x4000000A)
01631 #define TSC_ORD_ResetEstablishmentBit             ((TPM_COMMAND_CODE) 0x4000000B)
01632 
01633 //
01634 // Part 2, section 18: Context structures
01635 //
01636 
01637 ///
01638 /// Part 2, section 18.1: TPM_CONTEXT_BLOB
01639 ///
01640 typedef struct tdTPM_CONTEXT_BLOB {
01641   TPM_STRUCTURE_TAG               tag;
01642   TPM_RESOURCE_TYPE               resourceType;
01643   TPM_HANDLE                      handle;
01644   UINT8                           label[16];
01645   UINT32                          contextCount;
01646   TPM_DIGEST                      integrityDigest;
01647   UINT32                          additionalSize;
01648   UINT8                           *additionalData;
01649   UINT32                          sensitiveSize;
01650   UINT8                           *sensitiveData;
01651 } TPM_CONTEXT_BLOB;
01652 
01653 ///
01654 /// Part 2, section 18.2 TPM_CONTEXT_SENSITIVE
01655 ///
01656 typedef struct tdTPM_CONTEXT_SENSITIVE {
01657   TPM_STRUCTURE_TAG               tag;
01658   TPM_NONCE                       contextNonce;
01659   UINT32                          internalSize;
01660   UINT8                           *internalData;
01661 } TPM_CONTEXT_SENSITIVE;
01662 
01663 //
01664 // Part 2, section 19: NV Structures
01665 //
01666 
01667 //
01668 // Part 2, section 19.1.1: Required TPM_NV_INDEX values
01669 //
01670 #define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)
01671 #define TPM_NV_INDEX0                  ((UINT32)0x00000000)
01672 #define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)
01673 #define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)
01674 #define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)
01675 #define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)
01676 #define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)
01677 //
01678 // Part 2, section 19.1.2: Reserved Index values
01679 //
01680 #define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)
01681 #define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)
01682 #define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)
01683 #define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)
01684 #define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)
01685 #define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)
01686 
01687 ///
01688 /// Part 2, section 19.2: TPM_NV_ATTRIBUTES
01689 ///
01690 typedef struct tdTPM_NV_ATTRIBUTES {
01691   TPM_STRUCTURE_TAG               tag;
01692   UINT32                          attributes;
01693 } TPM_NV_ATTRIBUTES;
01694 
01695 #define TPM_NV_PER_READ_STCLEAR        (BIT31)
01696 #define TPM_NV_PER_AUTHREAD            (BIT18)
01697 #define TPM_NV_PER_OWNERREAD           (BIT17)
01698 #define TPM_NV_PER_PPREAD              (BIT16)
01699 #define TPM_NV_PER_GLOBALLOCK          (BIT15)
01700 #define TPM_NV_PER_WRITE_STCLEAR       (BIT14)
01701 #define TPM_NV_PER_WRITEDEFINE         (BIT13)
01702 #define TPM_NV_PER_WRITEALL            (BIT12)
01703 #define TPM_NV_PER_AUTHWRITE           (BIT2)
01704 #define TPM_NV_PER_OWNERWRITE          (BIT1)
01705 #define TPM_NV_PER_PPWRITE             (BIT0)
01706 
01707 ///
01708 /// Part 2, section 19.3: TPM_NV_DATA_PUBLIC
01709 ///
01710 typedef struct tdTPM_NV_DATA_PUBLIC {
01711   TPM_STRUCTURE_TAG               tag;
01712   TPM_NV_INDEX                    nvIndex;
01713   TPM_PCR_INFO_SHORT              pcrInfoRead;
01714   TPM_PCR_INFO_SHORT              pcrInfoWrite;
01715   TPM_NV_ATTRIBUTES               permission;
01716   BOOLEAN                         bReadSTClear;
01717   BOOLEAN                         bWriteSTClear;
01718   BOOLEAN                         bWriteDefine;
01719   UINT32                          dataSize;
01720 } TPM_NV_DATA_PUBLIC;
01721 
01722 //
01723 // Part 2, section 20: Delegate Structures
01724 //
01725 
01726 #define TPM_DEL_OWNER_BITS          ((UINT32)0x00000001)
01727 #define TPM_DEL_KEY_BITS            ((UINT32)0x00000002)
01728 ///
01729 /// Part 2, section 20.2: Delegate Definitions
01730 ///
01731 typedef struct tdTPM_DELEGATIONS {
01732   TPM_STRUCTURE_TAG               tag;
01733   UINT32                          delegateType;
01734   UINT32                          per1;
01735   UINT32                          per2;
01736 } TPM_DELEGATIONS;
01737 
01738 //
01739 // Part 2, section 20.2.1: Owner Permission Settings
01740 //
01741 #define TPM_DELEGATE_SetOrdinalAuditStatus          (BIT30)
01742 #define TPM_DELEGATE_DirWriteAuth                   (BIT29)
01743 #define TPM_DELEGATE_CMK_ApproveMA                  (BIT28)
01744 #define TPM_DELEGATE_NV_WriteValue                  (BIT27)
01745 #define TPM_DELEGATE_CMK_CreateTicket               (BIT26)
01746 #define TPM_DELEGATE_NV_ReadValue                   (BIT25)
01747 #define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (BIT24)
01748 #define TPM_DELEGATE_DAA_Join                       (BIT23)
01749 #define TPM_DELEGATE_AuthorizeMigrationKey          (BIT22)
01750 #define TPM_DELEGATE_CreateMaintenanceArchive       (BIT21)
01751 #define TPM_DELEGATE_LoadMaintenanceArchive         (BIT20)
01752 #define TPM_DELEGATE_KillMaintenanceFeature         (BIT19)
01753 #define TPM_DELEGATE_OwnerReadInteralPub            (BIT18)
01754 #define TPM_DELEGATE_ResetLockValue                 (BIT17)
01755 #define TPM_DELEGATE_OwnerClear                     (BIT16)
01756 #define TPM_DELEGATE_DisableOwnerClear              (BIT15)
01757 #define TPM_DELEGATE_NV_DefineSpace                 (BIT14)
01758 #define TPM_DELEGATE_OwnerSetDisable                (BIT13)
01759 #define TPM_DELEGATE_SetCapability                  (BIT12)
01760 #define TPM_DELEGATE_MakeIdentity                   (BIT11)
01761 #define TPM_DELEGATE_ActivateIdentity               (BIT10)
01762 #define TPM_DELEGATE_OwnerReadPubek                 (BIT9)
01763 #define TPM_DELEGATE_DisablePubekRead               (BIT8)
01764 #define TPM_DELEGATE_SetRedirection                 (BIT7)
01765 #define TPM_DELEGATE_FieldUpgrade                   (BIT6)
01766 #define TPM_DELEGATE_Delegate_UpdateVerification    (BIT5)
01767 #define TPM_DELEGATE_CreateCounter                  (BIT4)
01768 #define TPM_DELEGATE_ReleaseCounterOwner            (BIT3)
01769 #define TPM_DELEGATE_DelegateManage                 (BIT2)
01770 #define TPM_DELEGATE_Delegate_CreateOwnerDelegation (BIT1)
01771 #define TPM_DELEGATE_DAA_Sign                       (BIT0)
01772 
01773 //
01774 // Part 2, section 20.2.3: Key Permission settings
01775 //
01776 #define TPM_KEY_DELEGATE_CMK_ConvertMigration       (BIT28)
01777 #define TPM_KEY_DELEGATE_TickStampBlob              (BIT27)
01778 #define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (BIT26)
01779 #define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (BIT25)
01780 #define TPM_KEY_DELEGATE_CMK_CreateKey              (BIT24)
01781 #define TPM_KEY_DELEGATE_MigrateKey                 (BIT23)
01782 #define TPM_KEY_DELEGATE_LoadKey2                   (BIT22)
01783 #define TPM_KEY_DELEGATE_EstablishTransport         (BIT21)
01784 #define TPM_KEY_DELEGATE_ReleaseTransportSigned     (BIT20)
01785 #define TPM_KEY_DELEGATE_Quote2                     (BIT19)
01786 #define TPM_KEY_DELEGATE_Sealx                      (BIT18)
01787 #define TPM_KEY_DELEGATE_MakeIdentity               (BIT17)
01788 #define TPM_KEY_DELEGATE_ActivateIdentity           (BIT16)
01789 #define TPM_KEY_DELEGATE_GetAuditDigestSigned       (BIT15)
01790 #define TPM_KEY_DELEGATE_Sign                       (BIT14)
01791 #define TPM_KEY_DELEGATE_CertifyKey2                (BIT13)
01792 #define TPM_KEY_DELEGATE_CertifyKey                 (BIT12)
01793 #define TPM_KEY_DELEGATE_CreateWrapKey              (BIT11)
01794 #define TPM_KEY_DELEGATE_CMK_CreateBlob             (BIT10)
01795 #define TPM_KEY_DELEGATE_CreateMigrationBlob        (BIT9)
01796 #define TPM_KEY_DELEGATE_ConvertMigrationBlob       (BIT8)
01797 #define TPM_KEY_DELEGATE_CreateKeyDelegation        (BIT7)
01798 #define TPM_KEY_DELEGATE_ChangeAuth                 (BIT6)
01799 #define TPM_KEY_DELEGATE_GetPubKey                  (BIT5)
01800 #define TPM_KEY_DELEGATE_UnBind                     (BIT4)
01801 #define TPM_KEY_DELEGATE_Quote                      (BIT3)
01802 #define TPM_KEY_DELEGATE_Unseal                     (BIT2)
01803 #define TPM_KEY_DELEGATE_Seal                       (BIT1)
01804 #define TPM_KEY_DELEGATE_LoadKey                    (BIT0)
01805 
01806 //
01807 // Part 2, section 20.3: TPM_FAMILY_FLAGS
01808 //
01809 #define TPM_DELEGATE_ADMIN_LOCK           (BIT1)
01810 #define TPM_FAMFLAG_ENABLE                (BIT0)
01811 
01812 ///
01813 /// Part 2, section 20.4: TPM_FAMILY_LABEL
01814 ///
01815 typedef struct tdTPM_FAMILY_LABEL {
01816   UINT8                           label;
01817 } TPM_FAMILY_LABEL;
01818 
01819 ///
01820 /// Part 2, section 20.5: TPM_FAMILY_TABLE_ENTRY
01821 ///
01822 typedef struct tdTPM_FAMILY_TABLE_ENTRY {
01823   TPM_STRUCTURE_TAG               tag;
01824   TPM_FAMILY_LABEL                label;
01825   TPM_FAMILY_ID                   familyID;
01826   TPM_FAMILY_VERIFICATION         verificationCount;
01827   TPM_FAMILY_FLAGS                flags;
01828 } TPM_FAMILY_TABLE_ENTRY;
01829 
01830 //
01831 // Part 2, section 20.6: TPM_FAMILY_TABLE
01832 //
01833 #define TPM_NUM_FAMILY_TABLE_ENTRY_MIN 8
01834 
01835 typedef struct tdTPM_FAMILY_TABLE{
01836   TPM_FAMILY_TABLE_ENTRY famTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
01837 } TPM_FAMILY_TABLE;
01838 
01839 ///
01840 /// Part 2, section 20.7: TPM_DELEGATE_LABEL
01841 ///
01842 typedef struct tdTPM_DELEGATE_LABEL {
01843   UINT8                           label;
01844 } TPM_DELEGATE_LABEL;
01845 
01846 ///
01847 /// Part 2, section 20.8: TPM_DELEGATE_PUBLIC
01848 ///
01849 typedef struct tdTPM_DELEGATE_PUBLIC {
01850   TPM_STRUCTURE_TAG               tag;
01851   TPM_DELEGATE_LABEL              label;
01852   TPM_PCR_INFO_SHORT              pcrInfo;
01853   TPM_DELEGATIONS                 permissions;
01854   TPM_FAMILY_ID                   familyID;
01855   TPM_FAMILY_VERIFICATION         verificationCount;
01856 } TPM_DELEGATE_PUBLIC;
01857 
01858 ///
01859 /// Part 2, section 20.9: TPM_DELEGATE_TABLE_ROW
01860 ///
01861 typedef struct tdTPM_DELEGATE_TABLE_ROW {
01862   TPM_STRUCTURE_TAG               tag;
01863   TPM_DELEGATE_PUBLIC             pub;
01864   TPM_SECRET                      authValue;
01865 } TPM_DELEGATE_TABLE_ROW;
01866 
01867 //
01868 // Part 2, section 20.10: TPM_DELEGATE_TABLE
01869 //
01870 #define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
01871 
01872 typedef struct tdTPM_DELEGATE_TABLE{
01873   TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
01874 } TPM_DELEGATE_TABLE;
01875 
01876 ///
01877 /// Part 2, section 20.11: TPM_DELEGATE_SENSITIVE
01878 ///
01879 typedef struct tdTPM_DELEGATE_SENSITIVE {
01880   TPM_STRUCTURE_TAG               tag;
01881   TPM_SECRET                      authValue;
01882 } TPM_DELEGATE_SENSITIVE;
01883 
01884 ///
01885 /// Part 2, section 20.12: TPM_DELEGATE_OWNER_BLOB
01886 ///
01887 typedef struct tdTPM_DELEGATE_OWNER_BLOB {
01888   TPM_STRUCTURE_TAG               tag;
01889   TPM_DELEGATE_PUBLIC             pub;
01890   TPM_DIGEST                      integrityDigest;
01891   UINT32                          additionalSize;
01892   UINT8                           *additionalArea;
01893   UINT32                          sensitiveSize;
01894   UINT8                           *sensitiveArea;
01895 } TPM_DELEGATE_OWNER_BLOB;
01896 
01897 ///
01898 /// Part 2, section 20.13: TTPM_DELEGATE_KEY_BLOB
01899 ///
01900 typedef struct tdTPM_DELEGATE_KEY_BLOB {
01901   TPM_STRUCTURE_TAG               tag;
01902   TPM_DELEGATE_PUBLIC             pub;
01903   TPM_DIGEST                      integrityDigest;
01904   TPM_DIGEST                      pubKeyDigest;
01905   UINT32                          additionalSize;
01906   UINT8                           *additionalArea;
01907   UINT32                          sensitiveSize;
01908   UINT8                           *sensitiveArea;
01909 } TPM_DELEGATE_KEY_BLOB;
01910 
01911 //
01912 // Part 2, section 20.14: TPM_FAMILY_OPERATION Values
01913 //
01914 #define TPM_FAMILY_CREATE                 ((UINT32)0x00000001)
01915 #define TPM_FAMILY_ENABLE                 ((UINT32)0x00000002)
01916 #define TPM_FAMILY_ADMIN                  ((UINT32)0x00000003)
01917 #define TPM_FAMILY_INVALIDATE             ((UINT32)0x00000004)
01918 
01919 //
01920 // Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability
01921 //
01922 #define TPM_CAP_ORD                     ((TPM_CAPABILITY_AREA) 0x00000001)
01923 #define TPM_CAP_ALG                     ((TPM_CAPABILITY_AREA) 0x00000002)
01924 #define TPM_CAP_PID                     ((TPM_CAPABILITY_AREA) 0x00000003)
01925 #define TPM_CAP_FLAG                    ((TPM_CAPABILITY_AREA) 0x00000004)
01926 #define TPM_CAP_PROPERTY                ((TPM_CAPABILITY_AREA) 0x00000005)
01927 #define TPM_CAP_VERSION                 ((TPM_CAPABILITY_AREA) 0x00000006)
01928 #define TPM_CAP_KEY_HANDLE              ((TPM_CAPABILITY_AREA) 0x00000007)
01929 #define TPM_CAP_CHECK_LOADED            ((TPM_CAPABILITY_AREA) 0x00000008)
01930 #define TPM_CAP_SYM_MODE                ((TPM_CAPABILITY_AREA) 0x00000009)
01931 #define TPM_CAP_KEY_STATUS              ((TPM_CAPABILITY_AREA) 0x0000000C)
01932 #define TPM_CAP_NV_LIST                 ((TPM_CAPABILITY_AREA) 0x0000000D)
01933 #define TPM_CAP_MFR                     ((TPM_CAPABILITY_AREA) 0x00000010)
01934 #define TPM_CAP_NV_INDEX                ((TPM_CAPABILITY_AREA) 0x00000011)
01935 #define TPM_CAP_TRANS_ALG               ((TPM_CAPABILITY_AREA) 0x00000012)
01936 #define TPM_CAP_HANDLE                  ((TPM_CAPABILITY_AREA) 0x00000014)
01937 #define TPM_CAP_TRANS_ES                ((TPM_CAPABILITY_AREA) 0x00000015)
01938 #define TPM_CAP_AUTH_ENCRYPT            ((TPM_CAPABILITY_AREA) 0x00000017)
01939 #define TPM_CAP_SELECT_SIZE             ((TPM_CAPABILITY_AREA) 0x00000018)
01940 #define TPM_CAP_VERSION_VAL             ((TPM_CAPABILITY_AREA) 0x0000001A)
01941 
01942 #define TPM_CAP_FLAG_PERMANENT          ((TPM_CAPABILITY_AREA) 0x00000108)
01943 #define TPM_CAP_FLAG_VOLATILE           ((TPM_CAPABILITY_AREA) 0x00000109)
01944 
01945 //
01946 // Part 2, section 21.2: CAP_PROPERTY Subcap values for GetCapability
01947 //
01948 #define TPM_CAP_PROP_PCR                ((TPM_CAPABILITY_AREA) 0x00000101)
01949 #define TPM_CAP_PROP_DIR                ((TPM_CAPABILITY_AREA) 0x00000102)
01950 #define TPM_CAP_PROP_MANUFACTURER       ((TPM_CAPABILITY_AREA) 0x00000103)
01951 #define TPM_CAP_PROP_KEYS               ((TPM_CAPABILITY_AREA) 0x00000104)
01952 #define TPM_CAP_PROP_MIN_COUNTER        ((TPM_CAPABILITY_AREA) 0x00000107)
01953 #define TPM_CAP_PROP_AUTHSESS           ((TPM_CAPABILITY_AREA) 0x0000010A)
01954 #define TPM_CAP_PROP_TRANSESS           ((TPM_CAPABILITY_AREA) 0x0000010B)
01955 #define TPM_CAP_PROP_COUNTERS           ((TPM_CAPABILITY_AREA) 0x0000010C)
01956 #define TPM_CAP_PROP_MAX_AUTHSESS       ((TPM_CAPABILITY_AREA) 0x0000010D)
01957 #define TPM_CAP_PROP_MAX_TRANSESS       ((TPM_CAPABILITY_AREA) 0x0000010E)
01958 #define TPM_CAP_PROP_MAX_COUNTERS       ((TPM_CAPABILITY_AREA) 0x0000010F)
01959 #define TPM_CAP_PROP_MAX_KEYS           ((TPM_CAPABILITY_AREA) 0x00000110)
01960 #define TPM_CAP_PROP_OWNER              ((TPM_CAPABILITY_AREA) 0x00000111)
01961 #define TPM_CAP_PROP_CONTEXT            ((TPM_CAPABILITY_AREA) 0x00000112)
01962 #define TPM_CAP_PROP_MAX_CONTEXT        ((TPM_CAPABILITY_AREA) 0x00000113)
01963 #define TPM_CAP_PROP_FAMILYROWS         ((TPM_CAPABILITY_AREA) 0x00000114)
01964 #define TPM_CAP_PROP_TIS_TIMEOUT        ((TPM_CAPABILITY_AREA) 0x00000115)
01965 #define TPM_CAP_PROP_STARTUP_EFFECT     ((TPM_CAPABILITY_AREA) 0x00000116)
01966 #define TPM_CAP_PROP_DELEGATE_ROW       ((TPM_CAPABILITY_AREA) 0x00000117)
01967 #define TPM_CAP_PROP_DAA_MAX            ((TPM_CAPABILITY_AREA) 0x00000119)
01968 #define CAP_PROP_SESSION_DAA            ((TPM_CAPABILITY_AREA) 0x0000011A)
01969 #define TPM_CAP_PROP_CONTEXT_DIST       ((TPM_CAPABILITY_AREA) 0x0000011B)
01970 #define TPM_CAP_PROP_DAA_INTERRUPT      ((TPM_CAPABILITY_AREA) 0x0000011C)
01971 #define TPM_CAP_PROP_SESSIONS           ((TPM_CAPABILITY_AREA) 0x0000011D)
01972 #define TPM_CAP_PROP_MAX_SESSIONS       ((TPM_CAPABILITY_AREA) 0x0000011E)
01973 #define TPM_CAP_PROP_CMK_RESTRICTION    ((TPM_CAPABILITY_AREA) 0x0000011F)
01974 #define TPM_CAP_PROP_DURATION           ((TPM_CAPABILITY_AREA) 0x00000120)
01975 #define TPM_CAP_PROP_ACTIVE_COUNTER     ((TPM_CAPABILITY_AREA) 0x00000122)
01976 #define TPM_CAP_PROP_MAX_NV_AVAILABLE   ((TPM_CAPABILITY_AREA) 0x00000123)
01977 #define TPM_CAP_PROP_INPUT_BUFFER       ((TPM_CAPABILITY_AREA) 0x00000124)
01978 
01979 //
01980 // Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability
01981 //
01982 #define TPM_SET_PERM_FLAGS              ((TPM_CAPABILITY_AREA) 0x00000001)
01983 #define TPM_SET_PERM_DATA               ((TPM_CAPABILITY_AREA) 0x00000002)
01984 #define TPM_SET_STCLEAR_FLAGS           ((TPM_CAPABILITY_AREA) 0x00000003)
01985 #define TPM_SET_STCLEAR_DATA            ((TPM_CAPABILITY_AREA) 0x00000004)
01986 #define TPM_SET_STANY_FLAGS             ((TPM_CAPABILITY_AREA) 0x00000005)
01987 #define TPM_SET_STANY_DATA              ((TPM_CAPABILITY_AREA) 0x00000006)
01988 
01989 ///
01990 /// Part 2, section 21.6: TPM_CAP_VERSION_INFO
01991 ///   [size_is(vendorSpecificSize)] BYTE* vendorSpecific;
01992 ///
01993 typedef struct tdTPM_CAP_VERSION_INFO {
01994   TPM_STRUCTURE_TAG                 tag;
01995   TPM_VERSION                       version;
01996   UINT16                            specLevel;
01997   UINT8                             errataRev;
01998   UINT8                             tpmVendorID[4];
01999   UINT16                            vendorSpecificSize;
02000   UINT8                             *vendorSpecific;
02001 } TPM_CAP_VERSION_INFO;
02002 
02003 ///
02004 /// Part 2, section 21.10: TPM_DA_ACTION_TYPE
02005 ///
02006 typedef struct tdTPM_DA_ACTION_TYPE {
02007   TPM_STRUCTURE_TAG                 tag;
02008   UINT32                            actions;
02009 } TPM_DA_ACTION_TYPE;
02010 
02011 #define TPM_DA_ACTION_FAILURE_MODE     (((UINT32)1)<<3)
02012 #define TPM_DA_ACTION_DEACTIVATE       (((UINT32)1)<<2)
02013 #define TPM_DA_ACTION_DISABLE          (((UINT32)1)<<1)
02014 #define TPM_DA_ACTION_TIMEOUT          (((UINT32)1)<<0)
02015 
02016 ///
02017 /// Part 2, section 21.7: TPM_DA_INFO
02018 ///
02019 typedef struct tdTPM_DA_INFO {
02020   TPM_STRUCTURE_TAG                 tag;
02021   TPM_DA_STATE                      state;
02022   UINT16                            currentCount;
02023   UINT16                            thresholdCount;
02024   TPM_DA_ACTION_TYPE                actionAtThreshold;
02025   UINT32                            actionDependValue;
02026   UINT32                            vendorDataSize;
02027   UINT8                             *vendorData;
02028 } TPM_DA_INFO;
02029 
02030 ///
02031 /// Part 2, section 21.8: TPM_DA_INFO_LIMITED
02032 ///
02033 typedef struct tdTPM_DA_INFO_LIMITED {
02034   TPM_STRUCTURE_TAG                 tag;
02035   TPM_DA_STATE                      state;
02036   TPM_DA_ACTION_TYPE                actionAtThreshold;
02037   UINT32                            vendorDataSize;
02038   UINT8                             *vendorData;
02039 } TPM_DA_INFO_LIMITED;
02040 
02041 //
02042 // Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability
02043 //
02044 #define TPM_DA_STATE_INACTIVE          ((UINT8)0x00)
02045 #define TPM_DA_STATE_ACTIVE            ((UINT8)0x01)
02046 
02047 //
02048 // Part 2, section 22: DAA Structures
02049 //
02050 
02051 //
02052 // Part 2, section 22.1: Size definitions
02053 //
02054 #define TPM_DAA_SIZE_r0                (43)
02055 #define TPM_DAA_SIZE_r1                (43)
02056 #define TPM_DAA_SIZE_r2                (128)
02057 #define TPM_DAA_SIZE_r3                (168)
02058 #define TPM_DAA_SIZE_r4                (219)
02059 #define TPM_DAA_SIZE_NT                (20)
02060 #define TPM_DAA_SIZE_v0                (128)
02061 #define TPM_DAA_SIZE_v1                (192)
02062 #define TPM_DAA_SIZE_NE                (256)
02063 #define TPM_DAA_SIZE_w                 (256)
02064 #define TPM_DAA_SIZE_issuerModulus     (256)
02065 //
02066 // Part 2, section 22.2: Constant definitions
02067 //
02068 #define TPM_DAA_power0                 (104)
02069 #define TPM_DAA_power1                 (1024)
02070 
02071 ///
02072 /// Part 2, section 22.3: TPM_DAA_ISSUER
02073 ///
02074 typedef struct tdTPM_DAA_ISSUER {
02075   TPM_STRUCTURE_TAG               tag;
02076   TPM_DIGEST                      DAA_digest_R0;
02077   TPM_DIGEST                      DAA_digest_R1;
02078   TPM_DIGEST                      DAA_digest_S0;
02079   TPM_DIGEST                      DAA_digest_S1;
02080   TPM_DIGEST                      DAA_digest_n;
02081   TPM_DIGEST                      DAA_digest_gamma;
02082   UINT8                           DAA_generic_q[26];
02083 } TPM_DAA_ISSUER;
02084 
02085 ///
02086 /// Part 2, section 22.4: TPM_DAA_TPM
02087 ///
02088 typedef struct tdTPM_DAA_TPM {
02089   TPM_STRUCTURE_TAG               tag;
02090   TPM_DIGEST                      DAA_digestIssuer;
02091   TPM_DIGEST                      DAA_digest_v0;
02092   TPM_DIGEST                      DAA_digest_v1;
02093   TPM_DIGEST                      DAA_rekey;
02094   UINT32                          DAA_count;
02095 } TPM_DAA_TPM;
02096 
02097 ///
02098 /// Part 2, section 22.5: TPM_DAA_CONTEXT
02099 ///
02100 typedef struct tdTPM_DAA_CONTEXT {
02101   TPM_STRUCTURE_TAG               tag;
02102   TPM_DIGEST                      DAA_digestContext;
02103   TPM_DIGEST                      DAA_digest;
02104   TPM_DAA_CONTEXT_SEED            DAA_contextSeed;
02105   UINT8                           DAA_scratch[256];
02106   UINT8                           DAA_stage;
02107 } TPM_DAA_CONTEXT;
02108 
02109 ///
02110 /// Part 2, section 22.6: TPM_DAA_JOINDATA
02111 ///
02112 typedef struct tdTPM_DAA_JOINDATA {
02113   UINT8                           DAA_join_u0[128];
02114   UINT8                           DAA_join_u1[138];
02115   TPM_DIGEST                      DAA_digest_n0;
02116 } TPM_DAA_JOINDATA;
02117 
02118 ///
02119 /// Part 2, section 22.8: TPM_DAA_BLOB
02120 ///
02121 typedef struct tdTPM_DAA_BLOB {
02122   TPM_STRUCTURE_TAG               tag;
02123   TPM_RESOURCE_TYPE               resourceType;
02124   UINT8                           label[16];
02125   TPM_DIGEST                      blobIntegrity;
02126   UINT32                          additionalSize;
02127   UINT8                           *additionalData;
02128   UINT32                          sensitiveSize;
02129   UINT8                           *sensitiveData;
02130 } TPM_DAA_BLOB;
02131 
02132 ///
02133 /// Part 2, section 22.9: TPM_DAA_SENSITIVE
02134 ///
02135 typedef struct tdTPM_DAA_SENSITIVE {
02136   TPM_STRUCTURE_TAG               tag;
02137   UINT32                          internalSize;
02138   UINT8                           *internalData;
02139 } TPM_DAA_SENSITIVE;
02140 
02141 
02142 //
02143 // Part 2, section 23: Redirection
02144 //
02145 
02146 ///
02147 /// Part 2 section 23.1: TPM_REDIR_COMMAND
02148 /// This section defines exactly one value but does not
02149 /// give it a name. The definition of TPM_SetRedirection in Part3
02150 /// refers to exactly one name but does not give its value. We join
02151 /// them here.
02152 ///
02153 #define TPM_REDIR_GPIO              (0x00000001)
02154 
02155 ///
02156 /// TPM Command Headers defined in Part 3
02157 ///
02158 typedef struct tdTPM_RQU_COMMAND_HDR {
02159   TPM_STRUCTURE_TAG                 tag;
02160   UINT32                            paramSize;
02161   TPM_COMMAND_CODE                  ordinal;
02162 } TPM_RQU_COMMAND_HDR;
02163 
02164 ///
02165 /// TPM Response Headers defined in Part 3
02166 ///
02167 typedef struct tdTPM_RSP_COMMAND_HDR {
02168   TPM_STRUCTURE_TAG                 tag;
02169   UINT32                            paramSize;
02170   TPM_RESULT                        returnCode;
02171 } TPM_RSP_COMMAND_HDR;
02172 
02173 #pragma pack ()
02174 
02175 #endif