• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Microsoft Reference Implementation for TPM 2.0
2  *
3  *  The copyright in this software is being made available under the BSD License,
4  *  included below. This software may be subject to other third party and
5  *  contributor rights, including patent rights, and no such rights are granted
6  *  under this license.
7  *
8  *  Copyright (c) Microsoft Corporation
9  *
10  *  All rights reserved.
11  *
12  *  BSD License
13  *
14  *  Redistribution and use in source and binary forms, with or without modification,
15  *  are permitted provided that the following conditions are met:
16  *
17  *  Redistributions of source code must retain the above copyright notice, this list
18  *  of conditions and the following disclaimer.
19  *
20  *  Redistributions in binary form must reproduce the above copyright notice, this
21  *  list of conditions and the following disclaimer in the documentation and/or
22  *  other materials provided with the distribution.
23  *
24  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
25  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /*(Auto-generated)
36  *  Created by TpmStructures; Version 4.4 Mar 26, 2019
37  *  Date: Feb 28, 2020  Time: 03:04:46PM
38  */
39 
40 #ifndef _TPM_ALGORITHM_DEFINES_H_
41 #define _TPM_ALGORITHM_DEFINES_H_
42 
43 // Table 2:3 - Definition of Base Types
44 // Base Types are in BaseTypes.h
45 
46 #define ECC_CURVES                      \
47             {TPM_ECC_BN_P256,   TPM_ECC_BN_P638,   TPM_ECC_NIST_P192,              \
48              TPM_ECC_NIST_P224, TPM_ECC_NIST_P256, TPM_ECC_NIST_P384,              \
49              TPM_ECC_NIST_P521, TPM_ECC_SM2_P256}
50 #define ECC_CURVE_COUNT                 \
51             (ECC_BN_P256   + ECC_BN_P638   + ECC_NIST_P192 + ECC_NIST_P224 +       \
52              ECC_NIST_P256 + ECC_NIST_P384 + ECC_NIST_P521 + ECC_SM2_P256)
53 #define MAX_ECC_KEY_BITS                \
54             MAX(ECC_BN_P256 * 256,   MAX(ECC_BN_P638 * 638,                        \
55             MAX(ECC_NIST_P192 * 192, MAX(ECC_NIST_P224 * 224,                      \
56             MAX(ECC_NIST_P256 * 256, MAX(ECC_NIST_P384 * 384,                      \
57             MAX(ECC_NIST_P521 * 521, MAX(ECC_SM2_P256 * 256,                       \
58             0))))))))
59 #define MAX_ECC_KEY_BYTES               BITS_TO_BYTES(MAX_ECC_KEY_BITS)
60 
61 // Table 0:6 - Defines for PLATFORM Values
62 #define PLATFORM_FAMILY         TPM_SPEC_FAMILY
63 #define PLATFORM_LEVEL          TPM_SPEC_LEVEL
64 #define PLATFORM_VERSION        TPM_SPEC_VERSION
65 #define PLATFORM_YEAR           TPM_SPEC_YEAR
66 #define PLATFORM_DAY_OF_YEAR    TPM_SPEC_DAY_OF_YEAR
67 
68 // Table 1:3 - Defines for RSA Asymmetric Cipher Algorithm Constants
69 #define RSA_KEY_SIZES_BITS          \
70             (1024 * RSA_1024),  (2048 * RSA_2048), (3072 * RSA_3072),              \
71              (4096 * RSA_4096), (16384 * RSA_16384)
72 #if   RSA_16384
73 #   define RSA_MAX_KEY_SIZE_BITS    16384
74 #elif RSA_4096
75 #   define RSA_MAX_KEY_SIZE_BITS    4096
76 #elif RSA_3072
77 #   define RSA_MAX_KEY_SIZE_BITS    3072
78 #elif RSA_2048
79 #   define RSA_MAX_KEY_SIZE_BITS    2048
80 #elif RSA_1024
81 #   define RSA_MAX_KEY_SIZE_BITS    1024
82 #else
83 #   define RSA_MAX_KEY_SIZE_BITS    0
84 #endif
85 #define MAX_RSA_KEY_BITS            RSA_MAX_KEY_SIZE_BITS
86 #define MAX_RSA_KEY_BYTES           ((RSA_MAX_KEY_SIZE_BITS + 7) / 8)
87 
88 // Table 1:13 - Defines for SHA1 Hash Values
89 #define SHA1_DIGEST_SIZE    20
90 #define SHA1_BLOCK_SIZE     64
91 
92 // Table 1:14 - Defines for SHA256 Hash Values
93 #define SHA256_DIGEST_SIZE  32
94 #define SHA256_BLOCK_SIZE   64
95 
96 // Table 1:15 - Defines for SHA384 Hash Values
97 #define SHA384_DIGEST_SIZE  48
98 #define SHA384_BLOCK_SIZE   128
99 
100 // Table 1:16 - Defines for SHA512 Hash Values
101 #define SHA512_DIGEST_SIZE  64
102 #define SHA512_BLOCK_SIZE   128
103 
104 // Table 1:17 - Defines for SM3_256 Hash Values
105 #define SM3_256_DIGEST_SIZE     32
106 #define SM3_256_BLOCK_SIZE      64
107 
108 // Table 1:18 - Defines for SHA3_256 Hash Values
109 #define SHA3_256_DIGEST_SIZE    32
110 #define SHA3_256_BLOCK_SIZE     136
111 
112 // Table 1:19 - Defines for SHA3_384 Hash Values
113 #define SHA3_384_DIGEST_SIZE    48
114 #define SHA3_384_BLOCK_SIZE     104
115 
116 // Table 1:20 - Defines for SHA3_512 Hash Values
117 #define SHA3_512_DIGEST_SIZE    64
118 #define SHA3_512_BLOCK_SIZE     72
119 
120 // Table 1:21 - Defines for AES Symmetric Cipher Algorithm Constants
121 #define AES_KEY_SIZES_BITS          \
122             (128 * AES_128), (192 * AES_192), (256 * AES_256)
123 #if   AES_256
124 #   define AES_MAX_KEY_SIZE_BITS    256
125 #elif AES_192
126 #   define AES_MAX_KEY_SIZE_BITS    192
127 #elif AES_128
128 #   define AES_MAX_KEY_SIZE_BITS    128
129 #else
130 #   define AES_MAX_KEY_SIZE_BITS    0
131 #endif
132 #define MAX_AES_KEY_BITS            AES_MAX_KEY_SIZE_BITS
133 #define MAX_AES_KEY_BYTES           ((AES_MAX_KEY_SIZE_BITS + 7) / 8)
134 #define AES_128_BLOCK_SIZE_BYTES    (AES_128 * 16)
135 #define AES_192_BLOCK_SIZE_BYTES    (AES_192 * 16)
136 #define AES_256_BLOCK_SIZE_BYTES    (AES_256 * 16)
137 #define AES_BLOCK_SIZES             \
138             AES_128_BLOCK_SIZE_BYTES, AES_192_BLOCK_SIZE_BYTES,                    \
139             AES_256_BLOCK_SIZE_BYTES
140 #if   ALG_AES
141 #   define AES_MAX_BLOCK_SIZE       16
142 #else
143 #   define AES_MAX_BLOCK_SIZE       0
144 #endif
145 #define MAX_AES_BLOCK_SIZE_BYTES    AES_MAX_BLOCK_SIZE
146 
147 // Table 1:22 - Defines for SM4 Symmetric Cipher Algorithm Constants
148 #define SM4_KEY_SIZES_BITS          (128 * SM4_128)
149 #if   SM4_128
150 #   define SM4_MAX_KEY_SIZE_BITS    128
151 #else
152 #   define SM4_MAX_KEY_SIZE_BITS    0
153 #endif
154 #define MAX_SM4_KEY_BITS            SM4_MAX_KEY_SIZE_BITS
155 #define MAX_SM4_KEY_BYTES           ((SM4_MAX_KEY_SIZE_BITS + 7) / 8)
156 #define SM4_128_BLOCK_SIZE_BYTES    (SM4_128 * 16)
157 #define SM4_BLOCK_SIZES             SM4_128_BLOCK_SIZE_BYTES
158 #if   ALG_SM4
159 #   define SM4_MAX_BLOCK_SIZE       16
160 #else
161 #   define SM4_MAX_BLOCK_SIZE       0
162 #endif
163 #define MAX_SM4_BLOCK_SIZE_BYTES    SM4_MAX_BLOCK_SIZE
164 
165 // Table 1:23 - Defines for CAMELLIA Symmetric Cipher Algorithm Constants
166 #define CAMELLIA_KEY_SIZES_BITS         \
167             (128 * CAMELLIA_128), (192 * CAMELLIA_192), (256 * CAMELLIA_256)
168 #if   CAMELLIA_256
169 #   define CAMELLIA_MAX_KEY_SIZE_BITS   256
170 #elif CAMELLIA_192
171 #   define CAMELLIA_MAX_KEY_SIZE_BITS   192
172 #elif CAMELLIA_128
173 #   define CAMELLIA_MAX_KEY_SIZE_BITS   128
174 #else
175 #   define CAMELLIA_MAX_KEY_SIZE_BITS   0
176 #endif
177 #define MAX_CAMELLIA_KEY_BITS           CAMELLIA_MAX_KEY_SIZE_BITS
178 #define MAX_CAMELLIA_KEY_BYTES          ((CAMELLIA_MAX_KEY_SIZE_BITS + 7) / 8)
179 #define CAMELLIA_128_BLOCK_SIZE_BYTES   (CAMELLIA_128 * 16)
180 #define CAMELLIA_192_BLOCK_SIZE_BYTES   (CAMELLIA_192 * 16)
181 #define CAMELLIA_256_BLOCK_SIZE_BYTES   (CAMELLIA_256 * 16)
182 #define CAMELLIA_BLOCK_SIZES            \
183             CAMELLIA_128_BLOCK_SIZE_BYTES, CAMELLIA_192_BLOCK_SIZE_BYTES,          \
184             CAMELLIA_256_BLOCK_SIZE_BYTES
185 #if   ALG_CAMELLIA
186 #   define CAMELLIA_MAX_BLOCK_SIZE      16
187 #else
188 #   define CAMELLIA_MAX_BLOCK_SIZE      0
189 #endif
190 #define MAX_CAMELLIA_BLOCK_SIZE_BYTES   CAMELLIA_MAX_BLOCK_SIZE
191 
192 // Table 1:24 - Defines for TDES Symmetric Cipher Algorithm Constants
193 #define TDES_KEY_SIZES_BITS         (128 * TDES_128), (192 * TDES_192)
194 #if   TDES_192
195 #   define TDES_MAX_KEY_SIZE_BITS   192
196 #elif TDES_128
197 #   define TDES_MAX_KEY_SIZE_BITS   128
198 #else
199 #   define TDES_MAX_KEY_SIZE_BITS   0
200 #endif
201 #define MAX_TDES_KEY_BITS           TDES_MAX_KEY_SIZE_BITS
202 #define MAX_TDES_KEY_BYTES          ((TDES_MAX_KEY_SIZE_BITS + 7) / 8)
203 #define TDES_128_BLOCK_SIZE_BYTES   (TDES_128 * 8)
204 #define TDES_192_BLOCK_SIZE_BYTES   (TDES_192 * 8)
205 #define TDES_BLOCK_SIZES            \
206             TDES_128_BLOCK_SIZE_BYTES, TDES_192_BLOCK_SIZE_BYTES
207 #if   ALG_TDES
208 #   define TDES_MAX_BLOCK_SIZE      8
209 #else
210 #   define TDES_MAX_BLOCK_SIZE      0
211 #endif
212 #define MAX_TDES_BLOCK_SIZE_BYTES   TDES_MAX_BLOCK_SIZE
213 
214 // Additional values for benefit of code
215 #define TPM_CC_FIRST                        0x0000011F
216 #define TPM_CC_LAST                         0x0000019A
217 
218 
219 #if COMPRESSED_LISTS
220 #define ADD_FILL            0
221 #else
222 #define ADD_FILL            1
223 #endif
224 
225 // Size the array of library commands based on whether or not
226 // the array is packed (only defined commands) or dense
227 // (having entries for unimplemented commands)
228 #define LIBRARY_COMMAND_ARRAY_SIZE       (0      \
229     + (ADD_FILL || CC_NV_UndefineSpaceSpecial)              /* 0x0000011F */       \
230     + (ADD_FILL || CC_EvictControl)                         /* 0x00000120 */       \
231     + (ADD_FILL || CC_HierarchyControl)                     /* 0x00000121 */       \
232     + (ADD_FILL || CC_NV_UndefineSpace)                     /* 0x00000122 */       \
233     +  ADD_FILL                                             /* 0x00000123 */       \
234     + (ADD_FILL || CC_ChangeEPS)                            /* 0x00000124 */       \
235     + (ADD_FILL || CC_ChangePPS)                            /* 0x00000125 */       \
236     + (ADD_FILL || CC_Clear)                                /* 0x00000126 */       \
237     + (ADD_FILL || CC_ClearControl)                         /* 0x00000127 */       \
238     + (ADD_FILL || CC_ClockSet)                             /* 0x00000128 */       \
239     + (ADD_FILL || CC_HierarchyChangeAuth)                  /* 0x00000129 */       \
240     + (ADD_FILL || CC_NV_DefineSpace)                       /* 0x0000012A */       \
241     + (ADD_FILL || CC_PCR_Allocate)                         /* 0x0000012B */       \
242     + (ADD_FILL || CC_PCR_SetAuthPolicy)                    /* 0x0000012C */       \
243     + (ADD_FILL || CC_PP_Commands)                          /* 0x0000012D */       \
244     + (ADD_FILL || CC_SetPrimaryPolicy)                     /* 0x0000012E */       \
245     + (ADD_FILL || CC_FieldUpgradeStart)                    /* 0x0000012F */       \
246     + (ADD_FILL || CC_ClockRateAdjust)                      /* 0x00000130 */       \
247     + (ADD_FILL || CC_CreatePrimary)                        /* 0x00000131 */       \
248     + (ADD_FILL || CC_NV_GlobalWriteLock)                   /* 0x00000132 */       \
249     + (ADD_FILL || CC_GetCommandAuditDigest)                /* 0x00000133 */       \
250     + (ADD_FILL || CC_NV_Increment)                         /* 0x00000134 */       \
251     + (ADD_FILL || CC_NV_SetBits)                           /* 0x00000135 */       \
252     + (ADD_FILL || CC_NV_Extend)                            /* 0x00000136 */       \
253     + (ADD_FILL || CC_NV_Write)                             /* 0x00000137 */       \
254     + (ADD_FILL || CC_NV_WriteLock)                         /* 0x00000138 */       \
255     + (ADD_FILL || CC_DictionaryAttackLockReset)            /* 0x00000139 */       \
256     + (ADD_FILL || CC_DictionaryAttackParameters)           /* 0x0000013A */       \
257     + (ADD_FILL || CC_NV_ChangeAuth)                        /* 0x0000013B */       \
258     + (ADD_FILL || CC_PCR_Event)                            /* 0x0000013C */       \
259     + (ADD_FILL || CC_PCR_Reset)                            /* 0x0000013D */       \
260     + (ADD_FILL || CC_SequenceComplete)                     /* 0x0000013E */       \
261     + (ADD_FILL || CC_SetAlgorithmSet)                      /* 0x0000013F */       \
262     + (ADD_FILL || CC_SetCommandCodeAuditStatus)            /* 0x00000140 */       \
263     + (ADD_FILL || CC_FieldUpgradeData)                     /* 0x00000141 */       \
264     + (ADD_FILL || CC_IncrementalSelfTest)                  /* 0x00000142 */       \
265     + (ADD_FILL || CC_SelfTest)                             /* 0x00000143 */       \
266     + (ADD_FILL || CC_Startup)                              /* 0x00000144 */       \
267     + (ADD_FILL || CC_Shutdown)                             /* 0x00000145 */       \
268     + (ADD_FILL || CC_StirRandom)                           /* 0x00000146 */       \
269     + (ADD_FILL || CC_ActivateCredential)                   /* 0x00000147 */       \
270     + (ADD_FILL || CC_Certify)                              /* 0x00000148 */       \
271     + (ADD_FILL || CC_PolicyNV)                             /* 0x00000149 */       \
272     + (ADD_FILL || CC_CertifyCreation)                      /* 0x0000014A */       \
273     + (ADD_FILL || CC_Duplicate)                            /* 0x0000014B */       \
274     + (ADD_FILL || CC_GetTime)                              /* 0x0000014C */       \
275     + (ADD_FILL || CC_GetSessionAuditDigest)                /* 0x0000014D */       \
276     + (ADD_FILL || CC_NV_Read)                              /* 0x0000014E */       \
277     + (ADD_FILL || CC_NV_ReadLock)                          /* 0x0000014F */       \
278     + (ADD_FILL || CC_ObjectChangeAuth)                     /* 0x00000150 */       \
279     + (ADD_FILL || CC_PolicySecret)                         /* 0x00000151 */       \
280     + (ADD_FILL || CC_Rewrap)                               /* 0x00000152 */       \
281     + (ADD_FILL || CC_Create)                               /* 0x00000153 */       \
282     + (ADD_FILL || CC_ECDH_ZGen)                            /* 0x00000154 */       \
283     + (ADD_FILL || CC_HMAC || CC_MAC)                       /* 0x00000155 */       \
284     + (ADD_FILL || CC_Import)                               /* 0x00000156 */       \
285     + (ADD_FILL || CC_Load)                                 /* 0x00000157 */       \
286     + (ADD_FILL || CC_Quote)                                /* 0x00000158 */       \
287     + (ADD_FILL || CC_RSA_Decrypt)                          /* 0x00000159 */       \
288     +  ADD_FILL                                             /* 0x0000015A */       \
289     + (ADD_FILL || CC_HMAC_Start || CC_MAC_Start)           /* 0x0000015B */       \
290     + (ADD_FILL || CC_SequenceUpdate)                       /* 0x0000015C */       \
291     + (ADD_FILL || CC_Sign)                                 /* 0x0000015D */       \
292     + (ADD_FILL || CC_Unseal)                               /* 0x0000015E */       \
293     +  ADD_FILL                                             /* 0x0000015F */       \
294     + (ADD_FILL || CC_PolicySigned)                         /* 0x00000160 */       \
295     + (ADD_FILL || CC_ContextLoad)                          /* 0x00000161 */       \
296     + (ADD_FILL || CC_ContextSave)                          /* 0x00000162 */       \
297     + (ADD_FILL || CC_ECDH_KeyGen)                          /* 0x00000163 */       \
298     + (ADD_FILL || CC_EncryptDecrypt)                       /* 0x00000164 */       \
299     + (ADD_FILL || CC_FlushContext)                         /* 0x00000165 */       \
300     +  ADD_FILL                                             /* 0x00000166 */       \
301     + (ADD_FILL || CC_LoadExternal)                         /* 0x00000167 */       \
302     + (ADD_FILL || CC_MakeCredential)                       /* 0x00000168 */       \
303     + (ADD_FILL || CC_NV_ReadPublic)                        /* 0x00000169 */       \
304     + (ADD_FILL || CC_PolicyAuthorize)                      /* 0x0000016A */       \
305     + (ADD_FILL || CC_PolicyAuthValue)                      /* 0x0000016B */       \
306     + (ADD_FILL || CC_PolicyCommandCode)                    /* 0x0000016C */       \
307     + (ADD_FILL || CC_PolicyCounterTimer)                   /* 0x0000016D */       \
308     + (ADD_FILL || CC_PolicyCpHash)                         /* 0x0000016E */       \
309     + (ADD_FILL || CC_PolicyLocality)                       /* 0x0000016F */       \
310     + (ADD_FILL || CC_PolicyNameHash)                       /* 0x00000170 */       \
311     + (ADD_FILL || CC_PolicyOR)                             /* 0x00000171 */       \
312     + (ADD_FILL || CC_PolicyTicket)                         /* 0x00000172 */       \
313     + (ADD_FILL || CC_ReadPublic)                           /* 0x00000173 */       \
314     + (ADD_FILL || CC_RSA_Encrypt)                          /* 0x00000174 */       \
315     +  ADD_FILL                                             /* 0x00000175 */       \
316     + (ADD_FILL || CC_StartAuthSession)                     /* 0x00000176 */       \
317     + (ADD_FILL || CC_VerifySignature)                      /* 0x00000177 */       \
318     + (ADD_FILL || CC_ECC_Parameters)                       /* 0x00000178 */       \
319     + (ADD_FILL || CC_FirmwareRead)                         /* 0x00000179 */       \
320     + (ADD_FILL || CC_GetCapability)                        /* 0x0000017A */       \
321     + (ADD_FILL || CC_GetRandom)                            /* 0x0000017B */       \
322     + (ADD_FILL || CC_GetTestResult)                        /* 0x0000017C */       \
323     + (ADD_FILL || CC_Hash)                                 /* 0x0000017D */       \
324     + (ADD_FILL || CC_PCR_Read)                             /* 0x0000017E */       \
325     + (ADD_FILL || CC_PolicyPCR)                            /* 0x0000017F */       \
326     + (ADD_FILL || CC_PolicyRestart)                        /* 0x00000180 */       \
327     + (ADD_FILL || CC_ReadClock)                            /* 0x00000181 */       \
328     + (ADD_FILL || CC_PCR_Extend)                           /* 0x00000182 */       \
329     + (ADD_FILL || CC_PCR_SetAuthValue)                     /* 0x00000183 */       \
330     + (ADD_FILL || CC_NV_Certify)                           /* 0x00000184 */       \
331     + (ADD_FILL || CC_EventSequenceComplete)                /* 0x00000185 */       \
332     + (ADD_FILL || CC_HashSequenceStart)                    /* 0x00000186 */       \
333     + (ADD_FILL || CC_PolicyPhysicalPresence)               /* 0x00000187 */       \
334     + (ADD_FILL || CC_PolicyDuplicationSelect)              /* 0x00000188 */       \
335     + (ADD_FILL || CC_PolicyGetDigest)                      /* 0x00000189 */       \
336     + (ADD_FILL || CC_TestParms)                            /* 0x0000018A */       \
337     + (ADD_FILL || CC_Commit)                               /* 0x0000018B */       \
338     + (ADD_FILL || CC_PolicyPassword)                       /* 0x0000018C */       \
339     + (ADD_FILL || CC_ZGen_2Phase)                          /* 0x0000018D */       \
340     + (ADD_FILL || CC_EC_Ephemeral)                         /* 0x0000018E */       \
341     + (ADD_FILL || CC_PolicyNvWritten)                      /* 0x0000018F */       \
342     + (ADD_FILL || CC_PolicyTemplate)                       /* 0x00000190 */       \
343     + (ADD_FILL || CC_CreateLoaded)                         /* 0x00000191 */       \
344     + (ADD_FILL || CC_PolicyAuthorizeNV)                    /* 0x00000192 */       \
345     + (ADD_FILL || CC_EncryptDecrypt2)                      /* 0x00000193 */       \
346     + (ADD_FILL || CC_AC_GetCapability)                     /* 0x00000194 */       \
347     + (ADD_FILL || CC_AC_Send)                              /* 0x00000195 */       \
348     + (ADD_FILL || CC_Policy_AC_SendSelect)                 /* 0x00000196 */       \
349     + (ADD_FILL || CC_CertifyX509)                          /* 0x00000197 */       \
350     + (ADD_FILL || CC_ACT_SetTimeout)                       /* 0x00000198 */       \
351     + (ADD_FILL || CC_ECC_Encrypt)                          /* 0x00000199 */       \
352     + (ADD_FILL || CC_ECC_Decrypt)                          /* 0x0000019A */       \
353     )
354 
355 #define VENDOR_COMMAND_ARRAY_SIZE   (0 + CC_Vendor_TCG_Test)
356 
357 #define COMMAND_COUNT       (LIBRARY_COMMAND_ARRAY_SIZE + VENDOR_COMMAND_ARRAY_SIZE)
358 
359 #define HASH_COUNT          \
360             (ALG_SHA1     + ALG_SHA256   + ALG_SHA384   + ALG_SHA3_256 +           \
361              ALG_SHA3_384 + ALG_SHA3_512 + ALG_SHA512   + ALG_SM3_256)
362 
363 #define MAX_HASH_BLOCK_SIZE \
364             (MAX(ALG_SHA1     * SHA1_BLOCK_SIZE,                                   \
365              MAX(ALG_SHA256   * SHA256_BLOCK_SIZE,                                 \
366              MAX(ALG_SHA384   * SHA384_BLOCK_SIZE,                                 \
367              MAX(ALG_SHA3_256 * SHA3_256_BLOCK_SIZE,                               \
368              MAX(ALG_SHA3_384 * SHA3_384_BLOCK_SIZE,                               \
369              MAX(ALG_SHA3_512 * SHA3_512_BLOCK_SIZE,                               \
370              MAX(ALG_SHA512   * SHA512_BLOCK_SIZE,                                 \
371              MAX(ALG_SM3_256  * SM3_256_BLOCK_SIZE,                                \
372              0)))))))))
373 
374 #define MAX_DIGEST_SIZE     \
375             (MAX(ALG_SHA1     * SHA1_DIGEST_SIZE,                                  \
376              MAX(ALG_SHA256   * SHA256_DIGEST_SIZE,                                \
377              MAX(ALG_SHA384   * SHA384_DIGEST_SIZE,                                \
378              MAX(ALG_SHA3_256 * SHA3_256_DIGEST_SIZE,                              \
379              MAX(ALG_SHA3_384 * SHA3_384_DIGEST_SIZE,                              \
380              MAX(ALG_SHA3_512 * SHA3_512_DIGEST_SIZE,                              \
381              MAX(ALG_SHA512   * SHA512_DIGEST_SIZE,                                \
382              MAX(ALG_SM3_256  * SM3_256_DIGEST_SIZE,                               \
383              0)))))))))
384 
385 #if MAX_DIGEST_SIZE == 0 || MAX_HASH_BLOCK_SIZE == 0
386 #error "Hash data not valid"
387 #endif
388 
389 // Define the 2B structure that would hold any hash block
390 TPM2B_TYPE(MAX_HASH_BLOCK, MAX_HASH_BLOCK_SIZE);
391 
392 // Following typedef is for some old code
393 typedef TPM2B_MAX_HASH_BLOCK    TPM2B_HASH_BLOCK;
394 
395 /* Additional symmetric constants */
396 #define MAX_SYM_KEY_BITS        \
397             (MAX(AES_MAX_KEY_SIZE_BITS,      MAX(CAMELLIA_MAX_KEY_SIZE_BITS,       \
398              MAX(SM4_MAX_KEY_SIZE_BITS,      MAX(TDES_MAX_KEY_SIZE_BITS,           \
399              0)))))
400 
401 #define MAX_SYM_KEY_BYTES       ((MAX_SYM_KEY_BITS + 7) / 8)
402 
403 #define MAX_SYM_BLOCK_SIZE      \
404             (MAX(AES_MAX_BLOCK_SIZE,      MAX(CAMELLIA_MAX_BLOCK_SIZE,             \
405              MAX(SM4_MAX_BLOCK_SIZE,      MAX(TDES_MAX_BLOCK_SIZE,                 \
406              0)))))
407 
408 #if MAX_SYM_KEY_BITS == 0 || MAX_SYM_BLOCK_SIZE == 0
409 #   error Bad size for MAX_SYM_KEY_BITS or MAX_SYM_BLOCK
410 #endif
411 
412 
413 #endif // _TPM_ALGORITHM_DEFINES_H_
414