1
2 /*
3 * Licensed Materials - Property of IBM
4 *
5 * trousers - An open source TCG Software Stack
6 *
7 * (C) Copyright International Business Machines Corp. 2004, 2005
8 *
9 */
10
11
12 #include <stdio.h>
13 #include <string.h>
14
15 #include "trousers/tss.h"
16 #include "spi_utils.h"
17 #include "tsplog.h"
18
19 #ifdef TSS_DEBUG
20
21 /*
22 * LogBlobData()
23 *
24 * Log a blob's data to the debugging stream
25 *
26 * szDescriptor - The APPID tag found in the caller's environment at build time
27 * sizeOfBlob - The size of the data to log
28 * blob - the data to log
29 *
30 */
31
32
33 void
LogBlobData(char * szDescriptor,unsigned long sizeOfBlob,unsigned char * blob)34 LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob)
35 {
36 char temp[64];
37 int i;
38
39 if (getenv("TSS_DEBUG_OFF"))
40 return;
41
42 __tspi_memset(temp, 0, sizeof(temp));
43
44 for (i = 0; (unsigned long)i < sizeOfBlob; i++) {
45 if ((i > 0) && ((i % 16) == 0)) {
46 fprintf(stdout, "%s\n", temp);
47 __tspi_memset(temp, 0, sizeof(temp));
48 }
49 snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]);
50 }
51 fprintf(stdout, "%s\n", temp);
52 }
53
54 TSS_RESULT
LogTSPERR(TSS_RESULT result,char * file,int line)55 LogTSPERR(TSS_RESULT result, char *file, int line)
56 {
57 if (getenv("TSS_DEBUG_OFF") == NULL)
58 fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);
59
60 return (result | TSS_LAYER_TSP);
61 }
62
63 #endif
64