198944Sobrien 298944Sobrien/* 398944Sobrien * Licensed Materials - Property of IBM 498944Sobrien * 598944Sobrien * trousers - An open source TCG Software Stack 698944Sobrien * 798944Sobrien * (C) Copyright International Business Machines Corp. 2004, 2005 898944Sobrien * 998944Sobrien */ 1098944Sobrien 1198944Sobrien 1298944Sobrien#include <stdio.h> 1398944Sobrien#include <string.h> 1498944Sobrien 1598944Sobrien#include "trousers/tss.h" 1698944Sobrien#include "spi_utils.h" 1798944Sobrien#include "tsplog.h" 1898944Sobrien 1998944Sobrien#ifdef TSS_DEBUG 2098944Sobrien 2198944Sobrien/* 22130803Smarcel * LogBlobData() 23130803Smarcel * 2498944Sobrien * Log a blob's data to the debugging stream 2598944Sobrien * 2698944Sobrien * szDescriptor - The APPID tag found in the caller's environment at build time 2798944Sobrien * sizeOfBlob - The size of the data to log 2898944Sobrien * blob - the data to log 2998944Sobrien * 3098944Sobrien */ 3198944Sobrien 3298944Sobrien 3398944Sobrienvoid 3498944SobrienLogBlobData(char *szDescriptor, unsigned long sizeOfBlob, unsigned char *blob) 3598944Sobrien{ 3698944Sobrien char temp[64]; 3798944Sobrien int i; 3898944Sobrien 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 54TSS_RESULT 55LogTSPERR(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