Removed options.h not used, added TPM2_GetHierarchyDesc, and fixed indentation error

pull/398/head
Aidan Garske 2025-04-30 11:22:13 -07:00
parent f31929609f
commit d463f70975
4 changed files with 43 additions and 64 deletions

View File

@ -1,48 +0,0 @@
/* examples/u-boot/options.h
*
* Copyright (C) 2006-2021 wolfSSL Inc.
*
* This file is part of wolfTPM.
*
* wolfTPM is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfTPM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* Example wolfTPM options.h for U-boot compilation */
#ifndef WOLFTPM_OPTIONS_H
#define WOLFTPM_OPTIONS_H
#ifdef __cplusplus
extern "C" {
#endif
#undef __UBOOT__
#define __UBOOT__
#undef SIZEOF_LONG
#define SIZEOF_LONG 8
#undef WOLFTPM2_NO_WOLFCRYPT
#define WOLFTPM2_NO_WOLFCRYPT
#undef WOLFTPM_AUTODETECT
#define WOLFTPM_AUTODETECT
#ifdef __cplusplus
}
#endif
#endif /* WOLFTPM_OPTIONS_H */

View File

@ -6197,6 +6197,24 @@ TPM_ALG_ID TPM2_GetAlgId(const char* name)
return TPM_ALG_ERROR;
}
#ifdef DEBUG_WOLFTPM
const char* TPM2_GetHierarchyDesc(TPMI_RH_HIERARCHY_AUTH authHandle)
{
switch (authHandle) {
case TPM_RH_LOCKOUT:
return "Lockout";
case TPM_RH_ENDORSEMENT:
return "Endorsement";
case TPM_RH_OWNER:
return "Owner";
case TPM_RH_PLATFORM:
return "Platform";
default:
return "Unknown";
}
}
#endif /* DEBUG_WOLFTPM */
int TPM2_GetCurveSize(TPM_ECC_CURVE curveID)
{
switch (curveID) {

View File

@ -5764,10 +5764,10 @@ int wolfTPM2_ChangeHierarchyAuth(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
in.authHandle = authHandle;
/* use parameter encryption if session supplied */
if (session != NULL) {
rc = wolfTPM2_SetAuthSession(dev, 1, session, (TPMA_SESSION_decrypt |
TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
}
if (session != NULL) {
rc = wolfTPM2_SetAuthSession(dev, 1, session, (TPMA_SESSION_decrypt |
TPMA_SESSION_encrypt | TPMA_SESSION_continueSession));
}
if (rc == 0) {
/* TPM 2.0 PCR's are typically SHA-1 and SHA2-256 */
in.newAuth.size = TPM2_GetHashDigestSize(WOLFTPM2_WRAP_DIGEST);
@ -5782,18 +5782,7 @@ int wolfTPM2_ChangeHierarchyAuth(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
rc = TPM2_HierarchyChangeAuth(&in);
}
#ifdef DEBUG_WOLFTPM
switch (authHandle) {
case TPM_RH_LOCKOUT:
desc = "Lockout"; break;
case TPM_RH_ENDORSEMENT:
desc = "Endrosement"; break;
case TPM_RH_OWNER:
desc = "Owner"; break;
case TPM_RH_PLATFORM:
desc = "Platform"; break;
default:
break;
}
desc = TPM2_GetHierarchyDesc(authHandle);
if (rc == 0) {
printf("%s auth set to %d bytes of random\n", desc, in.newAuth.size);

View File

@ -3577,6 +3577,26 @@ WOLFTPM_API const char* TPM2_GetAlgName(TPM_ALG_ID alg);
*/
WOLFTPM_API TPM_ALG_ID TPM2_GetAlgId(const char* name);
#ifdef DEBUG_WOLFTPM
/*!
\ingroup TPM2_Proprietary
\brief Get readable string for TPM 2.0 hierarchy
\return pointer to a string constant
\param authHandle value of type TPMI_RH_HIERARCHY_AUTH specifying a valid
TPM 2.0 hierarchy
_Example_
\code
TPMI_RH_HIERARCHY_AUTH authHandle = TPM_RH_OWNER;
printf("\tHierarchy: %s\n", TPM2_GetHierarchyDesc(authHandle));
\endcode
*/
WOLFTPM_API const char* TPM2_GetHierarchyDesc(TPMI_RH_HIERARCHY_AUTH authHandle);
#endif
/*!
\ingroup TPM2_Proprietary
\brief Determine the size in bytes of any TPM ECC Curve