Home | History | Annotate | Download | only in tpm2
      1 // Copyright 2015 The Chromium OS Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // THIS CODE IS GENERATED - DO NOT MODIFY!
      6 
      7 #ifndef TPM2_TPM_TYPES_H_
      8 #define TPM2_TPM_TYPES_H_
      9 // Unprocessed: Table 1  Name Prefix Convention
     10 // Skipped: Table 2  Unmarshaling Errors
     11 // Table 3  Definition of Base Types
     12 typedef uint8_t UINT8;
     13 typedef uint8_t BYTE;
     14 typedef int8_t INT8;
     15 typedef int BOOL;
     16 typedef uint16_t UINT16;
     17 typedef int16_t INT16;
     18 typedef uint32_t UINT32;
     19 typedef int32_t INT32;
     20 typedef uint64_t UINT64;
     21 typedef int64_t INT64;
     22 
     23 // Table 4  Defines for Logic Values
     24 #define TRUE   1
     25 #define FALSE  0
     26 #define YES    1
     27 #define NO     0
     28 #define SET    1
     29 #define CLEAR  0
     30 
     31 // Table 5  Definition of Types for Documentation Clarity
     32 typedef UINT32 TPM_ALGORITHM_ID;
     33 typedef UINT32 TPM_MODIFIER_INDICATOR;
     34 typedef UINT32 TPM_AUTHORIZATION_SIZE;
     35 typedef UINT32 TPM_PARAMETER_SIZE;
     36 typedef UINT16 TPM_KEY_SIZE;
     37 typedef UINT16 TPM_KEY_BITS;
     38 
     39 // Skipped: Table 6  Definition of TPM_SPEC Constants <>
     40 // Table 7  Definition of TPM_GENERATED Constants <  O>
     41 typedef UINT32 TPM_GENERATED;
     42 #define TPM_GENERATED_VALUE  0xff544347
     43 
     44 // Unprocessed: Table 8  Legend for TPM_ALG_ID Table
     45 // Skipped: Table 9  Definition of TPM_ALG_ID Constants <  IN/OUT, S>
     46 // Skipped: Table 10  Definition of TPM_ECC_CURVE Constants <  IN/OUT, S>
     47 // Unprocessed: Table 11  TPM Command Format Fields Description
     48 // Unprocessed: Table 12  Legend for Command Code Tables
     49 // Skipped: Table 13  Definition of TPM_CC Constants <  IN/OUT, S>
     50 // Unprocessed: Table 14  Format-Zero Response Codes
     51 // Unprocessed: Table 15  Format-One Response Codes
     52 // Unprocessed: Table 16  Response Code Groupings
     53 // Table 17  Definition of TPM_RC Constants <  OUT>
     54 typedef UINT32 TPM_RC;
     55 #define TPM_RC_SUCCESS                                  0x000
     56 #define TPM_RC_BAD_TAG                                  0x01E
     57 #define RC_VER1                                         0x100
     58 #define TPM_RC_INITIALIZE         ((TPM_RC)(RC_VER1 + 0x000))
     59 #define TPM_RC_FAILURE            ((TPM_RC)(RC_VER1 + 0x001))
     60 #define TPM_RC_SEQUENCE           ((TPM_RC)(RC_VER1 + 0x003))
     61 #define TPM_RC_PRIVATE            ((TPM_RC)(RC_VER1 + 0x00B))
     62 #define TPM_RC_HMAC               ((TPM_RC)(RC_VER1 + 0x019))
     63 #define TPM_RC_DISABLED           ((TPM_RC)(RC_VER1 + 0x020))
     64 #define TPM_RC_EXCLUSIVE          ((TPM_RC)(RC_VER1 + 0x021))
     65 #define TPM_RC_AUTH_TYPE          ((TPM_RC)(RC_VER1 + 0x024))
     66 #define TPM_RC_AUTH_MISSING       ((TPM_RC)(RC_VER1 + 0x025))
     67 #define TPM_RC_POLICY             ((TPM_RC)(RC_VER1 + 0x026))
     68 #define TPM_RC_PCR                ((TPM_RC)(RC_VER1 + 0x027))
     69 #define TPM_RC_PCR_CHANGED        ((TPM_RC)(RC_VER1 + 0x028))
     70 #define TPM_RC_UPGRADE            ((TPM_RC)(RC_VER1 + 0x02D))
     71 #define TPM_RC_TOO_MANY_CONTEXTS  ((TPM_RC)(RC_VER1 + 0x02E))
     72 #define TPM_RC_AUTH_UNAVAILABLE   ((TPM_RC)(RC_VER1 + 0x02F))
     73 #define TPM_RC_REBOOT             ((TPM_RC)(RC_VER1 + 0x030))
     74 #define TPM_RC_UNBALANCED         ((TPM_RC)(RC_VER1 + 0x031))
     75 #define TPM_RC_COMMAND_SIZE       ((TPM_RC)(RC_VER1 + 0x042))
     76 #define TPM_RC_COMMAND_CODE       ((TPM_RC)(RC_VER1 + 0x043))
     77 #define TPM_RC_AUTHSIZE           ((TPM_RC)(RC_VER1 + 0x044))
     78 #define TPM_RC_AUTH_CONTEXT       ((TPM_RC)(RC_VER1 + 0x045))
     79 #define TPM_RC_NV_RANGE           ((TPM_RC)(RC_VER1 + 0x046))
     80 #define TPM_RC_NV_SIZE            ((TPM_RC)(RC_VER1 + 0x047))
     81 #define TPM_RC_NV_LOCKED          ((TPM_RC)(RC_VER1 + 0x048))
     82 #define TPM_RC_NV_AUTHORIZATION   ((TPM_RC)(RC_VER1 + 0x049))
     83 #define TPM_RC_NV_UNINITIALIZED   ((TPM_RC)(RC_VER1 + 0x04A))
     84 #define TPM_RC_NV_SPACE           ((TPM_RC)(RC_VER1 + 0x04B))
     85 #define TPM_RC_NV_DEFINED         ((TPM_RC)(RC_VER1 + 0x04C))
     86 #define TPM_RC_BAD_CONTEXT        ((TPM_RC)(RC_VER1 + 0x050))
     87 #define TPM_RC_CPHASH             ((TPM_RC)(RC_VER1 + 0x051))
     88 #define TPM_RC_PARENT             ((TPM_RC)(RC_VER1 + 0x052))
     89 #define TPM_RC_NEEDS_TEST         ((TPM_RC)(RC_VER1 + 0x053))
     90 #define TPM_RC_NO_RESULT          ((TPM_RC)(RC_VER1 + 0x054))
     91 #define TPM_RC_SENSITIVE          ((TPM_RC)(RC_VER1 + 0x055))
     92 #define RC_MAX_FM0                ((TPM_RC)(RC_VER1 + 0x07F))
     93 #define RC_FMT1                                         0x080
     94 #define TPM_RC_ASYMMETRIC         ((TPM_RC)(RC_FMT1 + 0x001))
     95 #define TPM_RC_ATTRIBUTES         ((TPM_RC)(RC_FMT1 + 0x002))
     96 #define TPM_RC_HASH               ((TPM_RC)(RC_FMT1 + 0x003))
     97 #define TPM_RC_VALUE              ((TPM_RC)(RC_FMT1 + 0x004))
     98 #define TPM_RC_HIERARCHY          ((TPM_RC)(RC_FMT1 + 0x005))
     99 #define TPM_RC_KEY_SIZE           ((TPM_RC)(RC_FMT1 + 0x007))
    100 #define TPM_RC_MGF                ((TPM_RC)(RC_FMT1 + 0x008))
    101 #define TPM_RC_MODE               ((TPM_RC)(RC_FMT1 + 0x009))
    102 #define TPM_RC_TYPE               ((TPM_RC)(RC_FMT1 + 0x00A))
    103 #define TPM_RC_HANDLE             ((TPM_RC)(RC_FMT1 + 0x00B))
    104 #define TPM_RC_KDF                ((TPM_RC)(RC_FMT1 + 0x00C))
    105 #define TPM_RC_RANGE              ((TPM_RC)(RC_FMT1 + 0x00D))
    106 #define TPM_RC_AUTH_FAIL          ((TPM_RC)(RC_FMT1 + 0x00E))
    107 #define TPM_RC_NONCE              ((TPM_RC)(RC_FMT1 + 0x00F))
    108 #define TPM_RC_PP                 ((TPM_RC)(RC_FMT1 + 0x010))
    109 #define TPM_RC_SCHEME             ((TPM_RC)(RC_FMT1 + 0x012))
    110 #define TPM_RC_SIZE               ((TPM_RC)(RC_FMT1 + 0x015))
    111 #define TPM_RC_SYMMETRIC          ((TPM_RC)(RC_FMT1 + 0x016))
    112 #define TPM_RC_TAG                ((TPM_RC)(RC_FMT1 + 0x017))
    113 #define TPM_RC_SELECTOR           ((TPM_RC)(RC_FMT1 + 0x018))
    114 #define TPM_RC_INSUFFICIENT       ((TPM_RC)(RC_FMT1 + 0x01A))
    115 #define TPM_RC_SIGNATURE          ((TPM_RC)(RC_FMT1 + 0x01B))
    116 #define TPM_RC_KEY                ((TPM_RC)(RC_FMT1 + 0x01C))
    117 #define TPM_RC_POLICY_FAIL        ((TPM_RC)(RC_FMT1 + 0x01D))
    118 #define TPM_RC_INTEGRITY          ((TPM_RC)(RC_FMT1 + 0x01F))
    119 #define TPM_RC_TICKET             ((TPM_RC)(RC_FMT1 + 0x020))
    120 #define TPM_RC_RESERVED_BITS      ((TPM_RC)(RC_FMT1 + 0x021))
    121 #define TPM_RC_BAD_AUTH           ((TPM_RC)(RC_FMT1 + 0x022))
    122 #define TPM_RC_EXPIRED            ((TPM_RC)(RC_FMT1 + 0x023))
    123 #define TPM_RC_POLICY_CC          ((TPM_RC)(RC_FMT1 + 0x024))
    124 #define TPM_RC_BINDING            ((TPM_RC)(RC_FMT1 + 0x025))
    125 #define TPM_RC_CURVE              ((TPM_RC)(RC_FMT1 + 0x026))
    126 #define TPM_RC_ECC_POINT          ((TPM_RC)(RC_FMT1 + 0x027))
    127 #define RC_WARN                                         0x900
    128 #define TPM_RC_CONTEXT_GAP        ((TPM_RC)(RC_WARN + 0x001))
    129 #define TPM_RC_OBJECT_MEMORY      ((TPM_RC)(RC_WARN + 0x002))
    130 #define TPM_RC_SESSION_MEMORY     ((TPM_RC)(RC_WARN + 0x003))
    131 #define TPM_RC_MEMORY             ((TPM_RC)(RC_WARN + 0x004))
    132 #define TPM_RC_SESSION_HANDLES    ((TPM_RC)(RC_WARN + 0x005))
    133 #define TPM_RC_OBJECT_HANDLES     ((TPM_RC)(RC_WARN + 0x006))
    134 #define TPM_RC_LOCALITY           ((TPM_RC)(RC_WARN + 0x007))
    135 #define TPM_RC_YIELDED            ((TPM_RC)(RC_WARN + 0x008))
    136 #define TPM_RC_CANCELED           ((TPM_RC)(RC_WARN + 0x009))
    137 #define TPM_RC_TESTING            ((TPM_RC)(RC_WARN + 0x00A))
    138 #define TPM_RC_REFERENCE_H0       ((TPM_RC)(RC_WARN + 0x010))
    139 #define TPM_RC_REFERENCE_H1       ((TPM_RC)(RC_WARN + 0x011))
    140 #define TPM_RC_REFERENCE_H2       ((TPM_RC)(RC_WARN + 0x012))
    141 #define TPM_RC_REFERENCE_H3       ((TPM_RC)(RC_WARN + 0x013))
    142 #define TPM_RC_REFERENCE_H4       ((TPM_RC)(RC_WARN + 0x014))
    143 #define TPM_RC_REFERENCE_H5       ((TPM_RC)(RC_WARN + 0x015))
    144 #define TPM_RC_REFERENCE_H6       ((TPM_RC)(RC_WARN + 0x016))
    145 #define TPM_RC_REFERENCE_S0       ((TPM_RC)(RC_WARN + 0x018))
    146 #define TPM_RC_REFERENCE_S1       ((TPM_RC)(RC_WARN + 0x019))
    147 #define TPM_RC_REFERENCE_S2       ((TPM_RC)(RC_WARN + 0x01A))
    148 #define TPM_RC_REFERENCE_S3       ((TPM_RC)(RC_WARN + 0x01B))
    149 #define TPM_RC_REFERENCE_S4       ((TPM_RC)(RC_WARN + 0x01C))
    150 #define TPM_RC_REFERENCE_S5       ((TPM_RC)(RC_WARN + 0x01D))
    151 #define TPM_RC_REFERENCE_S6       ((TPM_RC)(RC_WARN + 0x01E))
    152 #define TPM_RC_NV_RATE            ((TPM_RC)(RC_WARN + 0x020))
    153 #define TPM_RC_LOCKOUT            ((TPM_RC)(RC_WARN + 0x021))
    154 #define TPM_RC_RETRY              ((TPM_RC)(RC_WARN + 0x022))
    155 #define TPM_RC_NV_UNAVAILABLE     ((TPM_RC)(RC_WARN + 0x023))
    156 #define TPM_RC_NOT_USED            ((TPM_RC)(RC_WARN + 0x7F))
    157 #define TPM_RC_H                                        0x000
    158 #define TPM_RC_P                                        0x040
    159 #define TPM_RC_S                                        0x800
    160 #define TPM_RC_1                                        0x100
    161 #define TPM_RC_2                                        0x200
    162 #define TPM_RC_3                                        0x300
    163 #define TPM_RC_4                                        0x400
    164 #define TPM_RC_5                                        0x500
    165 #define TPM_RC_6                                        0x600
    166 #define TPM_RC_7                                        0x700
    167 #define TPM_RC_8                                        0x800
    168 #define TPM_RC_9                                        0x900
    169 #define TPM_RC_A                                        0xA00
    170 #define TPM_RC_B                                        0xB00
    171 #define TPM_RC_C                                        0xC00
    172 #define TPM_RC_D                                        0xD00
    173 #define TPM_RC_E                                        0xE00
    174 #define TPM_RC_F                                        0xF00
    175 #define TPM_RC_N_MASK                                   0xF00
    176 
    177 // Table 18  Definition of TPM_CLOCK_ADJUST Constants <  IN>
    178 typedef INT8 TPM_CLOCK_ADJUST;
    179 #define TPM_CLOCK_COARSE_SLOWER  -3
    180 #define TPM_CLOCK_MEDIUM_SLOWER  -2
    181 #define TPM_CLOCK_FINE_SLOWER    -1
    182 #define TPM_CLOCK_NO_CHANGE       0
    183 #define TPM_CLOCK_FINE_FASTER     1
    184 #define TPM_CLOCK_MEDIUM_FASTER   2
    185 #define TPM_CLOCK_COARSE_FASTER   3
    186 
    187 // Table 19  Definition of TPM_EO Constants <  IN/OUT>
    188 typedef UINT16 TPM_EO;
    189 #define TPM_EO_EQ           0x0000
    190 #define TPM_EO_NEQ          0x0001
    191 #define TPM_EO_SIGNED_GT    0x0002
    192 #define TPM_EO_UNSIGNED_GT  0x0003
    193 #define TPM_EO_SIGNED_LT    0x0004
    194 #define TPM_EO_UNSIGNED_LT  0x0005
    195 #define TPM_EO_SIGNED_GE    0x0006
    196 #define TPM_EO_UNSIGNED_GE  0x0007
    197 #define TPM_EO_SIGNED_LE    0x0008
    198 #define TPM_EO_UNSIGNED_LE  0x0009
    199 #define TPM_EO_BITSET       0x000A
    200 #define TPM_EO_BITCLEAR     0x000B
    201 
    202 // Table 20  Definition of TPM_ST Constants <  IN/OUT, S>
    203 typedef UINT16 TPM_ST;
    204 #define TPM_ST_RSP_COMMAND           0x00C4
    205 #define TPM_ST_NULL                  0X8000
    206 #define TPM_ST_NO_SESSIONS           0x8001
    207 #define TPM_ST_SESSIONS              0x8002
    208 #define TPM_ST_ATTEST_NV             0x8014
    209 #define TPM_ST_ATTEST_COMMAND_AUDIT  0x8015
    210 #define TPM_ST_ATTEST_SESSION_AUDIT  0x8016
    211 #define TPM_ST_ATTEST_CERTIFY        0x8017
    212 #define TPM_ST_ATTEST_QUOTE          0x8018
    213 #define TPM_ST_ATTEST_TIME           0x8019
    214 #define TPM_ST_ATTEST_CREATION       0x801A
    215 #define TPM_ST_CREATION              0x8021
    216 #define TPM_ST_VERIFIED              0x8022
    217 #define TPM_ST_AUTH_SECRET           0x8023
    218 #define TPM_ST_HASHCHECK             0x8024
    219 #define TPM_ST_AUTH_SIGNED           0x8025
    220 #define TPM_ST_FU_MANIFEST           0x8029
    221 
    222 // Table 21  Definition of TPM_SU Constants <  IN>
    223 typedef UINT16 TPM_SU;
    224 #define TPM_SU_CLEAR  0x0000
    225 #define TPM_SU_STATE  0x0001
    226 
    227 // Table 22  Definition of TPM_SE Constants <  IN>
    228 typedef UINT8 TPM_SE;
    229 #define TPM_SE_HMAC    0x00
    230 #define TPM_SE_POLICY  0x01
    231 #define TPM_SE_TRIAL   0x03
    232 
    233 // Table 23  Definition of TPM_CAP Constants
    234 typedef UINT32 TPM_CAP;
    235 #define TPM_CAP_FIRST            0x00000000
    236 #define TPM_CAP_ALGS             0x00000000
    237 #define TPM_CAP_HANDLES          0x00000001
    238 #define TPM_CAP_COMMANDS         0x00000002
    239 #define TPM_CAP_PP_COMMANDS      0x00000003
    240 #define TPM_CAP_AUDIT_COMMANDS   0x00000004
    241 #define TPM_CAP_PCRS             0x00000005
    242 #define TPM_CAP_TPM_PROPERTIES   0x00000006
    243 #define TPM_CAP_PCR_PROPERTIES   0x00000007
    244 #define TPM_CAP_ECC_CURVES       0x00000008
    245 #define TPM_CAP_LAST             0x00000008
    246 #define TPM_CAP_VENDOR_PROPERTY  0x00000100
    247 
    248 // Table 24  Definition of TPM_PT Constants <  IN/OUT, S>
    249 typedef UINT32 TPM_PT;
    250 #define TPM_PT_NONE                                0x00000000
    251 #define PT_GROUP                                   0x00000100
    252 #define PT_FIXED                               (PT_GROUP * 1)
    253 #define TPM_PT_FAMILY_INDICATOR      ((TPM_PT)(PT_FIXED + 0))
    254 #define TPM_PT_LEVEL                 ((TPM_PT)(PT_FIXED + 1))
    255 #define TPM_PT_REVISION              ((TPM_PT)(PT_FIXED + 2))
    256 #define TPM_PT_DAY_OF_YEAR           ((TPM_PT)(PT_FIXED + 3))
    257 #define TPM_PT_YEAR                  ((TPM_PT)(PT_FIXED + 4))
    258 #define TPM_PT_MANUFACTURER          ((TPM_PT)(PT_FIXED + 5))
    259 #define TPM_PT_VENDOR_STRING_1       ((TPM_PT)(PT_FIXED + 6))
    260 #define TPM_PT_VENDOR_STRING_2       ((TPM_PT)(PT_FIXED + 7))
    261 #define TPM_PT_VENDOR_STRING_3       ((TPM_PT)(PT_FIXED + 8))
    262 #define TPM_PT_VENDOR_STRING_4       ((TPM_PT)(PT_FIXED + 9))
    263 #define TPM_PT_VENDOR_TPM_TYPE      ((TPM_PT)(PT_FIXED + 10))
    264 #define TPM_PT_FIRMWARE_VERSION_1   ((TPM_PT)(PT_FIXED + 11))
    265 #define TPM_PT_FIRMWARE_VERSION_2   ((TPM_PT)(PT_FIXED + 12))
    266 #define TPM_PT_INPUT_BUFFER         ((TPM_PT)(PT_FIXED + 13))
    267 #define TPM_PT_HR_TRANSIENT_MIN     ((TPM_PT)(PT_FIXED + 14))
    268 #define TPM_PT_HR_PERSISTENT_MIN    ((TPM_PT)(PT_FIXED + 15))
    269 #define TPM_PT_HR_LOADED_MIN        ((TPM_PT)(PT_FIXED + 16))
    270 #define TPM_PT_ACTIVE_SESSIONS_MAX  ((TPM_PT)(PT_FIXED + 17))
    271 #define TPM_PT_PCR_COUNT            ((TPM_PT)(PT_FIXED + 18))
    272 #define TPM_PT_PCR_SELECT_MIN       ((TPM_PT)(PT_FIXED + 19))
    273 #define TPM_PT_CONTEXT_GAP_MAX      ((TPM_PT)(PT_FIXED + 20))
    274 #define TPM_PT_NV_COUNTERS_MAX      ((TPM_PT)(PT_FIXED + 22))
    275 #define TPM_PT_NV_INDEX_MAX         ((TPM_PT)(PT_FIXED + 23))
    276 #define TPM_PT_MEMORY               ((TPM_PT)(PT_FIXED + 24))
    277 #define TPM_PT_CLOCK_UPDATE         ((TPM_PT)(PT_FIXED + 25))
    278 #define TPM_PT_CONTEXT_HASH         ((TPM_PT)(PT_FIXED + 26))
    279 #define TPM_PT_CONTEXT_SYM          ((TPM_PT)(PT_FIXED + 27))
    280 #define TPM_PT_CONTEXT_SYM_SIZE     ((TPM_PT)(PT_FIXED + 28))
    281 #define TPM_PT_ORDERLY_COUNT        ((TPM_PT)(PT_FIXED + 29))
    282 #define TPM_PT_MAX_COMMAND_SIZE     ((TPM_PT)(PT_FIXED + 30))
    283 #define TPM_PT_MAX_RESPONSE_SIZE    ((TPM_PT)(PT_FIXED + 31))
    284 #define TPM_PT_MAX_DIGEST           ((TPM_PT)(PT_FIXED + 32))
    285 #define TPM_PT_MAX_OBJECT_CONTEXT   ((TPM_PT)(PT_FIXED + 33))
    286 #define TPM_PT_MAX_SESSION_CONTEXT  ((TPM_PT)(PT_FIXED + 34))
    287 #define TPM_PT_PS_FAMILY_INDICATOR  ((TPM_PT)(PT_FIXED + 35))
    288 #define TPM_PT_PS_LEVEL             ((TPM_PT)(PT_FIXED + 36))
    289 #define TPM_PT_PS_REVISION          ((TPM_PT)(PT_FIXED + 37))
    290 #define TPM_PT_PS_DAY_OF_YEAR       ((TPM_PT)(PT_FIXED + 38))
    291 #define TPM_PT_PS_YEAR              ((TPM_PT)(PT_FIXED + 39))
    292 #define TPM_PT_SPLIT_MAX            ((TPM_PT)(PT_FIXED + 40))
    293 #define TPM_PT_TOTAL_COMMANDS       ((TPM_PT)(PT_FIXED + 41))
    294 #define TPM_PT_LIBRARY_COMMANDS     ((TPM_PT)(PT_FIXED + 42))
    295 #define TPM_PT_VENDOR_COMMANDS      ((TPM_PT)(PT_FIXED + 43))
    296 #define TPM_PT_NV_BUFFER_MAX        ((TPM_PT)(PT_FIXED + 44))
    297 #define PT_VAR                                 (PT_GROUP * 2)
    298 #define TPM_PT_PERMANENT               ((TPM_PT)(PT_VAR + 0))
    299 #define TPM_PT_STARTUP_CLEAR           ((TPM_PT)(PT_VAR + 1))
    300 #define TPM_PT_HR_NV_INDEX             ((TPM_PT)(PT_VAR + 2))
    301 #define TPM_PT_HR_LOADED               ((TPM_PT)(PT_VAR + 3))
    302 #define TPM_PT_HR_LOADED_AVAIL         ((TPM_PT)(PT_VAR + 4))
    303 #define TPM_PT_HR_ACTIVE               ((TPM_PT)(PT_VAR + 5))
    304 #define TPM_PT_HR_ACTIVE_AVAIL         ((TPM_PT)(PT_VAR + 6))
    305 #define TPM_PT_HR_TRANSIENT_AVAIL      ((TPM_PT)(PT_VAR + 7))
    306 #define TPM_PT_HR_PERSISTENT           ((TPM_PT)(PT_VAR + 8))
    307 #define TPM_PT_HR_PERSISTENT_AVAIL     ((TPM_PT)(PT_VAR + 9))
    308 #define TPM_PT_NV_COUNTERS            ((TPM_PT)(PT_VAR + 10))
    309 #define TPM_PT_NV_COUNTERS_AVAIL      ((TPM_PT)(PT_VAR + 11))
    310 #define TPM_PT_ALGORITHM_SET          ((TPM_PT)(PT_VAR + 12))
    311 #define TPM_PT_LOADED_CURVES          ((TPM_PT)(PT_VAR + 13))
    312 #define TPM_PT_LOCKOUT_COUNTER        ((TPM_PT)(PT_VAR + 14))
    313 #define TPM_PT_MAX_AUTH_FAIL          ((TPM_PT)(PT_VAR + 15))
    314 #define TPM_PT_LOCKOUT_INTERVAL       ((TPM_PT)(PT_VAR + 16))
    315 #define TPM_PT_LOCKOUT_RECOVERY       ((TPM_PT)(PT_VAR + 17))
    316 #define TPM_PT_NV_WRITE_RECOVERY      ((TPM_PT)(PT_VAR + 18))
    317 #define TPM_PT_AUDIT_COUNTER_0        ((TPM_PT)(PT_VAR + 19))
    318 #define TPM_PT_AUDIT_COUNTER_1        ((TPM_PT)(PT_VAR + 20))
    319 
    320 // Table 25  Definition of TPM_PT_PCR Constants <  IN/OUT, S>
    321 typedef UINT32 TPM_PT_PCR;
    322 #define TPM_PT_PCR_FIRST         0x00000000
    323 #define TPM_PT_PCR_SAVE          0x00000000
    324 #define TPM_PT_PCR_EXTEND_L0     0x00000001
    325 #define TPM_PT_PCR_RESET_L0      0x00000002
    326 #define TPM_PT_PCR_EXTEND_L1     0x00000003
    327 #define TPM_PT_PCR_RESET_L1      0x00000004
    328 #define TPM_PT_PCR_EXTEND_L2     0x00000005
    329 #define TPM_PT_PCR_RESET_L2      0x00000006
    330 #define TPM_PT_PCR_EXTEND_L3     0x00000007
    331 #define TPM_PT_PCR_RESET_L3      0x00000008
    332 #define TPM_PT_PCR_EXTEND_L4     0x00000009
    333 #define TPM_PT_PCR_RESET_L4      0x0000000A
    334 #define TPM_PT_PCR_NO_INCREMENT  0x00000011
    335 #define TPM_PT_PCR_DRTM_RESET    0x00000012
    336 #define TPM_PT_PCR_POLICY        0x00000013
    337 #define TPM_PT_PCR_AUTH          0x00000014
    338 #define TPM_PT_PCR_LAST          0x00000014
    339 
    340 // Table 26  Definition of TPM_PS Constants <  OUT>
    341 typedef UINT32 TPM_PS;
    342 #define TPM_PS_MAIN            0x00000000
    343 #define TPM_PS_PC              0x00000001
    344 #define TPM_PS_PDA             0x00000002
    345 #define TPM_PS_CELL_PHONE      0x00000003
    346 #define TPM_PS_SERVER          0x00000004
    347 #define TPM_PS_PERIPHERAL      0x00000005
    348 #define TPM_PS_TSS             0x00000006
    349 #define TPM_PS_STORAGE         0x00000007
    350 #define TPM_PS_AUTHENTICATION  0x00000008
    351 #define TPM_PS_EMBEDDED        0x00000009
    352 #define TPM_PS_HARDCOPY        0x0000000A
    353 #define TPM_PS_INFRASTRUCTURE  0x0000000B
    354 #define TPM_PS_VIRTUALIZATION  0x0000000C
    355 #define TPM_PS_TNC             0x0000000D
    356 #define TPM_PS_MULTI_TENANT    0x0000000E
    357 #define TPM_PS_TC              0x0000000F
    358 
    359 // Table 27  Definition of Types for Handles
    360 typedef UINT32 TPM_HANDLE;
    361 
    362 // Table 28  Definition of TPM_HT Constants <  S>
    363 typedef UINT8 TPM_HT;
    364 #define TPM_HT_PCR             0x00
    365 #define TPM_HT_NV_INDEX        0x01
    366 #define TPM_HT_HMAC_SESSION    0x02
    367 #define TPM_HT_LOADED_SESSION  0x02
    368 #define TPM_HT_POLICY_SESSION  0x03
    369 #define TPM_HT_ACTIVE_SESSION  0x03
    370 #define TPM_HT_PERMANENT       0x40
    371 #define TPM_HT_TRANSIENT       0x80
    372 #define TPM_HT_PERSISTENT      0x81
    373 
    374 // Table 29  Definition of TPM_RH Constants <  S>
    375 typedef TPM_HANDLE TPM_RH;
    376 #define TPM_RH_FIRST        0x40000000
    377 #define TPM_RH_SRK          0x40000000
    378 #define TPM_RH_OWNER        0x40000001
    379 #define TPM_RH_REVOKE       0x40000002
    380 #define TPM_RH_TRANSPORT    0x40000003
    381 #define TPM_RH_OPERATOR     0x40000004
    382 #define TPM_RH_ADMIN        0x40000005
    383 #define TPM_RH_EK           0x40000006
    384 #define TPM_RH_NULL         0x40000007
    385 #define TPM_RH_UNASSIGNED   0x40000008
    386 #define TPM_RS_PW           0x40000009
    387 #define TPM_RH_LOCKOUT      0x4000000A
    388 #define TPM_RH_ENDORSEMENT  0x4000000B
    389 #define TPM_RH_PLATFORM     0x4000000C
    390 #define TPM_RH_PLATFORM_NV  0x4000000D
    391 #define TPM_RH_AUTH_00      0x40000010
    392 #define TPM_RH_AUTH_FF      0x4000010F
    393 #define TPM_RH_LAST         0x4000010F
    394 
    395 // Table 30  Definition of TPM_HC Constants <  S>
    396 typedef TPM_HANDLE TPM_HC;
    397 #define HR_HANDLE_MASK                                            0x00FFFFFF
    398 #define HR_RANGE_MASK                                             0xFF000000
    399 #define HR_SHIFT                                                          24
    400 #define HR_PCR                                     (TPM_HT_PCR <<  HR_SHIFT)
    401 #define HR_HMAC_SESSION                   (TPM_HT_HMAC_SESSION <<  HR_SHIFT)
    402 #define HR_POLICY_SESSION               (TPM_HT_POLICY_SESSION <<  HR_SHIFT)
    403 #define HR_TRANSIENT                         (TPM_HT_TRANSIENT <<  HR_SHIFT)
    404 #define HR_PERSISTENT                       (TPM_HT_PERSISTENT <<  HR_SHIFT)
    405 #define HR_NV_INDEX                           (TPM_HT_NV_INDEX <<  HR_SHIFT)
    406 #define HR_PERMANENT                         (TPM_HT_PERMANENT <<  HR_SHIFT)
    407 #define PCR_FIRST                                               (HR_PCR + 0)
    408 #define PCR_LAST                          (PCR_FIRST + IMPLEMENTATION_PCR-1)
    409 #define HMAC_SESSION_FIRST                             (HR_HMAC_SESSION + 0)
    410 #define HMAC_SESSION_LAST         (HMAC_SESSION_FIRST+MAX_ACTIVE_SESSIONS-1)
    411 #define LOADED_SESSION_FIRST                              HMAC_SESSION_FIRST
    412 #define LOADED_SESSION_LAST                                HMAC_SESSION_LAST
    413 #define POLICY_SESSION_FIRST                         (HR_POLICY_SESSION + 0)
    414 #define POLICY_SESSION_LAST   (POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS-1)
    415 #define TRANSIENT_FIRST                                   (HR_TRANSIENT + 0)
    416 #define ACTIVE_SESSION_FIRST                            POLICY_SESSION_FIRST
    417 #define ACTIVE_SESSION_LAST                              POLICY_SESSION_LAST
    418 #define TRANSIENT_LAST                (TRANSIENT_FIRST+MAX_LOADED_OBJECTS-1)
    419 #define PERSISTENT_FIRST                                 (HR_PERSISTENT + 0)
    420 #define PERSISTENT_LAST                      (PERSISTENT_FIRST + 0x00FFFFFF)
    421 #define PLATFORM_PERSISTENT                  (PERSISTENT_FIRST + 0x00800000)
    422 #define NV_INDEX_FIRST                                     (HR_NV_INDEX + 0)
    423 #define NV_INDEX_LAST                          (NV_INDEX_FIRST + 0x00FFFFFF)
    424 #define PERMANENT_FIRST                                         TPM_RH_FIRST
    425 #define PERMANENT_LAST                                           TPM_RH_LAST
    426 
    427 // Table 31  Definition of TPMA_ALGORITHM Bits
    428 typedef struct {
    429   UINT32 asymmetric    : 1;
    430   UINT32 symmetric     : 1;
    431   UINT32 hash          : 1;
    432   UINT32 object        : 1;
    433   UINT32 reserved4_7   : 4;
    434   UINT32 signing       : 1;
    435   UINT32 encrypting    : 1;
    436   UINT32 method        : 1;
    437   UINT32 reserved11_31 : 21;
    438 } TPMA_ALGORITHM;
    439 
    440 // Table 32  Definition of TPMA_OBJECT Bits
    441 typedef struct {
    442   UINT32 reserved0            : 1;
    443   UINT32 fixedTPM             : 1;
    444   UINT32 stClear              : 1;
    445   UINT32 reserved3            : 1;
    446   UINT32 fixedParent          : 1;
    447   UINT32 sensitiveDataOrigin  : 1;
    448   UINT32 userWithAuth         : 1;
    449   UINT32 adminWithPolicy      : 1;
    450   UINT32 reserved8_9          : 2;
    451   UINT32 noDA                 : 1;
    452   UINT32 encryptedDuplication : 1;
    453   UINT32 reserved12_15        : 4;
    454   UINT32 restricted           : 1;
    455   UINT32 decrypt              : 1;
    456   UINT32 sign                 : 1;
    457   UINT32 reserved19_31        : 13;
    458 } TPMA_OBJECT;
    459 
    460 // Table 33  Definition of TPMA_SESSION Bits <  IN/OUT>
    461 typedef struct {
    462   UINT8 continueSession : 1;
    463   UINT8 auditExclusive  : 1;
    464   UINT8 auditReset      : 1;
    465   UINT8 reserved3_4     : 2;
    466   UINT8 decrypt         : 1;
    467   UINT8 encrypt         : 1;
    468   UINT8 audit           : 1;
    469 } TPMA_SESSION;
    470 
    471 // Table 34  Definition of TPMA_LOCALITY Bits <  IN/OUT>
    472 typedef struct {
    473   UINT8 locZero  : 1;
    474   UINT8 locOne   : 1;
    475   UINT8 locTwo   : 1;
    476   UINT8 locThree : 1;
    477   UINT8 locFour  : 1;
    478   UINT8 Extended : 3;
    479 } TPMA_LOCALITY;
    480 
    481 // Table 35  Definition of TPMA_PERMANENT Bits <  OUT>
    482 typedef struct {
    483   UINT32 ownerAuthSet       : 1;
    484   UINT32 endorsementAuthSet : 1;
    485   UINT32 lockoutAuthSet     : 1;
    486   UINT32 reserved3_7        : 5;
    487   UINT32 disableClear       : 1;
    488   UINT32 inLockout          : 1;
    489   UINT32 tpmGeneratedEPS    : 1;
    490   UINT32 reserved11_31      : 21;
    491 } TPMA_PERMANENT;
    492 
    493 // Table 36  Definition of TPMA_STARTUP_CLEAR Bits <  OUT>
    494 typedef struct {
    495   UINT32 phEnable     : 1;
    496   UINT32 shEnable     : 1;
    497   UINT32 ehEnable     : 1;
    498   UINT32 phEnableNV   : 1;
    499   UINT32 reserved4_30 : 27;
    500   UINT32 orderly      : 1;
    501 } TPMA_STARTUP_CLEAR;
    502 
    503 // Table 37  Definition of TPMA_MEMORY Bits <  Out>
    504 typedef struct {
    505   UINT32 sharedRAM         : 1;
    506   UINT32 sharedNV          : 1;
    507   UINT32 objectCopiedToRam : 1;
    508   UINT32 reserved3_31      : 29;
    509 } TPMA_MEMORY;
    510 
    511 // Table 38  Definition of TPMA_CC Bits <  OUT>
    512 typedef struct {
    513   TPM_CC commandIndex  : 16;
    514   TPM_CC reserved16_21 : 6;
    515   TPM_CC nv            : 1;
    516   TPM_CC extensive     : 1;
    517   TPM_CC flushed       : 1;
    518   TPM_CC cHandles      : 3;
    519   TPM_CC rHandle       : 1;
    520   TPM_CC V             : 1;
    521   TPM_CC Res           : 2;
    522 } TPMA_CC;
    523 
    524 // Table 39  Definition of TPMI_YES_NO Type
    525 typedef BYTE TPMI_YES_NO;
    526 // Table 40  Definition of TPMI_DH_OBJECT Type
    527 typedef TPM_HANDLE TPMI_DH_OBJECT;
    528 // Table 41  Definition of TPMI_DH_PERSISTENT Type
    529 typedef TPM_HANDLE TPMI_DH_PERSISTENT;
    530 // Table 42  Definition of TPMI_DH_ENTITY Type <  IN>
    531 typedef TPM_HANDLE TPMI_DH_ENTITY;
    532 // Table 43  Definition of TPMI_DH_PCR Type <  IN>
    533 typedef TPM_HANDLE TPMI_DH_PCR;
    534 // Table 44  Definition of TPMI_SH_AUTH_SESSION Type <  IN/OUT>
    535 typedef TPM_HANDLE TPMI_SH_AUTH_SESSION;
    536 // Table 45  Definition of TPMI_SH_HMAC Type <  IN/OUT>
    537 typedef TPM_HANDLE TPMI_SH_HMAC;
    538 // Table 46  Definition of TPMI_SH_POLICY Type <  IN/OUT>
    539 typedef TPM_HANDLE TPMI_SH_POLICY;
    540 // Table 47  Definition of TPMI_DH_CONTEXT Type
    541 typedef TPM_HANDLE TPMI_DH_CONTEXT;
    542 // Table 48  Definition of TPMI_RH_HIERARCHY Type
    543 typedef TPM_HANDLE TPMI_RH_HIERARCHY;
    544 // Table 49  Definition of TPMI_RH_ENABLES Type
    545 typedef TPM_HANDLE TPMI_RH_ENABLES;
    546 // Table 50  Definition of TPMI_RH_HIERARCHY_AUTH Type <  IN>
    547 typedef TPM_HANDLE TPMI_RH_HIERARCHY_AUTH;
    548 // Table 51  Definition of TPMI_RH_PLATFORM Type <  IN>
    549 typedef TPM_HANDLE TPMI_RH_PLATFORM;
    550 // Table 52  Definition of TPMI_RH_OWNER Type <  IN>
    551 typedef TPM_HANDLE TPMI_RH_OWNER;
    552 // Table 53  Definition of TPMI_RH_ENDORSEMENT Type <  IN>
    553 typedef TPM_HANDLE TPMI_RH_ENDORSEMENT;
    554 // Table 54  Definition of TPMI_RH_PROVISION Type <  IN>
    555 typedef TPM_HANDLE TPMI_RH_PROVISION;
    556 // Table 55  Definition of TPMI_RH_CLEAR Type <  IN>
    557 typedef TPM_HANDLE TPMI_RH_CLEAR;
    558 // Table 56  Definition of TPMI_RH_NV_AUTH Type <  IN>
    559 typedef TPM_HANDLE TPMI_RH_NV_AUTH;
    560 // Table 57  Definition of TPMI_RH_LOCKOUT Type <  IN>
    561 typedef TPM_HANDLE TPMI_RH_LOCKOUT;
    562 // Table 58  Definition of TPMI_RH_NV_INDEX Type <  IN/OUT>
    563 typedef TPM_HANDLE TPMI_RH_NV_INDEX;
    564 // Table 59  Definition of TPMI_ALG_HASH Type
    565 typedef TPM_ALG_ID TPMI_ALG_HASH;
    566 // Table 60  Definition of TPMI_ALG_ASYM Type
    567 typedef TPM_ALG_ID TPMI_ALG_ASYM;
    568 // Table 61  Definition of TPMI_ALG_SYM Type
    569 typedef TPM_ALG_ID TPMI_ALG_SYM;
    570 // Table 62  Definition of TPMI_ALG_SYM_OBJECT Type
    571 typedef TPM_ALG_ID TPMI_ALG_SYM_OBJECT;
    572 // Table 63  Definition of TPMI_ALG_SYM_MODE Type
    573 typedef TPM_ALG_ID TPMI_ALG_SYM_MODE;
    574 // Table 64  Definition of TPMI_ALG_KDF Type
    575 typedef TPM_ALG_ID TPMI_ALG_KDF;
    576 // Table 65  Definition of TPMI_ALG_SIG_SCHEME Type
    577 typedef TPM_ALG_ID TPMI_ALG_SIG_SCHEME;
    578 // Table 66  Definition of TPMI_ECC_KEY_EXCHANGE Type
    579 typedef TPM_ALG_ID TPMI_ECC_KEY_EXCHANGE;
    580 // Table 67  Definition of TPMI_ST_COMMAND_TAG Type
    581 typedef TPM_ST TPMI_ST_COMMAND_TAG;
    582 // Table 68  Definition of TPMS_EMPTY Structure <  IN/OUT>
    583 typedef struct {
    584 } TPMS_EMPTY;
    585 
    586 // Table 69  Definition of TPMS_ALGORITHM_DESCRIPTION Structure <  OUT>
    587 typedef struct {
    588   TPM_ALG_ID      alg;
    589   TPMA_ALGORITHM  attributes;
    590 } TPMS_ALGORITHM_DESCRIPTION;
    591 
    592 // Table 70  Definition of TPMU_HA Union <  IN/OUT, S>
    593 typedef union {
    594 #ifdef TPM_ALG_SHA
    595   BYTE  sha[SHA_DIGEST_SIZE];
    596 #endif
    597 #ifdef TPM_ALG_SHA1
    598   BYTE  sha1[SHA1_DIGEST_SIZE];
    599 #endif
    600 #ifdef TPM_ALG_SHA256
    601   BYTE  sha256[SHA256_DIGEST_SIZE];
    602 #endif
    603 #ifdef TPM_ALG_SHA384
    604   BYTE  sha384[SHA384_DIGEST_SIZE];
    605 #endif
    606 #ifdef TPM_ALG_SHA512
    607   BYTE  sha512[SHA512_DIGEST_SIZE];
    608 #endif
    609 #ifdef TPM_ALG_SM3_256
    610   BYTE  sm3_256[SM3_256_DIGEST_SIZE];
    611 #endif
    612 } TPMU_HA;
    613 
    614 // Table 71  Definition of TPMT_HA Structure <  IN/OUT>
    615 typedef struct {
    616   TPMI_ALG_HASH  hashAlg;
    617   TPMU_HA        digest;
    618 } TPMT_HA;
    619 
    620 // Table 72  Definition of TPM2B_DIGEST Structure
    621 typedef union {
    622   struct {
    623     UINT16  size;
    624     BYTE    buffer[sizeof(TPMU_HA)];
    625   } t;
    626   TPM2B b;
    627 } TPM2B_DIGEST;
    628 
    629 // Table 73  Definition of TPM2B_DATA Structure
    630 typedef union {
    631   struct {
    632     UINT16  size;
    633     BYTE    buffer[sizeof(TPMT_HA)];
    634   } t;
    635   TPM2B b;
    636 } TPM2B_DATA;
    637 
    638 // Table 74  Definition of Types for TPM2B_NONCE
    639 typedef TPM2B_DIGEST TPM2B_NONCE;
    640 
    641 // Table 75  Definition of Types for TPM2B_AUTH
    642 typedef TPM2B_DIGEST TPM2B_AUTH;
    643 
    644 // Table 76  Definition of Types for TPM2B_OPERAND
    645 typedef TPM2B_DIGEST TPM2B_OPERAND;
    646 
    647 // Table 77  Definition of TPM2B_EVENT Structure
    648 typedef union {
    649   struct {
    650     UINT16  size;
    651     BYTE    buffer[1024];
    652   } t;
    653   TPM2B b;
    654 } TPM2B_EVENT;
    655 
    656 // Table 78  Definition of TPM2B_MAX_BUFFER Structure
    657 typedef union {
    658   struct {
    659     UINT16  size;
    660     BYTE    buffer[MAX_DIGEST_BUFFER];
    661   } t;
    662   TPM2B b;
    663 } TPM2B_MAX_BUFFER;
    664 
    665 // Table 79  Definition of TPM2B_MAX_NV_BUFFER Structure
    666 typedef union {
    667   struct {
    668     UINT16  size;
    669     BYTE    buffer[MAX_NV_BUFFER_SIZE];
    670   } t;
    671   TPM2B b;
    672 } TPM2B_MAX_NV_BUFFER;
    673 
    674 // Table 80  Definition of TPM2B_TIMEOUT Structure <  IN/OUT>
    675 typedef union {
    676   struct {
    677     UINT16  size;
    678     BYTE    buffer[sizeof(UINT64)];
    679   } t;
    680   TPM2B b;
    681 } TPM2B_TIMEOUT;
    682 
    683 // Table 81  Definition of TPM2B_IV Structure <  IN/OUT>
    684 typedef union {
    685   struct {
    686     UINT16  size;
    687     BYTE    buffer[MAX_SYM_BLOCK_SIZE];
    688   } t;
    689   TPM2B b;
    690 } TPM2B_IV;
    691 
    692 // Table 82  Definition of TPMU_NAME Union <>
    693 typedef union {
    694   TPMT_HA     digest;
    695   TPM_HANDLE  handle;
    696 } TPMU_NAME;
    697 
    698 // Table 83  Definition of TPM2B_NAME Structure
    699 typedef union {
    700   struct {
    701     UINT16  size;
    702     BYTE    name[sizeof(TPMU_NAME)];
    703   } t;
    704   TPM2B b;
    705 } TPM2B_NAME;
    706 
    707 // Table 84  Definition of TPMS_PCR_SELECT Structure
    708 typedef struct {
    709   UINT8  sizeofSelect;
    710   BYTE   pcrSelect[PCR_SELECT_MAX];
    711 } TPMS_PCR_SELECT;
    712 
    713 // Table 85  Definition of TPMS_PCR_SELECTION Structure
    714 typedef struct {
    715   TPMI_ALG_HASH  hash;
    716   UINT8          sizeofSelect;
    717   BYTE           pcrSelect[PCR_SELECT_MAX];
    718 } TPMS_PCR_SELECTION;
    719 
    720 // Unprocessed: Table 86  Values for   proof   Used in Tickets
    721 // Unprocessed: Table 87  General Format of a Ticket
    722 // Table 88  Definition of TPMT_TK_CREATION Structure
    723 typedef struct {
    724   TPM_ST             tag;
    725   TPMI_RH_HIERARCHY  hierarchy;
    726   TPM2B_DIGEST       digest;
    727 } TPMT_TK_CREATION;
    728 
    729 // Table 89  Definition of TPMT_TK_VERIFIED Structure
    730 typedef struct {
    731   TPM_ST             tag;
    732   TPMI_RH_HIERARCHY  hierarchy;
    733   TPM2B_DIGEST       digest;
    734 } TPMT_TK_VERIFIED;
    735 
    736 // Table 90  Definition of TPMT_TK_AUTH Structure
    737 typedef struct {
    738   TPM_ST             tag;
    739   TPMI_RH_HIERARCHY  hierarchy;
    740   TPM2B_DIGEST       digest;
    741 } TPMT_TK_AUTH;
    742 
    743 // Table 91  Definition of TPMT_TK_HASHCHECK Structure
    744 typedef struct {
    745   TPM_ST             tag;
    746   TPMI_RH_HIERARCHY  hierarchy;
    747   TPM2B_DIGEST       digest;
    748 } TPMT_TK_HASHCHECK;
    749 
    750 // Table 92  Definition of TPMS_ALG_PROPERTY Structure <  OUT>
    751 typedef struct {
    752   TPM_ALG_ID      alg;
    753   TPMA_ALGORITHM  algProperties;
    754 } TPMS_ALG_PROPERTY;
    755 
    756 // Table 93  Definition of TPMS_TAGGED_PROPERTY Structure <  OUT>
    757 typedef struct {
    758   TPM_PT  property;
    759   UINT32  value;
    760 } TPMS_TAGGED_PROPERTY;
    761 
    762 // Table 94  Definition of TPMS_TAGGED_PCR_SELECT Structure <  OUT>
    763 typedef struct {
    764   TPM_PT  tag;
    765   UINT8   sizeofSelect;
    766   BYTE    pcrSelect[PCR_SELECT_MAX];
    767 } TPMS_TAGGED_PCR_SELECT;
    768 
    769 // Table 95  Definition of TPML_CC Structure
    770 typedef struct {
    771   UINT32  count;
    772   TPM_CC  commandCodes[MAX_CAP_CC];
    773 } TPML_CC;
    774 
    775 // Table 96  Definition of TPML_CCA Structure <  OUT>
    776 typedef struct {
    777   UINT32   count;
    778   TPMA_CC  commandAttributes[MAX_CAP_CC];
    779 } TPML_CCA;
    780 
    781 // Table 97  Definition of TPML_ALG Structure
    782 typedef struct {
    783   UINT32      count;
    784   TPM_ALG_ID  algorithms[MAX_ALG_LIST_SIZE];
    785 } TPML_ALG;
    786 
    787 // Table 98  Definition of TPML_HANDLE Structure <  OUT>
    788 typedef struct {
    789   UINT32      count;
    790   TPM_HANDLE  handle[MAX_CAP_HANDLES];
    791 } TPML_HANDLE;
    792 
    793 // Table 99  Definition of TPML_DIGEST Structure
    794 typedef struct {
    795   UINT32        count;
    796   TPM2B_DIGEST  digests[8];
    797 } TPML_DIGEST;
    798 
    799 // Table 100  Definition of TPML_DIGEST_VALUES Structure
    800 typedef struct {
    801   UINT32   count;
    802   TPMT_HA  digests[HASH_COUNT];
    803 } TPML_DIGEST_VALUES;
    804 
    805 // Table 101  Definition of TPM2B_DIGEST_VALUES Structure
    806 typedef union {
    807   struct {
    808     UINT16  size;
    809     BYTE    buffer[sizeof(TPML_DIGEST_VALUES)];
    810   } t;
    811   TPM2B b;
    812 } TPM2B_DIGEST_VALUES;
    813 
    814 // Table 102  Definition of TPML_PCR_SELECTION Structure
    815 typedef struct {
    816   UINT32              count;
    817   TPMS_PCR_SELECTION  pcrSelections[HASH_COUNT];
    818 } TPML_PCR_SELECTION;
    819 
    820 // Table 103  Definition of TPML_ALG_PROPERTY Structure <  OUT>
    821 typedef struct {
    822   UINT32             count;
    823   TPMS_ALG_PROPERTY  algProperties[MAX_CAP_ALGS];
    824 } TPML_ALG_PROPERTY;
    825 
    826 // Table 104  Definition of TPML_TAGGED_TPM_PROPERTY Structure <  OUT>
    827 typedef struct {
    828   UINT32                count;
    829   TPMS_TAGGED_PROPERTY  tpmProperty[MAX_TPM_PROPERTIES];
    830 } TPML_TAGGED_TPM_PROPERTY;
    831 
    832 // Table 105  Definition of TPML_TAGGED_PCR_PROPERTY Structure <  OUT>
    833 typedef struct {
    834   UINT32                  count;
    835   TPMS_TAGGED_PCR_SELECT  pcrProperty[MAX_PCR_PROPERTIES];
    836 } TPML_TAGGED_PCR_PROPERTY;
    837 
    838 // Table 106  Definition of TPML_ECC_CURVE Structure <  OUT>
    839 typedef struct {
    840   UINT32         count;
    841   TPM_ECC_CURVE  eccCurves[MAX_ECC_CURVES];
    842 } TPML_ECC_CURVE;
    843 
    844 // Table 107  Definition of TPMU_CAPABILITIES Union <  OUT>
    845 typedef union {
    846   TPML_ALG_PROPERTY         algorithms;
    847   TPML_HANDLE               handles;
    848   TPML_CCA                  command;
    849   TPML_CC                   ppCommands;
    850   TPML_CC                   auditCommands;
    851   TPML_PCR_SELECTION        assignedPCR;
    852   TPML_TAGGED_TPM_PROPERTY  tpmProperties;
    853   TPML_TAGGED_PCR_PROPERTY  pcrProperties;
    854   TPML_ECC_CURVE            eccCurves;
    855 } TPMU_CAPABILITIES;
    856 
    857 // Table 108  Definition of TPMS_CAPABILITY_DATA Structure <  OUT>
    858 typedef struct {
    859   TPM_CAP            capability;
    860   TPMU_CAPABILITIES  data;
    861 } TPMS_CAPABILITY_DATA;
    862 
    863 // Table 109  Definition of TPMS_CLOCK_INFO Structure
    864 typedef struct {
    865   UINT64       clock;
    866   UINT32       resetCount;
    867   UINT32       restartCount;
    868   TPMI_YES_NO  safe;
    869 } TPMS_CLOCK_INFO;
    870 
    871 // Table 110  Definition of TPMS_TIME_INFO Structure
    872 typedef struct {
    873   UINT64           time;
    874   TPMS_CLOCK_INFO  clockInfo;
    875 } TPMS_TIME_INFO;
    876 
    877 // Table 111  Definition of TPMS_TIME_ATTEST_INFO Structure <  OUT>
    878 typedef struct {
    879   TPMS_TIME_INFO  time;
    880   UINT64          firmwareVersion;
    881 } TPMS_TIME_ATTEST_INFO;
    882 
    883 // Table 112  Definition of TPMS_CERTIFY_INFO Structure <  OUT>
    884 typedef struct {
    885   TPM2B_NAME  name;
    886   TPM2B_NAME  qualifiedName;
    887 } TPMS_CERTIFY_INFO;
    888 
    889 // Table 113  Definition of TPMS_QUOTE_INFO Structure <  OUT>
    890 typedef struct {
    891   TPML_PCR_SELECTION  pcrSelect;
    892   TPM2B_DIGEST        pcrDigest;
    893 } TPMS_QUOTE_INFO;
    894 
    895 // Table 114  Definition of TPMS_COMMAND_AUDIT_INFO Structure <  OUT>
    896 typedef struct {
    897   UINT64        auditCounter;
    898   TPM_ALG_ID    digestAlg;
    899   TPM2B_DIGEST  auditDigest;
    900   TPM2B_DIGEST  commandDigest;
    901 } TPMS_COMMAND_AUDIT_INFO;
    902 
    903 // Table 115  Definition of TPMS_SESSION_AUDIT_INFO Structure <  OUT>
    904 typedef struct {
    905   TPMI_YES_NO   exclusiveSession;
    906   TPM2B_DIGEST  sessionDigest;
    907 } TPMS_SESSION_AUDIT_INFO;
    908 
    909 // Table 116  Definition of TPMS_CREATION_INFO Structure <  OUT>
    910 typedef struct {
    911   TPM2B_NAME    objectName;
    912   TPM2B_DIGEST  creationHash;
    913 } TPMS_CREATION_INFO;
    914 
    915 // Table 117  Definition of TPMS_NV_CERTIFY_INFO Structure <  OUT>
    916 typedef struct {
    917   TPM2B_NAME           indexName;
    918   UINT16               offset;
    919   TPM2B_MAX_NV_BUFFER  nvContents;
    920 } TPMS_NV_CERTIFY_INFO;
    921 
    922 // Table 118  Definition of TPMI_ST_ATTEST Type <  OUT>
    923 typedef TPM_ST TPMI_ST_ATTEST;
    924 // Table 119  Definition of TPMU_ATTEST Union <  OUT>
    925 typedef union {
    926   TPMS_CERTIFY_INFO        certify;
    927   TPMS_CREATION_INFO       creation;
    928   TPMS_QUOTE_INFO          quote;
    929   TPMS_COMMAND_AUDIT_INFO  commandAudit;
    930   TPMS_SESSION_AUDIT_INFO  sessionAudit;
    931   TPMS_TIME_ATTEST_INFO    time;
    932   TPMS_NV_CERTIFY_INFO     nv;
    933 } TPMU_ATTEST;
    934 
    935 // Table 120  Definition of TPMS_ATTEST Structure <  OUT>
    936 typedef struct {
    937   TPM_GENERATED    magic;
    938   TPMI_ST_ATTEST   type;
    939   TPM2B_NAME       qualifiedSigner;
    940   TPM2B_DATA       extraData;
    941   TPMS_CLOCK_INFO  clockInfo;
    942   UINT64           firmwareVersion;
    943   TPMU_ATTEST      attested;
    944 } TPMS_ATTEST;
    945 
    946 // Table 121  Definition of TPM2B_ATTEST Structure <  OUT>
    947 typedef union {
    948   struct {
    949     UINT16  size;
    950     BYTE    attestationData[sizeof(TPMS_ATTEST)];
    951   } t;
    952   TPM2B b;
    953 } TPM2B_ATTEST;
    954 
    955 // Table 122  Definition of TPMS_AUTH_COMMAND Structure <  IN>
    956 typedef struct {
    957   TPMI_SH_AUTH_SESSION  sessionHandle;
    958   TPM2B_NONCE           nonce;
    959   TPMA_SESSION          sessionAttributes;
    960   TPM2B_AUTH            hmac;
    961 } TPMS_AUTH_COMMAND;
    962 
    963 // Table 123  Definition of TPMS_AUTH_RESPONSE Structure <  OUT>
    964 typedef struct {
    965   TPM2B_NONCE   nonce;
    966   TPMA_SESSION  sessionAttributes;
    967   TPM2B_AUTH    hmac;
    968 } TPMS_AUTH_RESPONSE;
    969 
    970 // Table 124  Definition of   TPMI_!ALG.S_KEY_BITS Type
    971 typedef TPM_KEY_BITS TPMI_AES_KEY_BITS;
    972 typedef TPM_KEY_BITS TPMI_SM4_KEY_BITS;
    973 typedef TPM_KEY_BITS TPMI_CAMELLIA_KEY_BITS;
    974 
    975 
    976 // Table 125  Definition of TPMU_SYM_KEY_BITS Union
    977 typedef union {
    978 #ifdef TPM_ALG_AES
    979   TPMI_AES_KEY_BITS       aes;
    980 #endif
    981 #ifdef TPM_ALG_SM4
    982   TPMI_SM4_KEY_BITS       sm4;
    983 #endif
    984 #ifdef TPM_ALG_CAMELLIA
    985   TPMI_CAMELLIA_KEY_BITS  camellia;
    986 #endif
    987   TPM_KEY_BITS            sym;
    988 #ifdef TPM_ALG_XOR
    989   TPMI_ALG_HASH           xor_;
    990 #endif
    991 } TPMU_SYM_KEY_BITS;
    992 
    993 // Table 126  Definition of TPMU_SYM_MODE Union
    994 typedef union {
    995 #ifdef TPM_ALG_AES
    996   TPMI_ALG_SYM_MODE  aes;
    997 #endif
    998 #ifdef TPM_ALG_SM4
    999   TPMI_ALG_SYM_MODE  sm4;
   1000 #endif
   1001 #ifdef TPM_ALG_CAMELLIA
   1002   TPMI_ALG_SYM_MODE  camellia;
   1003 #endif
   1004   TPMI_ALG_SYM_MODE  sym;
   1005 } TPMU_SYM_MODE;
   1006 
   1007 // Table 127 xDefinition of TPMU_SYM_DETAILS Union
   1008 typedef union {
   1009 } TPMU_SYM_DETAILS;
   1010 
   1011 // Table 128  Definition of TPMT_SYM_DEF Structure
   1012 typedef struct {
   1013   TPMI_ALG_SYM       algorithm;
   1014   TPMU_SYM_KEY_BITS  keyBits;
   1015   TPMU_SYM_MODE      mode;
   1016 } TPMT_SYM_DEF;
   1017 
   1018 // Table 129  Definition of TPMT_SYM_DEF_OBJECT Structure
   1019 typedef struct {
   1020   TPMI_ALG_SYM_OBJECT  algorithm;
   1021   TPMU_SYM_KEY_BITS    keyBits;
   1022   TPMU_SYM_MODE        mode;
   1023 } TPMT_SYM_DEF_OBJECT;
   1024 
   1025 // Table 130  Definition of TPM2B_SYM_KEY Structure
   1026 typedef union {
   1027   struct {
   1028     UINT16  size;
   1029     BYTE    buffer[MAX_SYM_KEY_BYTES];
   1030   } t;
   1031   TPM2B b;
   1032 } TPM2B_SYM_KEY;
   1033 
   1034 // Table 131  Definition of TPMS_SYMCIPHER_PARMS Structure
   1035 typedef struct {
   1036   TPMT_SYM_DEF_OBJECT  sym;
   1037 } TPMS_SYMCIPHER_PARMS;
   1038 
   1039 // Table 132  Definition of TPM2B_SENSITIVE_DATA Structure
   1040 typedef union {
   1041   struct {
   1042     UINT16  size;
   1043     BYTE    buffer[MAX_SYM_DATA];
   1044   } t;
   1045   TPM2B b;
   1046 } TPM2B_SENSITIVE_DATA;
   1047 
   1048 // Table 133  Definition of TPMS_SENSITIVE_CREATE Structure <  IN>
   1049 typedef struct {
   1050   TPM2B_AUTH            userAuth;
   1051   TPM2B_SENSITIVE_DATA  data;
   1052 } TPMS_SENSITIVE_CREATE;
   1053 
   1054 // Table 134  Definition of TPM2B_SENSITIVE_CREATE Structure <  IN, S>
   1055 typedef union {
   1056   struct {
   1057     UINT16                 size;
   1058     TPMS_SENSITIVE_CREATE  sensitive;
   1059   } t;
   1060   TPM2B b;
   1061 } TPM2B_SENSITIVE_CREATE;
   1062 
   1063 // Table 135  Definition of TPMS_SCHEME_HASH Structure
   1064 typedef struct {
   1065   TPMI_ALG_HASH  hashAlg;
   1066 } TPMS_SCHEME_HASH;
   1067 
   1068 // Table 136  Definition of TPMS_SCHEME_ECDAA Structure
   1069 typedef struct {
   1070   TPMI_ALG_HASH  hashAlg;
   1071   UINT16         count;
   1072 } TPMS_SCHEME_ECDAA;
   1073 
   1074 // Table 137  Definition of TPMI_ALG_KEYEDHASH_SCHEME Type
   1075 typedef TPM_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME;
   1076 // Table 138  Definition of Types for HMAC_SIG_SCHEME
   1077 typedef TPMS_SCHEME_HASH TPMS_SCHEME_HMAC;
   1078 
   1079 // Table 139  Definition of TPMS_SCHEME_XOR Structure
   1080 typedef struct {
   1081   TPMI_ALG_HASH  hashAlg;
   1082   TPMI_ALG_KDF   kdf;
   1083 } TPMS_SCHEME_XOR;
   1084 
   1085 // Table 140  Definition of TPMU_SCHEME_KEYEDHASH Union <  IN/OUT, S>
   1086 typedef union {
   1087 #ifdef TPM_ALG_HMAC
   1088   TPMS_SCHEME_HMAC  hmac;
   1089 #endif
   1090 #ifdef TPM_ALG_XOR
   1091   TPMS_SCHEME_XOR   xor_;
   1092 #endif
   1093 } TPMU_SCHEME_KEYEDHASH;
   1094 
   1095 // Table 141  Definition of TPMT_KEYEDHASH_SCHEME Structure
   1096 typedef struct {
   1097   TPMI_ALG_KEYEDHASH_SCHEME  scheme;
   1098   TPMU_SCHEME_KEYEDHASH      details;
   1099 } TPMT_KEYEDHASH_SCHEME;
   1100 
   1101 // Table 142  Definition of Types for RSA Signature Schemes
   1102 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSASSA;
   1103 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSAPSS;
   1104 
   1105 // Table 143  Definition of Types for ECC Signature Schemes
   1106 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_ECDSA;
   1107 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_SM2;
   1108 typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_ECSCHNORR;
   1109 typedef TPMS_SCHEME_ECDAA TPMS_SIG_SCHEME_ECDAA;
   1110 
   1111 // Table 144  Definition of TPMU_SIG_SCHEME Union <  IN/OUT, S>
   1112 typedef union {
   1113 #ifdef TPM_ALG_RSASSA
   1114   TPMS_SIG_SCHEME_RSASSA     rsassa;
   1115 #endif
   1116 #ifdef TPM_ALG_RSAPSS
   1117   TPMS_SIG_SCHEME_RSAPSS     rsapss;
   1118 #endif
   1119 #ifdef TPM_ALG_ECDSA
   1120   TPMS_SIG_SCHEME_ECDSA      ecdsa;
   1121 #endif
   1122 #ifdef TPM_ALG_ECDAA
   1123   TPMS_SIG_SCHEME_ECDAA      ecdaa;
   1124 #endif
   1125 #ifdef TPM_ALG_SM2
   1126   TPMS_SIG_SCHEME_SM2        sm2;
   1127 #endif
   1128 #ifdef TPM_ALG_ECSCHNORR
   1129   TPMS_SIG_SCHEME_ECSCHNORR  ecschnorr;
   1130 #endif
   1131 #ifdef TPM_ALG_HMAC
   1132   TPMS_SCHEME_HMAC           hmac;
   1133 #endif
   1134   TPMS_SCHEME_HASH           any;
   1135 } TPMU_SIG_SCHEME;
   1136 
   1137 // Table 145  Definition of TPMT_SIG_SCHEME Structure
   1138 typedef struct {
   1139   TPMI_ALG_SIG_SCHEME  scheme;
   1140   TPMU_SIG_SCHEME      details;
   1141 } TPMT_SIG_SCHEME;
   1142 
   1143 // Table 146  Definition of Types for Encryption Schemes
   1144 typedef TPMS_SCHEME_HASH TPMS_ENC_SCHEME_OAEP;
   1145 typedef TPMS_EMPTY TPMS_ENC_SCHEME_RSAES;
   1146 
   1147 // Table 147  Definition of Types for ECC Key Exchange
   1148 typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECDH;
   1149 typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECMQV;
   1150 
   1151 // Table 148  Definition of Types for KDF Schemes
   1152 typedef TPMS_SCHEME_HASH TPMS_SCHEME_MGF1;
   1153 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_56A;
   1154 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF2;
   1155 typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_108;
   1156 
   1157 // Table 149  Definition of TPMU_KDF_SCHEME Union <  IN/OUT, S>
   1158 typedef union {
   1159 #ifdef TPM_ALG_MGF1
   1160   TPMS_SCHEME_MGF1            mgf1;
   1161 #endif
   1162 #ifdef TPM_ALG_KDF1_SP800_56A
   1163   TPMS_SCHEME_KDF1_SP800_56A  kdf1_sp800_56a;
   1164 #endif
   1165 #ifdef TPM_ALG_KDF2
   1166   TPMS_SCHEME_KDF2            kdf2;
   1167 #endif
   1168 #ifdef TPM_ALG_KDF1_SP800_108
   1169   TPMS_SCHEME_KDF1_SP800_108  kdf1_sp800_108;
   1170 #endif
   1171 } TPMU_KDF_SCHEME;
   1172 
   1173 // Table 150  Definition of TPMT_KDF_SCHEME Structure
   1174 typedef struct {
   1175   TPMI_ALG_KDF     scheme;
   1176   TPMU_KDF_SCHEME  details;
   1177 } TPMT_KDF_SCHEME;
   1178 
   1179 // Table 151  Definition of TPMI_ALG_ASYM_SCHEME Type <>
   1180 typedef TPM_ALG_ID TPMI_ALG_ASYM_SCHEME;
   1181 // Table 152  Definition of TPMU_ASYM_SCHEME Union
   1182 typedef union {
   1183 #ifdef TPM_ALG_ECDH
   1184   TPMS_KEY_SCHEME_ECDH       ecdh;
   1185 #endif
   1186 #ifdef TPM_ALG_ECMQV
   1187   TPMS_KEY_SCHEME_ECMQV      ecmqv;
   1188 #endif
   1189 #ifdef TPM_ALG_RSASSA
   1190   TPMS_SIG_SCHEME_RSASSA     rsassa;
   1191 #endif
   1192 #ifdef TPM_ALG_RSAPSS
   1193   TPMS_SIG_SCHEME_RSAPSS     rsapss;
   1194 #endif
   1195 #ifdef TPM_ALG_ECDSA
   1196   TPMS_SIG_SCHEME_ECDSA      ecdsa;
   1197 #endif
   1198 #ifdef TPM_ALG_ECDAA
   1199   TPMS_SIG_SCHEME_ECDAA      ecdaa;
   1200 #endif
   1201 #ifdef TPM_ALG_SM2
   1202   TPMS_SIG_SCHEME_SM2        sm2;
   1203 #endif
   1204 #ifdef TPM_ALG_ECSCHNORR
   1205   TPMS_SIG_SCHEME_ECSCHNORR  ecschnorr;
   1206 #endif
   1207 #ifdef TPM_ALG_RSAES
   1208   TPMS_ENC_SCHEME_RSAES      rsaes;
   1209 #endif
   1210 #ifdef TPM_ALG_OAEP
   1211   TPMS_ENC_SCHEME_OAEP       oaep;
   1212 #endif
   1213   TPMS_SCHEME_HASH           anySig;
   1214 } TPMU_ASYM_SCHEME;
   1215 
   1216 // Table 153  Definition of TPMT_ASYM_SCHEME Structure <>
   1217 typedef struct {
   1218   TPMI_ALG_ASYM_SCHEME  scheme;
   1219   TPMU_ASYM_SCHEME      details;
   1220 } TPMT_ASYM_SCHEME;
   1221 
   1222 // Table 154  Definition of TPMI_ALG_RSA_SCHEME Type
   1223 typedef TPM_ALG_ID TPMI_ALG_RSA_SCHEME;
   1224 // Table 155  Definition of TPMT_RSA_SCHEME Structure
   1225 typedef struct {
   1226   TPMI_ALG_RSA_SCHEME  scheme;
   1227   TPMU_ASYM_SCHEME     details;
   1228 } TPMT_RSA_SCHEME;
   1229 
   1230 // Table 156  Definition of TPMI_ALG_RSA_DECRYPT Type
   1231 typedef TPM_ALG_ID TPMI_ALG_RSA_DECRYPT;
   1232 // Table 157  Definition of TPMT_RSA_DECRYPT Structure
   1233 typedef struct {
   1234   TPMI_ALG_RSA_DECRYPT  scheme;
   1235   TPMU_ASYM_SCHEME      details;
   1236 } TPMT_RSA_DECRYPT;
   1237 
   1238 // Table 158  Definition of TPM2B_PUBLIC_KEY_RSA Structure
   1239 typedef union {
   1240   struct {
   1241     UINT16  size;
   1242     BYTE    buffer[MAX_RSA_KEY_BYTES];
   1243   } t;
   1244   TPM2B b;
   1245 } TPM2B_PUBLIC_KEY_RSA;
   1246 
   1247 // Table 159  Definition of TPMI_RSA_KEY_BITS Type
   1248 typedef TPM_KEY_BITS TPMI_RSA_KEY_BITS;
   1249 // Table 160  Definition of TPM2B_PRIVATE_KEY_RSA Structure
   1250 typedef union {
   1251   struct {
   1252     UINT16  size;
   1253     BYTE    buffer[MAX_RSA_KEY_BYTES/2];
   1254   } t;
   1255   TPM2B b;
   1256 } TPM2B_PRIVATE_KEY_RSA;
   1257 
   1258 // Table 161  Definition of TPM2B_ECC_PARAMETER Structure
   1259 typedef union {
   1260   struct {
   1261     UINT16  size;
   1262     BYTE    buffer[MAX_ECC_KEY_BYTES];
   1263   } t;
   1264   TPM2B b;
   1265 } TPM2B_ECC_PARAMETER;
   1266 
   1267 // Table 162  Definition of TPMS_ECC_POINT Structure
   1268 typedef struct {
   1269   TPM2B_ECC_PARAMETER  x;
   1270   TPM2B_ECC_PARAMETER  y;
   1271 } TPMS_ECC_POINT;
   1272 
   1273 // Table   163    Definition of TPM2B_ECC_POINT Structure
   1274 typedef union {
   1275   struct {
   1276     UINT16          size;
   1277     TPMS_ECC_POINT  point;
   1278   } t;
   1279   TPM2B b;
   1280 } TPM2B_ECC_POINT;
   1281 
   1282 // Table 164  Definition of TPMI_ALG_ECC_SCHEME Type
   1283 typedef TPM_ALG_ID TPMI_ALG_ECC_SCHEME;
   1284 // Table 165  Definition of TPMI_ECC_CURVE Type
   1285 typedef TPM_ECC_CURVE TPMI_ECC_CURVE;
   1286 // Table 166  Definition of TPMT_ECC_SCHEME Structure
   1287 typedef struct {
   1288   TPMI_ALG_ECC_SCHEME  scheme;
   1289   TPMU_ASYM_SCHEME     details;
   1290 } TPMT_ECC_SCHEME;
   1291 
   1292 // Table 167  Definition of TPMS_ALGORITHM_DETAIL_ECC Structure <  OUT>
   1293 typedef struct {
   1294   TPM_ECC_CURVE        curveID;
   1295   UINT16               keySize;
   1296   TPMT_KDF_SCHEME      kdf;
   1297   TPMT_ECC_SCHEME      sign;
   1298   TPM2B_ECC_PARAMETER  p;
   1299   TPM2B_ECC_PARAMETER  a;
   1300   TPM2B_ECC_PARAMETER  b;
   1301   TPM2B_ECC_PARAMETER  gX;
   1302   TPM2B_ECC_PARAMETER  gY;
   1303   TPM2B_ECC_PARAMETER  n;
   1304   TPM2B_ECC_PARAMETER  h;
   1305 } TPMS_ALGORITHM_DETAIL_ECC;
   1306 
   1307 // Table 168  Definition of TPMS_SIGNATURE_RSA Structure
   1308 typedef struct {
   1309   TPMI_ALG_HASH         hash;
   1310   TPM2B_PUBLIC_KEY_RSA  sig;
   1311 } TPMS_SIGNATURE_RSA;
   1312 
   1313 // Table 169  Definition of Types for Signature
   1314 typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSASSA;
   1315 typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSAPSS;
   1316 
   1317 // Table 170  Definition of TPMS_SIGNATURE_ECC Structure
   1318 typedef struct {
   1319   TPMI_ALG_HASH        hash;
   1320   TPM2B_ECC_PARAMETER  signatureR;
   1321   TPM2B_ECC_PARAMETER  signatureS;
   1322 } TPMS_SIGNATURE_ECC;
   1323 
   1324 // Table 171  Definition of Types for TPMS_SIGNATUE_ECC
   1325 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDSA;
   1326 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDAA;
   1327 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_SM2;
   1328 typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECSCHNORR;
   1329 
   1330 // Table 172  Definition of TPMU_SIGNATURE Union <  IN/OUT, S>
   1331 typedef union {
   1332 #ifdef TPM_ALG_RSASSA
   1333   TPMS_SIGNATURE_RSASSA     rsassa;
   1334 #endif
   1335 #ifdef TPM_ALG_RSAPSS
   1336   TPMS_SIGNATURE_RSAPSS     rsapss;
   1337 #endif
   1338 #ifdef TPM_ALG_ECDSA
   1339   TPMS_SIGNATURE_ECDSA      ecdsa;
   1340 #endif
   1341 #ifdef TPM_ALG_ECDAA
   1342   TPMS_SIGNATURE_ECDAA      ecdaa;
   1343 #endif
   1344 #ifdef TPM_ALG_SM2
   1345   TPMS_SIGNATURE_SM2        sm2;
   1346 #endif
   1347 #ifdef TPM_ALG_ECSCHNORR
   1348   TPMS_SIGNATURE_ECSCHNORR  ecschnorr;
   1349 #endif
   1350 #ifdef TPM_ALG_HMAC
   1351   TPMT_HA                   hmac;
   1352 #endif
   1353   TPMS_SCHEME_HASH          any;
   1354 } TPMU_SIGNATURE;
   1355 
   1356 // Table 173  Definition of TPMT_SIGNATURE Structure
   1357 typedef struct {
   1358   TPMI_ALG_SIG_SCHEME  sigAlg;
   1359   TPMU_SIGNATURE       signature;
   1360 } TPMT_SIGNATURE;
   1361 
   1362 // Table 174  Definition of TPMU_ENCRYPTED_SECRET Union <  S>
   1363 typedef union {
   1364 #ifdef TPM_ALG_ECC
   1365   BYTE  ecc[sizeof(TPMS_ECC_POINT)];
   1366 #endif
   1367 #ifdef TPM_ALG_RSA
   1368   BYTE  rsa[MAX_RSA_KEY_BYTES];
   1369 #endif
   1370 #ifdef TPM_ALG_SYMCIPHER
   1371   BYTE  symmetric[sizeof(TPM2B_DIGEST)];
   1372 #endif
   1373 #ifdef TPM_ALG_KEYEDHASH
   1374   BYTE  keyedHash[sizeof(TPM2B_DIGEST)];
   1375 #endif
   1376 } TPMU_ENCRYPTED_SECRET;
   1377 
   1378 // Table 175  Definition of TPM2B_ENCRYPTED_SECRET Structure
   1379 typedef union {
   1380   struct {
   1381     UINT16  size;
   1382     BYTE    secret[sizeof(TPMU_ENCRYPTED_SECRET)];
   1383   } t;
   1384   TPM2B b;
   1385 } TPM2B_ENCRYPTED_SECRET;
   1386 
   1387 // Table 176  Definition of TPMI_ALG_PUBLIC Type
   1388 typedef TPM_ALG_ID TPMI_ALG_PUBLIC;
   1389 // Table 177  Definition of TPMU_PUBLIC_ID Union <  IN/OUT, S>
   1390 typedef union {
   1391 #ifdef TPM_ALG_KEYEDHASH
   1392   TPM2B_DIGEST          keyedHash;
   1393 #endif
   1394 #ifdef TPM_ALG_SYMCIPHER
   1395   TPM2B_DIGEST          sym;
   1396 #endif
   1397 #ifdef TPM_ALG_RSA
   1398   TPM2B_PUBLIC_KEY_RSA  rsa;
   1399 #endif
   1400 #ifdef TPM_ALG_ECC
   1401   TPMS_ECC_POINT        ecc;
   1402 #endif
   1403 } TPMU_PUBLIC_ID;
   1404 
   1405 // Table 178  Definition of TPMS_KEYEDHASH_PARMS Structure
   1406 typedef struct {
   1407   TPMT_KEYEDHASH_SCHEME  scheme;
   1408 } TPMS_KEYEDHASH_PARMS;
   1409 
   1410 // Table 179  Definition of TPMS_ASYM_PARMS Structure <>
   1411 typedef struct {
   1412   TPMT_SYM_DEF_OBJECT  symmetric;
   1413   TPMT_ASYM_SCHEME     scheme;
   1414 } TPMS_ASYM_PARMS;
   1415 
   1416 // Table 180  Definition of TPMS_RSA_PARMS Structure
   1417 typedef struct {
   1418   TPMT_SYM_DEF_OBJECT  symmetric;
   1419   TPMT_RSA_SCHEME      scheme;
   1420   TPMI_RSA_KEY_BITS    keyBits;
   1421   UINT32               exponent;
   1422 } TPMS_RSA_PARMS;
   1423 
   1424 // Table 181  Definition of TPMS_ECC_PARMS Structure
   1425 typedef struct {
   1426   TPMT_SYM_DEF_OBJECT  symmetric;
   1427   TPMT_ECC_SCHEME      scheme;
   1428   TPMI_ECC_CURVE       curveID;
   1429   TPMT_KDF_SCHEME      kdf;
   1430 } TPMS_ECC_PARMS;
   1431 
   1432 // Table 182  Definition of TPMU_PUBLIC_PARMS Union <  IN/OUT, S>
   1433 typedef union {
   1434 #ifdef TPM_ALG_KEYEDHASH
   1435   TPMS_KEYEDHASH_PARMS  keyedHashDetail;
   1436 #endif
   1437 #ifdef TPM_ALG_SYMCIPHER
   1438   TPMS_SYMCIPHER_PARMS  symDetail;
   1439 #endif
   1440 #ifdef TPM_ALG_RSA
   1441   TPMS_RSA_PARMS        rsaDetail;
   1442 #endif
   1443 #ifdef TPM_ALG_ECC
   1444   TPMS_ECC_PARMS        eccDetail;
   1445 #endif
   1446   TPMS_ASYM_PARMS       asymDetail;
   1447 } TPMU_PUBLIC_PARMS;
   1448 
   1449 // Table 183  Definition of TPMT_PUBLIC_PARMS Structure
   1450 typedef struct {
   1451   TPMI_ALG_PUBLIC    type;
   1452   TPMU_PUBLIC_PARMS  parameters;
   1453 } TPMT_PUBLIC_PARMS;
   1454 
   1455 // Table 184  Definition of TPMT_PUBLIC Structure
   1456 typedef struct {
   1457   TPMI_ALG_PUBLIC    type;
   1458   TPMI_ALG_HASH      nameAlg;
   1459   TPMA_OBJECT        objectAttributes;
   1460   TPM2B_DIGEST       authPolicy;
   1461   TPMU_PUBLIC_PARMS  parameters;
   1462   TPMU_PUBLIC_ID     unique;
   1463 } TPMT_PUBLIC;
   1464 
   1465 // Table 185  Definition of TPM2B_PUBLIC Structure
   1466 typedef union {
   1467   struct {
   1468     UINT16       size;
   1469     TPMT_PUBLIC  publicArea;
   1470   } t;
   1471   TPM2B b;
   1472 } TPM2B_PUBLIC;
   1473 
   1474 // Table 186  Definition of TPM2B_PRIVATE_VENDOR_SPECIFIC Structure<>
   1475 typedef union {
   1476   struct {
   1477     UINT16  size;
   1478     BYTE    buffer[PRIVATE_VENDOR_SPECIFIC_BYTES];
   1479   } t;
   1480   TPM2B b;
   1481 } TPM2B_PRIVATE_VENDOR_SPECIFIC;
   1482 
   1483 // Table 187  Definition of TPMU_SENSITIVE_COMPOSITE Union <  IN/OUT, S>
   1484 typedef union {
   1485 #ifdef TPM_ALG_RSA
   1486   TPM2B_PRIVATE_KEY_RSA          rsa;
   1487 #endif
   1488 #ifdef TPM_ALG_ECC
   1489   TPM2B_ECC_PARAMETER            ecc;
   1490 #endif
   1491 #ifdef TPM_ALG_KEYEDHASH
   1492   TPM2B_SENSITIVE_DATA           bits;
   1493 #endif
   1494 #ifdef TPM_ALG_SYMCIPHER
   1495   TPM2B_SYM_KEY                  sym;
   1496 #endif
   1497   TPM2B_PRIVATE_VENDOR_SPECIFIC  any;
   1498 } TPMU_SENSITIVE_COMPOSITE;
   1499 
   1500 // Table 188  Definition of TPMT_SENSITIVE Structure
   1501 typedef struct {
   1502   TPMI_ALG_PUBLIC           sensitiveType;
   1503   TPM2B_AUTH                authValue;
   1504   TPM2B_DIGEST              seedValue;
   1505   TPMU_SENSITIVE_COMPOSITE  sensitive;
   1506 } TPMT_SENSITIVE;
   1507 
   1508 // Table 189  Definition of TPM2B_SENSITIVE Structure <  IN/OUT>
   1509 typedef union {
   1510   struct {
   1511     UINT16          size;
   1512     TPMT_SENSITIVE  sensitiveArea;
   1513   } t;
   1514   TPM2B b;
   1515 } TPM2B_SENSITIVE;
   1516 
   1517 // Table 190  Definition of _PRIVATE Structure <>
   1518 typedef struct {
   1519   TPM2B_DIGEST    integrityOuter;
   1520   TPM2B_DIGEST    integrityInner;
   1521   TPMT_SENSITIVE  sensitive;
   1522 } _PRIVATE;
   1523 
   1524 // Table 191  Definition of TPM2B_PRIVATE Structure <  IN/OUT, S>
   1525 typedef union {
   1526   struct {
   1527     UINT16  size;
   1528     BYTE    buffer[sizeof(_PRIVATE)];
   1529   } t;
   1530   TPM2B b;
   1531 } TPM2B_PRIVATE;
   1532 
   1533 // Table 192  Definition of _ID_OBJECT Structure <>
   1534 typedef struct {
   1535   TPM2B_DIGEST  integrityHMAC;
   1536   TPM2B_DIGEST  encIdentity;
   1537 } _ID_OBJECT;
   1538 
   1539 // Table 193  Definition of TPM2B_ID_OBJECT Structure <  IN/OUT>
   1540 typedef union {
   1541   struct {
   1542     UINT16  size;
   1543     BYTE    credential[sizeof(_ID_OBJECT)];
   1544   } t;
   1545   TPM2B b;
   1546 } TPM2B_ID_OBJECT;
   1547 
   1548 // Table 194  Definition of TPM_NV_INDEX Bits <>
   1549 typedef struct {
   1550   UINT32 index : 24;
   1551   UINT32 RH_NV : 8;
   1552 } TPM_NV_INDEX;
   1553 
   1554 // Table 195  Definition of TPMA_NV Bits
   1555 typedef struct {
   1556   UINT32 TPMA_NV_PPWRITE        : 1;
   1557   UINT32 TPMA_NV_OWNERWRITE     : 1;
   1558   UINT32 TPMA_NV_AUTHWRITE      : 1;
   1559   UINT32 TPMA_NV_POLICYWRITE    : 1;
   1560   UINT32 TPMA_NV_COUNTER        : 1;
   1561   UINT32 TPMA_NV_BITS           : 1;
   1562   UINT32 TPMA_NV_EXTEND         : 1;
   1563   UINT32 reserved7_9            : 3;
   1564   UINT32 TPMA_NV_POLICY_DELETE  : 1;
   1565   UINT32 TPMA_NV_WRITELOCKED    : 1;
   1566   UINT32 TPMA_NV_WRITEALL       : 1;
   1567   UINT32 TPMA_NV_WRITEDEFINE    : 1;
   1568   UINT32 TPMA_NV_WRITE_STCLEAR  : 1;
   1569   UINT32 TPMA_NV_GLOBALLOCK     : 1;
   1570   UINT32 TPMA_NV_PPREAD         : 1;
   1571   UINT32 TPMA_NV_OWNERREAD      : 1;
   1572   UINT32 TPMA_NV_AUTHREAD       : 1;
   1573   UINT32 TPMA_NV_POLICYREAD     : 1;
   1574   UINT32 reserved20_24          : 5;
   1575   UINT32 TPMA_NV_NO_DA          : 1;
   1576   UINT32 TPMA_NV_ORDERLY        : 1;
   1577   UINT32 TPMA_NV_CLEAR_STCLEAR  : 1;
   1578   UINT32 TPMA_NV_READLOCKED     : 1;
   1579   UINT32 TPMA_NV_WRITTEN        : 1;
   1580   UINT32 TPMA_NV_PLATFORMCREATE : 1;
   1581   UINT32 TPMA_NV_READ_STCLEAR   : 1;
   1582 } TPMA_NV;
   1583 
   1584 // Table 196  Definition of TPMS_NV_PUBLIC Structure
   1585 typedef struct {
   1586   TPMI_RH_NV_INDEX  nvIndex;
   1587   TPMI_ALG_HASH     nameAlg;
   1588   TPMA_NV           attributes;
   1589   TPM2B_DIGEST      authPolicy;
   1590   UINT16            dataSize;
   1591 } TPMS_NV_PUBLIC;
   1592 
   1593 // Table 197  Definition of TPM2B_NV_PUBLIC Structure
   1594 typedef union {
   1595   struct {
   1596     UINT16          size;
   1597     TPMS_NV_PUBLIC  nvPublic;
   1598   } t;
   1599   TPM2B b;
   1600 } TPM2B_NV_PUBLIC;
   1601 
   1602 // Table 198  Definition of TPM2B_CONTEXT_SENSITIVE Structure <  IN/OUT>
   1603 typedef union {
   1604   struct {
   1605     UINT16  size;
   1606     BYTE    buffer[MAX_CONTEXT_SIZE];
   1607   } t;
   1608   TPM2B b;
   1609 } TPM2B_CONTEXT_SENSITIVE;
   1610 
   1611 // Table 199  Definition of TPMS_CONTEXT_DATA Structure <  IN/OUT, S>
   1612 typedef struct {
   1613   TPM2B_DIGEST             integrity;
   1614   TPM2B_CONTEXT_SENSITIVE  encrypted;
   1615 } TPMS_CONTEXT_DATA;
   1616 
   1617 // Table 200  Definition of TPM2B_CONTEXT_DATA Structure <  IN/OUT>
   1618 typedef union {
   1619   struct {
   1620     UINT16  size;
   1621     BYTE    buffer[sizeof(TPMS_CONTEXT_DATA)];
   1622   } t;
   1623   TPM2B b;
   1624 } TPM2B_CONTEXT_DATA;
   1625 
   1626 // Table 201  Definition of TPMS_CONTEXT Structure
   1627 typedef struct {
   1628   UINT64              sequence;
   1629   TPMI_DH_CONTEXT     savedHandle;
   1630   TPMI_RH_HIERARCHY   hierarchy;
   1631   TPM2B_CONTEXT_DATA  contextBlob;
   1632 } TPMS_CONTEXT;
   1633 
   1634 // Unprocessed: Table 202  Context Handle Values
   1635 // Table 203  Definition of TPMS_CREATION_DATA Structure <  OUT>
   1636 typedef struct {
   1637   TPML_PCR_SELECTION  pcrSelect;
   1638   TPM2B_DIGEST        pcrDigest;
   1639   TPMA_LOCALITY       locality;
   1640   TPM_ALG_ID          parentNameAlg;
   1641   TPM2B_NAME          parentName;
   1642   TPM2B_NAME          parentQualifiedName;
   1643   TPM2B_DATA          outsideInfo;
   1644 } TPMS_CREATION_DATA;
   1645 
   1646 // Table 204  Definition of TPM2B_CREATION_DATA Structure <  OUT>
   1647 typedef union {
   1648   struct {
   1649     UINT16              size;
   1650     TPMS_CREATION_DATA  creationData;
   1651   } t;
   1652   TPM2B b;
   1653 } TPM2B_CREATION_DATA;
   1654 
   1655 
   1656 #endif  // TPM2_TPM_TYPES_H_
   1657