Skip to content

Commit 83c517d

Browse files
committed
Made shutdown get called by reset so we preserve og functionality
1 parent a152f6e commit 83c517d

File tree

2 files changed

+16
-52
lines changed

2 files changed

+16
-52
lines changed

src/tpm2_wrap.c

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5673,48 +5673,6 @@ int wolfTPM2_HmacFinish(WOLFTPM2_DEV* dev, WOLFTPM2_HMAC* hmac,
56735673
return rc;
56745674
}
56755675

5676-
/* performs a reset sequence */
5677-
int wolfTPM2_Shutdown(WOLFTPM2_DEV* dev, int doStartup)
5678-
{
5679-
int rc;
5680-
Shutdown_In shutdownIn;
5681-
Startup_In startupIn;
5682-
5683-
if (dev == NULL) {
5684-
return BAD_FUNC_ARG;
5685-
}
5686-
5687-
/* shutdown */
5688-
XMEMSET(&shutdownIn, 0, sizeof(shutdownIn));
5689-
shutdownIn.shutdownType = TPM_SU_CLEAR;
5690-
rc = TPM2_Shutdown(&shutdownIn);
5691-
if (rc != TPM_RC_SUCCESS) {
5692-
#ifdef DEBUG_WOLFTPM
5693-
printf("TPM2_Shutdown failed 0x%x: %s\n", rc, TPM2_GetRCString(rc));
5694-
#endif
5695-
}
5696-
5697-
/* startup */
5698-
if (doStartup) {
5699-
XMEMSET(&startupIn, 0, sizeof(startupIn));
5700-
startupIn.startupType = TPM_SU_CLEAR;
5701-
rc = TPM2_Startup(&startupIn);
5702-
if (rc != TPM_RC_SUCCESS) {
5703-
#ifdef DEBUG_WOLFTPM
5704-
printf("TPM2_Startup failed %d: %s\n",
5705-
rc, wolfTPM2_GetRCString(rc));
5706-
#endif
5707-
return rc;
5708-
}
5709-
}
5710-
5711-
#ifdef DEBUG_WOLFTPM
5712-
printf("wolfTPM2_Shutdown complete\n");
5713-
#endif
5714-
5715-
return rc;
5716-
}
5717-
57185676
/* performs a reset, shutdown, or startup sequence */
57195677
int wolfTPM2_Reset(WOLFTPM2_DEV* dev, int doShutdown, int doStartup)
57205678
{
@@ -5759,6 +5717,12 @@ int wolfTPM2_Reset(WOLFTPM2_DEV* dev, int doShutdown, int doStartup)
57595717
return rc;
57605718
}
57615719

5720+
/* performs a shutdown or reset sequence */
5721+
int wolfTPM2_Shutdown(WOLFTPM2_DEV* dev, int doStartup)
5722+
{
5723+
return wolfTPM2_Reset(dev, 1, doStartup);
5724+
}
5725+
57625726
int wolfTPM2_UnloadHandles(WOLFTPM2_DEV* dev, word32 handleStart,
57635727
word32 handleCount)
57645728
{

wolftpm/tpm2_wrap.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,39 +2540,39 @@ WOLFTPM_API int wolfTPM2_SetCommand(WOLFTPM2_DEV* dev, TPM_CC commandCode,
25402540

25412541
/*!
25422542
\ingroup wolfTPM2_Wrappers
2543-
\brief Helper function to shutdown or reset the TPM
2544-
\note If doStartup is set, then TPM2_Startup is performed right after TPM2_Shutdown
2543+
\brief Helper function to shutdown, startup or reset the TPM
2544+
\note The behavior depends on the doStartup and doShutdown flags:
2545+
\note - Both flags set to 1: Performs a full TPM restart (shutdown then startup)
2546+
\note - Only doStartup=1: Just starts up the TPM
2547+
\note - Only doShutdown=1: Just shuts down the TPM
25452548
25462549
\return TPM_RC_SUCCESS: successful
25472550
\return TPM_RC_FAILURE: generic failure (check TPM IO and TPM return code)
25482551
\return BAD_FUNC_ARG: check the provided arguments
25492552
25502553
\param dev pointer to a TPM2_DEV struct
25512554
\param doStartup integer value, non-zero values represent "perform Startup after Shutdown"
2555+
\param doShutdown integer value, non-zero values represent "perform Shutdown"
25522556
25532557
\sa wolfTPM2_Init
25542558
*/
2555-
WOLFTPM_API int wolfTPM2_Shutdown(WOLFTPM2_DEV* dev, int doStartup);
2559+
WOLFTPM_API int wolfTPM2_Reset(WOLFTPM2_DEV* dev, int doShutdown, int doStartup);
25562560

25572561
/*!
25582562
\ingroup wolfTPM2_Wrappers
2559-
\brief Helper function to shutdown, startup or reset the TPM
2560-
\note The behavior depends on the doStartup and doShutdown flags:
2561-
\note - Both flags set to 1: Performs a full TPM restart (shutdown then startup)
2562-
\note - Only doStartup=1: Just starts up the TPM
2563-
\note - Only doShutdown=1: Just shuts down the TPM
2563+
\brief Helper function to shutdown or reset the TPM
2564+
\note If doStartup is set, then TPM2_Startup is performed right after TPM2_Shutdown
25642565
25652566
\return TPM_RC_SUCCESS: successful
25662567
\return TPM_RC_FAILURE: generic failure (check TPM IO and TPM return code)
25672568
\return BAD_FUNC_ARG: check the provided arguments
25682569
25692570
\param dev pointer to a TPM2_DEV struct
25702571
\param doStartup integer value, non-zero values represent "perform Startup after Shutdown"
2571-
\param doShutdown integer value, non-zero values represent "perform Shutdown"
25722572
25732573
\sa wolfTPM2_Init
25742574
*/
2575-
WOLFTPM_API int wolfTPM2_Reset(WOLFTPM2_DEV* dev, int doShutdown, int doStartup);
2575+
WOLFTPM_API int wolfTPM2_Shutdown(WOLFTPM2_DEV* dev, int doStartup);
25762576

25772577
/*!
25782578
\ingroup wolfTPM2_Wrappers

0 commit comments

Comments
 (0)