mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-11 18:03:57 +00:00
tpm12: Implement TPM_PrintFourLimit to print 4 or less bytes
Implement TPM_PrintFourLimit to print only up to 4 bytes or less. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
ae15c8c76b
commit
accf4437c6
@ -57,17 +57,40 @@ int tpm_swallow_printf_args(const char *format, ...)
|
||||
|
||||
#else
|
||||
|
||||
/* TPM_PrintFour() prints a prefix plus 4 bytes of a buffer */
|
||||
|
||||
void TPM_PrintFour(const char *string, const unsigned char* buff)
|
||||
void TPM_PrintFourLimit(const char *string,
|
||||
const unsigned char *buff, size_t buflen)
|
||||
{
|
||||
if (buff != NULL) {
|
||||
TPMLIB_LogPrintf("%s %02x %02x %02x %02x\n",
|
||||
string,
|
||||
buff[0],
|
||||
buff[1],
|
||||
buff[2],
|
||||
buff[3]);
|
||||
switch (buflen) {
|
||||
case 0:
|
||||
TPMLIB_LogPrintf("%s (no data)\n", string);
|
||||
break;
|
||||
case 1:
|
||||
TPMLIB_LogPrintf("%s %02x\n",
|
||||
string,
|
||||
buff[0]);
|
||||
break;
|
||||
case 2:
|
||||
TPMLIB_LogPrintf("%s %02x %02x\n",
|
||||
string,
|
||||
buff[0],
|
||||
buff[1]);
|
||||
break;
|
||||
case 3:
|
||||
TPMLIB_LogPrintf("%s %02x %02x %02x\n",
|
||||
string,
|
||||
buff[0],
|
||||
buff[1],
|
||||
buff[2]);
|
||||
break;
|
||||
default:
|
||||
TPMLIB_LogPrintf("%s %02x %02x %02x %02x\n",
|
||||
string,
|
||||
buff[0],
|
||||
buff[1],
|
||||
buff[2],
|
||||
buff[3]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
TPMLIB_LogPrintf("%s null\n", string);
|
||||
@ -75,6 +98,13 @@ void TPM_PrintFour(const char *string, const unsigned char* buff)
|
||||
return;
|
||||
}
|
||||
|
||||
/* TPM_PrintFour() prints a prefix plus 4 bytes of a buffer */
|
||||
|
||||
void TPM_PrintFour(const char *string, const unsigned char* buff)
|
||||
{
|
||||
TPM_PrintFourLimit(string, buff, 4);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* TPM_PrintAll() prints 'string', the length, and then the entire byte array
|
||||
|
||||
@ -46,6 +46,8 @@
|
||||
/* prototypes */
|
||||
|
||||
void TPM_PrintFour(const char *string, const unsigned char* buff);
|
||||
void TPM_PrintFourLimit(const char *string,
|
||||
const unsigned char* buff, size_t bufflen);
|
||||
void TPM_PrintAll(const char *string, const unsigned char* buff, uint32_t length);
|
||||
|
||||
#if 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user