Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAPI: Add check whether auth values exist for hierarchies. #2824

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tss2-fapi/api/Fapi_Provision.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ Fapi_Provision_Finish(FAPI_CONTEXT *context)
command->auth_state = (*capabilityData)->data.tpmProperties.tpmProperty[0].value;
SAFE_FREE(*capabilityData);

if (command->auth_state & TPMA_PERMANENT_ENDORSEMENTAUTHSET) {
hierarchy_he->misc.hierarchy.with_auth = TPM2_YES;
}
if (command->auth_state & TPMA_PERMANENT_OWNERAUTHSET) {
hierarchy_hs->misc.hierarchy.with_auth = TPM2_YES;
}
if (command->auth_state & TPMA_PERMANENT_LOCKOUTAUTHSET) {
hierarchy_lockout->misc.hierarchy.with_auth = TPM2_YES;
}

/* Check the TPM capabilities for the persistent handle. */
if (command->public_templ.persistent_handle) {
r = Esys_GetCapability_Async(context->esys,
Expand Down
32 changes: 1 addition & 31 deletions src/tss2-fapi/fapi_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,38 +760,8 @@ ifapi_init_primary_finish(FAPI_CONTEXT *context, TSS2_KEY_TYPE ktype, IFAPI_OBJE
if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN)
return TSS2_FAPI_RC_TRY_AGAIN;

/* Retry with authorization callback after trial with null auth */
if (number_rc(r) == TPM2_RC_BAD_AUTH
&& hierarchy->misc.hierarchy.with_auth == TPM2_NO) {
char *description;
r = ifapi_get_description(hierarchy, &description);
return_if_error(r, "Get description");
goto_if_error_reset_state(r, "FAPI Provision", error_cleanup);

r = ifapi_set_auth(context, hierarchy, description);
SAFE_FREE(description);
goto_if_error_reset_state(r, "CreatePrimary", error_cleanup);

r = Esys_CreatePrimary_Async(context->esys, hierarchy->public.handle,
(context->session1 == ESYS_TR_NONE) ?
ESYS_TR_PASSWORD : context->session1,
ESYS_TR_NONE, ESYS_TR_NONE,
&context->cmd.Provision.inSensitive,
&context->cmd.Provision.public_templ.public,
&context->cmd.Provision.outsideInfo,
&context->cmd.Provision.creationPCR);
goto_if_error_reset_state(r, "CreatePrimary", error_cleanup);

if (ktype == TSS2_EK) {
context->state = PROVISION_AUTH_EK_AUTH_SENT;
} else {
context->state = PROVISION_AUTH_SRK_AUTH_SENT;
}
hierarchy->misc.hierarchy.with_auth = TPM2_YES;
return TSS2_FAPI_RC_TRY_AGAIN;

} else {
goto_if_error_reset_state(r, "FAPI Provision", error_cleanup);
}
/* Set EK or SRK handle in context. */
if (ktype == TSS2_EK) {
context->ek_handle = primaryHandle;
Expand Down
Loading