1 /********************************************************************************/
2 /*										*/
3 /*			     Structure Print and Scan Utilities			*/
4 /*			     Written by Ken Goldman				*/
5 /*		       IBM Thomas J. Watson Research Center			*/
6 /*										*/
7 /* (c) Copyright IBM Corporation 2015 - 2020.					*/
8 /*										*/
9 /* All rights reserved.								*/
10 /* 										*/
11 /* Redistribution and use in source and binary forms, with or without		*/
12 /* modification, are permitted provided that the following conditions are	*/
13 /* met:										*/
14 /* 										*/
15 /* Redistributions of source code must retain the above copyright notice,	*/
16 /* this list of conditions and the following disclaimer.			*/
17 /* 										*/
18 /* Redistributions in binary form must reproduce the above copyright		*/
19 /* notice, this list of conditions and the following disclaimer in the		*/
20 /* documentation and/or other materials provided with the distribution.		*/
21 /* 										*/
22 /* Neither the names of the IBM Corporation nor the names of its		*/
23 /* contributors may be used to endorse or promote products derived from		*/
24 /* this software without specific prior written permission.			*/
25 /* 										*/
26 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS		*/
27 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT		*/
28 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR	*/
29 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT		*/
30 /* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,	*/
31 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT		*/
32 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,	*/
33 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY	*/
34 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT		*/
35 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE	*/
36 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.		*/
37 /********************************************************************************/
38 
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <inttypes.h>
43 
44 #include <ibmtss/tsserror.h>
45 #include <ibmtss/tssutils.h>
46 
47 #include <ibmtss/tssprint.h>
48 
49 extern int tssVerbose;
50 
51 #ifdef TPM_TSS_NO_PRINT
52 
53 /* false to compile out printf */
54 int tssSwallowRc = 0;
55 /* function prototype to match the printf prototype */
TSS_SwallowPrintf(const char * format,...)56 int TSS_SwallowPrintf(const char *format, ...)
57 {
58     format = format;
59     return 0;
60 }
61 
62 #endif
63 
64 #ifndef TPM_TSS_NOFILE
65 /* TSS_Array_Scan() converts a string to a binary array */
66 
TSS_Array_Scan(unsigned char ** data,size_t * len,const char * string)67 uint32_t TSS_Array_Scan(unsigned char **data,	/* output binary, freed by caller */
68 			size_t *len,
69 			const char *string)	/* input string */
70 {
71     uint32_t rc = 0;
72     size_t strLength;
73 
74     if (rc == 0) {
75 	strLength = strlen(string);
76 	if ((strLength %2) != 0) {
77 	    if (tssVerbose) printf("TSS_Array_Scan: Error, string length %lu is not even\n",
78 				   (unsigned long)strLength);
79 	    rc = TSS_RC_BAD_PROPERTY_VALUE;
80 	}
81     }
82     if (rc == 0) {
83 	*len = strLength / 2;		/* safe because already tested for even number of bytes */
84         rc = TSS_Malloc(data, (*len) + 8);
85     }
86     if (rc == 0) {
87 	unsigned int i;
88 	for (i = 0 ; i < *len ; i++) {
89 	    unsigned int tmpint;
90 	    int irc = sscanf(string + (2*i), "%2x", &tmpint);
91 	    *((*data)+i) = tmpint;
92 	    if (irc != 1) {
93 		if (tssVerbose) printf("TSS_Array_Scan: invalid hexascii\n");
94 		rc = TSS_RC_BAD_PROPERTY_VALUE;
95 	    }
96 	}
97     }
98     return rc;
99 }
100 #endif /* TPM_TSS_NOFILE */
101 
102 /* TSS_PrintAll() prints 'string', the length, and then the entire byte array
103  */
104 
TSS_PrintAll(const char * string,const unsigned char * buff,uint32_t length)105 void TSS_PrintAll(const char *string, const unsigned char* buff, uint32_t length)
106 {
107     TSS_PrintAlli(string, 1, buff, length);
108 }
109 
110 /* TSS_PrintAlli() prints 'string', the length, and then the entire byte array
111 
112    Each line indented 'indent' spaces.
113 */
114 
TSS_PrintAlli(const char * string,unsigned int indent,const unsigned char * buff,uint32_t length)115 void TSS_PrintAlli(const char *string, unsigned int indent, const unsigned char* buff, uint32_t length)
116 {
117     TSS_PrintAllLogLevel(LOGLEVEL_DEBUG, string, indent, buff, length);
118 }
119 
120 /* TSS_PrintAllLogLevel() prints based on loglevel the 'string', the length, and then the entire
121    byte array
122 
123    loglevel LOGLEVEL_DEBUG prints the length and prints the array with a newline every 16 bytes.
124    otherwise prints no length and prints the array with no newlines.
125 
126 */
127 
TSS_PrintAllLogLevel(uint32_t loglevel,const char * string,unsigned int indent,const unsigned char * buff,uint32_t length)128 void TSS_PrintAllLogLevel(uint32_t loglevel, const char *string, unsigned int indent,
129 			  const unsigned char* buff, uint32_t length)
130 {
131     uint32_t i;
132     if (buff != NULL) {
133         if (loglevel == LOGLEVEL_DEBUG) {
134 	    printf("%*s" "%s length %u\n" "%*s", indent, "", string, length, indent, "");
135 	}
136         else {
137 	    printf("%*s" "%s" "%*s", indent, "", string, indent, "");
138 	}
139         for (i = 0 ; i < length ; i++) {
140             if ((loglevel == LOGLEVEL_DEBUG) && i && !( i % 16 )) {
141                 printf("\n" "%*s", indent, "");
142 	    }
143             printf("%.2x ",buff[i]);
144         }
145 	printf("\n");
146     }
147     else {
148         printf("%*s" "%s null\n", indent, "", string);
149     }
150     return;
151 }
152 
153 #ifndef TPM_TSS_NO_PRINT
154 #ifdef TPM_TPM20
155 
TSS_TPM2B_Print(const char * string,unsigned int indent,TPM2B * source)156 void TSS_TPM2B_Print(const char *string, unsigned int indent, TPM2B *source)
157 {
158     TSS_PrintAlli(string, indent, source->buffer, source->size);
159     return;
160 }
161 
162 /* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */
163 
TSS_TPM_ALG_ID_Print(const char * string,TPM_ALG_ID source,unsigned int indent)164 void TSS_TPM_ALG_ID_Print(const char *string, TPM_ALG_ID source, unsigned int indent)
165 {
166     printf("%*s", indent, "");
167     switch (source) {
168       case  ALG_RSA_VALUE:
169 	printf("%s TPM_ALG_RSA\n", string);
170 	break;
171       case  ALG_TDES_VALUE:
172 	printf("%s TPM_ALG_TDES\n", string);
173 	break;
174       case  ALG_SHA1_VALUE:
175 	printf("%s TPM_ALG_SHA1\n", string);
176 	break;
177       case  ALG_HMAC_VALUE:
178 	printf("%s TPM_ALG_HMAC\n", string);
179 	break;
180       case  ALG_AES_VALUE:
181 	printf("%s TPM_ALG_AES\n", string);
182 	break;
183       case  ALG_MGF1_VALUE:
184 	printf("%s TPM_ALG_MGF1\n", string);
185 	break;
186       case  ALG_KEYEDHASH_VALUE:
187 	printf("%s TPM_ALG_KEYEDHASH\n", string);
188 	break;
189       case  ALG_XOR_VALUE:
190 	printf("%s TPM_ALG_XOR\n", string);
191 	break;
192       case  ALG_SHA256_VALUE:
193 	printf("%s TPM_ALG_SHA256\n", string);
194 	break;
195       case  ALG_SHA384_VALUE:
196 	printf("%s TPM_ALG_SHA384\n", string);
197 	break;
198       case  ALG_SHA512_VALUE:
199 	printf("%s TPM_ALG_SHA512\n", string);
200 	break;
201       case  ALG_NULL_VALUE:
202 	printf("%s TPM_ALG_NULL\n", string);
203 	break;
204       case  ALG_SM3_256_VALUE:
205 	printf("%s TPM_ALG_SM3_256\n", string);
206 	break;
207       case  ALG_SM4_VALUE:
208 	printf("%s TPM_ALG_SM4\n", string);
209 	break;
210       case  ALG_RSASSA_VALUE:
211 	printf("%s TPM_ALG_RSASSA\n", string);
212 	break;
213       case  ALG_RSAES_VALUE:
214 	printf("%s TPM_ALG_RSAES\n", string);
215 	break;
216       case  ALG_RSAPSS_VALUE:
217 	printf("%s TPM_ALG_RSAPSS\n", string);
218 	break;
219       case  ALG_OAEP_VALUE:
220 	printf("%s TPM_ALG_OAEP\n", string);
221 	break;
222       case  ALG_ECDSA_VALUE:
223 	printf("%s TPM_ALG_ECDSA\n", string);
224 	break;
225       case  ALG_ECDH_VALUE:
226 	printf("%s TPM_ALG_ECDH\n", string);
227 	break;
228       case  ALG_ECDAA_VALUE:
229 	printf("%s TPM_ALG_ECDAA\n", string);
230 	break;
231       case  ALG_SM2_VALUE:
232 	printf("%s TPM_ALG_SM2\n", string);
233 	break;
234       case  ALG_ECSCHNORR_VALUE:
235 	printf("%s TPM_ALG_ECSCHNORR\n", string);
236 	break;
237       case  ALG_ECMQV_VALUE:
238 	printf("%s TPM_ALG_ECMQV\n", string);
239 	break;
240       case  ALG_KDF1_SP800_56A_VALUE:
241 	printf("%s TPM_ALG_KDF1_SP800_56A\n", string);
242 	break;
243       case  ALG_KDF2_VALUE:
244 	printf("%s TPM_ALG_KDF2\n", string);
245 	break;
246       case  ALG_KDF1_SP800_108_VALUE:
247 	printf("%s TPM_ALG_KDF1_SP800_108\n", string);
248 	break;
249       case  ALG_ECC_VALUE:
250 	printf("%s TPM_ALG_ECC\n", string);
251 	break;
252       case  ALG_SYMCIPHER_VALUE:
253 	printf("%s TPM_ALG_SYMCIPHER\n", string);
254 	break;
255       case  ALG_CAMELLIA_VALUE:
256 	printf("%s TPM_ALG_CAMELLIA\n", string);
257 	break;
258       case ALG_SHA3_256_VALUE:
259 	printf("%s TPM_ALG_SHA3_256\n", string);
260 	break;
261       case ALG_SHA3_384_VALUE:
262 	printf("%s TPM_ALG_SHA3_384\n", string);
263 	break;
264       case ALG_SHA3_512_VALUE:
265 	printf("%s TPM_ALG_SHA3_512\n", string);
266 	break;
267       case ALG_CMAC_VALUE:
268 	printf("%s TPM_ALG_CMAC\n", string);
269 	break;
270       case  ALG_CTR_VALUE:
271 	printf("%s TPM_ALG_CTR\n", string);
272 	break;
273       case  ALG_OFB_VALUE:
274 	printf("%s TPM_ALG_OFB\n", string);
275 	break;
276       case  ALG_CBC_VALUE:
277 	printf("%s TPM_ALG_CBC\n", string);
278 	break;
279       case  ALG_CFB_VALUE:
280 	printf("%s TPM_ALG_CFB\n", string);
281 	break;
282       case  ALG_ECB_VALUE:
283 	printf("%s TPM_ALG_ECB\n", string);
284 	break;
285       default:
286 	printf("%s TPM_ALG_ID value %04hx unknown\n", string, source);
287     }
288     return;
289 }
290 
291 /* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */
292 
TSS_TPM_ECC_CURVE_Print(const char * string,TPM_ECC_CURVE source,unsigned int indent)293 void TSS_TPM_ECC_CURVE_Print(const char *string, TPM_ECC_CURVE source, unsigned int indent)
294 {
295     printf("%*s", indent, "");
296     switch (source) {
297       case TPM_ECC_NONE:
298 	printf("%s TPM_ECC_NONE\n", string);
299 	break;
300       case TPM_ECC_NIST_P192:
301 	printf("%s TPM_ECC_NIST_P192\n", string);
302 	break;
303       case TPM_ECC_NIST_P224:
304 	printf("%s TPM_ECC_NIST_P224\n", string);
305 	break;
306       case TPM_ECC_NIST_P256:
307 	printf("%s TPM_ECC_NIST_P256\n", string);
308 	break;
309       case TPM_ECC_NIST_P384:
310 	printf("%s TPM_ECC_NIST_P384\n", string);
311 	break;
312       case TPM_ECC_NIST_P521:
313 	printf("%s TPM_ECC_NIST_P521\n", string);
314 	break;
315       case TPM_ECC_BN_P256:
316 	printf("%s TPM_ECC_BN_P256\n", string);
317 	break;
318       case TPM_ECC_BN_P638:
319 	printf("%s TPM_ECC_BN_P638\n", string);
320 	break;
321       case TPM_ECC_SM2_P256:
322 	printf("%s TPM_ECC_SM2_P256\n", string);
323 	break;
324       default:
325 	printf("%s TPM_ECC_CURVE value %04hx unknown\n", string, source);
326     }
327     return;
328 }
329 
330 /* Table 100 - Definition of TPMS_TAGGED_POLICY Structure <OUT> */
331 
TSS_TPMS_TAGGED_POLICY_Print(TPMS_TAGGED_POLICY * source,unsigned int indent)332 void TSS_TPMS_TAGGED_POLICY_Print(TPMS_TAGGED_POLICY *source, unsigned int indent)
333 {
334     TSS_TPM_HANDLE_Print("handle", source->handle, indent);
335     TSS_TPMT_HA_Print(&source->policyHash, indent);
336     return;
337 }
338 
339 /* Table 12 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */
340 
TSS_TPM_CC_Print(const char * string,TPM_CC source,unsigned int indent)341 void TSS_TPM_CC_Print(const char *string, TPM_CC source, unsigned int indent)
342 {
343     printf("%*s", indent, "");
344     switch (source) {
345       case TPM_CC_NV_UndefineSpaceSpecial:
346 	printf("%s TPM_CC_NV_UndefineSpaceSpecial\n", string);
347 	break;
348       case TPM_CC_EvictControl:
349 	printf("%s TPM_CC_EvictControl\n", string);
350 	break;
351       case TPM_CC_HierarchyControl:
352 	printf("%s TPM_CC_HierarchyControl\n", string);
353 	break;
354       case TPM_CC_NV_UndefineSpace:
355 	printf("%s TPM_CC_NV_UndefineSpace\n", string);
356 	break;
357       case TPM_CC_ChangeEPS:
358 	printf("%s TPM_CC_ChangeEPS\n", string);
359 	break;
360       case TPM_CC_ChangePPS:
361 	printf("%s TPM_CC_ChangePPS\n", string);
362 	break;
363       case TPM_CC_Clear:
364 	printf("%s TPM_CC_Clear\n", string);
365 	break;
366       case TPM_CC_ClearControl:
367 	printf("%s TPM_CC_ClearControl\n", string);
368 	break;
369       case TPM_CC_ClockSet:
370 	printf("%s TPM_CC_ClockSet\n", string);
371 	break;
372       case TPM_CC_HierarchyChangeAuth:
373 	printf("%s TPM_CC_HierarchyChangeAuth\n", string);
374 	break;
375       case TPM_CC_NV_DefineSpace:
376 	printf("%s TPM_CC_NV_DefineSpace\n", string);
377 	break;
378       case TPM_CC_PCR_Allocate:
379 	printf("%s TPM_CC_PCR_Allocate\n", string);
380 	break;
381       case TPM_CC_PCR_SetAuthPolicy:
382 	printf("%s TPM_CC_PCR_SetAuthPolicy\n", string);
383 	break;
384       case TPM_CC_PP_Commands:
385 	printf("%s TPM_CC_PP_Commands\n", string);
386 	break;
387       case TPM_CC_SetPrimaryPolicy:
388 	printf("%s TPM_CC_SetPrimaryPolicy\n", string);
389 	break;
390 #if 0
391       case TPM_CC_FieldUpgradeStart:
392 	printf("%s TPM_CC_FieldUpgradeStart\n", string);
393 	break;
394 #endif
395       case TPM_CC_ClockRateAdjust:
396 	printf("%s TPM_CC_ClockRateAdjust\n", string);
397 	break;
398       case TPM_CC_CreatePrimary:
399 	printf("%s TPM_CC_CreatePrimary\n", string);
400 	break;
401       case TPM_CC_NV_GlobalWriteLock:
402 	printf("%s TPM_CC_NV_GlobalWriteLock\n", string);
403 	break;
404       case TPM_CC_GetCommandAuditDigest:
405 	printf("%s TPM_CC_GetCommandAuditDigest\n", string);
406 	break;
407       case TPM_CC_NV_Increment:
408 	printf("%s TPM_CC_NV_Increment\n", string);
409 	break;
410       case TPM_CC_NV_SetBits:
411 	printf("%s TPM_CC_NV_SetBits\n", string);
412 	break;
413       case TPM_CC_NV_Extend:
414 	printf("%s TPM_CC_NV_Extend\n", string);
415 	break;
416       case TPM_CC_NV_Write:
417 	printf("%s TPM_CC_NV_Write\n", string);
418 	break;
419       case TPM_CC_NV_WriteLock:
420 	printf("%s TPM_CC_NV_WriteLock\n", string);
421 	break;
422       case TPM_CC_DictionaryAttackLockReset:
423 	printf("%s TPM_CC_DictionaryAttackLockReset\n", string);
424 	break;
425       case TPM_CC_DictionaryAttackParameters:
426 	printf("%s TPM_CC_DictionaryAttackParameters\n", string);
427 	break;
428       case TPM_CC_NV_ChangeAuth:
429 	printf("%s TPM_CC_NV_ChangeAuth\n", string);
430 	break;
431       case TPM_CC_PCR_Event:
432 	printf("%s TPM_CC_PCR_Event\n", string);
433 	break;
434       case TPM_CC_PCR_Reset:
435 	printf("%s TPM_CC_PCR_Reset\n", string);
436 	break;
437       case TPM_CC_SequenceComplete:
438 	printf("%s TPM_CC_SequenceComplete\n", string);
439 	break;
440       case TPM_CC_SetAlgorithmSet:
441 	printf("%s TPM_CC_SetAlgorithmSet\n", string);
442 	break;
443       case TPM_CC_SetCommandCodeAuditStatus:
444 	printf("%s TPM_CC_SetCommandCodeAuditStatus\n", string);
445 	break;
446 #if 0
447       case TPM_CC_FieldUpgradeData:
448 	printf("%s TPM_CC_FieldUpgradeData\n", string);
449 	break;
450 #endif
451       case TPM_CC_IncrementalSelfTest:
452 	printf("%s TPM_CC_IncrementalSelfTest\n", string);
453 	break;
454       case TPM_CC_SelfTest:
455 	printf("%s TPM_CC_SelfTest\n", string);
456 	break;
457       case TPM_CC_Startup:
458 	printf("%s TPM_CC_Startup\n", string);
459 	break;
460       case TPM_CC_Shutdown:
461 	printf("%s TPM_CC_Shutdown\n", string);
462 	break;
463       case TPM_CC_StirRandom:
464 	printf("%s TPM_CC_StirRandom\n", string);
465 	break;
466       case TPM_CC_ActivateCredential:
467 	printf("%s TPM_CC_ActivateCredential\n", string);
468 	break;
469       case TPM_CC_Certify:
470 	printf("%s TPM_CC_Certify\n", string);
471 	break;
472       case TPM_CC_PolicyNV:
473 	printf("%s TPM_CC_PolicyNV\n", string);
474 	break;
475       case TPM_CC_CertifyCreation:
476 	printf("%s TPM_CC_CertifyCreation\n", string);
477 	break;
478       case TPM_CC_Duplicate:
479 	printf("%s TPM_CC_Duplicate\n", string);
480 	break;
481       case TPM_CC_GetTime:
482 	printf("%s TPM_CC_GetTime\n", string);
483 	break;
484       case TPM_CC_GetSessionAuditDigest:
485 	printf("%s TPM_CC_GetSessionAuditDigest\n", string);
486 	break;
487       case TPM_CC_NV_Read:
488 	printf("%s TPM_CC_NV_Read\n", string);
489 	break;
490       case TPM_CC_NV_ReadLock:
491 	printf("%s TPM_CC_NV_ReadLock\n", string);
492 	break;
493       case TPM_CC_ObjectChangeAuth:
494 	printf("%s TPM_CC_ObjectChangeAuth\n", string);
495 	break;
496       case TPM_CC_PolicySecret:
497 	printf("%s TPM_CC_PolicySecret\n", string);
498 	break;
499       case TPM_CC_Rewrap:
500 	printf("%s TPM_CC_Rewrap\n", string);
501 	break;
502       case TPM_CC_Create:
503 	printf("%s TPM_CC_Create\n", string);
504 	break;
505       case TPM_CC_ECDH_ZGen:
506 	printf("%s TPM_CC_ECDH_ZGen\n", string);
507 	break;
508       case TPM_CC_HMAC:
509 	printf("%s TPM_CC_HMAC\n", string);
510 	break;
511 #if 0
512       case TPM_CC_MAC:
513 	printf("%s TPM_CC_MAC\n", string);
514 	break;
515 #endif
516       case TPM_CC_Import:
517 	printf("%s TPM_CC_Import\n", string);
518 	break;
519       case TPM_CC_Load:
520 	printf("%s TPM_CC_Load\n", string);
521 	break;
522       case TPM_CC_Quote:
523 	printf("%s TPM_CC_Quote\n", string);
524 	break;
525       case TPM_CC_RSA_Decrypt:
526 	printf("%s TPM_CC_RSA_Decrypt\n", string);
527 	break;
528       case TPM_CC_HMAC_Start:
529 	printf("%s TPM_CC_HMAC_Start\n", string);
530 	break;
531 #if 0
532       case TPM_CC_MAC_Start:
533 	printf("%s TPM_CC_MAC_Start\n", string);
534 	break;
535 #endif
536       case TPM_CC_SequenceUpdate:
537 	printf("%s TPM_CC_SequenceUpdate\n", string);
538 	break;
539       case TPM_CC_Sign:
540 	printf("%s TPM_CC_Sign\n", string);
541 	break;
542       case TPM_CC_Unseal:
543 	printf("%s TPM_CC_Unseal\n", string);
544 	break;
545       case TPM_CC_PolicySigned:
546 	printf("%s TPM_CC_PolicySigned\n", string);
547 	break;
548       case TPM_CC_ContextLoad:
549 	printf("%s TPM_CC_ContextLoad\n", string);
550 	break;
551       case TPM_CC_ContextSave:
552 	printf("%s TPM_CC_ContextSave\n", string);
553 	break;
554       case TPM_CC_ECDH_KeyGen:
555 	printf("%s TPM_CC_ECDH_KeyGen\n", string);
556 	break;
557       case TPM_CC_EncryptDecrypt:
558 	printf("%s TPM_CC_EncryptDecrypt\n", string);
559 	break;
560       case TPM_CC_FlushContext:
561 	printf("%s TPM_CC_FlushContext\n", string);
562 	break;
563       case TPM_CC_LoadExternal:
564 	printf("%s TPM_CC_LoadExternal\n", string);
565 	break;
566       case TPM_CC_MakeCredential:
567 	printf("%s TPM_CC_MakeCredential\n", string);
568 	break;
569       case TPM_CC_NV_ReadPublic:
570 	printf("%s TPM_CC_NV_ReadPublic\n", string);
571 	break;
572       case TPM_CC_PolicyAuthorize:
573 	printf("%s TPM_CC_PolicyAuthorize\n", string);
574 	break;
575       case TPM_CC_PolicyAuthValue:
576 	printf("%s TPM_CC_PolicyAuthValue\n", string);
577 	break;
578       case TPM_CC_PolicyCommandCode:
579 	printf("%s TPM_CC_PolicyCommandCode\n", string);
580 	break;
581       case TPM_CC_PolicyCounterTimer:
582 	printf("%s TPM_CC_PolicyCounterTimer\n", string);
583 	break;
584       case TPM_CC_PolicyCpHash:
585 	printf("%s TPM_CC_PolicyCpHash\n", string);
586 	break;
587       case TPM_CC_PolicyLocality:
588 	printf("%s TPM_CC_PolicyLocality\n", string);
589 	break;
590       case TPM_CC_PolicyNameHash:
591 	printf("%s TPM_CC_PolicyNameHash\n", string);
592 	break;
593       case TPM_CC_PolicyOR:
594 	printf("%s TPM_CC_PolicyOR\n", string);
595 	break;
596       case TPM_CC_PolicyTicket:
597 	printf("%s TPM_CC_PolicyTicket\n", string);
598 	break;
599       case TPM_CC_ReadPublic:
600 	printf("%s TPM_CC_ReadPublic\n", string);
601 	break;
602       case TPM_CC_RSA_Encrypt:
603 	printf("%s TPM_CC_RSA_Encrypt\n", string);
604 	break;
605       case TPM_CC_StartAuthSession:
606 	printf("%s TPM_CC_StartAuthSession\n", string);
607 	break;
608       case TPM_CC_VerifySignature:
609 	printf("%s TPM_CC_VerifySignature\n", string);
610 	break;
611       case TPM_CC_ECC_Parameters:
612 	printf("%s TPM_CC_ECC_Parameters\n", string);
613 	break;
614 #if 0
615       case TPM_CC_FirmwareRead:
616 	printf("%s TPM_CC_FirmwareRead\n", string);
617 	break;
618 #endif
619       case TPM_CC_GetCapability:
620 	printf("%s TPM_CC_GetCapability\n", string);
621 	break;
622       case TPM_CC_GetRandom:
623 	printf("%s TPM_CC_GetRandom\n", string);
624 	break;
625       case TPM_CC_GetTestResult:
626 	printf("%s TPM_CC_GetTestResult\n", string);
627 	break;
628       case TPM_CC_Hash:
629 	printf("%s TPM_CC_Hash\n", string);
630 	break;
631       case TPM_CC_PCR_Read:
632 	printf("%s TPM_CC_PCR_Read\n", string);
633 	break;
634       case TPM_CC_PolicyPCR:
635 	printf("%s TPM_CC_PolicyPCR\n", string);
636 	break;
637       case TPM_CC_PolicyRestart:
638 	printf("%s TPM_CC_PolicyRestart\n", string);
639 	break;
640       case TPM_CC_ReadClock:
641 	printf("%s TPM_CC_ReadClock\n", string);
642 	break;
643       case TPM_CC_PCR_Extend:
644 	printf("%s TPM_CC_PCR_Extend\n", string);
645 	break;
646       case TPM_CC_PCR_SetAuthValue:
647 	printf("%s TPM_CC_PCR_SetAuthValue\n", string);
648 	break;
649       case TPM_CC_NV_Certify:
650 	printf("%s TPM_CC_NV_Certify\n", string);
651 	break;
652       case TPM_CC_EventSequenceComplete:
653 	printf("%s TPM_CC_EventSequenceComplete\n", string);
654 	break;
655       case TPM_CC_HashSequenceStart:
656 	printf("%s TPM_CC_HashSequenceStart\n", string);
657 	break;
658       case TPM_CC_PolicyPhysicalPresence:
659 	printf("%s TPM_CC_PolicyPhysicalPresence\n", string);
660 	break;
661       case TPM_CC_PolicyDuplicationSelect:
662 	printf("%s TPM_CC_PolicyDuplicationSelect\n", string);
663 	break;
664       case TPM_CC_PolicyGetDigest:
665 	printf("%s TPM_CC_PolicyGetDigest\n", string);
666 	break;
667       case TPM_CC_TestParms:
668 	printf("%s TPM_CC_TestParms\n", string);
669 	break;
670       case TPM_CC_Commit:
671 	printf("%s TPM_CC_Commit\n", string);
672 	break;
673       case TPM_CC_PolicyPassword:
674 	printf("%s TPM_CC_PolicyPassword\n", string);
675 	break;
676       case TPM_CC_ZGen_2Phase:
677 	printf("%s TPM_CC_ZGen_2Phase\n", string);
678 	break;
679       case TPM_CC_EC_Ephemeral:
680 	printf("%s TPM_CC_EC_Ephemeral\n", string);
681 	break;
682       case TPM_CC_PolicyNvWritten:
683 	printf("%s TPM_CC_PolicyNvWritten\n", string);
684 	break;
685       case TPM_CC_PolicyTemplate:
686 	printf("%s TPM_CC_PolicyTemplate\n", string);
687 	break;
688       case TPM_CC_CreateLoaded:
689 	printf("%s TPM_CC_CreateLoaded\n", string);
690 	break;
691       case TPM_CC_PolicyAuthorizeNV:
692 	printf("%s TPM_CC_PolicyAuthorizeNV\n", string);
693 	break;
694       case TPM_CC_EncryptDecrypt2:
695 	printf("%s TPM_CC_EncryptDecrypt2\n", string);
696 	break;
697 #if 0
698       case TPM_CC_AC_GetCapability:
699 	printf("%s TPM_CC_AC_GetCapability\n", string);
700 	break;
701       case TPM_CC_AC_Send:
702 	printf("%s TPM_CC_AC_Send\n", string);
703 	break;
704       case TPM_CC_Policy_AC_SendSelect:
705 	printf("%s TPM_CC_Policy_AC_SendSelect\n", string);
706 	break;
707 #endif
708       default:
709 	printf("%s TPM_CC value %08x unknown\n", string, source);
710     }
711     return;
712 }
713 
714 /* Table 17 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */
715 
TSS_TPM_CLOCK_ADJUST_Print(const char * string,TPM_CLOCK_ADJUST source,unsigned int indent)716 void TSS_TPM_CLOCK_ADJUST_Print(const char *string, TPM_CLOCK_ADJUST source, unsigned int indent)
717 {
718     printf("%*s", indent, "");
719     switch (source) {
720       case TPM_CLOCK_COARSE_SLOWER:
721 	printf("%s TPM_CLOCK_COARSE_SLOWER\n", string);
722 	break;
723       case TPM_CLOCK_MEDIUM_SLOWER:
724 	printf("%s TPM_CLOCK_MEDIUM_SLOWER\n", string);
725 	break;
726       case TPM_CLOCK_FINE_SLOWER:
727 	printf("%s TPM_CLOCK_FINE_SLOWER\n", string);
728 	break;
729       case TPM_CLOCK_NO_CHANGE:
730 	printf("%s TPM_CLOCK_NO_CHANGE\n", string);
731 	break;
732       case TPM_CLOCK_FINE_FASTER:
733 	printf("%s TPM_CLOCK_FINE_FASTER\n", string);
734 	break;
735       case TPM_CLOCK_MEDIUM_FASTER:
736 	printf("%s TPM_CLOCK_MEDIUM_FASTER\n", string);
737 	break;
738       case TPM_CLOCK_COARSE_FASTER:
739 	printf("%s TPM_CLOCK_COARSE_FASTER\n", string);
740 	break;
741       default:
742 	printf("%s TPM_CLOCK_ADJUST value %d unknown\n", string, source);
743     }
744     return;
745 }
746 
747 /* Table 18 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */
748 
TSS_TPM_EO_Print(const char * string,TPM_EO source,unsigned int indent)749 void TSS_TPM_EO_Print(const char *string, TPM_EO source, unsigned int indent)
750 {
751     printf("%*s", indent, "");
752     switch (source) {
753       case TPM_EO_EQ:
754 	printf("%s TPM_EO_EQ\n", string);
755 	break;
756       case TPM_EO_NEQ:
757 	printf("%s TPM_EO_NEQ\n", string);
758 	break;
759       case TPM_EO_SIGNED_GT:
760 	printf("%s TPM_EO_SIGNED_GT\n", string);
761 	break;
762       case TPM_EO_UNSIGNED_GT:
763 	printf("%s TPM_EO_UNSIGNED_GT\n", string);
764 	break;
765       case TPM_EO_SIGNED_LT:
766 	printf("%s TPM_EO_SIGNED_LT\n", string);
767 	break;
768       case TPM_EO_UNSIGNED_LT:
769 	printf("%s TPM_EO_UNSIGNED_LT\n", string);
770 	break;
771       case TPM_EO_SIGNED_GE:
772 	printf("%s TPM_EO_SIGNED_GE\n", string);
773 	break;
774       case TPM_EO_UNSIGNED_GE:
775 	printf("%s TPM_EO_UNSIGNED_GE\n", string);
776 	break;
777       case TPM_EO_SIGNED_LE:
778 	printf("%s TPM_EO_SIGNED_LE\n", string);
779 	break;
780       case TPM_EO_UNSIGNED_LE:
781 	printf("%s TPM_EO_UNSIGNED_LE\n", string);
782 	break;
783       case TPM_EO_BITSET:
784 	printf("%s TPM_EO_BITSET\n", string);
785 	break;
786       case TPM_EO_BITCLEAR:
787 	printf("%s TPM_EO_BITCLEAR\n", string);
788 	break;
789       default:
790 	printf("%s TPM_EO value %04hx unknown\n", string, source);
791     }
792     return;
793 }
794 
795 /* Table 19 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */
796 
TSS_TPM_ST_Print(const char * string,TPM_ST source,unsigned int indent)797 void TSS_TPM_ST_Print(const char *string, TPM_ST source, unsigned int indent)
798 {
799     printf("%*s", indent, "");
800     switch (source) {
801       case TPM_ST_RSP_COMMAND:
802 	printf("%s TPM_ST_RSP_COMMAND\n", string);
803 	break;
804       case TPM_ST_NULL:
805 	printf("%s TPM_ST_NULL\n", string);
806 	break;
807       case TPM_ST_NO_SESSIONS:
808 	printf("%s TPM_ST_NO_SESSIONS\n", string);
809 	break;
810       case TPM_ST_SESSIONS:
811 	printf("%s TPM_ST_SESSIONS\n", string);
812 	break;
813       case TPM_ST_ATTEST_NV:
814 	printf("%s TPM_ST_ATTEST_NV\n", string);
815 	break;
816       case TPM_ST_ATTEST_COMMAND_AUDIT:
817 	printf("%s TPM_ST_ATTEST_COMMAND_AUDIT\n", string);
818 	break;
819       case TPM_ST_ATTEST_SESSION_AUDIT:
820 	printf("%s TPM_ST_ATTEST_SESSION_AUDIT\n", string);
821 	break;
822       case TPM_ST_ATTEST_CERTIFY:
823 	printf("%s TPM_ST_ATTEST_CERTIFY\n", string);
824 	break;
825       case TPM_ST_ATTEST_QUOTE:
826 	printf("%s TPM_ST_ATTEST_QUOTE\n", string);
827 	break;
828       case TPM_ST_ATTEST_TIME:
829 	printf("%s TPM_ST_ATTEST_TIME\n", string);
830 	break;
831       case TPM_ST_ATTEST_CREATION:
832 	printf("%s TPM_ST_ATTEST_CREATION\n", string);
833 	break;
834       case TPM_ST_ATTEST_NV_DIGEST:
835 	printf("%s TPM_ST_ATTEST_NV_DIGEST\n", string);
836 	break;
837       case TPM_ST_CREATION:
838 	printf("%s TPM_ST_CREATION\n", string);
839 	break;
840       case TPM_ST_VERIFIED:
841 	printf("%s TPM_ST_VERIFIED\n", string);
842 	break;
843       case TPM_ST_AUTH_SECRET:
844 	printf("%s TPM_ST_AUTH_SECRET\n", string);
845 	break;
846       case TPM_ST_HASHCHECK:
847 	printf("%s TPM_ST_HASHCHECK\n", string);
848 	break;
849       case TPM_ST_AUTH_SIGNED:
850 	printf("%s TPM_ST_AUTH_SIGNED\n", string);
851 	break;
852       default:
853 	printf("%s TPM_ST value %04hx unknown\n", string, source);
854     }
855     return;
856 }
857 
858 /* Table 20 - Definition of (UINT16) TPM_SU Constants <IN> */
859 
TSS_TPM_SU_Print(const char * string,TPM_SU source,unsigned int indent)860 void TSS_TPM_SU_Print(const char *string, TPM_SU source, unsigned int indent)
861 {
862     printf("%*s", indent, "");
863     switch (source) {
864       case TPM_SU_CLEAR:
865 	printf("%s TPM_SU_CLEAR\n", string);
866 	break;
867       case TPM_SU_STATE:
868 	printf("%s TPM_SU_STATE\n", string);
869 	break;
870       default:
871 	printf("%s TPM_SU value %04hx unknown\n", string, source);
872     }
873     return;
874 }
875 
876 /* Table 21 - Definition of (UINT8) TPM_SE Constants <IN> */
877 
TSS_TPM_SE_Print(const char * string,TPM_SE source,unsigned int indent)878 void TSS_TPM_SE_Print(const char *string, TPM_SE source, unsigned int indent)
879 {
880     printf("%*s", indent, "");
881     switch (source) {
882       case TPM_SE_HMAC:
883 	printf("%s TPM_SE_HMAC\n", string);
884 	break;
885       case TPM_SE_POLICY:
886 	printf("%s TPM_SE_POLICY\n", string);
887 	break;
888       case TPM_SE_TRIAL:
889 	printf("%s TPM_SE_TRIAL\n", string);
890 	break;
891       default:
892 	printf("%s TPM_SE value %02x unknown\n", string, source);
893     }
894     return;
895 }
896 
897 /* Table 22 - Definition of (UINT32) TPM_CAP Constants */
898 
TSS_TPM_CAP_Print(const char * string,TPM_CAP source,unsigned int indent)899 void TSS_TPM_CAP_Print(const char *string, TPM_CAP source, unsigned int indent)
900 {
901     printf("%*s", indent, "");
902     switch (source) {
903      case TPM_CAP_ALGS:
904        printf("%s TPM_CAP_ALGS\n", string);
905 	break;
906       case TPM_CAP_HANDLES:
907 	printf("%s TPM_CAP_HANDLES\n", string);
908 	break;
909       case TPM_CAP_COMMANDS:
910 	printf("%s TPM_CAP_COMMANDS\n", string);
911 	break;
912       case TPM_CAP_PP_COMMANDS:
913 	printf("%s TPM_CAP_PP_COMMANDS\n", string);
914 	break;
915       case TPM_CAP_AUDIT_COMMANDS:
916 	printf("%s TPM_CAP_AUDIT_COMMANDS\n", string);
917 	break;
918       case TPM_CAP_PCRS:
919 	printf("%s TPM_CAP_PCRS\n", string);
920 	break;
921       case TPM_CAP_TPM_PROPERTIES:
922 	printf("%s TPM_CAP_TPM_PROPERTIES\n", string);
923 	break;
924       case TPM_CAP_PCR_PROPERTIES:
925 	printf("%s TPM_CAP_PCR_PROPERTIES\n", string);
926 	break;
927       case TPM_CAP_ECC_CURVES:
928 	printf("%s TPM_CAP_ECC_CURVES\n", string);
929 	break;
930       case TPM_CAP_AUTH_POLICIES:
931 	printf("%s TPM_CAP_AUTH_POLICIES\n", string);
932 	break;
933       case TPM_CAP_VENDOR_PROPERTY:
934 	printf("%s TPM_CAP_VENDOR_PROPERTY\n", string);
935 	break;
936       default:
937 	printf("%s TPM_CAP value %08x unknown\n", string, source);
938     }
939     return;
940 }
941 
942 /* Table 26 - Definition of Types for Handles */
943 
TSS_TPM_HANDLE_Print(const char * string,TPM_HANDLE source,unsigned int indent)944 void TSS_TPM_HANDLE_Print(const char *string, TPM_HANDLE source, unsigned int indent)
945 {
946     printf("%*s", indent, "");
947     switch (source) {
948       case TPM_RH_SRK:
949 	printf("%s TPM_RH_SRK\n", string);
950 	break;
951       case TPM_RH_OWNER:
952 	printf("%s TPM_RH_OWNER\n", string);
953 	break;
954       case TPM_RH_REVOKE:
955 	printf("%s TPM_RH_REVOKE\n", string);
956 	break;
957       case TPM_RH_TRANSPORT:
958 	printf("%s TPM_RH_TRANSPORT\n", string);
959 	break;
960       case TPM_RH_OPERATOR:
961 	printf("%s TPM_RH_OPERATOR\n", string);
962 	break;
963       case TPM_RH_ADMIN:
964 	printf("%s TPM_RH_ADMIN\n", string);
965 	break;
966       case TPM_RH_EK:
967 	printf("%s TPM_RH_EK\n", string);
968 	break;
969       case TPM_RH_NULL:
970 	printf("%s TPM_RH_NULL\n", string);
971 	break;
972       case TPM_RH_UNASSIGNED:
973 	printf("%s TPM_RH_UNASSIGNED\n", string);
974 	break;
975       case TPM_RS_PW:
976 	printf("%s TPM_RS_PW\n", string);
977 	break;
978       case TPM_RH_LOCKOUT:
979 	printf("%s TPM_RH_LOCKOUT\n", string);
980 	break;
981       case TPM_RH_ENDORSEMENT:
982 	printf("%s TPM_RH_ENDORSEMENT\n", string);
983 	break;
984       case TPM_RH_PLATFORM:
985 	printf("%s TPM_RH_PLATFORM\n", string);
986 	break;
987       case TPM_RH_PLATFORM_NV:
988 	printf("%s TPM_RH_PLATFORM_NV\n", string);
989 	break;
990       default:
991 	printf("%s TPM_HANDLE %08x\n", string, source);
992     }
993     return;
994 }
995 
996 /* Table 30 - Definition of (UINT32) TPMA_ALGORITHM Bits */
997 
TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source,unsigned int indent)998 void TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source, unsigned int indent)
999 {
1000     if (source.val & TPMA_ALGORITHM_ASYMMETRIC) printf("%*s" "TPMA_ALGORITHM: asymmetric\n", indent, "");
1001     if (source.val & TPMA_ALGORITHM_SYMMETRIC) printf("%*s" "TPMA_ALGORITHM: symmetric\n", indent, "");
1002     if (source.val & TPMA_ALGORITHM_HASH) printf("%*s" "TPMA_ALGORITHM: hash\n", indent, "");
1003     if (source.val & TPMA_ALGORITHM_OBJECT) printf("%*s" "TPMA_ALGORITHM: object\n", indent, "");
1004     if (source.val & TPMA_ALGORITHM_SIGNING) printf("%*s" "TPMA_ALGORITHM: signing\n", indent, "");
1005     if (source.val & TPMA_ALGORITHM_ENCRYPTING) printf("%*s" "TPMA_ALGORITHM: encrypting\n", indent, "");
1006     if (source.val & TPMA_ALGORITHM_METHOD) printf("%*s" "TPMA_ALGORITHM: method\n", indent, "");
1007     return;
1008 }
1009 
1010 /* Table 31 - Definition of (UINT32) TPMA_OBJECT Bits */
1011 
TSS_TPMA_OBJECT_Print(const char * string,TPMA_OBJECT source,unsigned int indent)1012 void TSS_TPMA_OBJECT_Print(const char *string, TPMA_OBJECT source, unsigned int indent)
1013 {
1014     printf("%*s%s: %08x\n", indent, "", string, source.val);
1015     if (source.val & TPMA_OBJECT_FIXEDTPM) printf("%*s%s: fixedTpm\n", indent, "", string);
1016     if (source.val & TPMA_OBJECT_STCLEAR) printf("%*s%s: stClear\n", indent, "", string);
1017     if (source.val & TPMA_OBJECT_FIXEDPARENT) printf("%*s%s: fixedParent\n", indent, "", string);
1018     if (source.val & TPMA_OBJECT_SENSITIVEDATAORIGIN) printf("%*s%s: sensitiveDataOrigin\n", indent, "", string);
1019     if (source.val & TPMA_OBJECT_USERWITHAUTH) printf("%*s%s: userWithAuth\n", indent, "", string);
1020     if (source.val & TPMA_OBJECT_ADMINWITHPOLICY) printf("%*s%s: adminWithPolicy\n", indent, "", string);
1021     if (source.val & TPMA_OBJECT_NODA) printf("%*s%s: noDA\n", indent, "", string);
1022     if (source.val & TPMA_OBJECT_ENCRYPTEDDUPLICATION) printf("%*s%s: encryptedDuplication\n", indent, "", string);
1023     if (source.val & TPMA_OBJECT_RESTRICTED) printf("%*s%s: restricted\n", indent, "", string);
1024     if (source.val & TPMA_OBJECT_DECRYPT) printf("%*s%s: decrypt\n", indent, "", string);
1025     if (source.val & TPMA_OBJECT_SIGN) printf("%*s%s: sign\n", indent, "", string);
1026     return;
1027 }
1028 
1029 /* Table 32 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */
1030 
TSS_TPMA_SESSION_Print(TPMA_SESSION source,unsigned int indent)1031 void TSS_TPMA_SESSION_Print(TPMA_SESSION source, unsigned int indent)
1032 {
1033 
1034     if (source.val & TPMA_SESSION_CONTINUESESSION) printf("%*s" "TPMA_SESSION: continue\n", indent, "");
1035     if (source.val & TPMA_SESSION_AUDITEXCLUSIVE) printf("%*s" "TPMA_SESSION: auditexclusive\n", indent, "");
1036     if (source.val & TPMA_SESSION_AUDITRESET) printf("%*s" "TPMA_SESSION: auditreset\n", indent, "");
1037     if (source.val & TPMA_SESSION_DECRYPT) printf("%*s" "TPMA_SESSION: decrypt\n", indent, "");
1038     if (source.val & TPMA_SESSION_ENCRYPT) printf("%*s" "TPMA_SESSION: encrypt\n", indent, "");
1039     if (source.val & TPMA_SESSION_AUDIT) printf("%*s" "TPMA_SESSION: audit\n", indent, "");
1040     return;
1041 }
1042 
1043 /* Table 33 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */
1044 
TSS_TPMA_LOCALITY_Print(TPMA_LOCALITY source,unsigned int indent)1045 void TSS_TPMA_LOCALITY_Print(TPMA_LOCALITY source, unsigned int indent)
1046 {
1047     if (source.val & TPMA_LOCALITY_ZERO) printf("%*s" "TPMA_LOCALITY: zero\n", indent, "");
1048     if (source.val & TPMA_LOCALITY_ONE) printf("%*s" "TPMA_LOCALITY: one\n", indent, "");
1049     if (source.val & TPMA_LOCALITY_TWO) printf("%*s" "TPMA_LOCALITY: two\n", indent, "");
1050     if (source.val & TPMA_LOCALITY_THREE) printf("%*s" "TPMA_LOCALITY: three\n", indent, "");
1051     if (source.val & TPMA_LOCALITY_FOUR) printf("%*s" "TPMA_LOCALITY: four\n", indent, "");
1052     if (source.val & TPMA_LOCALITY_EXTENDED) printf("%*s" "TPMA_LOCALITY: extended\n", indent, "");
1053     return;
1054 }
1055 
1056 /* Table 34 - Definition of (UINT32) TPMA_PERMANENT Bits <OUT> */
1057 
TSS_TPMA_PERMANENT_Print(TPMA_PERMANENT source,unsigned int indent)1058 void TSS_TPMA_PERMANENT_Print(TPMA_PERMANENT source, unsigned int indent)
1059 {
1060     printf("%*s" "TPMA_PERMANENT: ownerAuthSet %s\n", indent, "",
1061 	   (source.val & TPMA_PERMANENT_OWNERAUTHSET) ? "yes" : "no");
1062     printf("%*s" "TPMA_PERMANENT: endorsementAuthSet %s\n", indent, "",
1063 	   (source.val & TPMA_PERMANENT_ENDORSEMENTAUTHSET)  ? "yes" : "no");
1064     printf("%*s" "TPMA_PERMANENT: lockoutAuthSet %s\n", indent, "",
1065 	   (source.val & TPMA_PERMANENT_LOCKOUTAUTHSET)  ? "yes" : "no");
1066     printf("%*s" "TPMA_PERMANENT: disableClear %s\n", indent, "",
1067 	   (source.val & TPMA_PERMANENT_DISABLECLEAR) ? "yes" : "no");
1068     printf("%*s" "TPMA_PERMANENT: inLockout %s\n", indent, "",
1069 	   (source.val & TPMA_PERMANENT_INLOCKOUT) ? "yes" : "no");
1070     printf("%*s" "TPMA_PERMANENT: tpmGeneratedEPS %s\n", indent, "",
1071 	   (source.val & TPMA_PERMANENT_TPMGENERATEDEPS)  ? "yes" : "no");
1072     return;
1073 }
1074 
1075 /* Table 35 - Definition of (UINT32) TPMA_STARTUP_CLEAR Bits <OUT> */
1076 
TSS_TPMA_STARTUP_CLEAR_Print(TPMA_STARTUP_CLEAR source,unsigned int indent)1077 void TSS_TPMA_STARTUP_CLEAR_Print(TPMA_STARTUP_CLEAR source, unsigned int indent)
1078 {
1079     printf("%*s" "TPMA_STARTUP_CLEAR: phEnable %s\n", indent, "",
1080 	   (source.val & TPMA_STARTUP_CLEAR_PHENABLE)  ? "yes" : "no");
1081     printf("%*s" "TPMA_STARTUP_CLEAR: shEnable %s\n", indent, "",
1082 	   (source.val & TPMA_STARTUP_CLEAR_SHENABLE)  ? "yes" : "no");
1083     printf("%*s" "TPMA_STARTUP_CLEAR: ehEnable %s\n", indent, "",
1084 	   (source.val & TPMA_STARTUP_CLEAR_EHENABLE)  ? "yes" : "no");
1085     printf("%*s" "TPMA_STARTUP_CLEAR: phEnableNV %s\n", indent, "",
1086 	   (source.val & TPMA_STARTUP_CLEAR_PHENABLENV)  ? "yes" : "no");
1087     printf("%*s" "TPMA_STARTUP_CLEAR: orderly %s\n", indent, "",
1088 	   (source.val & TPMA_STARTUP_CLEAR_ORDERLY)  ? "yes" : "no");
1089     return;
1090 }
1091 
1092 /* Table 36 - Definition of (UINT32) TPMA_MEMORY Bits <Out> */
1093 
TSS_TPMA_MEMORY_Print(TPMA_MEMORY source,unsigned int indent)1094 void TSS_TPMA_MEMORY_Print(TPMA_MEMORY source, unsigned int indent)
1095 {
1096     printf("%*s" "TPMA_MEMORY: sharedRAM %s\n", indent, "",
1097 	   (source.val & TPMA_MEMORY_SHAREDRAM) ? "yes" : "no");
1098     printf("%*s" "TPMA_MEMORY: sharedNV %s\n", indent, "",
1099 	   (source.val & TPMA_MEMORY_SHAREDNV) ? "yes" : "no");
1100     printf("%*s" "TPMA_MEMORY: objectCopiedToRam %s\n", indent, "",
1101 	   (source.val & TPMA_MEMORY_OBJECTCOPIEDTORAM) ? "yes" : "no");
1102     return;
1103 }
1104 
1105 /* Table 38 - Definition of (UINT32) TPMA_MODES Bits <Out> */
1106 
TSS_TPMA_MODES_Print(TPMA_MODES source,unsigned int indent)1107 void TSS_TPMA_MODES_Print(TPMA_MODES source, unsigned int indent)
1108 {
1109     printf("%*s" "TPMA_MODES: TPMA_MODES_FIPS_140_2 %s\n", indent, "",
1110 	   (source.val & TPMA_MODES_FIPS_140_2) ? "yes" : "no");
1111     return;
1112 }
1113 
1114 /* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */
1115 
TSS_TPMI_YES_NO_Print(const char * string,TPMI_YES_NO source,unsigned int indent)1116 void TSS_TPMI_YES_NO_Print(const char *string, TPMI_YES_NO source, unsigned int indent)
1117 {
1118     printf("%*s", indent, "");
1119     switch (source) {
1120       case NO:
1121 	printf("%s no\n", string);
1122 	break;
1123       case YES:
1124 	printf("%s yes\n", string);
1125 	break;
1126       default:
1127 	printf("%s TPMI_YES_NO %02x unknown\n", string, source);
1128     }
1129     return;
1130 }
1131 
1132 /* Table 75 - Definition of TPMU_HA Union <IN/OUT, S> */
1133 
1134 
TSS_TPMU_HA_Print(TPMU_HA * source,uint32_t selector,unsigned int indent)1135 void TSS_TPMU_HA_Print(TPMU_HA *source, uint32_t selector, unsigned int indent)
1136 {
1137     switch (selector) {
1138 #ifdef TPM_ALG_SHA1
1139       case TPM_ALG_SHA1:
1140 	TSS_PrintAlli("sha1", indent, source->sha1, SHA1_DIGEST_SIZE);
1141 	break;
1142 #endif
1143 #ifdef TPM_ALG_SHA256
1144       case TPM_ALG_SHA256:
1145 	TSS_PrintAlli("sha256", indent, source->sha256, SHA256_DIGEST_SIZE);
1146 	break;
1147 #endif
1148 #ifdef TPM_ALG_SHA384
1149       case TPM_ALG_SHA384:
1150 	TSS_PrintAlli("sha384", indent, source->sha384, SHA384_DIGEST_SIZE);
1151 	break;
1152 #endif
1153 #ifdef TPM_ALG_SHA512
1154       case TPM_ALG_SHA512:
1155 	TSS_PrintAlli("sha512", indent, source->sha512, SHA512_DIGEST_SIZE);
1156 	break;
1157 #endif
1158 #ifdef TPM_ALG_SM3_256
1159       case TPM_ALG_SM3_256:
1160 	TSS_PrintAlli("sm3_256", indent, source->sm3_256, SM3_256_DIGEST_SIZE);
1161 	break;
1162 #endif
1163       case TPM_ALG_NULL:
1164 	break;
1165       default:
1166 	printf("%*s" "TPMU_HA: selection %08x not implemented\n", indent, "", selector);
1167     }
1168     return;
1169 }
1170 
1171 /* Table 76 - Definition of TPMT_HA Structure <IN/OUT> */
1172 
TSS_TPMT_HA_Print(TPMT_HA * source,unsigned int indent)1173 void TSS_TPMT_HA_Print(TPMT_HA *source, unsigned int indent)
1174 {
1175     TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2);
1176     TSS_TPMU_HA_Print(&source->digest, source->hashAlg, indent+2);
1177     return;
1178 }
1179 
1180 /* Table 89 - Definition of TPMS_PCR_SELECT Structure */
1181 
TSS_TPMS_PCR_SELECT_Print(TPMS_PCR_SELECT * source,unsigned int indent)1182 void TSS_TPMS_PCR_SELECT_Print(TPMS_PCR_SELECT *source, unsigned int indent)
1183 {
1184     printf("%*s" "TSS_TPMS_PCR_SELECT sizeofSelect %u\n", indent, "", source->sizeofSelect);
1185     TSS_PrintAlli("pcrSelect", indent, source->pcrSelect, source->sizeofSelect);
1186     return;
1187 }
1188 
1189 /* Table 90 - Definition of TPMS_PCR_SELECTION Structure */
1190 
TSS_TPMS_PCR_SELECTION_Print(TPMS_PCR_SELECTION * source,unsigned int indent)1191 void TSS_TPMS_PCR_SELECTION_Print(TPMS_PCR_SELECTION *source, unsigned int indent)
1192 {
1193     TSS_TPM_ALG_ID_Print("hash", source->hash, indent+2);
1194     TSS_PrintAlli("TPMS_PCR_SELECTION", indent+2,
1195 		  source->pcrSelect,
1196 		  source->sizeofSelect);
1197     return;
1198 }
1199 
1200 /* Table 93 - Definition of TPMT_TK_CREATION Structure */
1201 
TSS_TPMT_TK_CREATION_Print(TPMT_TK_CREATION * source,unsigned int indent)1202 void TSS_TPMT_TK_CREATION_Print(TPMT_TK_CREATION *source, unsigned int indent)
1203 {
1204     TSS_TPM_ST_Print("tag", source->tag, indent);
1205     TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent);
1206     TSS_TPM2B_Print("TPMT_TK_CREATION digest", indent, &source->digest.b);
1207     return;
1208 }
1209 
1210 /* Table 94 - Definition of TPMT_TK_VERIFIED Structure */
1211 
TSS_TPMT_TK_VERIFIED_Print(TPMT_TK_VERIFIED * source,unsigned int indent)1212 void TSS_TPMT_TK_VERIFIED_Print(TPMT_TK_VERIFIED *source, unsigned int indent)
1213 {
1214     TSS_TPM_ST_Print("tag", source->tag, indent);
1215     TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent);
1216     TSS_TPM2B_Print("TPMT_TK_VERIFIED digest", indent, &source->digest.b);
1217     return;
1218 }
1219 
1220 /* Table 95 - Definition of TPMT_TK_AUTH Structure */
1221 
TSS_TPMT_TK_AUTH_Print(TPMT_TK_AUTH * source,unsigned int indent)1222 void TSS_TPMT_TK_AUTH_Print(TPMT_TK_AUTH *source, unsigned int indent)
1223 {
1224     TSS_TPM_ST_Print("tag", source->tag, indent);
1225     TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent);
1226     TSS_TPM2B_Print("TPMT_TK_AUTH digest", indent, &source->digest.b);
1227     return;
1228 }
1229 
1230 /* Table 96 - Definition of TPMT_TK_HASHCHECK Structure */
1231 
TSS_TPMT_TK_HASHCHECK_Print(TPMT_TK_HASHCHECK * source,unsigned int indent)1232 void TSS_TPMT_TK_HASHCHECK_Print(TPMT_TK_HASHCHECK *source, unsigned int indent)
1233 {
1234     TSS_TPM_ST_Print("tag", source->tag, indent);
1235     TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent);
1236     TSS_TPM2B_Print("TPMT_TK_AUTH digest", indent, &source->digest.b);
1237     return;
1238 }
1239 
1240 /* Table 101 - Definition of TPML_CC Structure */
1241 
TSS_TPML_CC_Print(TPML_CC * source,unsigned int indent)1242 void TSS_TPML_CC_Print(TPML_CC *source, unsigned int indent)
1243 {
1244     uint32_t i;
1245     printf("%*s" "TPML_CC count %u\n", indent, "", source->count);
1246     for (i = 0 ; (i < source->count) ; i++) {
1247 	TSS_TPM_CC_Print("commandCode", source->commandCodes[i], indent);
1248     }
1249     return;
1250 }
1251 
1252 /* Table 102 - Definition of TPML_PCR_SELECTION Structure */
1253 
TSS_TPML_PCR_SELECTION_Print(TPML_PCR_SELECTION * source,unsigned int indent)1254 void TSS_TPML_PCR_SELECTION_Print(TPML_PCR_SELECTION *source, unsigned int indent)
1255 {
1256     uint32_t i;
1257     printf("%*s" "TPML_PCR_SELECTION count %u\n", indent, "", source->count);
1258     for (i = 0 ; (i < source->count) ; i++) {
1259 	TSS_TPMS_PCR_SELECTION_Print(&source->pcrSelections[i], indent);
1260     }
1261     return;
1262 }
1263 
1264 /* Table 103 - Definition of TPML_ALG Structure */
1265 
TSS_TPML_ALG_Print(TPML_ALG * source,unsigned int indent)1266 void TSS_TPML_ALG_Print(TPML_ALG *source, unsigned int indent)
1267 {
1268     uint32_t i;
1269     printf("%*s" "TPML_ALG count %u\n", indent, "", source->count);
1270     for (i = 0 ; (i < source->count) ; i++) {
1271 	TSS_TPM_ALG_ID_Print("algorithms", source->algorithms[i], indent);
1272     }
1273     return;
1274 }
1275 
1276 /* Table 105 - Definition of TPML_DIGEST Structure */
1277 
TSS_TPML_DIGEST_Print(TPML_DIGEST * source,unsigned int indent)1278 void TSS_TPML_DIGEST_Print(TPML_DIGEST *source, unsigned int indent)
1279 {
1280     uint32_t i;
1281     printf("%*s" "TPML_DIGEST count %u\n", indent, "", source->count);
1282     for (i = 0 ; (i < source->count) ; i++) {
1283 	TSS_TPM2B_Print("TPML_DIGEST digest", indent, &source->digests[i].b);
1284     }
1285     return;
1286 }
1287 
1288 /* Table 106 - Definition of TPML_DIGEST_VALUES Structure */
1289 
TSS_TPML_DIGEST_VALUES_Print(TPML_DIGEST_VALUES * source,unsigned int indent)1290 void TSS_TPML_DIGEST_VALUES_Print(TPML_DIGEST_VALUES *source, unsigned int indent)
1291 {
1292     uint32_t i;
1293     printf("%*s" "TPML_DIGEST_VALUES count %u\n", indent, "", source->count);
1294     for (i = 0 ; (i < source->count) ; i++) {
1295 	TSS_TPMT_HA_Print(&source->digests[i], indent);
1296     }
1297     return;
1298 }
1299 
1300 /* Table 115 - Definition of TPMS_CLOCK_INFO Structure */
1301 
TSS_TPMS_CLOCK_INFO_Print(TPMS_CLOCK_INFO * source,unsigned int indent)1302 void TSS_TPMS_CLOCK_INFO_Print(TPMS_CLOCK_INFO *source, unsigned int indent)
1303 {
1304     printf("%*s" "TPMS_CLOCK_INFO clock %"PRIu64"\n", indent, "", source->clock);
1305     printf("%*s" "TPMS_CLOCK_INFO resetCount %u\n", indent, "", source->resetCount);
1306     printf("%*s" "TPMS_CLOCK_INFO restartCount %u\n", indent, "", source->restartCount);
1307     printf("%*s" "TPMS_CLOCK_INFO safe %x\n", indent, "", source->safe);
1308     return;
1309 }
1310 
1311 /* Table 116 - Definition of TPMS_TIME_INFO Structure */
1312 
TSS_TPMS_TIME_INFO_Print(TPMS_TIME_INFO * source,unsigned int indent)1313 void TSS_TPMS_TIME_INFO_Print(TPMS_TIME_INFO *source, unsigned int indent)
1314 {
1315     uint64_t days;
1316     uint64_t hours;
1317     uint64_t minutes;
1318     uint64_t seconds;
1319     printf("%*s" "TPMS_TIME_INFO time %"PRIu64" msec", indent, "", source->time);
1320     days = source->time/(1000 * 60 * 60 * 24);
1321     hours = (source->time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
1322     minutes = (source->time % (1000 * 60 * 60)) / (1000 * 60);
1323     seconds = (source->time % (1000 * 60)) / (1000);
1324     printf(" - %"PRIu64" days %"PRIu64" hours %"PRIu64" minutes %"PRIu64" seconds\n",
1325 	   days, hours, minutes, seconds);
1326     TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2);
1327     return;
1328 }
1329 
1330 /* Table 117 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */
1331 
TSS_TPMS_TIME_ATTEST_INFO_Print(TPMS_TIME_ATTEST_INFO * source,unsigned int indent)1332 void TSS_TPMS_TIME_ATTEST_INFO_Print(TPMS_TIME_ATTEST_INFO *source, unsigned int indent)
1333 {
1334     TSS_TPMS_TIME_INFO_Print(&source->time, indent+2);
1335     printf("%*s" "TPMS_TIME_ATTEST_INFO firmwareVersion %"PRIu64"\n", indent, "", source->firmwareVersion);
1336     return;
1337 }
1338 
1339 /* Table 118 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */
1340 
TSS_TPMS_CERTIFY_INFO_Print(TPMS_CERTIFY_INFO * source,unsigned int indent)1341 void TSS_TPMS_CERTIFY_INFO_Print(TPMS_CERTIFY_INFO *source, unsigned int indent)
1342 {
1343     TSS_TPM2B_Print("TPMS_CERTIFY_INFO name", indent, &source->name.b);
1344     TSS_TPM2B_Print("TPMS_CERTIFY_INFO qualifiedName", indent, &source->qualifiedName.b);
1345     return;
1346 }
1347 
1348 /* Table 119 - Definition of TPMS_QUOTE_INFO Structure <OUT> */
1349 
TSS_TPMS_QUOTE_INFO_Print(TPMS_QUOTE_INFO * source,unsigned int indent)1350 void TSS_TPMS_QUOTE_INFO_Print(TPMS_QUOTE_INFO *source, unsigned int indent)
1351 {
1352     TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2);
1353     TSS_TPM2B_Print("TPMS_QUOTE_INFO pcrDigest", indent+2, &source->pcrDigest.b);
1354     return;
1355 }
1356 
1357 /* Table 120 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */
1358 
TSS_TPMS_COMMAND_AUDIT_INFO_Print(TPMS_COMMAND_AUDIT_INFO * source,unsigned int indent)1359 void TSS_TPMS_COMMAND_AUDIT_INFO_Print(TPMS_COMMAND_AUDIT_INFO *source, unsigned int indent)
1360 {
1361     printf("%*s" "TPMS_COMMAND_AUDIT_INFO auditCounter %"PRIu64"\n", indent, "", source->auditCounter);
1362     TSS_TPM_ALG_ID_Print("digestAlg", source->digestAlg, indent);
1363     TSS_TPM2B_Print("TPMS_COMMAND_AUDIT_INFO auditDigest", indent, &source->auditDigest.b);
1364     TSS_TPM2B_Print("TPMS_COMMAND_AUDIT_INFO commandDigest", indent, &source->commandDigest.b);
1365     return;
1366 }
1367 
1368 /* Table 121 - Definition of TPMS_SESSION_AUDIT_INFO Structure */
1369 
TSS_TPMS_SESSION_AUDIT_INFO_Print(TPMS_SESSION_AUDIT_INFO * source,unsigned int indent)1370 void TSS_TPMS_SESSION_AUDIT_INFO_Print(TPMS_SESSION_AUDIT_INFO *source, unsigned int indent)
1371 {
1372     printf("%*s" "TPMS_SESSION_AUDIT_INFO exclusiveSession %d\n", indent, "",
1373 	   source->exclusiveSession);
1374     TSS_TPM2B_Print("TPMS_SESSION_AUDIT_INFO sessionDigest", indent, &source->sessionDigest.b);
1375    return;
1376 }
1377 
1378 /* Table 122 - Definition of TPMS_CREATION_INFO Structure <OUT> */
1379 
TSS_TPMS_CREATION_INFO_Print(TPMS_CREATION_INFO * source,unsigned int indent)1380 void TSS_TPMS_CREATION_INFO_Print(TPMS_CREATION_INFO *source, unsigned int indent)
1381 {
1382     TSS_TPM2B_Print("TPMS_CREATION_INFO objectName", indent, &source->objectName.b);
1383     TSS_TPM2B_Print("TPMS_CREATION_INFO creationHash", indent, &source->creationHash.b);
1384     return;
1385 }
1386 
1387 /* Table 123 - Definition of TPMS_NV_CERTIFY_INFO Structure */
1388 
TSS_TPMS_NV_CERTIFY_INFO_Print(TPMS_NV_CERTIFY_INFO * source,unsigned int indent)1389 void TSS_TPMS_NV_CERTIFY_INFO_Print(TPMS_NV_CERTIFY_INFO *source, unsigned int indent)
1390 {
1391     TSS_TPM2B_Print("TPMS_NV_CERTIFY_INFO indexName", indent, &source->indexName.b);
1392     printf("%*s" "TPMS_NV_CERTIFY_INFO offset %d\n", indent, "",  source->offset);
1393     TSS_TPM2B_Print("TPMS_NV_CERTIFY_INFO nvContents", indent, &source->nvContents.b);
1394     return;
1395 }
1396 
1397 /* Table 125 - Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */
TSS_TPMS_NV_DIGEST_CERTIFY_INFO_Print(TPMS_NV_DIGEST_CERTIFY_INFO * source,unsigned int indent)1398 void TSS_TPMS_NV_DIGEST_CERTIFY_INFO_Print(TPMS_NV_DIGEST_CERTIFY_INFO  *source, unsigned int indent)
1399 {
1400     TSS_TPM2B_Print("TPMS_NV_DIGEST_CERTIFY_INFO indexName", indent, &source->indexName.b);
1401     TSS_TPM2B_Print("TPMS_NV_DIGEST_CERTIFY_INFO nvDigest", indent, &source->nvDigest.b);
1402     return;
1403 }
1404 
1405 /* Table 124 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */
1406 
TSS_TPMI_ST_ATTEST_Print(const char * string,TPMI_ST_ATTEST selector,unsigned int indent)1407 void TSS_TPMI_ST_ATTEST_Print(const char *string, TPMI_ST_ATTEST selector, unsigned int indent)
1408 {
1409     printf("%*s", indent, "");
1410     switch (selector) {
1411       case TPM_ST_ATTEST_CERTIFY:
1412 	printf("%s TPM_ST_ATTEST_CERTIFY\n", string);
1413 	break;
1414       case TPM_ST_ATTEST_CREATION:
1415 	printf("%s TPM_ST_ATTEST_CREATION\n", string);
1416 	break;
1417       case TPM_ST_ATTEST_QUOTE:
1418 	printf("%s TPM_ST_ATTEST_QUOTE\n", string);
1419 	break;
1420       case TPM_ST_ATTEST_COMMAND_AUDIT:
1421 	printf("%s TPM_ST_ATTEST_COMMAND_AUDIT\n", string);
1422 	break;
1423       case TPM_ST_ATTEST_SESSION_AUDIT:
1424 	printf("%s TPM_ST_ATTEST_SESSION_AUDIT\n", string);
1425 	break;
1426       case TPM_ST_ATTEST_TIME:
1427 	printf("%s TPM_ST_ATTEST_TIME\n", string);
1428 	break;
1429       case TPM_ST_ATTEST_NV:
1430 	printf("%s TPM_ST_ATTEST_NV\n", string);
1431 	break;
1432       case TPM_ST_ATTEST_NV_DIGEST:
1433 	printf("%s TPM_ST_ATTEST_NV_DIGEST\n", string);
1434 	break;
1435       default:
1436 	printf("%s TPMI_ST_ATTEST_Print: selection %04hx not implemented\n", string, selector);
1437     }
1438     return;
1439 }
1440 
1441 /* Table 125 - Definition of TPMU_ATTEST Union <OUT> */
1442 
TSS_TPMU_ATTEST_Print(TPMU_ATTEST * source,TPMI_ST_ATTEST selector,unsigned int indent)1443 void TSS_TPMU_ATTEST_Print(TPMU_ATTEST *source, TPMI_ST_ATTEST selector, unsigned int indent)
1444 {
1445     switch (selector) {
1446       case TPM_ST_ATTEST_CERTIFY:
1447 	TSS_TPMS_CERTIFY_INFO_Print(&source->certify, indent+2);
1448 	break;
1449       case TPM_ST_ATTEST_CREATION:
1450 	TSS_TPMS_CREATION_INFO_Print(&source->creation, indent+2);
1451 	break;
1452       case TPM_ST_ATTEST_QUOTE:
1453 	TSS_TPMS_QUOTE_INFO_Print(&source->quote, indent+2);
1454 	break;
1455       case TPM_ST_ATTEST_COMMAND_AUDIT:
1456 	TSS_TPMS_COMMAND_AUDIT_INFO_Print(&source->commandAudit, indent+2);
1457 	break;
1458       case TPM_ST_ATTEST_SESSION_AUDIT:
1459 	TSS_TPMS_SESSION_AUDIT_INFO_Print(&source->sessionAudit, indent+2);
1460 	break;
1461       case TPM_ST_ATTEST_TIME:
1462 	TSS_TPMS_TIME_ATTEST_INFO_Print(&source->time, indent+2);
1463 	break;
1464       case TPM_ST_ATTEST_NV:
1465 	TSS_TPMS_NV_CERTIFY_INFO_Print(&source->nv, indent+2);
1466 	break;
1467       case TPM_ST_ATTEST_NV_DIGEST:
1468 	TSS_TPMS_NV_DIGEST_CERTIFY_INFO_Print(&source->nvDigest, indent+2);
1469 	break;
1470       default:
1471 	printf("%*s" "TPMU_ATTEST selection %04hx not implemented\n", indent, "", selector);
1472     }
1473     return;
1474 }
1475 
1476 /* Table 126 - Definition of TPMS_ATTEST Structure <OUT> */
1477 
TSS_TPMS_ATTEST_Print(TPMS_ATTEST * source,unsigned int indent)1478 void TSS_TPMS_ATTEST_Print(TPMS_ATTEST *source, unsigned int indent)
1479 {
1480     printf("%*s" "TPMS_ATTEST magic %08x\n", indent+2, "", source->magic);
1481     TSS_TPMI_ST_ATTEST_Print("type", source->type, indent+2);
1482     TSS_TPM2B_Print("TPMS_ATTEST qualifiedSigner", indent+2, &source->qualifiedSigner.b);
1483     TSS_TPM2B_Print("TPMS_ATTEST extraData", indent+2, &source->extraData.b);
1484     TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2);
1485     printf("%*s" "TPMS_ATTEST firmwareVersion %"PRIu64"\n",  indent+2, "", source->firmwareVersion);
1486     TSS_TPMU_ATTEST_Print(&source->attested, source->type, indent+2);
1487     return;
1488 }
1489 
1490 #if 0	/* Removed because it required a large stack allocation.  The utilities didn't use it, but
1491 	   rather did the unmarshal and print themselves. */
1492 
1493 /* Table 127 - Definition of TPM2B_ATTEST Structure <OUT> */
1494 
1495 void TSS_TPM2B_ATTEST_Print(TPM2B_ATTEST *source, unsigned int indent)
1496 {
1497     TPM_RC			rc = 0;
1498     TPMS_ATTEST 		attests;
1499     uint32_t			size;
1500     uint8_t			*buffer = NULL;
1501 
1502     /* unmarshal the TPMS_ATTEST from the TPM2B_ATTEST */
1503     if (rc == 0) {
1504 	buffer = source->t.attestationData;
1505 	size = source->t.size;
1506 	rc = TSS_TPMS_ATTEST_Unmarshalu(&attests, &buffer, &size);
1507     }
1508     if (rc == 0) {
1509 	TSS_TPMS_ATTEST_Print(&attests, indent+2);
1510     }
1511     else {
1512 	printf("%*s" "TPMS_ATTEST_Unmarshal failed\n", indent, "");
1513     }
1514     return;
1515 }
1516 #endif
1517 
1518 /* Table 128 - Definition of TPMS_AUTH_COMMAND Structure <IN> */
1519 
TSS_TPMS_AUTH_COMMAND_Print(TPMS_AUTH_COMMAND * source,unsigned int indent)1520 void TSS_TPMS_AUTH_COMMAND_Print(TPMS_AUTH_COMMAND *source, unsigned int indent)
1521 {
1522     TSS_TPM_HANDLE_Print("sessionHandle", source->sessionHandle, indent);
1523     TSS_TPM2B_Print("TPMS_AUTH_COMMAND nonce", indent, &source->nonce.b);
1524     TSS_TPMA_SESSION_Print(source->sessionAttributes, indent);
1525     TSS_TPM2B_Print("TPMS_AUTH_COMMAND hmac", indent, &source->hmac.b);
1526     return;
1527 }
1528 
1529 /* Table 129 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */
1530 
TSS_TPMS_AUTH_RESPONSE_Print(TPMS_AUTH_RESPONSE * source,unsigned int indent)1531 void TSS_TPMS_AUTH_RESPONSE_Print(TPMS_AUTH_RESPONSE *source, unsigned int indent)
1532 {
1533     TSS_PrintAlli("TPMS_AUTH_RESPONSE nonce", indent,
1534 		  source->nonce.t.buffer,
1535 		  source->nonce.t.size);
1536     TSS_TPMA_SESSION_Print(source->sessionAttributes, indent);
1537     TSS_TPM2B_Print("TPMS_AUTH_RESPONSE hmac", indent, &source->hmac.b);
1538     return;
1539 }
1540 
1541 /* Table 130 - Definition of  {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS   Type */
1542 
TSS_TPM_KEY_BITS_Print(TPM_KEY_BITS source,unsigned int indent)1543 void TSS_TPM_KEY_BITS_Print(TPM_KEY_BITS source, unsigned int indent)
1544 {
1545     printf("%*s" "TPM_KEY_BITS %u\n", indent, "", source);
1546     return;
1547 }
1548 
1549 /* Table 131 - Definition of TPMU_SYM_KEY_BITS Union */
1550 
TSS_TPMU_SYM_KEY_BITS_Print(TPMU_SYM_KEY_BITS * source,TPMI_ALG_SYM selector,unsigned int indent)1551 void TSS_TPMU_SYM_KEY_BITS_Print(TPMU_SYM_KEY_BITS *source, TPMI_ALG_SYM selector, unsigned int indent)
1552 {
1553     switch (selector) {
1554 #ifdef TPM_ALG_AES
1555       case TPM_ALG_AES:
1556 	TSS_TPM_KEY_BITS_Print(source->aes, indent);
1557 	break;
1558 #endif
1559 #ifdef TPM_ALG_SM4
1560       case TPM_ALG_SM4:
1561 	TSS_TPM_KEY_BITS_Print(source->sm4, indent);
1562 	break;
1563 #endif
1564 #ifdef TPM_ALG_CAMELLIA
1565       case TPM_ALG_CAMELLIA:
1566 	TSS_TPM_KEY_BITS_Print(source->camellia, indent);
1567 	break;
1568 #endif
1569 #ifdef TPM_ALG_XOR
1570       case TPM_ALG_XOR:
1571 	TSS_TPM_ALG_ID_Print("xorr", source->xorr, indent);
1572 	break;
1573 #endif
1574       default:
1575 	printf("%*s" "TPMI_ALG_SYM value %04hx unknown\n", indent, "", selector);
1576     }
1577 
1578     return;
1579 }
1580 
1581 /* Table 134 - Definition of TPMT_SYM_DEF Structure */
1582 
TSS_TPMT_SYM_DEF_Print(TPMT_SYM_DEF * source,unsigned int indent)1583 void TSS_TPMT_SYM_DEF_Print(TPMT_SYM_DEF *source, unsigned int indent)
1584 {
1585     TSS_TPM_ALG_ID_Print("algorithm", source->algorithm, indent);
1586     TSS_TPMU_SYM_KEY_BITS_Print(&source->keyBits, source->algorithm, indent);
1587     TSS_TPM_ALG_ID_Print("mode", source->mode.sym, indent);
1588     return;
1589 }
1590 
1591 /* Table 135 - Definition of TPMT_SYM_DEF_OBJECT Structure */
1592 
TSS_TPMT_SYM_DEF_OBJECT_Print(TPMT_SYM_DEF_OBJECT * source,unsigned int indent)1593 void TSS_TPMT_SYM_DEF_OBJECT_Print(TPMT_SYM_DEF_OBJECT *source, unsigned int indent)
1594 {
1595     TSS_TPM_ALG_ID_Print("algorithm", source->algorithm, indent+2);
1596     if (source->algorithm != TPM_ALG_NULL) {
1597 	printf("%*s" "keyBits: %u\n", indent+2, "", source->keyBits.sym);
1598 	TSS_TPM_ALG_ID_Print("mode", source->mode.sym, indent+2);
1599     }
1600     return;
1601 }
1602 
1603 /* Table 139 - Definition of TPMS_DERIVE Structure */
1604 
TSS_TPMS_DERIVE_Print(TPMS_DERIVE * source,unsigned int indent)1605 void TSS_TPMS_DERIVE_Print(TPMS_DERIVE *source, unsigned int indent)
1606 {
1607     TSS_TPM2B_Print("TPMS_DERIVE label", indent, &source->label.b);
1608     TSS_TPM2B_Print("TPMS_DERIVE context", indent, &source->context.b);
1609     return;
1610 }
1611 
1612 /* Table 143 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */
1613 
TSS_TPMS_SENSITIVE_CREATE_Print(TPMS_SENSITIVE_CREATE * source,unsigned int indent)1614 void TSS_TPMS_SENSITIVE_CREATE_Print(TPMS_SENSITIVE_CREATE *source, unsigned int indent)
1615 {
1616     TSS_TPM2B_Print("userAuth", indent, &source->userAuth.b);
1617     TSS_TPM2B_Print("data", indent, &source->data.b);
1618     return;
1619 }
1620 
1621 /* Table 144 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */
1622 
TSS_TPM2B_SENSITIVE_CREATE_Print(const char * string,TPM2B_SENSITIVE_CREATE * source,unsigned int indent)1623 void TSS_TPM2B_SENSITIVE_CREATE_Print(const char *string, TPM2B_SENSITIVE_CREATE *source, unsigned int indent)
1624 {
1625     printf("%*s" "%s\n", indent, "", string);
1626     TSS_TPMS_SENSITIVE_CREATE_Print(&source->sensitive, indent+2);
1627     return;
1628 }
1629 
1630 /* Table 146 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */
1631 
TSS_TPMS_SCHEME_ECDAA_Print(TPMS_SCHEME_ECDAA * source,unsigned int indent)1632 void TSS_TPMS_SCHEME_ECDAA_Print(TPMS_SCHEME_ECDAA *source, unsigned int indent)
1633 {
1634     TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2);
1635     printf("%*s" "TPMS_SCHEME_ECDAA count %u\n", indent+2, "", source->count);
1636     return;
1637 }
1638 
1639 /* Table 149 - Definition of TPMS_SCHEME_XOR Structure */
1640 
TSS_TPMS_SCHEME_XOR_Print(TPMS_SCHEME_XOR * source,unsigned int indent)1641 void TSS_TPMS_SCHEME_XOR_Print(TPMS_SCHEME_XOR *source, unsigned int indent)
1642 {
1643     TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2);
1644     TSS_TPM_ALG_ID_Print("kdf", source->kdf, indent+2);
1645     return;
1646 }
1647 
1648 /* Table 150 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */
1649 
TSS_TPMU_SCHEME_KEYEDHASH_Print(TPMU_SCHEME_KEYEDHASH * source,TPMI_ALG_KEYEDHASH_SCHEME selector,unsigned int indent)1650 void TSS_TPMU_SCHEME_KEYEDHASH_Print(TPMU_SCHEME_KEYEDHASH *source, TPMI_ALG_KEYEDHASH_SCHEME selector,
1651 				     unsigned int indent)
1652 {
1653     switch (selector) {
1654 #ifdef TPM_ALG_HMAC
1655       case TPM_ALG_HMAC:
1656 	TSS_TPM_ALG_ID_Print("hmac", source->hmac.hashAlg, indent+2);
1657 	break;
1658 #endif
1659 #ifdef TPM_ALG_XOR
1660       case TPM_ALG_XOR:
1661 	TSS_TPMS_SCHEME_XOR_Print(&source->xorr, indent+2);
1662 	break;
1663 #endif
1664       default:
1665 	printf("%*s" "TPMU_SCHEME_KEYEDHASH selection %04hx not implemented\n", indent, "", selector);
1666     }
1667     return;
1668 }
1669 
1670 /* Table 151 - Definition of TPMT_KEYEDHASH_SCHEME Structure */
1671 
TSS_TPMT_KEYEDHASH_SCHEME_Print(TPMT_KEYEDHASH_SCHEME * source,unsigned int indent)1672 void TSS_TPMT_KEYEDHASH_SCHEME_Print(TPMT_KEYEDHASH_SCHEME *source, unsigned int indent)
1673 {
1674     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1675     if (source->scheme != TPM_ALG_NULL) {
1676 	TSS_TPMU_SCHEME_KEYEDHASH_Print(&source->details, source->scheme, indent+2);
1677     }
1678     return;
1679 }
1680 
1681 /* Table 154 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */
1682 
TSS_TPMU_SIG_SCHEME_Print(TPMU_SIG_SCHEME * source,TPMI_ALG_SIG_SCHEME selector,unsigned int indent)1683 void TSS_TPMU_SIG_SCHEME_Print(TPMU_SIG_SCHEME *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent)
1684 {
1685     switch (selector) {
1686 #ifdef TPM_ALG_RSASSA
1687       case TPM_ALG_RSASSA:
1688 	TSS_TPM_ALG_ID_Print("rsassa", source->rsassa.hashAlg, indent+2);
1689 	break;
1690 #endif
1691 #ifdef TPM_ALG_RSAPSS
1692       case TPM_ALG_RSAPSS:
1693 	TSS_TPM_ALG_ID_Print("rsapss", source->rsapss.hashAlg, indent+2);
1694 	break;
1695 #endif
1696 #ifdef TPM_ALG_ECDSA
1697       case TPM_ALG_ECDSA:
1698 	TSS_TPM_ALG_ID_Print("ecdsa", source->ecdsa.hashAlg, indent+2);
1699 	break;
1700 #endif
1701 #ifdef TPM_ALG_ECDAA
1702       case TPM_ALG_ECDAA:
1703 	TSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2);
1704 	break;
1705 #endif
1706 #ifdef TPM_ALG_SM2
1707       case TPM_ALG_SM2:
1708 	TSS_TPM_ALG_ID_Print("sm2", source->sm2.hashAlg, indent+2);
1709 	break;
1710 #endif
1711 #ifdef TPM_ALG_ECSCHNORR
1712       case TPM_ALG_ECSCHNORR:
1713 	TSS_TPM_ALG_ID_Print("ecSchnorr", source->ecSchnorr.hashAlg, indent+2);
1714 	break;
1715 #endif
1716 #ifdef TPM_ALG_HMAC
1717       case TPM_ALG_HMAC:
1718 	TSS_TPM_ALG_ID_Print("hmac", source->hmac.hashAlg, indent+2);
1719 	break;
1720 #endif
1721       default:
1722 	printf("%*s" "TPMU_SIG_SCHEME selection %04hx not implemented\n", indent, "", selector);
1723     }
1724     return;
1725 }
1726 
1727 /* Table " Definition", 155 - Definition of TPMT_SIG_SCHEME Structure */
1728 
TSS_TPMT_SIG_SCHEME_Print(TPMT_SIG_SCHEME * source,unsigned int indent)1729 void TSS_TPMT_SIG_SCHEME_Print(TPMT_SIG_SCHEME *source, unsigned int indent)
1730 {
1731     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1732     if (source->scheme != TPM_ALG_NULL) {
1733 	TSS_TPMU_SIG_SCHEME_Print(&source->details, source->scheme, indent+2);
1734     }
1735     return;
1736 }
1737 
1738 /* Table 160 - Definition of TPMT_KDF_SCHEME Structure */
1739 
TSS_TPMT_KDF_SCHEME_Print(TPMT_KDF_SCHEME * source,unsigned int indent)1740 void TSS_TPMT_KDF_SCHEME_Print(TPMT_KDF_SCHEME *source, unsigned int indent)
1741 {
1742     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1743     if (source->scheme != TPM_ALG_NULL) {
1744 	TSS_TPM_ALG_ID_Print("details", source->details.mgf1.hashAlg, indent+2);
1745     }
1746     return;
1747 }
1748 
1749 /* Table 162 - Definition of TPMU_ASYM_SCHEME Union */
1750 
TSS_TPMU_ASYM_SCHEME_Print(TPMU_ASYM_SCHEME * source,TPMI_ALG_ASYM_SCHEME selector,unsigned int indent)1751 void TSS_TPMU_ASYM_SCHEME_Print(TPMU_ASYM_SCHEME *source, TPMI_ALG_ASYM_SCHEME selector, unsigned int indent)
1752 {
1753     switch (selector) {
1754 #ifdef TPM_ALG_ECDH
1755       case TPM_ALG_ECDH:
1756 	TSS_TPM_ALG_ID_Print("ecdh", source->ecdh.hashAlg, indent+2);
1757 	break;
1758 #endif
1759 #ifdef TPM_ALG_ECMQV
1760       case TPM_ALG_ECMQV:
1761 	TSS_TPM_ALG_ID_Print("ecmqvh", source->ecmqvh.hashAlg, indent+2);
1762 	break;
1763 #endif
1764 #ifdef TPM_ALG_RSASSA
1765       case TPM_ALG_RSASSA:
1766 	TSS_TPM_ALG_ID_Print("rsassa", source->rsassa.hashAlg, indent+2);
1767 	break;
1768 #endif
1769 #ifdef TPM_ALG_RSAPSS
1770       case TPM_ALG_RSAPSS:
1771 	TSS_TPM_ALG_ID_Print("rsapss", source->rsapss.hashAlg, indent+2);
1772 	break;
1773 #endif
1774 #ifdef TPM_ALG_ECDSA
1775       case TPM_ALG_ECDSA:
1776 	TSS_TPM_ALG_ID_Print("ecdsa", source->ecdsa.hashAlg, indent+2);
1777 	break;
1778 #endif
1779 #ifdef TPM_ALG_ECDAA
1780       case TPM_ALG_ECDAA:
1781 	TSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2);
1782 	break;
1783 #endif
1784 #ifdef TPM_ALG_SM2
1785       case TPM_ALG_SM2:
1786 	TSS_TPM_ALG_ID_Print("sm2", source->sm2.hashAlg, indent+2);
1787 	break;
1788 #endif
1789 #ifdef TPM_ALG_ECSCHNORR
1790       case TPM_ALG_ECSCHNORR:
1791 	TSS_TPM_ALG_ID_Print("ecSchnorr", source->ecSchnorr.hashAlg, indent+2);
1792 	break;
1793 #endif
1794 #ifdef TPM_ALG_RSAES
1795       case TPM_ALG_RSAES:
1796 	break;
1797 #endif
1798 #ifdef TPM_ALG_OAEP
1799       case TPM_ALG_OAEP:
1800 	TSS_TPM_ALG_ID_Print("oaep", source->oaep.hashAlg, indent+2);
1801 	break;
1802 #endif
1803       default:
1804 	printf("%*s" "TPMU_ASYM_SCHEME selection %04hx not implemented\n", indent, "", selector);
1805     }
1806     return;
1807 }
1808 
1809 /* Table 163 - Definition of TPMT_ASYM_SCHEME Structure <> */
1810 
TSS_TPMT_ASYM_SCHEME_Print(TPMT_ASYM_SCHEME * source,unsigned int indent)1811 void TSS_TPMT_ASYM_SCHEME_Print(TPMT_ASYM_SCHEME *source, unsigned int indent)
1812 {
1813     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1814     if (source->scheme != TPM_ALG_NULL) {
1815 	TSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2);
1816     }
1817     return;
1818 }
1819 
1820 /* Table 165 - Definition of {RSA} TPMT_RSA_SCHEME Structure */
1821 
TSS_TPMT_RSA_SCHEME_Print(TPMT_RSA_SCHEME * source,unsigned int indent)1822 void TSS_TPMT_RSA_SCHEME_Print(TPMT_RSA_SCHEME *source, unsigned int indent)
1823 {
1824     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent);
1825     if (source->scheme != TPM_ALG_NULL) {
1826 	TSS_TPM_ALG_ID_Print("details", source->details.anySig.hashAlg, indent+2);
1827     }
1828     return;
1829 }
1830 
1831 /* Table 167 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */
1832 
TSS_TPMT_RSA_DECRYPT_Print(TPMT_RSA_DECRYPT * source,unsigned int indent)1833 void TSS_TPMT_RSA_DECRYPT_Print(TPMT_RSA_DECRYPT *source, unsigned int indent)
1834 {
1835     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1836     if (source->scheme != TPM_ALG_NULL) {
1837 	TSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2);
1838     }
1839     return;
1840 }
1841 
1842 /* Table 169 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */
1843 
TSS_TPMI_RSA_KEY_BITS_Print(TPMI_RSA_KEY_BITS source,unsigned int indent)1844 void TSS_TPMI_RSA_KEY_BITS_Print(TPMI_RSA_KEY_BITS source, unsigned int indent)
1845 {
1846     printf("%*s" "TPM_KEY_BITS keyBits: %u\n", indent, "", source);
1847     return;
1848 }
1849 
1850 /* Table 172 - Definition of {ECC} TPMS_ECC_POINT Structure */
1851 
TSS_TPMS_ECC_POINT_Print(TPMS_ECC_POINT * source,unsigned int indent)1852 void TSS_TPMS_ECC_POINT_Print(TPMS_ECC_POINT *source, unsigned int indent)
1853 {
1854     TSS_TPM2B_Print("TPMS_ECC_POINT x", indent+2, &source->x.b);
1855     TSS_TPM2B_Print("TPMS_ECC_POINT y", indent+2, &source->y.b);
1856     return;
1857 }
1858 
1859 /* Table 173 - Definition of {ECC} TPM2B_ECC_POINT Structure */
1860 
TSS_TPM2B_ECC_POINT_Print(const char * string,TPM2B_ECC_POINT * source,unsigned int indent)1861 void TSS_TPM2B_ECC_POINT_Print(const char *string, TPM2B_ECC_POINT *source, unsigned int indent)
1862 {
1863     printf("%*s" "%s\n", indent, "", string);
1864     TSS_TPMS_ECC_POINT_Print(&source->point, indent);
1865     return;
1866 }
1867 
1868 /* Table 175 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */
1869 
TSS_TPMI_ECC_CURVE_Print(const char * string,TPMI_ECC_CURVE source,unsigned int indent)1870 void TSS_TPMI_ECC_CURVE_Print(const char *string, TPMI_ECC_CURVE source, unsigned int indent)
1871 {
1872     printf("%*s", indent, "");
1873     switch (source) {
1874       case TPM_ECC_BN_P256:
1875 	printf("%s TPM_ECC_BN_P256\n", string);
1876 	break;
1877       case TPM_ECC_NIST_P256:
1878 	printf("%s TPM_ECC_NIST_P256\n", string);
1879 	break;
1880       case TPM_ECC_NIST_P384:
1881 	printf("%s TPM_ECC_NIST_P384\n", string);
1882 	break;
1883       default:
1884 	printf("%s TPMI_ECC_CURVE %04hx unknown\n", string, source);
1885     }
1886     return;
1887 }
1888 
1889 /* Table 176 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */
1890 
TSS_TPMT_ECC_SCHEME_Print(TPMT_ECC_SCHEME * source,unsigned int indent)1891 void TSS_TPMT_ECC_SCHEME_Print(TPMT_ECC_SCHEME *source, unsigned int indent)
1892 {
1893     TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2);
1894     if (source->scheme != TPM_ALG_NULL) {
1895 	TSS_TPM_ALG_ID_Print("details", source->details.anySig.hashAlg, indent+2);
1896     }
1897     return;
1898 }
1899 
1900 /* Table 177 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */
1901 
TSS_TPMS_ALGORITHM_DETAIL_ECC_Print(TPMS_ALGORITHM_DETAIL_ECC * source,unsigned int indent)1902 void TSS_TPMS_ALGORITHM_DETAIL_ECC_Print(TPMS_ALGORITHM_DETAIL_ECC *source, unsigned int indent)
1903 {
1904     TSS_TPM_ECC_CURVE_Print("curveID", source->curveID, indent+2);
1905     printf("%*s" "TPMS_ALGORITHM_DETAIL_ECC keySize %u\n", indent+2, "", source->keySize);
1906     TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent+2);
1907     TSS_TPMT_ECC_SCHEME_Print(&source->sign, indent+2);
1908     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC p", indent, &source->p.b);
1909     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC a", indent, &source->a.b);
1910     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC b", indent, &source->b.b);
1911     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC gX", indent, &source->gX.b);
1912     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC gY", indent, &source->gY.b);
1913     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC n", indent, &source->n.b);
1914     TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC h", indent, &source->h.b);
1915     return;
1916 }
1917 
1918 /* Table 178 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */
1919 
TSS_TPMS_SIGNATURE_RSA_Print(TPMS_SIGNATURE_RSA * source,unsigned int indent)1920 void TSS_TPMS_SIGNATURE_RSA_Print(TPMS_SIGNATURE_RSA *source, unsigned int indent)
1921 {
1922     TSS_TPM_ALG_ID_Print("hash", source->hash, indent+2);
1923     TSS_TPM2B_Print("TPMS_SIGNATURE_RSA sig", indent+2, &source->sig.b);
1924     return;
1925 }
1926 
1927 /* Table 179 - Definition of Types for {RSA} Signature */
1928 
TSS_TPMS_SIGNATURE_RSASSA_Print(TPMS_SIGNATURE_RSASSA * source,unsigned int indent)1929 void TSS_TPMS_SIGNATURE_RSASSA_Print(TPMS_SIGNATURE_RSASSA *source, unsigned int indent)
1930 {
1931     TSS_TPMS_SIGNATURE_RSA_Print(source, indent+2);
1932     return;
1933 }
1934 
1935 /* Table 180 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */
1936 
TSS_TPMS_SIGNATURE_ECC_Print(TPMS_SIGNATURE_ECC * source,unsigned int indent)1937 void TSS_TPMS_SIGNATURE_ECC_Print(TPMS_SIGNATURE_ECC *source, unsigned int indent)
1938 {
1939     TSS_TPM_ALG_ID_Print("hash", source->hash, indent);
1940     TSS_TPM2B_Print("TPMS_SIGNATURE_ECC signatureR", indent, &source->signatureR.b);
1941     TSS_TPM2B_Print("TPMS_SIGNATURE_ECC signatureS", indent, &source->signatureS.b);
1942     return;
1943 }
1944 
1945 /* Table 182 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */
1946 
TSS_TPMU_SIGNATURE_Print(TPMU_SIGNATURE * source,TPMI_ALG_SIG_SCHEME selector,unsigned int indent)1947 void TSS_TPMU_SIGNATURE_Print(TPMU_SIGNATURE *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent)
1948 {
1949     switch (selector) {
1950 #ifdef TPM_ALG_RSASSA
1951       case TPM_ALG_RSASSA:
1952 	TSS_TPMS_SIGNATURE_RSA_Print(&source->rsassa, indent+2);
1953 	break;
1954 #endif
1955 #ifdef TPM_ALG_RSAPSS
1956       case TPM_ALG_RSAPSS:
1957 	TSS_TPMS_SIGNATURE_RSA_Print(&source->rsapss, indent+2);
1958 	break;
1959 #endif
1960 #ifdef TPM_ALG_ECDSA
1961       case TPM_ALG_ECDSA:
1962 	TSS_TPMS_SIGNATURE_ECC_Print(&source->ecdsa, indent+2);
1963 	break;
1964 #endif
1965 #ifdef TPM_ALG_ECDAA
1966       case TPM_ALG_ECDAA:
1967 	TSS_TPMS_SIGNATURE_ECC_Print(&source->ecdaa, indent+2);
1968 	break;
1969 #endif
1970 #ifdef TPM_ALG_SM2
1971       case TPM_ALG_SM2:
1972 	TSS_TPMS_SIGNATURE_ECC_Print(&source->sm2, indent+2);
1973 	break;
1974 #endif
1975 #ifdef TPM_ALG_ECSCHNORR
1976       case TPM_ALG_ECSCHNORR:
1977 	TSS_TPMS_SIGNATURE_ECC_Print(&source->ecschnorr, indent+2);
1978 	break;
1979 #endif
1980 #ifdef TPM_ALG_HMAC
1981       case TPM_ALG_HMAC:
1982 	TSS_TPMT_HA_Print(&source->hmac, indent+2);
1983 	break;
1984 #endif
1985      default:
1986 	printf("%*s" "TPMU_SIGNATURE selection %04hx not implemented\n", indent, "", selector);
1987 
1988     }
1989 }
1990 
1991 /* Table 183 - Definition of TPMT_SIGNATURE Structure */
1992 
TSS_TPMT_SIGNATURE_Print(TPMT_SIGNATURE * source,unsigned int indent)1993 void TSS_TPMT_SIGNATURE_Print(TPMT_SIGNATURE *source, unsigned int indent)
1994 {
1995     TSS_TPM_ALG_ID_Print("sigAlg", source->sigAlg, indent+2);
1996     if (source->sigAlg != TPM_ALG_NULL) {
1997 	TSS_TPMU_SIGNATURE_Print(&source->signature, source->sigAlg, indent);
1998     }
1999     return;
2000 }
2001 
2002 /* Table 186 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */
2003 
TSS_TPMI_ALG_PUBLIC_Print(const char * string,TPMI_ALG_PUBLIC source,unsigned int indent)2004 void TSS_TPMI_ALG_PUBLIC_Print(const char *string, TPMI_ALG_PUBLIC source, unsigned int indent)
2005 {
2006     printf("%*s", indent, "");
2007     switch (source) {
2008 #ifdef TPM_ALG_KEYEDHASH
2009       case TPM_ALG_KEYEDHASH:
2010 	printf("%s TPM_ALG_KEYEDHASH\n", string);
2011 	break;
2012 #endif
2013 #ifdef TPM_ALG_RSA
2014       case TPM_ALG_RSA:
2015 	printf("%s TPM_ALG_RSA\n", string);
2016 	break;
2017 #endif
2018 #ifdef TPM_ALG_ECC
2019       case TPM_ALG_ECC:
2020 	printf("%s TPM_ALG_ECC\n", string);
2021 	break;
2022 #endif
2023 #ifdef TPM_ALG_SYMCIPHER
2024       case TPM_ALG_SYMCIPHER:
2025 	printf("%s TPM_ALG_SYMCIPHER\n", string);
2026 	break;
2027 #endif
2028       default:
2029 	printf("%s selection %04hx not implemented\n", string, source);
2030     }
2031     return;
2032 }
2033 
2034 /* Table 187 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */
2035 
TSS_TPMU_PUBLIC_ID_Print(TPMU_PUBLIC_ID * source,TPMI_ALG_PUBLIC selector,unsigned int indent)2036 void TSS_TPMU_PUBLIC_ID_Print(TPMU_PUBLIC_ID *source, TPMI_ALG_PUBLIC selector, unsigned int indent)
2037 {
2038     switch (selector) {
2039 #ifdef TPM_ALG_KEYEDHASH
2040       case TPM_ALG_KEYEDHASH:
2041 	TSS_TPM2B_Print("TPM_ALG_KEYEDHASH keyedHash", indent, &source->keyedHash.b);
2042 	break;
2043 #endif
2044 #ifdef TPM_ALG_SYMCIPHER
2045       case TPM_ALG_SYMCIPHER:
2046 	TSS_TPM2B_Print("TPM_ALG_SYMCIPHER sym", indent, &source->sym.b);
2047 	break;
2048 #endif
2049 #ifdef TPM_ALG_RSA
2050       case TPM_ALG_RSA:
2051 	TSS_TPM2B_Print("TPM_ALG_RSA rsa", indent, &source->rsa.b);
2052 	break;
2053 #endif
2054 #ifdef TPM_ALG_ECC
2055       case TPM_ALG_ECC:
2056 	TSS_TPM2B_Print("TPM_ALG_ECC x", indent, &source->ecc.x.b);
2057 	TSS_TPM2B_Print("TPM_ALG_ECC y", indent, &source->ecc.y.b);
2058 	break;
2059 #endif
2060       default:
2061 	printf("%*s" "TPMU_PUBLIC_ID_Print: selection %04hx not implemented\n", indent, "", selector);
2062     }
2063     return;
2064 }
2065 
2066 /* Table 188 - Definition of TPMS_KEYEDHASH_PARMS Structure */
2067 
TSS_TPMS_KEYEDHASH_PARMS_Print(TPMS_KEYEDHASH_PARMS * source,unsigned int indent)2068 void TSS_TPMS_KEYEDHASH_PARMS_Print(TPMS_KEYEDHASH_PARMS *source, unsigned int indent)
2069 {
2070     TSS_TPMT_KEYEDHASH_SCHEME_Print(&source->scheme, indent);
2071     return;
2072 }
2073 
2074 /* Table 189 - Definition of TPMS_ASYM_PARMS Structure <> */
2075 
TSS_TPMS_ASYM_PARMS_Print(TPMS_ASYM_PARMS * source,unsigned int indent)2076 void TSS_TPMS_ASYM_PARMS_Print(TPMS_ASYM_PARMS *source, unsigned int indent)
2077 {
2078     TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent+2);
2079     TSS_TPMT_ASYM_SCHEME_Print(&source->scheme, indent+2);
2080     return;
2081 }
2082 
2083 /* Table 190 - Definition of {RSA} TPMS_RSA_PARMS Structure */
2084 
TSS_TPMS_RSA_PARMS_Print(TPMS_RSA_PARMS * source,unsigned int indent)2085 void TSS_TPMS_RSA_PARMS_Print(TPMS_RSA_PARMS *source, unsigned int indent)
2086 {
2087     TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent);
2088     TSS_TPMT_RSA_SCHEME_Print(&source->scheme, indent);
2089     TSS_TPMI_RSA_KEY_BITS_Print(source->keyBits, indent);
2090     printf("%*s" "TPMS_RSA_PARMS exponent %08x\n", indent, "", source->exponent);
2091     return;
2092 }
2093 
2094 /* Table 191 - Definition of {ECC} TPMS_ECC_PARMS Structure */
2095 
TSS_TPMS_ECC_PARMS_Print(TPMS_ECC_PARMS * source,unsigned int indent)2096 void TSS_TPMS_ECC_PARMS_Print(TPMS_ECC_PARMS *source, unsigned int indent)
2097 {
2098     TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent);
2099     TSS_TPMT_ECC_SCHEME_Print(&source->scheme, indent);
2100     TSS_TPMI_ECC_CURVE_Print("curveID", source->curveID, indent);
2101     TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent);
2102     return;
2103 }
2104 
2105 /* Table 192 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */
2106 
TSS_TPMU_PUBLIC_PARMS_Print(TPMU_PUBLIC_PARMS * source,uint32_t selector,unsigned int indent)2107 void TSS_TPMU_PUBLIC_PARMS_Print(TPMU_PUBLIC_PARMS *source, uint32_t selector, unsigned int indent)
2108 {
2109     switch (selector) {
2110       case TPM_ALG_KEYEDHASH:
2111 	printf("%*s" "TPMU_PUBLIC_PARMS keyedHashDetail\n", indent, "");
2112 	TSS_TPMS_KEYEDHASH_PARMS_Print(&source->keyedHashDetail, indent);
2113 	break;
2114 #if 0
2115       case TPM_ALG_SYMCIPHER:
2116 	printf("%*s" "TPMU_PUBLIC_PARMS symDetail\n", indent, "");
2117 	TSS_TPMS_SYMCIPHER_PARMS_Print(&source->symDetail, indent);
2118 	break;
2119 #endif
2120 #ifdef TPM_ALG_RSA
2121       case TPM_ALG_RSA:
2122 	printf("%*s" "TPMU_PUBLIC_PARMS rsaDetail\n", indent, "");
2123 	TSS_TPMS_RSA_PARMS_Print(&source->rsaDetail, indent);
2124 	break;
2125 #endif
2126 #ifdef TPM_ALG_ECC
2127       case TPM_ALG_ECC:
2128 	printf("%*s" "TPMU_PUBLIC_PARMS eccDetail\n", indent, "");
2129 	TSS_TPMS_ECC_PARMS_Print(&source->eccDetail, indent);
2130 	break;
2131 #endif
2132       default:
2133 	printf("%*s" "TPMU_PUBLIC_PARMS: selector %04x not implemented\n", indent, "", selector);
2134     }
2135     return;
2136 }
2137 
2138 /* Table 193 - Definition of TPMT_PUBLIC_PARMS Structure */
2139 
TSS_TPMT_PUBLIC_PARMS_Print(TPMT_PUBLIC_PARMS * source,unsigned int indent)2140 void TSS_TPMT_PUBLIC_PARMS_Print(TPMT_PUBLIC_PARMS *source, unsigned int indent)
2141 {
2142     TSS_TPM_ALG_ID_Print("type", source->type, indent);
2143     TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent);
2144     return;
2145 }
2146 /* Table 194 - Definition of TPMT_PUBLIC Structure */
2147 
TSS_TPMT_PUBLIC_Print(TPMT_PUBLIC * source,unsigned int indent)2148 void TSS_TPMT_PUBLIC_Print(TPMT_PUBLIC *source, unsigned int indent)
2149 {
2150     TSS_TPMI_ALG_PUBLIC_Print("type", source->type, indent);
2151     TSS_TPM_ALG_ID_Print("nameAlg", source->nameAlg, indent);
2152     TSS_TPMA_OBJECT_Print("objectAttributes", source->objectAttributes, indent);
2153     TSS_TPM2B_Print("authPolicy", indent, &source->authPolicy.b);
2154     TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent);
2155     TSS_TPMU_PUBLIC_ID_Print(&source->unique, source->type, indent);
2156     return;
2157 }
2158 
2159 /* Table 195 - Definition of TPM2B_PUBLIC Structure */
2160 
TSS_TPM2B_PUBLIC_Print(const char * string,TPM2B_PUBLIC * source,unsigned int indent)2161 void TSS_TPM2B_PUBLIC_Print(const char *string, TPM2B_PUBLIC *source, unsigned int indent)
2162 {
2163     printf("%*s" "%s\n", indent, "", string);
2164     TSS_TPMT_PUBLIC_Print(&source->publicArea, indent+2);
2165     return;
2166 }
2167 
2168 /* Table 198 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */
2169 
TSS_TPMU_SENSITIVE_COMPOSITE_Print(TPMU_SENSITIVE_COMPOSITE * source,uint32_t selector,unsigned int indent)2170 void TSS_TPMU_SENSITIVE_COMPOSITE_Print(TPMU_SENSITIVE_COMPOSITE *source, uint32_t selector, unsigned int indent)
2171 {
2172     switch (selector) {
2173 #ifdef TPM_ALG_RSA
2174       case TPM_ALG_RSA:
2175 	TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE rsa", indent+2, &source->rsa.b);
2176 	break;
2177 #endif
2178 #ifdef TPM_ALG_ECC
2179       case TPM_ALG_ECC:
2180 	TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE ecc", indent+2, &source->ecc.b);
2181 	break;
2182 #endif
2183 #ifdef TPM_ALG_KEYEDHASH
2184       case TPM_ALG_KEYEDHASH:
2185 	TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE bits", indent+2, &source->bits.b);
2186 	break;
2187 #endif
2188 #ifdef TPM_ALG_SYMCIPHER
2189       case TPM_ALG_SYMCIPHER:
2190 	TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE sym", indent+2, &source->sym.b);
2191 	break;
2192 #endif
2193       default:
2194 	printf("%*s" "TPMU_SENSITIVE_COMPOSITE: selection %08x not implemented \n", indent+2, "", selector);
2195     }
2196     return;
2197 }
2198 
2199 /* Table 199 - Definition of TPMT_SENSITIVE Structure */
2200 
TSS_TPMT_SENSITIVE_Print(TPMT_SENSITIVE * source,unsigned int indent)2201 void TSS_TPMT_SENSITIVE_Print(TPMT_SENSITIVE *source, unsigned int indent)
2202 {
2203     TSS_TPM_ALG_ID_Print("sensitiveType", source->sensitiveType, indent+2);
2204     TSS_TPM2B_Print("TPMT_SENSITIVE authValue", indent+2, &source->authValue.b);
2205     TSS_TPM2B_Print("TPMT_SENSITIVE seedValue", indent+2, &source->seedValue.b);
2206     TSS_TPMU_SENSITIVE_COMPOSITE_Print(&source->sensitive, source->sensitiveType, indent+2);
2207     return;
2208 }
2209 
2210 /* Table 200 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */
2211 
TSS_TPM2B_SENSITIVE_Print(TPM2B_SENSITIVE * source,unsigned int indent)2212 void TSS_TPM2B_SENSITIVE_Print(TPM2B_SENSITIVE *source, unsigned int indent)
2213 {
2214     printf("%*s" "TPM2B_SENSITIVE size %u\n", indent+2, "", source->t.size);
2215     if (source->t.size != 0) {
2216 	TSS_TPMT_SENSITIVE_Print(&source->t.sensitiveArea, indent+2);
2217     }
2218     return;
2219 }
2220 
2221 /* Table 207 - Definition of TPMS_NV_PIN_COUNTER_PARAMETERS Structure */
2222 
TSS_TPMS_NV_PIN_COUNTER_PARAMETERS_Print(TPMS_NV_PIN_COUNTER_PARAMETERS * source,unsigned int indent)2223 void TSS_TPMS_NV_PIN_COUNTER_PARAMETERS_Print(TPMS_NV_PIN_COUNTER_PARAMETERS *source, unsigned int indent)
2224 {
2225     printf("%*s" "pinCount %u\n", indent+2, "", source->pinCount);
2226     printf("%*s" "pinLimit %u\n", indent+2, "", source->pinLimit);
2227     return;
2228 }
2229 
2230 /* Table 208 - Definition of (UINT32) TPMA_NV Bits */
2231 
TSS_TPMA_NV_Print(TPMA_NV source,unsigned int indent)2232 void TSS_TPMA_NV_Print(TPMA_NV source, unsigned int indent)
2233 {
2234     uint32_t nvType;
2235 
2236     if (source.val & TPMA_NVA_PPWRITE) printf("%*s" "TPMA_NV_PPWRITE\n", indent, "");
2237     if (source.val & TPMA_NVA_OWNERWRITE) printf("%*s" "TPMA_NV_OWNERWRITE\n", indent, "");
2238     if (source.val & TPMA_NVA_AUTHWRITE) printf("%*s" "TPMA_NV_AUTHWRITE\n", indent, "");
2239     if (source.val & TPMA_NVA_POLICYWRITE) printf("%*s" "TPMA_NV_POLICYWRITE\n", indent, "");
2240 
2241     nvType = (source.val & TPMA_NVA_TPM_NT_MASK) >> 4;
2242     switch (nvType) {
2243       case TPM_NT_ORDINARY:
2244 	printf("%*s" "TPM_NT_ORDINARY\n", indent, "");
2245 	break;
2246       case TPM_NT_COUNTER:
2247 	printf("%*s" "TPM_NT_COUNTER\n", indent, "");
2248 	break;
2249       case TPM_NT_BITS:
2250 	printf("%*s" "TPM_NT_COUNTER\n", indent, "");
2251 	break;
2252       case TPM_NT_EXTEND:
2253 	printf("%*s" "TPM_NT_EXTEND\n", indent, "");
2254 	break;
2255       case TPM_NT_PIN_FAIL:
2256 	printf("%*s" "TPM_NT_PIN_FAIL\n", indent, "");
2257 	break;
2258       case TPM_NT_PIN_PASS:
2259 	printf("%*s" "TPM_NT_PIN_PASS\n", indent, "");
2260 	break;
2261       default:
2262 	printf("%*s" "TPMA_NV type %02x unknown\n", indent, "", nvType);
2263     }
2264 
2265     if (source.val & TPMA_NVA_POLICY_DELETE) printf("%*s" "TPMA_NV_POLICY_DELETE\n", indent, "");
2266     if (source.val & TPMA_NVA_WRITELOCKED) printf("%*s" "TPMA_NV_WRITELOCKED\n", indent, "");
2267     if (source.val & TPMA_NVA_WRITEALL) printf("%*s" "TPMA_NV_WRITEALL\n", indent, "");
2268     if (source.val & TPMA_NVA_WRITEDEFINE) printf("%*s" "TPMA_NV_WRITEDEFINE\n", indent, "");
2269     if (source.val & TPMA_NVA_WRITE_STCLEAR) printf("%*s" "TPMA_NV_WRITE_STCLEAR\n", indent, "");
2270     if (source.val & TPMA_NVA_GLOBALLOCK) printf("%*s" "TPMA_NV_GLOBALLOCK\n", indent, "");
2271     if (source.val & TPMA_NVA_PPREAD) printf("%*s" "TPMA_NV_PPREAD\n", indent, "");
2272     if (source.val & TPMA_NVA_OWNERREAD) printf("%*s" "TPMA_NV_OWNERREAD\n", indent, "");
2273     if (source.val & TPMA_NVA_AUTHREAD) printf("%*s" "TPMA_NV_AUTHREAD\n", indent, "");
2274     if (source.val & TPMA_NVA_POLICYREAD) printf("%*s" "TPMA_NV_POLICYREAD\n", indent, "");
2275     if (source.val & TPMA_NVA_NO_DA) printf("%*s" "TPMA_NV_NO_DA\n", indent, "");
2276     if (source.val & TPMA_NVA_ORDERLY) printf("%*s" "TPMA_NV_ORDERLY\n", indent, "");
2277     if (source.val & TPMA_NVA_CLEAR_STCLEAR) printf("%*s" "TPMA_NV_CLEAR_STCLEAR\n", indent, "");
2278     if (source.val & TPMA_NVA_READLOCKED) printf("%*s" "TPMA_NV_READLOCKED\n", indent, "");
2279     if (source.val & TPMA_NVA_WRITTEN) printf("%*s" "TPMA_NV_WRITTEN\n", indent, "");
2280     if (source.val & TPMA_NVA_PLATFORMCREATE) printf("%*s" "TPMA_NV_PLATFORMCREATE\n", indent, "");
2281     if (source.val & TPMA_NVA_READ_STCLEAR) printf("%*s" "TPMA_NV_READ_STCLEAR\n", indent, "");
2282     return;
2283 }
2284 
2285 /* Table 209 - Definition of TPMS_NV_PUBLIC Structure */
2286 
TSS_TPMS_NV_PUBLIC_Print(TPMS_NV_PUBLIC * source,unsigned int indent)2287 void TSS_TPMS_NV_PUBLIC_Print(TPMS_NV_PUBLIC *source, unsigned int indent)
2288 {
2289     printf("%*s" "TPMS_NV_PUBLIC nvIndex %08x\n", indent+2, "", source->nvIndex);
2290     TSS_TPM_ALG_ID_Print("nameAlg", source->nameAlg, indent+2);
2291     TSS_TPMA_NV_Print(source->attributes, indent+2);
2292     TSS_TPM2B_Print("TPMS_NV_PUBLIC authPolicy", indent+2, &source->authPolicy.b);
2293     printf("%*s" "TPMS_NV_PUBLIC dataSize %u\n", indent+2, "", source->dataSize);
2294     return;
2295 }
2296 
2297 /* Table 210 - Definition of TPM2B_NV_PUBLIC Structure */
2298 
TSS_TPM2B_NV_PUBLIC_Print(TPM2B_NV_PUBLIC * source,unsigned int indent)2299 void TSS_TPM2B_NV_PUBLIC_Print(TPM2B_NV_PUBLIC *source, unsigned int indent)
2300 {
2301     TSS_TPMS_NV_PUBLIC_Print(&source->nvPublic, indent+2);
2302     return;
2303 }
2304 
2305 /* Table 212 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */
2306 
TSS_TPMS_CONTEXT_DATA_Print(TPMS_CONTEXT_DATA * source,unsigned int indent)2307 void TSS_TPMS_CONTEXT_DATA_Print(TPMS_CONTEXT_DATA *source, unsigned int indent)
2308 {
2309     TSS_TPM2B_Print("TPMS_CONTEXT_DATA integrity", indent+2, &source->integrity.b);
2310     TSS_TPM2B_Print("TPMS_CONTEXT_DATA encrypted", indent+2, &source->encrypted.b);
2311     return;
2312 }
2313 
2314 /* Table 214 - Definition of TPMS_CONTEXT Structure */
2315 
TSS_TPMS_CONTEXT_Print(TPMS_CONTEXT * source,unsigned int indent)2316 void TSS_TPMS_CONTEXT_Print(TPMS_CONTEXT *source, unsigned int indent)
2317 {
2318     printf("%*s" "TPMS_CONTEXT sequence %"PRIu64"\n", indent+2, "", source->sequence);
2319     TSS_TPM_HANDLE_Print("savedHandle", source->savedHandle, indent+2);
2320     TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent+2);
2321     TSS_TPM2B_Print("TPMS_CONTEXT contextBlob", indent+2, &source->contextBlob.b);
2322     return;
2323 }
2324 
2325 /* Table 216 - Definition of TPMS_CREATION_DATA Structure <OUT> */
2326 
TSS_TPMS_CREATION_DATA_Print(TPMS_CREATION_DATA * source,unsigned int indent)2327 void TSS_TPMS_CREATION_DATA_Print(TPMS_CREATION_DATA *source, unsigned int indent)
2328 {
2329     TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2);
2330     TSS_TPM2B_Print("TPMS_CREATION_DATA pcrDigest", indent+2, &source->pcrDigest.b);
2331     TSS_TPMA_LOCALITY_Print(source->locality, indent+2);
2332     TSS_TPM_ALG_ID_Print("parentNameAlg", source->parentNameAlg, indent+2);
2333     TSS_TPM2B_Print("TPMS_CREATION_DATA parentName", indent+2, &source->parentName.b);
2334     TSS_TPM2B_Print("TPMS_CREATION_DATA parentQualifiedName", indent+2, &source->parentQualifiedName.b);
2335     TSS_TPM2B_Print("TPMS_CREATION_DATA outsideInfo", indent+2, &source->outsideInfo.b);
2336 return;
2337 }
2338 
2339 /* Table 217 - Definition of TPM2B_CREATION_DATA Structure <OUT> */
2340 
TSS_TPM2B_CREATION_DATA_Print(TPM2B_CREATION_DATA * source,unsigned int indent)2341 void TSS_TPM2B_CREATION_DATA_Print(TPM2B_CREATION_DATA *source, unsigned int indent)
2342 {
2343     printf("%*s" "TPM2B_CREATION_DATA size %u\n", indent+2, "", source->size);
2344     TSS_TPMS_CREATION_DATA_Print(&source->creationData, indent+2);
2345     return;
2346 }
2347 
2348 #endif	/* TPM_TPM20 */
2349 
2350 #endif /* TPM_TSS_NO_PRINT */
2351