|
|
fbce52 |
From e607f78a054acfdbe119499c3608bdb2a44423d9 Mon Sep 17 00:00:00 2001
|
|
|
fbce52 |
From: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
|
|
|
fbce52 |
Date: Thu, 7 May 2020 11:51:17 +0200
|
|
|
fbce52 |
Subject: [PATCH] Fix ESYS_TR hierarchy transition
|
|
|
fbce52 |
|
|
|
fbce52 |
Fix those cases of TPM2_RH_ to ESYS_TR_RH_ translations that were missed in
|
|
|
fbce52 |
780800c0be69a49b9097f8eae653cdb0623d2100
|
|
|
fbce52 |
|
|
|
fbce52 |
Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
|
|
|
fbce52 |
---
|
|
|
fbce52 |
lib/tpm2.c | 20 ++++++++++++++------
|
|
|
fbce52 |
1 file changed, 14 insertions(+), 6 deletions(-)
|
|
|
fbce52 |
|
|
|
fbce52 |
diff --git a/lib/tpm2.c b/lib/tpm2.c
|
|
|
fbce52 |
index e7ff77047bef..909a4422339d 100644
|
|
|
fbce52 |
--- a/lib/tpm2.c
|
|
|
fbce52 |
+++ b/lib/tpm2.c
|
|
|
fbce52 |
@@ -656,6 +656,12 @@ uint32_t fix_esys_hierarchy(TPMI_RH_HIERARCHY hierarchy)
|
|
|
fbce52 |
{
|
|
|
fbce52 |
#if defined(ESYS_3_0)
|
|
|
fbce52 |
switch (hierarchy) {
|
|
|
fbce52 |
+ case ESYS_TR_RH_NULL:
|
|
|
fbce52 |
+ case ESYS_TR_RH_OWNER:
|
|
|
fbce52 |
+ case ESYS_TR_RH_ENDORSEMENT:
|
|
|
fbce52 |
+ case ESYS_TR_RH_PLATFORM:
|
|
|
fbce52 |
+ case ESYS_TR_RH_PLATFORM_NV:
|
|
|
fbce52 |
+ return hierarchy;
|
|
|
fbce52 |
case TPM2_RH_NULL:
|
|
|
fbce52 |
return ESYS_TR_RH_NULL;
|
|
|
fbce52 |
case TPM2_RH_OWNER:
|
|
|
fbce52 |
@@ -664,14 +670,16 @@ uint32_t fix_esys_hierarchy(TPMI_RH_HIERARCHY hierarchy)
|
|
|
fbce52 |
return ESYS_TR_RH_ENDORSEMENT;
|
|
|
fbce52 |
case TPM2_RH_PLATFORM:
|
|
|
fbce52 |
return ESYS_TR_RH_PLATFORM;
|
|
|
fbce52 |
+ case TPM2_RH_PLATFORM_NV:
|
|
|
fbce52 |
+ return ESYS_TR_RH_PLATFORM_NV;
|
|
|
fbce52 |
default:
|
|
|
fbce52 |
- return TSS2_ESYS_RC_BAD_VALUE;
|
|
|
fbce52 |
+ LOG_ERR("An unknown hierarchy handle was passed: 0x%08x", hierarchy);
|
|
|
fbce52 |
+ return 0xffffffff;
|
|
|
fbce52 |
}
|
|
|
fbce52 |
#elif defined(ESYS_2_3)
|
|
|
fbce52 |
return hierarchy;
|
|
|
fbce52 |
#else
|
|
|
fbce52 |
- UNUSED(hierarchy);
|
|
|
fbce52 |
- return TSS2_ESYS_RC_BAD_VALUE;
|
|
|
fbce52 |
+#error "Need to define either ESYS_3_0 or ESYS_2_3"
|
|
|
fbce52 |
#endif
|
|
|
fbce52 |
}
|
|
|
fbce52 |
|
|
|
fbce52 |
@@ -1154,7 +1162,7 @@ tool_rc tpm2_hierarchycontrol(ESYS_CONTEXT *esys_context,
|
|
|
fbce52 |
}
|
|
|
fbce52 |
|
|
|
fbce52 |
TSS2_RC rval = Esys_HierarchyControl(esys_context, auth_hierarchy->tr_handle,
|
|
|
fbce52 |
- shandle, ESYS_TR_NONE, ESYS_TR_NONE, enable, state);
|
|
|
fbce52 |
+ shandle, ESYS_TR_NONE, ESYS_TR_NONE, fix_esys_hierarchy(enable), state);
|
|
|
fbce52 |
if (rval != TPM2_RC_SUCCESS && rval != TPM2_RC_INITIALIZE) {
|
|
|
fbce52 |
LOG_PERR(Esys_HierarchyControl, rval);
|
|
|
fbce52 |
return tool_rc_from_tpm(rval);
|
|
|
fbce52 |
@@ -1251,7 +1259,7 @@ tool_rc tpm2_hmac_sequencecomplete(ESYS_CONTEXT *esys_context,
|
|
|
fbce52 |
|
|
|
fbce52 |
TPM2_RC rval = Esys_SequenceComplete(esys_context, sequence_handle,
|
|
|
fbce52 |
hmac_key_obj_shandle, ESYS_TR_NONE, ESYS_TR_NONE, input_buffer,
|
|
|
fbce52 |
- TPM2_RH_NULL, result, validation);
|
|
|
fbce52 |
+ fix_esys_hierarchy(TPM2_RH_NULL), result, validation);
|
|
|
fbce52 |
if (rval != TSS2_RC_SUCCESS) {
|
|
|
fbce52 |
LOG_PERR(Esys_HMAC, rval);
|
|
|
fbce52 |
return tool_rc_from_tpm(rval);
|
|
|
fbce52 |
@@ -1907,7 +1915,7 @@ tool_rc tpm2_loadexternal(ESYS_CONTEXT *ectx, const TPM2B_SENSITIVE *private,
|
|
|
fbce52 |
|
|
|
fbce52 |
TSS2_RC rval = Esys_LoadExternal(ectx,
|
|
|
fbce52 |
ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE,
|
|
|
fbce52 |
- private, public, hierarchy,
|
|
|
fbce52 |
+ private, public, fix_esys_hierarchy(hierarchy),
|
|
|
fbce52 |
object_handle);
|
|
|
fbce52 |
if (rval != TSS2_RC_SUCCESS) {
|
|
|
fbce52 |
LOG_PERR(Esys_LoadExternal, rval);
|
|
|
fbce52 |
--
|
|
|
fbce52 |
2.27.0
|
|
|
fbce52 |
|