Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 1 | // This file was extracted from the TCG Published |
| 2 | // Trusted Platform Module Library |
| 3 | // Part 4: Supporting Routines |
| 4 | // Family "2.0" |
| 5 | // Level 00 Revision 01.16 |
| 6 | // October 30, 2014 |
| 7 | |
| 8 | #ifndef _IMPLEMENTATION_H_ |
| 9 | #define _IMPLEMENTATION_H_ |
| 10 | #include "BaseTypes.h" |
| 11 | #include "TPMB.h" |
| 12 | #undef TRUE |
| 13 | #undef FALSE |
| 14 | // |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 15 | // This table is built in to TpmStructures() Change these definitions |
| 16 | // to turn all algorithms or commands on or off |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 17 | // |
| 18 | #define ALG_YES YES |
| 19 | #define ALG_NO NO |
| 20 | #define CC_YES YES |
| 21 | #define CC_NO NO |
| 22 | // |
| 23 | // From TPM 2.0 Part 2: Table 4 - Defines for Logic Values |
| 24 | // |
| 25 | #define TRUE 1 |
| 26 | #define FALSE 0 |
| 27 | #define YES 1 |
| 28 | #define NO 0 |
| 29 | #define SET 1 |
| 30 | #define CLEAR 0 |
| 31 | // |
| 32 | // From Vendor-Specific: Table 1 - Defines for Processor Values |
| 33 | // |
| 34 | #define BIG_ENDIAN_TPM NO |
| 35 | #define LITTLE_ENDIAN_TPM YES |
| 36 | #define NO_AUTO_ALIGN NO |
| 37 | // |
| 38 | // From Vendor-Specific: Table 2 - Defines for Implemented Algorithms |
| 39 | // |
| 40 | #define ALG_RSA ALG_YES |
| 41 | #define ALG_SHA1 ALG_YES |
| 42 | #define ALG_HMAC ALG_YES |
| 43 | #define ALG_AES ALG_YES |
| 44 | #define ALG_MGF1 ALG_YES |
| 45 | #define ALG_XOR ALG_YES |
| 46 | #define ALG_KEYEDHASH ALG_YES |
| 47 | #define ALG_SHA256 ALG_YES |
| 48 | #define ALG_SHA384 ALG_YES |
Andrey Pronin | f037a5c | 2016-11-29 12:39:30 -0800 | [diff] [blame] | 49 | #define ALG_SHA512 ALG_YES |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 50 | #define ALG_SM3_256 ALG_NO |
| 51 | #define ALG_SM4 ALG_NO |
| 52 | #define ALG_RSASSA (ALG_YES*ALG_RSA) |
| 53 | #define ALG_RSAES (ALG_YES*ALG_RSA) |
| 54 | #define ALG_RSAPSS (ALG_YES*ALG_RSA) |
| 55 | #define ALG_OAEP (ALG_YES*ALG_RSA) |
| 56 | #define ALG_ECC ALG_YES |
| 57 | #define ALG_ECDH (ALG_YES*ALG_ECC) |
| 58 | #define ALG_ECDSA (ALG_YES*ALG_ECC) |
nagendra modadugu | 16e65be | 2016-03-08 11:05:25 -0800 | [diff] [blame] | 59 | #ifdef EMBEDDED_MODE |
| 60 | #define ALG_ECDAA (ALG_NO*ALG_ECC) |
| 61 | #define ALG_SM2 (ALG_NO*ALG_ECC) |
| 62 | #define ALG_ECSCHNORR (ALG_NO*ALG_ECC) |
| 63 | #else |
nagendra modadugu | afa4372 | 2016-03-07 18:38:56 -0800 | [diff] [blame] | 64 | #define ALG_ECDAA (ALG_YES*ALG_ECC) |
| 65 | #define ALG_SM2 (ALG_YES*ALG_ECC) |
| 66 | #define ALG_ECSCHNORR (ALG_YES*ALG_ECC) |
nagendra modadugu | 16e65be | 2016-03-08 11:05:25 -0800 | [diff] [blame] | 67 | #endif |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 68 | #define ALG_ECMQV (ALG_NO*ALG_ECC) |
| 69 | #define ALG_SYMCIPHER ALG_YES |
| 70 | #define ALG_KDF1_SP800_56A (ALG_YES*ALG_ECC) |
| 71 | #define ALG_KDF2 ALG_NO |
| 72 | #define ALG_KDF1_SP800_108 ALG_YES |
| 73 | #define ALG_CTR ALG_YES |
| 74 | #define ALG_OFB ALG_YES |
| 75 | #define ALG_CBC ALG_YES |
| 76 | #define ALG_CFB ALG_YES |
| 77 | #define ALG_ECB ALG_YES |
| 78 | // |
| 79 | // From Vendor-Specific: Table 4 - Defines for Key Size Constants |
| 80 | // |
| 81 | #define RSA_KEY_SIZES_BITS {1024,2048} |
| 82 | #define RSA_KEY_SIZE_BITS_1024 RSA_ALLOWED_KEY_SIZE_1024 |
| 83 | #define RSA_KEY_SIZE_BITS_2048 RSA_ALLOWED_KEY_SIZE_2048 |
| 84 | #define MAX_RSA_KEY_BITS 2048 |
| 85 | #define MAX_RSA_KEY_BYTES 256 |
| 86 | #define AES_KEY_SIZES_BITS {128,256} |
| 87 | #define AES_KEY_SIZE_BITS_128 AES_ALLOWED_KEY_SIZE_128 |
| 88 | #define AES_KEY_SIZE_BITS_256 AES_ALLOWED_KEY_SIZE_256 |
| 89 | #define MAX_AES_KEY_BITS 256 |
| 90 | #define MAX_AES_KEY_BYTES 32 |
| 91 | #define MAX_AES_BLOCK_SIZE_BYTES \ |
| 92 | MAX(AES_128_BLOCK_SIZE_BYTES, \ |
| 93 | MAX(AES_256_BLOCK_SIZE_BYTES, 0)) |
| 94 | #define SM4_KEY_SIZES_BITS {128} |
| 95 | #define SM4_KEY_SIZE_BITS_128 SM4_ALLOWED_KEY_SIZE_128 |
| 96 | #define MAX_SM4_KEY_BITS 128 |
| 97 | #define MAX_SM4_KEY_BYTES 16 |
| 98 | #define MAX_SM4_BLOCK_SIZE_BYTES \ |
| 99 | MAX(SM4_128_BLOCK_SIZE_BYTES, 0) |
| 100 | #define CAMELLIA_KEY_SIZES_BITS {128} |
| 101 | #define CAMELLIA_KEY_SIZE_BITS_128 CAMELLIA_ALLOWED_KEY_SIZE_128 |
| 102 | #define MAX_CAMELLIA_KEY_BITS 128 |
| 103 | #define MAX_CAMELLIA_KEY_BYTES 16 |
| 104 | #define MAX_CAMELLIA_BLOCK_SIZE_BYTES \ |
| 105 | MAX(CAMELLIA_128_BLOCK_SIZE_BYTES, 0) |
| 106 | // |
| 107 | // From Vendor-Specific: Table 5 - Defines for Implemented Curves |
| 108 | // |
| 109 | #define ECC_NIST_P256 YES |
| 110 | #define ECC_NIST_P384 YES |
| 111 | #define ECC_BN_P256 YES |
| 112 | #define ECC_CURVES {\ |
| 113 | TPM_ECC_BN_P256, TPM_ECC_NIST_P256, TPM_ECC_NIST_P384} |
| 114 | #define ECC_KEY_SIZES_BITS {256, 384} |
| 115 | #define ECC_KEY_SIZE_BITS_256 |
| 116 | #define ECC_KEY_SIZE_BITS_384 |
| 117 | #define MAX_ECC_KEY_BITS 384 |
| 118 | #define MAX_ECC_KEY_BYTES 48 |
| 119 | // |
| 120 | // From Vendor-Specific: Table 6 - Defines for Implemented Commands |
| 121 | // |
Andrey Pronin | fe21434 | 2018-07-02 15:46:25 -0700 | [diff] [blame] | 122 | |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 123 | // Flags to define wherever command is needed for a particular environment: |
| 124 | // - Commands mandatory for Chrome OS |
| 125 | #define CC_S_CROS_MUST (1 << 1) |
| 126 | // - Commands required by TCG PC Client Profile |
| 127 | #define CC_S_TCG_MUST (1 << 2) |
| 128 | // - Commands mandatory for Windows |
| 129 | #define CC_S_WIN_MUST (1 << 3) |
| 130 | // - Commands recommended for Windows |
| 131 | #define CC_S_WIN_REC (1 << 4) |
| 132 | // - Commands devoted to firmware upgrade |
| 133 | #define CC_S_FWUPGRADE (1 << 5) |
| 134 | // - Commands required for ChromeOS AP firmware |
| 135 | #define CC_S_COREBOOT (1 << 6) |
| 136 | // - Other commands: optional for all OS and TCG |
| 137 | #define CC_S_OPTIONAL (1 << 7) |
| 138 | |
| 139 | // Flags to define common combinations of flags: |
| 140 | // - Commands mandatory for ChromeOS and TCG |
| 141 | #define CC_S_CROS_TCG (CC_S_CROS_MUST | CC_S_TCG_MUST) |
| 142 | // - Commands mandatory and recommended for Windows |
| 143 | #define CC_S_WINDOWS (CC_S_WIN_MUST | CC_S_WIN_REC) |
| 144 | // - Commands mandatory for TCG and Windows, including recommended for Windows |
| 145 | #define CC_S_WIN_TCG (CC_S_WINDOWS | CC_S_TCG_MUST) |
| 146 | // - Commands mandatory for ChromeOS, Windows, TCG |
| 147 | #define CC_S_ALL_MUST (CC_S_CROS_MUST | CC_S_WINDOWS | CC_S_TCG_MUST) |
| 148 | |
| 149 | // Flags to select supported environment (for CC_ENABLED_SET) |
Namyoon Woo | 872d8d0 | 2020-03-23 10:37:53 -0700 | [diff] [blame] | 150 | // CC_S_CROS_ONLY - Only ChromeOS / Coreboot |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 151 | // CC_S_WINDOWS_ONLY - Support only Windows mandatory and recommended |
| 152 | // CC_S_COMMON_SET - Common subset of mandatory and recommended |
| 153 | // commands, excluding OPTIONAL |
| 154 | #define CC_S_CROS_ONLY (CC_S_CROS_MUST | CC_S_COREBOOT) |
| 155 | #define CC_S_WINDOWS_ONLY (CC_S_WINDOWS | CC_S_COREBOOT) |
| 156 | #define CC_S_COMMON_SET (CC_S_CROS_ONLY | CC_S_WIN_TCG) |
| 157 | |
| 158 | // CC_ENABLED_SET defines flags to select supported environment |
| 159 | #ifndef CC_ENABLED_SET |
Namyoon Woo | 872d8d0 | 2020-03-23 10:37:53 -0700 | [diff] [blame] | 160 | #define CC_ENABLED_SET (CC_S_CROS_ONLY) |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 161 | #endif |
| 162 | |
| 163 | #define CC_SET(mask) ((CC_ENABLED_SET & (mask)) ? CC_YES : CC_NO) |
| 164 | #define IS_CC_ENABLED(cmd) ((CC_##cmd) == CC_YES) |
| 165 | |
| 166 | #define CC_ActivateCredential CC_SET(CC_S_ALL_MUST) |
| 167 | #define CC_Certify CC_SET(CC_S_ALL_MUST) |
| 168 | #define CC_CertifyCreation CC_SET(CC_S_ALL_MUST) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 169 | // |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 170 | #define CC_ChangeEPS CC_SET(CC_S_OPTIONAL) |
| 171 | #define CC_ChangePPS CC_SET(CC_S_OPTIONAL) |
| 172 | |
| 173 | #define CC_Clear CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 174 | #define CC_ClearControl CC_SET(CC_S_WIN_TCG) |
| 175 | #define CC_ClockRateAdjust CC_SET(CC_S_TCG_MUST) |
| 176 | #define CC_ClockSet CC_SET(CC_S_WINDOWS) |
| 177 | #define CC_Commit CC_SET((CC_S_CROS_TCG * ALG_ECC)) |
| 178 | #define CC_ContextLoad CC_SET(CC_S_ALL_MUST) |
| 179 | #define CC_ContextSave CC_SET(CC_S_ALL_MUST) |
| 180 | #define CC_Create CC_SET(CC_S_ALL_MUST) |
| 181 | #define CC_CreatePrimary CC_SET(CC_S_ALL_MUST) |
| 182 | #define CC_DictionaryAttackLockReset CC_SET(CC_S_ALL_MUST) |
| 183 | #define CC_DictionaryAttackParameters CC_SET(CC_S_ALL_MUST) |
| 184 | #define CC_Duplicate CC_SET(CC_S_WIN_TCG) |
| 185 | #define CC_ECC_Parameters CC_SET((CC_S_CROS_TCG * ALG_ECC)) |
| 186 | #define CC_ECDH_KeyGen CC_SET((CC_S_CROS_TCG * ALG_ECC)) |
| 187 | #define CC_ECDH_ZGen CC_SET((CC_S_CROS_TCG * ALG_ECC)) |
| 188 | #define CC_EC_Ephemeral CC_SET((CC_S_OPTIONAL * ALG_ECC)) |
| 189 | #define CC_EncryptDecrypt CC_SET(CC_S_OPTIONAL) |
| 190 | #define CC_EventSequenceComplete CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 191 | #define CC_EvictControl CC_SET(CC_S_ALL_MUST) |
| 192 | #define CC_FieldUpgradeData CC_SET(CC_S_FWUPGRADE) |
| 193 | #define CC_FieldUpgradeStart CC_SET(CC_S_FWUPGRADE) |
| 194 | #define CC_FirmwareRead CC_SET(CC_S_FWUPGRADE) |
| 195 | #define CC_FlushContext CC_SET(CC_S_ALL_MUST) |
| 196 | #define CC_GetCapability CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 197 | #define CC_GetCommandAuditDigest CC_SET(CC_S_OPTIONAL) |
| 198 | #define CC_GetRandom CC_SET(CC_S_ALL_MUST) |
| 199 | #define CC_GetSessionAuditDigest CC_SET(CC_S_TCG_MUST) |
| 200 | #define CC_GetTestResult CC_SET(CC_S_ALL_MUST) |
| 201 | #define CC_GetTime CC_SET(CC_S_TCG_MUST) |
| 202 | #define CC_Hash CC_SET(CC_S_ALL_MUST) |
| 203 | #define CC_HashSequenceStart CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 204 | #define CC_HierarchyChangeAuth CC_SET(CC_S_ALL_MUST) |
| 205 | #define CC_HierarchyControl CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 206 | #define CC_HMAC CC_SET(CC_S_CROS_TCG) |
| 207 | #define CC_HMAC_Start CC_SET(CC_S_TCG_MUST) |
| 208 | #define CC_Import CC_SET(CC_S_ALL_MUST) |
| 209 | #define CC_IncrementalSelfTest CC_SET(CC_S_TCG_MUST) |
| 210 | #define CC_Load CC_SET(CC_S_ALL_MUST) |
| 211 | #define CC_LoadExternal CC_SET((CC_S_CROS_TCG | CC_S_WIN_REC)) |
| 212 | #define CC_MakeCredential CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 213 | #define CC_NV_Certify CC_SET(CC_S_CROS_TCG) |
| 214 | #define CC_NV_ChangeAuth CC_SET(CC_S_WIN_TCG) |
| 215 | #define CC_NV_DefineSpace CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 216 | #define CC_NV_Extend CC_SET(CC_S_CROS_TCG) |
| 217 | #define CC_NV_GlobalWriteLock CC_SET(CC_S_OPTIONAL) |
Mary Ruthven | 0ffbd23 | 2021-12-21 08:00:00 -0600 | [diff] [blame] | 218 | #define CC_NV_Increment CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 219 | #define CC_NV_Read CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 220 | #define CC_NV_ReadLock CC_SET(CC_S_CROS_TCG) |
| 221 | #define CC_NV_ReadPublic CC_SET(CC_S_ALL_MUST) |
| 222 | #define CC_NV_SetBits CC_SET(CC_S_TCG_MUST) |
| 223 | #define CC_NV_UndefineSpace CC_SET(CC_S_ALL_MUST) |
| 224 | #define CC_NV_UndefineSpaceSpecial CC_SET(CC_S_CROS_TCG) |
| 225 | #define CC_NV_Write CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 226 | #define CC_NV_WriteLock CC_SET((CC_S_CROS_TCG | CC_S_COREBOOT)) |
| 227 | #define CC_ObjectChangeAuth CC_SET(CC_S_ALL_MUST) |
| 228 | #define CC_PCR_Allocate CC_SET(CC_S_CROS_TCG) |
| 229 | #define CC_PCR_Event CC_SET(CC_S_WIN_TCG) |
| 230 | #define CC_PCR_Extend CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 231 | #define CC_PCR_Read CC_SET(CC_S_ALL_MUST) |
Evan Green | b9f81dd | 2022-01-07 11:03:02 -0800 | [diff] [blame] | 232 | #define CC_PCR_Reset CC_SET((CC_S_WIN_TCG | CC_S_CROS_MUST)) |
Vadim Sukhomlinov | c764929 | 2019-02-05 10:03:17 -0800 | [diff] [blame] | 233 | #define CC_PCR_SetAuthPolicy CC_SET(CC_S_OPTIONAL) |
| 234 | #define CC_PCR_SetAuthValue CC_SET(CC_S_OPTIONAL) |
| 235 | #define CC_PolicyAuthorize CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 236 | #define CC_PolicyAuthValue CC_SET(CC_S_ALL_MUST) |
| 237 | #define CC_PolicyCommandCode CC_SET(CC_S_ALL_MUST) |
| 238 | #define CC_PolicyCounterTimer CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 239 | #define CC_PolicyCpHash CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 240 | #define CC_PolicyDuplicationSelect CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 241 | #define CC_PolicyGetDigest CC_SET(CC_S_ALL_MUST) |
| 242 | #define CC_PolicyLocality CC_SET(CC_S_TCG_MUST) |
| 243 | #define CC_PolicyNameHash CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 244 | #define CC_PolicyNV CC_SET((CC_S_TCG_MUST | CC_S_WINDOWS)) |
| 245 | #define CC_PolicyNvWritten CC_SET(CC_S_TCG_MUST) |
| 246 | #define CC_PolicyOR CC_SET(CC_S_ALL_MUST) |
| 247 | #define CC_PolicyPassword CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 248 | #define CC_PolicyPCR CC_SET(CC_S_ALL_MUST) |
| 249 | #define CC_PolicyPhysicalPresence CC_SET(CC_S_OPTIONAL) |
| 250 | #define CC_PolicyRestart CC_SET(CC_S_ALL_MUST) |
| 251 | #define CC_PolicySecret CC_SET(CC_S_ALL_MUST) |
| 252 | #define CC_PolicySigned CC_SET((CC_S_CROS_TCG | CC_S_WIN_REC)) |
| 253 | #define CC_PolicyTicket CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 254 | #define CC_PP_Commands CC_SET(CC_S_OPTIONAL) |
| 255 | #define CC_Quote CC_SET(CC_S_ALL_MUST) |
| 256 | #define CC_ReadClock CC_SET(CC_S_WIN_TCG) |
| 257 | #define CC_ReadPublic CC_SET(CC_S_ALL_MUST) |
| 258 | #define CC_Rewrap CC_SET(CC_S_OPTIONAL) |
| 259 | #define CC_RSA_Decrypt CC_SET((CC_S_ALL_MUST * ALG_RSA)) |
| 260 | #define CC_RSA_Encrypt CC_SET((CC_S_CROS_TCG * ALG_RSA)) |
| 261 | #define CC_SelfTest CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 262 | #define CC_SequenceComplete CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 263 | #define CC_SequenceUpdate CC_SET((CC_S_TCG_MUST | CC_S_WIN_REC)) |
| 264 | #define CC_SetAlgorithmSet CC_SET(CC_S_OPTIONAL) |
| 265 | #define CC_SetCommandCodeAuditStatus CC_SET(CC_S_OPTIONAL) |
| 266 | #define CC_SetPrimaryPolicy CC_SET(CC_S_TCG_MUST) |
| 267 | #define CC_Shutdown CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 268 | #define CC_Sign CC_SET(CC_S_ALL_MUST) |
| 269 | #define CC_StartAuthSession CC_SET(CC_S_ALL_MUST) |
| 270 | #define CC_Startup CC_SET((CC_S_ALL_MUST | CC_S_COREBOOT)) |
| 271 | #define CC_StirRandom CC_SET(CC_S_ALL_MUST) |
| 272 | #define CC_TestParms CC_SET(CC_S_TCG_MUST) |
| 273 | #define CC_Unseal CC_SET(CC_S_ALL_MUST) |
| 274 | #define CC_Vendor_TCG_Test CC_SET(CC_S_OPTIONAL) |
| 275 | #define CC_VerifySignature CC_SET((CC_S_CROS_TCG | CC_S_WIN_REC)) |
| 276 | #define CC_ZGen_2Phase CC_SET((CC_S_OPTIONAL * ALG_ECC)) |
| 277 | |
Namyoon Woo | 6599490 | 2019-10-31 10:38:51 -0700 | [diff] [blame] | 278 | #define IS_CCE_ENABLED(cmd) ((CCE_##cmd) == CC_YES) |
Namyoon Woo | f442814 | 2019-10-30 19:02:58 -0700 | [diff] [blame] | 279 | #define CCE_PolicyFidoSigned CC_SET(CC_S_CROS_TCG) |
| 280 | |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 281 | // |
| 282 | // From Vendor-Specific: Table 7 - Defines for Implementation Values |
| 283 | // |
| 284 | #define FIELD_UPGRADE_IMPLEMENTED NO |
| 285 | #define BSIZE UINT16 |
| 286 | #define BUFFER_ALIGNMENT 4 |
| 287 | #define IMPLEMENTATION_PCR 24 |
| 288 | #define PLATFORM_PCR 24 |
| 289 | #define DRTM_PCR 17 |
| 290 | #define HCRTM_PCR 0 |
| 291 | #define NUM_LOCALITIES 5 |
| 292 | #define MAX_HANDLE_NUM 3 |
| 293 | #define MAX_ACTIVE_SESSIONS 64 |
| 294 | #define CONTEXT_SLOT UINT16 |
| 295 | #define CONTEXT_COUNTER UINT64 |
| 296 | #define MAX_LOADED_SESSIONS 3 |
| 297 | #define MAX_SESSION_NUM 3 |
| 298 | #define MAX_LOADED_OBJECTS 3 |
| 299 | #define MIN_EVICT_OBJECTS 2 |
| 300 | #define PCR_SELECT_MIN ((PLATFORM_PCR+7)/8) |
| 301 | #define PCR_SELECT_MAX ((IMPLEMENTATION_PCR+7)/8) |
| 302 | #define NUM_POLICY_PCR_GROUP 1 |
| 303 | #define NUM_AUTHVALUE_PCR_GROUP 1 |
| 304 | #define MAX_CONTEXT_SIZE 2048 |
| 305 | #define MAX_DIGEST_BUFFER 1024 |
| 306 | #define MAX_NV_INDEX_SIZE 2048 |
| 307 | // |
| 308 | #define MAX_NV_BUFFER_SIZE 1024 |
| 309 | #define MAX_CAP_BUFFER 1024 |
Vadim Bendebury | 7878aef | 2015-08-12 12:57:26 -0700 | [diff] [blame] | 310 | #ifdef EMBEDDED_MODE |
Vadim Bendebury | 2cd8968 | 2016-08-07 19:50:32 -0700 | [diff] [blame] | 311 | // This must be matched by the package using this library! |
Vadim Bendebury | 1a68fe6 | 2017-01-26 10:43:07 -0800 | [diff] [blame] | 312 | #define NV_MEMORY_SIZE 11980 |
Vadim Bendebury | 889c3dd | 2016-12-03 07:27:09 +0800 | [diff] [blame] | 313 | // Versioning NV storage format will allow to smoothly migrate NVRAM contents. |
Andrey Pronin | f037a5c | 2016-11-29 12:39:30 -0800 | [diff] [blame] | 314 | // Versions: |
Vadim Bendebury | 2175612 | 2016-12-29 11:14:03 -0800 | [diff] [blame] | 315 | // 1 - full non-serialized objects in NVMEM, max SHA digest is SHA-256 |
| 316 | // 2 - a mix of serialized and non-serialized objects in NVMEM, max SHA digest |
| 317 | // is SHA-512. Eviction objects can be stored either serialized or |
| 318 | // non-serialized. The size of the stored entity smaller than |
| 319 | // sizeof(OBJECT) is considered an indication of the serialized form. |
| 320 | |
Andrey Pronin | f037a5c | 2016-11-29 12:39:30 -0800 | [diff] [blame] | 321 | #define NV_FORMAT_VERSION 2 |
Vadim Bendebury | 7878aef | 2015-08-12 12:57:26 -0700 | [diff] [blame] | 322 | #else |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 323 | #define NV_MEMORY_SIZE 16384 |
Vadim Bendebury | 7878aef | 2015-08-12 12:57:26 -0700 | [diff] [blame] | 324 | #endif |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 325 | #define NUM_STATIC_PCR 16 |
| 326 | #define MAX_ALG_LIST_SIZE 64 |
| 327 | #define TIMER_PRESCALE 100000 |
| 328 | #define PRIMARY_SEED_SIZE 32 |
| 329 | #define CONTEXT_ENCRYPT_ALG TPM_ALG_AES |
| 330 | #define CONTEXT_ENCRYPT_KEY_BITS MAX_SYM_KEY_BITS |
| 331 | #define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS+7)/8) |
| 332 | #define CONTEXT_INTEGRITY_HASH_ALG TPM_ALG_SHA256 |
| 333 | #define CONTEXT_INTEGRITY_HASH_SIZE SHA256_DIGEST_SIZE |
| 334 | #define PROOF_SIZE CONTEXT_INTEGRITY_HASH_SIZE |
| 335 | #define NV_CLOCK_UPDATE_INTERVAL 12 |
| 336 | #define NUM_POLICY_PCR 1 |
Vadim Bendebury | e987095 | 2018-12-21 09:55:20 -0800 | [diff] [blame] | 337 | #define MAX_COMMAND_SIZE 2048 |
| 338 | #define MAX_RESPONSE_SIZE 2048 |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 339 | #define ORDERLY_BITS 8 |
| 340 | #define MAX_ORDERLY_COUNT ((1<<ORDERLY_BITS)-1) |
| 341 | #define ALG_ID_FIRST TPM_ALG_FIRST |
| 342 | #define ALG_ID_LAST TPM_ALG_LAST |
| 343 | #define MAX_SYM_DATA 128 |
| 344 | #define MAX_RNG_ENTROPY_SIZE 64 |
| 345 | #define RAM_INDEX_SPACE 512 |
| 346 | #define RSA_DEFAULT_PUBLIC_EXPONENT 0x00010001 |
| 347 | #define ENABLE_PCR_NO_INCREMENT YES |
| 348 | #define CRT_FORMAT_RSA YES |
| 349 | #define PRIVATE_VENDOR_SPECIFIC_BYTES \ |
| 350 | ((MAX_RSA_KEY_BYTES/2)*(3+CRT_FORMAT_RSA*2)) |
| 351 | // |
| 352 | // From TCG Algorithm Registry: Table 2 - Definition of TPM_ALG_ID Constants |
| 353 | // |
| 354 | typedef UINT16 TPM_ALG_ID; |
| 355 | #define TPM_ALG_ERROR (TPM_ALG_ID)(0x0000) |
| 356 | #define ALG_ERROR_VALUE 0x0000 |
| 357 | #if defined ALG_RSA && ALG_RSA == YES |
| 358 | #define TPM_ALG_RSA (TPM_ALG_ID)(0x0001) |
| 359 | #endif |
| 360 | #define ALG_RSA_VALUE 0x0001 |
| 361 | #if defined ALG_SHA && ALG_SHA == YES |
| 362 | #define TPM_ALG_SHA (TPM_ALG_ID)(0x0004) |
| 363 | #endif |
| 364 | #define ALG_SHA_VALUE 0x0004 |
| 365 | #if defined ALG_SHA1 && ALG_SHA1 == YES |
| 366 | #define TPM_ALG_SHA1 (TPM_ALG_ID)(0x0004) |
| 367 | #endif |
| 368 | #define ALG_SHA1_VALUE 0x0004 |
| 369 | #if defined ALG_HMAC && ALG_HMAC == YES |
| 370 | #define TPM_ALG_HMAC (TPM_ALG_ID)(0x0005) |
| 371 | #endif |
| 372 | #define ALG_HMAC_VALUE 0x0005 |
| 373 | #if defined ALG_AES && ALG_AES == YES |
| 374 | #define TPM_ALG_AES (TPM_ALG_ID)(0x0006) |
| 375 | #endif |
| 376 | #define ALG_AES_VALUE 0x0006 |
| 377 | #if defined ALG_MGF1 && ALG_MGF1 == YES |
| 378 | #define TPM_ALG_MGF1 (TPM_ALG_ID)(0x0007) |
| 379 | #endif |
| 380 | #define ALG_MGF1_VALUE 0x0007 |
| 381 | #if defined ALG_KEYEDHASH && ALG_KEYEDHASH == YES |
| 382 | #define TPM_ALG_KEYEDHASH (TPM_ALG_ID)(0x0008) |
| 383 | #endif |
| 384 | #define ALG_KEYEDHASH_VALUE 0x0008 |
| 385 | #if defined ALG_XOR && ALG_XOR == YES |
| 386 | #define TPM_ALG_XOR (TPM_ALG_ID)(0x000A) |
| 387 | // |
| 388 | #endif |
| 389 | #define ALG_XOR_VALUE 0x000A |
| 390 | #if defined ALG_SHA256 && ALG_SHA256 == YES |
| 391 | #define TPM_ALG_SHA256 (TPM_ALG_ID)(0x000B) |
| 392 | #endif |
| 393 | #define ALG_SHA256_VALUE 0x000B |
| 394 | #if defined ALG_SHA384 && ALG_SHA384 == YES |
| 395 | #define TPM_ALG_SHA384 (TPM_ALG_ID)(0x000C) |
| 396 | #endif |
| 397 | #define ALG_SHA384_VALUE 0x000C |
| 398 | #if defined ALG_SHA512 && ALG_SHA512 == YES |
| 399 | #define TPM_ALG_SHA512 (TPM_ALG_ID)(0x000D) |
| 400 | #endif |
| 401 | #define ALG_SHA512_VALUE 0x000D |
| 402 | #define TPM_ALG_NULL (TPM_ALG_ID)(0x0010) |
| 403 | #define ALG_NULL_VALUE 0x0010 |
| 404 | #if defined ALG_SM3_256 && ALG_SM3_256 == YES |
| 405 | #define TPM_ALG_SM3_256 (TPM_ALG_ID)(0x0012) |
| 406 | #endif |
| 407 | #define ALG_SM3_256_VALUE 0x0012 |
| 408 | #if defined ALG_SM4 && ALG_SM4 == YES |
| 409 | #define TPM_ALG_SM4 (TPM_ALG_ID)(0x0013) |
| 410 | #endif |
| 411 | #define ALG_SM4_VALUE 0x0013 |
| 412 | #if defined ALG_RSASSA && ALG_RSASSA == YES |
| 413 | #define TPM_ALG_RSASSA (TPM_ALG_ID)(0x0014) |
Andrey Pronin | 569c3c5 | 2016-12-15 14:19:49 -0800 | [diff] [blame] | 414 | #define SUPPORT_PADDING_ONLY_RSASSA YES |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 415 | #endif |
| 416 | #define ALG_RSASSA_VALUE 0x0014 |
| 417 | #if defined ALG_RSAES && ALG_RSAES == YES |
| 418 | #define TPM_ALG_RSAES (TPM_ALG_ID)(0x0015) |
| 419 | #endif |
| 420 | #define ALG_RSAES_VALUE 0x0015 |
| 421 | #if defined ALG_RSAPSS && ALG_RSAPSS == YES |
| 422 | #define TPM_ALG_RSAPSS (TPM_ALG_ID)(0x0016) |
| 423 | #endif |
| 424 | #define ALG_RSAPSS_VALUE 0x0016 |
| 425 | #if defined ALG_OAEP && ALG_OAEP == YES |
| 426 | #define TPM_ALG_OAEP (TPM_ALG_ID)(0x0017) |
| 427 | #endif |
| 428 | #define ALG_OAEP_VALUE 0x0017 |
| 429 | #if defined ALG_ECDSA && ALG_ECDSA == YES |
| 430 | #define TPM_ALG_ECDSA (TPM_ALG_ID)(0x0018) |
| 431 | #endif |
| 432 | #define ALG_ECDSA_VALUE 0x0018 |
| 433 | #if defined ALG_ECDH && ALG_ECDH == YES |
| 434 | #define TPM_ALG_ECDH (TPM_ALG_ID)(0x0019) |
| 435 | #endif |
| 436 | #define ALG_ECDH_VALUE 0x0019 |
| 437 | #if defined ALG_ECDAA && ALG_ECDAA == YES |
| 438 | #define TPM_ALG_ECDAA (TPM_ALG_ID)(0x001A) |
| 439 | #endif |
| 440 | #define ALG_ECDAA_VALUE 0x001A |
| 441 | #if defined ALG_SM2 && ALG_SM2 == YES |
| 442 | #define TPM_ALG_SM2 (TPM_ALG_ID)(0x001B) |
| 443 | #endif |
| 444 | #define ALG_SM2_VALUE 0x001B |
| 445 | #if defined ALG_ECSCHNORR && ALG_ECSCHNORR == YES |
| 446 | #define TPM_ALG_ECSCHNORR (TPM_ALG_ID)(0x001C) |
| 447 | #endif |
| 448 | #define ALG_ECSCHNORR_VALUE 0x001C |
| 449 | #if defined ALG_ECMQV && ALG_ECMQV == YES |
| 450 | #define TPM_ALG_ECMQV (TPM_ALG_ID)(0x001D) |
| 451 | #endif |
| 452 | #define ALG_ECMQV_VALUE 0x001D |
| 453 | #if defined ALG_KDF1_SP800_56A && ALG_KDF1_SP800_56A == YES |
| 454 | #define TPM_ALG_KDF1_SP800_56A (TPM_ALG_ID)(0x0020) |
| 455 | #endif |
| 456 | #define ALG_KDF1_SP800_56A_VALUE 0x0020 |
| 457 | #if defined ALG_KDF2 && ALG_KDF2 == YES |
| 458 | #define TPM_ALG_KDF2 (TPM_ALG_ID)(0x0021) |
| 459 | #endif |
| 460 | #define ALG_KDF2_VALUE 0x0021 |
| 461 | #if defined ALG_KDF1_SP800_108 && ALG_KDF1_SP800_108 == YES |
| 462 | #define TPM_ALG_KDF1_SP800_108 (TPM_ALG_ID)(0x0022) |
| 463 | #endif |
| 464 | #define ALG_KDF1_SP800_108_VALUE 0x0022 |
| 465 | #if defined ALG_ECC && ALG_ECC == YES |
| 466 | #define TPM_ALG_ECC (TPM_ALG_ID)(0x0023) |
| 467 | #endif |
| 468 | #define ALG_ECC_VALUE 0x0023 |
| 469 | #if defined ALG_SYMCIPHER && ALG_SYMCIPHER == YES |
| 470 | #define TPM_ALG_SYMCIPHER (TPM_ALG_ID)(0x0025) |
| 471 | #endif |
| 472 | #define ALG_SYMCIPHER_VALUE 0x0025 |
| 473 | #if defined ALG_CAMELLIA && ALG_CAMELLIA == YES |
| 474 | #define TPM_ALG_CAMELLIA (TPM_ALG_ID)(0x0026) |
| 475 | #endif |
| 476 | #define ALG_CAMELLIA_VALUE 0x0026 |
| 477 | #if defined ALG_CTR && ALG_CTR == YES |
| 478 | #define TPM_ALG_CTR (TPM_ALG_ID)(0x0040) |
| 479 | #endif |
| 480 | #define ALG_CTR_VALUE 0x0040 |
| 481 | #if defined ALG_OFB && ALG_OFB == YES |
| 482 | #define TPM_ALG_OFB (TPM_ALG_ID)(0x0041) |
| 483 | #endif |
| 484 | #define ALG_OFB_VALUE 0x0041 |
| 485 | #if defined ALG_CBC && ALG_CBC == YES |
| 486 | #define TPM_ALG_CBC (TPM_ALG_ID)(0x0042) |
| 487 | #endif |
| 488 | #define ALG_CBC_VALUE 0x0042 |
| 489 | #if defined ALG_CFB && ALG_CFB == YES |
| 490 | #define TPM_ALG_CFB (TPM_ALG_ID)(0x0043) |
| 491 | #endif |
| 492 | #define ALG_CFB_VALUE 0x0043 |
| 493 | #if defined ALG_ECB && ALG_ECB == YES |
| 494 | #define TPM_ALG_ECB (TPM_ALG_ID)(0x0044) |
| 495 | #endif |
| 496 | #define ALG_ECB_VALUE 0x0044 |
| 497 | #define TPM_ALG_FIRST (TPM_ALG_ID)(0x0001) |
| 498 | #define ALG_FIRST_VALUE 0x0001 |
| 499 | #define TPM_ALG_LAST (TPM_ALG_ID)(0x0044) |
| 500 | #define ALG_LAST_VALUE 0x0044 |
| 501 | // |
| 502 | // From TCG Algorithm Registry: Table 3 - Definition of TPM_ECC_CURVE Constants |
| 503 | // |
| 504 | typedef UINT16 TPM_ECC_CURVE; |
| 505 | #define TPM_ECC_NONE (TPM_ECC_CURVE)(0x0000) |
| 506 | #define TPM_ECC_NIST_P192 (TPM_ECC_CURVE)(0x0001) |
| 507 | #define TPM_ECC_NIST_P224 (TPM_ECC_CURVE)(0x0002) |
| 508 | #define TPM_ECC_NIST_P256 (TPM_ECC_CURVE)(0x0003) |
| 509 | #define TPM_ECC_NIST_P384 (TPM_ECC_CURVE)(0x0004) |
| 510 | #define TPM_ECC_NIST_P521 (TPM_ECC_CURVE)(0x0005) |
| 511 | #define TPM_ECC_BN_P256 (TPM_ECC_CURVE)(0x0010) |
| 512 | #define TPM_ECC_BN_P638 (TPM_ECC_CURVE)(0x0011) |
| 513 | #define TPM_ECC_SM2_P256 (TPM_ECC_CURVE)(0x0020) |
| 514 | // |
| 515 | // From TCG Algorithm Registry: Table 4 - Defines for NIST_P192 ECC Values Data in CrpiEccData.c From |
| 516 | // TCG Algorithm Registry: Table 5 - Defines for NIST_P224 ECC Values Data in CrpiEccData.c From TCG |
| 517 | // Algorithm Registry: Table 6 - Defines for NIST_P256 ECC Values Data in CrpiEccData.c From TCG |
| 518 | // Algorithm Registry: Table 7 - Defines for NIST_P384 ECC Values Data in CrpiEccData.c From TCG |
| 519 | // |
| 520 | // Algorithm Registry: Table 8 - Defines for NIST_P521 ECC Values Data in CrpiEccData.c From TCG |
| 521 | // Algorithm Registry: Table 9 - Defines for BN_P256 ECC Values Data in CrpiEccData.c From TCG |
| 522 | // Algorithm Registry: Table 10 - Defines for BN_P638 ECC Values Data in CrpiEccData.c From TCG |
| 523 | // Algorithm Registry: Table 11 - Defines for SM2_P256 ECC Values Data in CrpiEccData.c From TCG |
| 524 | // Algorithm Registry: Table 12 - Defines for SHA1 Hash Values |
| 525 | // |
| 526 | #define SHA1_DIGEST_SIZE 20 |
Vadim Bendebury | 0232bac | 2015-09-17 17:26:29 -0700 | [diff] [blame] | 527 | #define SHA_DIGEST_SIZE SHA1_DIGEST_SIZE |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 528 | #define SHA1_BLOCK_SIZE 64 |
| 529 | #define SHA1_DER_SIZE 15 |
| 530 | #define SHA1_DER \ |
| 531 | 0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14 |
| 532 | // |
| 533 | // From TCG Algorithm Registry: Table 13 - Defines for SHA256 Hash Values |
| 534 | // |
| 535 | #define SHA256_DIGEST_SIZE 32 |
| 536 | #define SHA256_BLOCK_SIZE 64 |
| 537 | #define SHA256_DER_SIZE 19 |
| 538 | #define SHA256_DER \ |
Andrey Pronin | 81e7087 | 2016-11-28 19:12:12 -0800 | [diff] [blame] | 539 | 0x30,0x31,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,\ |
| 540 | 0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20 |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 541 | // |
| 542 | // From TCG Algorithm Registry: Table 14 - Defines for SHA384 Hash Values |
| 543 | // |
| 544 | #define SHA384_DIGEST_SIZE 48 |
| 545 | #define SHA384_BLOCK_SIZE 128 |
| 546 | #define SHA384_DER_SIZE 19 |
| 547 | #define SHA384_DER \ |
Andrey Pronin | 81e7087 | 2016-11-28 19:12:12 -0800 | [diff] [blame] | 548 | 0x30,0x41,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,\ |
| 549 | 0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30 |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 550 | // |
| 551 | // From TCG Algorithm Registry: Table 15 - Defines for SHA512 Hash Values |
| 552 | // |
| 553 | #define SHA512_DIGEST_SIZE 64 |
| 554 | #define SHA512_BLOCK_SIZE 128 |
| 555 | #define SHA512_DER_SIZE 19 |
| 556 | #define SHA512_DER \ |
Andrey Pronin | 81e7087 | 2016-11-28 19:12:12 -0800 | [diff] [blame] | 557 | 0x30,0x51,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,\ |
| 558 | 0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40 |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 559 | // |
| 560 | // From TCG Algorithm Registry: Table 16 - Defines for SM3_256 Hash Values |
| 561 | // |
| 562 | #define SM3_256_DIGEST_SIZE 32 |
| 563 | #define SM3_256_BLOCK_SIZE 64 |
| 564 | #define SM3_256_DER_SIZE 18 |
| 565 | #define SM3_256_DER \ |
Andrey Pronin | 81e7087 | 2016-11-28 19:12:12 -0800 | [diff] [blame] | 566 | 0x30,0x30,0x30,0x0C,0x06,0x08,0x2A,0x81,0x1C,\ |
| 567 | 0x81,0x45,0x01,0x83,0x11,0x05,0x00,0x04,0x20 |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 568 | // |
| 569 | // From TCG Algorithm Registry: Table 17 - Defines for AES Symmetric Cipher Algorithm Constants |
| 570 | // |
| 571 | #define AES_ALLOWED_KEY_SIZE_128 YES |
| 572 | #define AES_ALLOWED_KEY_SIZE_192 YES |
| 573 | #define AES_ALLOWED_KEY_SIZE_256 YES |
| 574 | #define AES_128_BLOCK_SIZE_BYTES 16 |
| 575 | #define AES_192_BLOCK_SIZE_BYTES 16 |
| 576 | #define AES_256_BLOCK_SIZE_BYTES 16 |
| 577 | // |
| 578 | // From TCG Algorithm Registry: Table 18 - Defines for SM4 Symmetric Cipher Algorithm Constants |
| 579 | #define SM4_ALLOWED_KEY_SIZE_128 YES |
| 580 | #define SM4_128_BLOCK_SIZE_BYTES 16 |
| 581 | // |
| 582 | // From TCG Algorithm Registry: Table 19 - Defines for CAMELLIA Symmetric Cipher Algorithm Constants |
| 583 | // |
| 584 | #define CAMELLIA_ALLOWED_KEY_SIZE_128 YES |
| 585 | #define CAMELLIA_ALLOWED_KEY_SIZE_192 YES |
| 586 | #define CAMELLIA_ALLOWED_KEY_SIZE_256 YES |
| 587 | #define CAMELLIA_128_BLOCK_SIZE_BYTES 16 |
| 588 | #define CAMELLIA_192_BLOCK_SIZE_BYTES 16 |
| 589 | #define CAMELLIA_256_BLOCK_SIZE_BYTES 16 |
| 590 | // |
| 591 | // From TPM 2.0 Part 2: Table 13 - Definition of TPM_CC Constants |
| 592 | // |
| 593 | typedef UINT32 TPM_CC; |
| 594 | #define TPM_CC_FIRST (TPM_CC)(0x0000011F) |
| 595 | #define TPM_CC_PP_FIRST (TPM_CC)(0x0000011F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 596 | #define TPM_CC_NV_UndefineSpaceSpecial (TPM_CC)(0x0000011F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 597 | #define TPM_CC_EvictControl (TPM_CC)(0x00000120) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 598 | #define TPM_CC_HierarchyControl (TPM_CC)(0x00000121) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 599 | #define TPM_CC_NV_UndefineSpace (TPM_CC)(0x00000122) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 600 | #define TPM_CC_ChangeEPS (TPM_CC)(0x00000124) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 601 | #define TPM_CC_ChangePPS (TPM_CC)(0x00000125) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 602 | #define TPM_CC_Clear (TPM_CC)(0x00000126) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 603 | #define TPM_CC_ClearControl (TPM_CC)(0x00000127) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 604 | #define TPM_CC_ClockSet (TPM_CC)(0x00000128) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 605 | #define TPM_CC_HierarchyChangeAuth (TPM_CC)(0x00000129) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 606 | #define TPM_CC_NV_DefineSpace (TPM_CC)(0x0000012A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 607 | #define TPM_CC_PCR_Allocate (TPM_CC)(0x0000012B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 608 | #define TPM_CC_PCR_SetAuthPolicy (TPM_CC)(0x0000012C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 609 | #define TPM_CC_PP_Commands (TPM_CC)(0x0000012D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 610 | #define TPM_CC_SetPrimaryPolicy (TPM_CC)(0x0000012E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 611 | #define TPM_CC_FieldUpgradeStart (TPM_CC)(0x0000012F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 612 | #define TPM_CC_ClockRateAdjust (TPM_CC)(0x00000130) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 613 | #define TPM_CC_CreatePrimary (TPM_CC)(0x00000131) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 614 | #define TPM_CC_NV_GlobalWriteLock (TPM_CC)(0x00000132) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 615 | #define TPM_CC_PP_LAST (TPM_CC)(0x00000132) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 616 | #define TPM_CC_GetCommandAuditDigest (TPM_CC)(0x00000133) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 617 | #define TPM_CC_NV_Increment (TPM_CC)(0x00000134) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 618 | #define TPM_CC_NV_SetBits (TPM_CC)(0x00000135) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 619 | #define TPM_CC_NV_Extend (TPM_CC)(0x00000136) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 620 | #define TPM_CC_NV_Write (TPM_CC)(0x00000137) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 621 | #define TPM_CC_NV_WriteLock (TPM_CC)(0x00000138) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 622 | #define TPM_CC_DictionaryAttackLockReset (TPM_CC)(0x00000139) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 623 | #define TPM_CC_DictionaryAttackParameters (TPM_CC)(0x0000013A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 624 | #define TPM_CC_NV_ChangeAuth (TPM_CC)(0x0000013B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 625 | #define TPM_CC_PCR_Event (TPM_CC)(0x0000013C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 626 | #define TPM_CC_PCR_Reset (TPM_CC)(0x0000013D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 627 | #define TPM_CC_SequenceComplete (TPM_CC)(0x0000013E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 628 | #define TPM_CC_SetAlgorithmSet (TPM_CC)(0x0000013F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 629 | #define TPM_CC_SetCommandCodeAuditStatus (TPM_CC)(0x00000140) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 630 | #define TPM_CC_FieldUpgradeData (TPM_CC)(0x00000141) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 631 | #define TPM_CC_IncrementalSelfTest (TPM_CC)(0x00000142) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 632 | #define TPM_CC_SelfTest (TPM_CC)(0x00000143) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 633 | #define TPM_CC_Startup (TPM_CC)(0x00000144) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 634 | #define TPM_CC_Shutdown (TPM_CC)(0x00000145) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 635 | #define TPM_CC_StirRandom (TPM_CC)(0x00000146) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 636 | #define TPM_CC_ActivateCredential (TPM_CC)(0x00000147) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 637 | #define TPM_CC_Certify (TPM_CC)(0x00000148) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 638 | #define TPM_CC_PolicyNV (TPM_CC)(0x00000149) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 639 | #define TPM_CC_CertifyCreation (TPM_CC)(0x0000014A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 640 | #define TPM_CC_Duplicate (TPM_CC)(0x0000014B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 641 | #define TPM_CC_GetTime (TPM_CC)(0x0000014C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 642 | #define TPM_CC_GetSessionAuditDigest (TPM_CC)(0x0000014D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 643 | #define TPM_CC_NV_Read (TPM_CC)(0x0000014E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 644 | #define TPM_CC_NV_ReadLock (TPM_CC)(0x0000014F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 645 | #define TPM_CC_ObjectChangeAuth (TPM_CC)(0x00000150) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 646 | #define TPM_CC_PolicySecret (TPM_CC)(0x00000151) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 647 | #define TPM_CC_Rewrap (TPM_CC)(0x00000152) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 648 | #define TPM_CC_Create (TPM_CC)(0x00000153) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 649 | #define TPM_CC_ECDH_ZGen (TPM_CC)(0x00000154) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 650 | #define TPM_CC_HMAC (TPM_CC)(0x00000155) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 651 | #define TPM_CC_Import (TPM_CC)(0x00000156) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 652 | #define TPM_CC_Load (TPM_CC)(0x00000157) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 653 | #define TPM_CC_Quote (TPM_CC)(0x00000158) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 654 | #define TPM_CC_RSA_Decrypt (TPM_CC)(0x00000159) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 655 | #define TPM_CC_HMAC_Start (TPM_CC)(0x0000015B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 656 | #define TPM_CC_SequenceUpdate (TPM_CC)(0x0000015C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 657 | #define TPM_CC_Sign (TPM_CC)(0x0000015D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 658 | #define TPM_CC_Unseal (TPM_CC)(0x0000015E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 659 | #define TPM_CC_PolicySigned (TPM_CC)(0x00000160) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 660 | #define TPM_CC_ContextLoad (TPM_CC)(0x00000161) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 661 | #define TPM_CC_ContextSave (TPM_CC)(0x00000162) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 662 | #define TPM_CC_ECDH_KeyGen (TPM_CC)(0x00000163) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 663 | #define TPM_CC_EncryptDecrypt (TPM_CC)(0x00000164) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 664 | #define TPM_CC_FlushContext (TPM_CC)(0x00000165) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 665 | #define TPM_CC_LoadExternal (TPM_CC)(0x00000167) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 666 | #define TPM_CC_MakeCredential (TPM_CC)(0x00000168) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 667 | #define TPM_CC_NV_ReadPublic (TPM_CC)(0x00000169) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 668 | #define TPM_CC_PolicyAuthorize (TPM_CC)(0x0000016A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 669 | #define TPM_CC_PolicyAuthValue (TPM_CC)(0x0000016B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 670 | #define TPM_CC_PolicyCommandCode (TPM_CC)(0x0000016C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 671 | #define TPM_CC_PolicyCounterTimer (TPM_CC)(0x0000016D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 672 | #define TPM_CC_PolicyCpHash (TPM_CC)(0x0000016E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 673 | #define TPM_CC_PolicyLocality (TPM_CC)(0x0000016F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 674 | #define TPM_CC_PolicyNameHash (TPM_CC)(0x00000170) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 675 | #define TPM_CC_PolicyOR (TPM_CC)(0x00000171) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 676 | #define TPM_CC_PolicyTicket (TPM_CC)(0x00000172) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 677 | #define TPM_CC_ReadPublic (TPM_CC)(0x00000173) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 678 | #define TPM_CC_RSA_Encrypt (TPM_CC)(0x00000174) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 679 | #define TPM_CC_StartAuthSession (TPM_CC)(0x00000176) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 680 | #define TPM_CC_VerifySignature (TPM_CC)(0x00000177) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 681 | #define TPM_CC_ECC_Parameters (TPM_CC)(0x00000178) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 682 | #define TPM_CC_FirmwareRead (TPM_CC)(0x00000179) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 683 | #define TPM_CC_GetCapability (TPM_CC)(0x0000017A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 684 | #define TPM_CC_GetRandom (TPM_CC)(0x0000017B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 685 | #define TPM_CC_GetTestResult (TPM_CC)(0x0000017C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 686 | #define TPM_CC_Hash (TPM_CC)(0x0000017D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 687 | #define TPM_CC_PCR_Read (TPM_CC)(0x0000017E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 688 | #define TPM_CC_PolicyPCR (TPM_CC)(0x0000017F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 689 | #define TPM_CC_PolicyRestart (TPM_CC)(0x00000180) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 690 | #define TPM_CC_ReadClock (TPM_CC)(0x00000181) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 691 | #define TPM_CC_PCR_Extend (TPM_CC)(0x00000182) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 692 | #define TPM_CC_PCR_SetAuthValue (TPM_CC)(0x00000183) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 693 | #define TPM_CC_NV_Certify (TPM_CC)(0x00000184) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 694 | #define TPM_CC_EventSequenceComplete (TPM_CC)(0x00000185) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 695 | #define TPM_CC_HashSequenceStart (TPM_CC)(0x00000186) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 696 | #define TPM_CC_PolicyPhysicalPresence (TPM_CC)(0x00000187) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 697 | #define TPM_CC_PolicyDuplicationSelect (TPM_CC)(0x00000188) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 698 | #define TPM_CC_PolicyGetDigest (TPM_CC)(0x00000189) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 699 | #define TPM_CC_TestParms (TPM_CC)(0x0000018A) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 700 | #define TPM_CC_Commit (TPM_CC)(0x0000018B) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 701 | #define TPM_CC_PolicyPassword (TPM_CC)(0x0000018C) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 702 | #define TPM_CC_ZGen_2Phase (TPM_CC)(0x0000018D) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 703 | #define TPM_CC_EC_Ephemeral (TPM_CC)(0x0000018E) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 704 | #define TPM_CC_PolicyNvWritten (TPM_CC)(0x0000018F) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 705 | #define TPM_CC_LAST (TPM_CC)(0x0000018F) |
Namyoon Woo | 6599490 | 2019-10-31 10:38:51 -0700 | [diff] [blame] | 706 | |
| 707 | /* |
| 708 | * Extended TPM Commands |
| 709 | */ |
| 710 | #define TPM_CCE_BIT_MASK (TPM_CC)(0x20000000) |
| 711 | #define TPM_CCE_FIRST (TPM_CC)(TPM_CCE_BIT_MASK|0x8001) |
Namyoon Woo | f442814 | 2019-10-30 19:02:58 -0700 | [diff] [blame] | 712 | #define TPM_CCE_PolicyFidoSigned (TPM_CC)(TPM_CCE_FIRST) |
Namyoon Woo | 6599490 | 2019-10-31 10:38:51 -0700 | [diff] [blame] | 713 | #define TPM_CCE_LAST (TPM_CC)(TPM_CCE_BIT_MASK|0x8001) |
| 714 | |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 715 | #ifndef MAX |
| 716 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
| 717 | #endif |
| 718 | #define MAX_HASH_BLOCK_SIZE ( \ |
| 719 | MAX(ALG_SHA1 * SHA1_BLOCK_SIZE, \ |
| 720 | MAX(ALG_SHA256 * SHA256_BLOCK_SIZE, \ |
| 721 | MAX(ALG_SHA384 * SHA384_BLOCK_SIZE, \ |
| 722 | MAX(ALG_SM3_256 * SM3_256_BLOCK_SIZE, \ |
| 723 | MAX(ALG_SHA512 * SHA512_BLOCK_SIZE, \ |
| 724 | 0 )))))) |
| 725 | #define MAX_DIGEST_SIZE ( \ |
| 726 | MAX(ALG_SHA1 * SHA1_DIGEST_SIZE, \ |
| 727 | MAX(ALG_SHA256 * SHA256_DIGEST_SIZE, \ |
| 728 | MAX(ALG_SHA384 * SHA384_DIGEST_SIZE, \ |
| 729 | MAX(ALG_SM3_256 * SM3_256_DIGEST_SIZE, \ |
| 730 | MAX(ALG_SHA512 * SHA512_DIGEST_SIZE, \ |
| 731 | 0 )))))) |
| 732 | #if MAX_DIGEST_SIZE == 0 || MAX_HASH_BLOCK_SIZE == 0 |
| 733 | #error "Hash data not valid" |
| 734 | #endif |
| 735 | #define HASH_COUNT (ALG_SHA1+ALG_SHA256+ALG_SHA384+ALG_SM3_256+ALG_SHA512) |
| 736 | // |
| 737 | // Define the 2B structure that would hold any hash block |
| 738 | // |
| 739 | TPM2B_TYPE(MAX_HASH_BLOCK, MAX_HASH_BLOCK_SIZE); |
| 740 | // |
| 741 | // Folloing typedef is for some old code |
| 742 | // |
| 743 | typedef TPM2B_MAX_HASH_BLOCK TPM2B_HASH_BLOCK; |
| 744 | #ifndef MAX |
| 745 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
| 746 | #endif |
| 747 | #ifndef ALG_CAMELLIA |
| 748 | # define ALG_CAMELLIA NO |
| 749 | #endif |
| 750 | #ifndef MAX_CAMELLIA_KEY_BITS |
| 751 | # define MAX_CAMELLIA_KEY_BITS 0 |
| 752 | # define MAX_CAMELLIA_BLOCK_SIZE_BYTES 0 |
| 753 | #endif |
| 754 | #ifndef ALG_SM4 |
| 755 | # define ALG_SM4 NO |
| 756 | #endif |
| 757 | #ifndef MAX_SM4_KEY_BITS |
| 758 | # define MAX_SM4_KEY_BITS 0 |
| 759 | # define MAX_SM4_BLOCK_SIZE_BYTES 0 |
| 760 | #endif |
| 761 | #ifndef ALG_AES |
| 762 | # define ALG_AES NO |
| 763 | #endif |
| 764 | #ifndef MAX_AES_KEY_BITS |
| 765 | # define MAX_AES_KEY_BITS 0 |
| 766 | # define MAX_AES_BLOCK_SIZE_BYTES 0 |
| 767 | #endif |
| 768 | #define MAX_SYM_KEY_BITS ( \ |
| 769 | MAX(MAX_CAMELLIA_KEY_BITS * ALG_CAMELLIA, \ |
| 770 | MAX(MAX_SM4_KEY_BITS * ALG_SM4, \ |
| 771 | MAX(MAX_AES_KEY_BITS * ALG_AES, \ |
| 772 | 0)))) |
| 773 | #define MAX_SYM_KEY_BYTES ((MAX_SYM_KEY_BITS + 7) / 8) |
| 774 | #define MAX_SYM_BLOCK_SIZE ( \ |
| 775 | MAX(MAX_CAMELLIA_BLOCK_SIZE_BYTES * ALG_CAMELLIA, \ |
| 776 | MAX(MAX_SM4_BLOCK_SIZE_BYTES * ALG_SM4, \ |
| 777 | MAX(MAX_AES_BLOCK_SIZE_BYTES * ALG_AES, \ |
| 778 | 0)))) |
| 779 | #if MAX_SYM_KEY_BITS == 0 || MAX_SYM_BLOCK_SIZE == 0 |
| 780 | # error Bad size for MAX_SYM_KEY_BITS or MAX_SYM_BLOCK_SIZE |
| 781 | #endif |
| 782 | // |
| 783 | // Define the 2B structure for a seed |
| 784 | // |
| 785 | TPM2B_TYPE(SEED, PRIMARY_SEED_SIZE); |
Vadim Bendebury | 34f0a9a | 2015-05-29 12:24:59 -0700 | [diff] [blame] | 786 | |
| 787 | #define UNREFERENCED_PARAMETER(x) (void)(x) |
Vadim Bendebury | 5679752 | 2015-05-20 10:32:25 -0700 | [diff] [blame] | 788 | #endif // _IMPLEMENTATION_H_ |