Skip to content

Commit

Permalink
sessionconfig: print TPM handle
Browse files Browse the repository at this point in the history
Print the TPM handle so folks can pass it to APIs that need TPM handle,
like the kernel keyring.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
  • Loading branch information
William Roberts committed Apr 14, 2021
1 parent a620527 commit 56445e2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/tpm2_sessionconfig.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -44,6 +45,12 @@ static tool_rc process_output(ESYS_CONTEXT *esys_context) {
ctx.bmask);
}

TPM2_HANDLE tpm_handle;
TSS2_RC rv = Esys_TR_GetTpmHandle(esys_context, sessionhandle, &tpm_handle);
if (rv != TSS2_RC_SUCCESS) {
return tool_rc_general_error;
}

/*
* Describe session attributes
*/
Expand All @@ -54,6 +61,8 @@ static tool_rc process_output(ESYS_CONTEXT *esys_context) {
return rc;
}

tpm2_tool_output("Session-Handle: 0x%.8"PRIx32"\n", tpm_handle);

bool is_attr_set = false;
tpm2_tool_output("Session-Attributes: ");
PRINT_SESSION_ATTRIBUTE(TPMA_SESSION_CONTINUESESSION, "continuesession");
Expand Down

0 comments on commit 56445e2

Please sign in to comment.