Fixes for command auth flag typo. Fix to make sure extra auth are not provided.

pull/305/head
David Garske 2023-10-12 14:19:42 -07:00
parent f3e1bbbf3d
commit cdcdf389c3
3 changed files with 18 additions and 10 deletions

View File

@ -2427,7 +2427,8 @@ TPM_RC TPM2_EventSequenceComplete(EventSequenceComplete_In* in,
TPM2_Packet packet;
CmdInfo_t info = {0,0,0,0};
info.inHandleCnt = 2;
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_AUTH_USER1);
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_AUTH_USER1 |
CMD_FLAG_AUTH_USER2);
TPM2_Packet_Init(ctx, &packet);
@ -2697,8 +2698,8 @@ TPM_RC TPM2_GetCommandAuditDigest(GetCommandAuditDigest_In* in,
TPM2_Packet packet;
CmdInfo_t info = {0,0,0,0};
info.inHandleCnt = 2;
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_DEC2 |
CMD_FLAG_AUTH_USER1 | CMD_FLAG_AUTH_USER1);
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_DEC2 | CMD_FLAG_AUTH_USER1 |
CMD_FLAG_AUTH_USER2);
TPM2_Packet_Init(ctx, &packet);
@ -4694,7 +4695,7 @@ TPM_RC TPM2_NV_UndefineSpaceSpecial(NV_UndefineSpaceSpecial_In* in)
TPM2_Packet packet;
CmdInfo_t info = {0,0,0,0};
info.inHandleCnt = 2;
info.flags = (CMD_FLAG_AUTH_ADMIN | CMD_FLAG_AUTH_USER1);
info.flags = (CMD_FLAG_AUTH_ADMIN | CMD_FLAG_AUTH_USER2);
TPM2_Packet_Init(ctx, &packet);
@ -5082,7 +5083,8 @@ TPM_RC TPM2_NV_Certify(NV_Certify_In* in, NV_Certify_Out* out)
TPM2_Packet packet;
CmdInfo_t info = {0,0,0,0};
info.inHandleCnt = 3;
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_DEC2 | CMD_FLAG_AUTH_USER1);
info.flags = (CMD_FLAG_ENC2 | CMD_FLAG_DEC2 | CMD_FLAG_AUTH_USER1 |
CMD_FLAG_AUTH_USER2);
TPM2_Packet_Init(ctx, &packet);

View File

@ -290,7 +290,7 @@ void TPM2_Packet_AppendAuthCmd(TPM2_Packet* packet, TPMS_AUTH_COMMAND* authCmd)
* If the info is not provided then returns the populated ctx->session,
* otherwise adjusted based on the command information provided.
*/
int TPM2_GetCmdAuthCount(TPM2_CTX* ctx, CmdInfo_t* info)
int TPM2_GetCmdAuthCount(TPM2_CTX* ctx, const CmdInfo_t* info)
{
int authSessCount = 0, sessionCount;
TPMI_SH_AUTH_SESSION sessionHandle;
@ -330,12 +330,18 @@ int TPM2_GetCmdAuthCount(TPM2_CTX* ctx, CmdInfo_t* info)
(sessionAttributes & TPMA_SESSION_audit))
authSessCount++;
}
#ifdef DEBUG_WOLFTPM
else if (authReq) {
else if (!authReq) {
/* we cannot accept further authentications */
break;
}
else {
/* This will result in a TPM_RC_AUTH_MISSING auth error from the TPM
* Make sure the wolfTPM2_SetAuth* API is called for the index! */
#ifdef DEBUG_WOLFTPM
printf("Warning: Command requires auth at index %d!\n",
sessionCount);
#endif
}
#endif
}
return authSessCount;
}

View File

@ -131,7 +131,7 @@ WOLFTPM_LOCAL TPM_RC TPM2_Packet_Parse(TPM_RC rc, TPM2_Packet* packet);
WOLFTPM_LOCAL int TPM2_Packet_Finalize(TPM2_Packet* packet, TPM_ST tag, TPM_CC cc);
WOLFTPM_LOCAL int TPM2_GetCmdAuthCount(TPM2_CTX* ctx, CmdInfo_t* info);
WOLFTPM_LOCAL int TPM2_GetCmdAuthCount(TPM2_CTX* ctx, const CmdInfo_t* info);
#ifdef __cplusplus
} /* extern "C" */