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 "tsplog.h" 17 18 #ifdef TSS_DEBUG 19 20 /* 21 * LogBlobData() 22 * 23 * Log a blob's data to the debugging stream 24 * 25 * szDescriptor - The APPID tag found in the caller's environment at build time 26 * sizeOfBlob - The size of the data to log 27 * blob - the data to log 28 * 29 */ 30 31 32 void 33 LogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob) 34 { 35 char temp[64]; 36 int i; 37 38 if (getenv("TSS_DEBUG_OFF")) 39 return; 40 41 memset(temp, 0, sizeof(temp)); 42 43 for (i = 0; (unsigned long)i < sizeOfBlob; i++) { 44 if ((i > 0) && ((i % 16) == 0)) { 45 fprintf(stdout, "%s\n", temp); 46 memset(temp, 0, sizeof(temp)); 47 } 48 snprintf(&temp[(i%16)*3], 4, "%.2X ", blob[i]); 49 } 50 fprintf(stdout, "%s\n", temp); 51 } 52 53 TSS_RESULT 54 LogTSPERR(TSS_RESULT result, char *file, int line) 55 { 56 if (getenv("TSS_DEBUG_OFF") == NULL) 57 fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result); 58 59 return (result | TSS_LAYER_TSP); 60 } 61 62 #endif 63