mirror of https://github.com/wolfSSL/wolfTPM.git
Added TPM2_PrintAuth for debugging purposes
Signed-off-by: Dimitar Tomov <dimi@wolfssl.com>pull/145/head
parent
33861a676a
commit
df0107605e
17
src/tpm2.c
17
src/tpm2.c
|
@ -4609,9 +4609,10 @@ TPM_RC TPM2_NV_DefineSpace(NV_DefineSpace_In* in)
|
|||
TPM2_Packet_AppendU32(&packet, in->authHandle);
|
||||
info.authCnt = TPM2_Packet_AppendAuth(&packet, ctx);
|
||||
|
||||
/* 1st TPM2B parameter, TPM2B_AUTH different from Authorization Area */
|
||||
TPM2_Packet_AppendU16(&packet, in->auth.size);
|
||||
TPM2_Packet_AppendBytes(&packet, in->auth.buffer, in->auth.size);
|
||||
|
||||
/* 2nd TPM2B parameter, TPM2B_PUBLIC */
|
||||
in->publicInfo.size = 4 + 2 + 4 + 2 +
|
||||
in->publicInfo.nvPublic.authPolicy.size + 2;
|
||||
TPM2_Packet_AppendU16(&packet, in->publicInfo.size);
|
||||
|
@ -5686,6 +5687,20 @@ void TPM2_PrintBin(const byte* buffer, word32 length)
|
|||
length -= sz;
|
||||
}
|
||||
}
|
||||
|
||||
void TPM2_PrintAuth(const TPMS_AUTH_COMMAND* authCmd)
|
||||
{
|
||||
if (authCmd == NULL)
|
||||
return;
|
||||
|
||||
printf("authCmd:\n");
|
||||
printf("sessionHandle=0x%7X\n", authCmd->sessionHandle);
|
||||
printf("nonceSize=%u nonceBuffer:\n", authCmd->nonce.size);
|
||||
TPM2_PrintBin(authCmd->nonce.buffer, authCmd->nonce.size);
|
||||
printf("sessionAttributes=0x%2X\n", authCmd->sessionAttributes);
|
||||
printf("hmacSize=%u hmacBuffer:\n", authCmd->hmac.size);
|
||||
TPM2_PrintBin(authCmd->hmac.buffer, authCmd->hmac.size);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -320,6 +320,8 @@ void TPM2_Packet_AppendAuthCmd(TPM2_Packet* packet, TPMS_AUTH_COMMAND* authCmd)
|
|||
if (packet == NULL || authCmd == NULL)
|
||||
return;
|
||||
|
||||
TPM2_PrintAuth(authCmd);
|
||||
|
||||
/* make sure continueSession is set for TPM_RS_PW */
|
||||
if (authCmd->sessionHandle == TPM_RS_PW &&
|
||||
(authCmd->sessionAttributes & TPMA_SESSION_continueSession) == 0) {
|
||||
|
|
|
@ -2819,8 +2819,10 @@ WOLFTPM_API UINT16 TPM2_GetVendorID(void);
|
|||
|
||||
#ifdef DEBUG_WOLFTPM
|
||||
WOLFTPM_API void TPM2_PrintBin(const byte* buffer, word32 length);
|
||||
WOLFTPM_API void TPM2_PrintAuth(const TPMS_AUTH_COMMAND* authCmd);
|
||||
#else
|
||||
#define TPM2_PrintBin(b, l)
|
||||
#define TPM2_PrintAuth(b, l)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue