Skip to content

Commit d463f70

Browse files
committed
Removed options.h not used, added TPM2_GetHierarchyDesc, and fixed indentation error
1 parent f319296 commit d463f70

4 files changed

Lines changed: 43 additions & 64 deletions

File tree

examples/u-boot/options.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/tpm2.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6197,6 +6197,24 @@ TPM_ALG_ID TPM2_GetAlgId(const char* name)
61976197
return TPM_ALG_ERROR;
61986198
}
61996199

6200+
#ifdef DEBUG_WOLFTPM
6201+
const char* TPM2_GetHierarchyDesc(TPMI_RH_HIERARCHY_AUTH authHandle)
6202+
{
6203+
switch (authHandle) {
6204+
case TPM_RH_LOCKOUT:
6205+
return "Lockout";
6206+
case TPM_RH_ENDORSEMENT:
6207+
return "Endorsement";
6208+
case TPM_RH_OWNER:
6209+
return "Owner";
6210+
case TPM_RH_PLATFORM:
6211+
return "Platform";
6212+
default:
6213+
return "Unknown";
6214+
}
6215+
}
6216+
#endif /* DEBUG_WOLFTPM */
6217+
62006218
int TPM2_GetCurveSize(TPM_ECC_CURVE curveID)
62016219
{
62026220
switch (curveID) {

src/tpm2_wrap.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5764,10 +5764,10 @@ int wolfTPM2_ChangeHierarchyAuth(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
57645764
in.authHandle = authHandle;
57655765

57665766
/* use parameter encryption if session supplied */
5767-
if (session != NULL) {
5768-
rc = wolfTPM2_SetAuthSession(dev, 1, session, (TPMA_SESSION_decrypt |
5769-
TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
5770-
}
5767+
if (session != NULL) {
5768+
rc = wolfTPM2_SetAuthSession(dev, 1, session, (TPMA_SESSION_decrypt |
5769+
TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
5770+
}
57715771
if (rc == 0) {
57725772
/* TPM 2.0 PCR's are typically SHA-1 and SHA2-256 */
57735773
in.newAuth.size = TPM2_GetHashDigestSize(WOLFTPM2_WRAP_DIGEST);
@@ -5782,18 +5782,7 @@ int wolfTPM2_ChangeHierarchyAuth(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
57825782
rc = TPM2_HierarchyChangeAuth(&in);
57835783
}
57845784
#ifdef DEBUG_WOLFTPM
5785-
switch (authHandle) {
5786-
case TPM_RH_LOCKOUT:
5787-
desc = "Lockout"; break;
5788-
case TPM_RH_ENDORSEMENT:
5789-
desc = "Endrosement"; break;
5790-
case TPM_RH_OWNER:
5791-
desc = "Owner"; break;
5792-
case TPM_RH_PLATFORM:
5793-
desc = "Platform"; break;
5794-
default:
5795-
break;
5796-
}
5785+
desc = TPM2_GetHierarchyDesc(authHandle);
57975786

57985787
if (rc == 0) {
57995788
printf("%s auth set to %d bytes of random\n", desc, in.newAuth.size);

wolftpm/tpm2.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,26 @@ WOLFTPM_API const char* TPM2_GetAlgName(TPM_ALG_ID alg);
35773577
*/
35783578
WOLFTPM_API TPM_ALG_ID TPM2_GetAlgId(const char* name);
35793579

3580+
#ifdef DEBUG_WOLFTPM
3581+
/*!
3582+
\ingroup TPM2_Proprietary
3583+
\brief Get readable string for TPM 2.0 hierarchy
3584+
3585+
\return pointer to a string constant
3586+
3587+
\param authHandle value of type TPMI_RH_HIERARCHY_AUTH specifying a valid
3588+
TPM 2.0 hierarchy
3589+
3590+
_Example_
3591+
\code
3592+
TPMI_RH_HIERARCHY_AUTH authHandle = TPM_RH_OWNER;
3593+
3594+
printf("\tHierarchy: %s\n", TPM2_GetHierarchyDesc(authHandle));
3595+
\endcode
3596+
*/
3597+
WOLFTPM_API const char* TPM2_GetHierarchyDesc(TPMI_RH_HIERARCHY_AUTH authHandle);
3598+
#endif
3599+
35803600
/*!
35813601
\ingroup TPM2_Proprietary
35823602
\brief Determine the size in bytes of any TPM ECC Curve

0 commit comments

Comments
 (0)