Skip to content

Commit

Permalink
Test: Reset PCR16 upon test exit
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Fuchs <[email protected]>
  • Loading branch information
AndreasFuchsTPM committed Jul 31, 2024
1 parent ac930eb commit cc18b1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
8 changes: 8 additions & 0 deletions test/integration/esys-event-sequence-complete.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ test_esys_event_sequence_complete(ESYS_CONTEXT * esys_context)
&results);
goto_if_error(r, "Error: EventSequenceComplete", error);

r = Esys_PCR_Reset(
esys_context,
pcrHandle_handle,
ESYS_TR_PASSWORD,
ESYS_TR_NONE,
ESYS_TR_NONE);
goto_if_error(r, "Error: PCR_Reset", error);

Esys_Free(results);
return EXIT_SUCCESS;

Expand Down
7 changes: 7 additions & 0 deletions test/integration/esys-pcr-basic.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ test_esys_pcr_basic(ESYS_CONTEXT * esys_context)
ESYS_TR_NONE,
&eventData,
&digestsEvent);
goto_if_error(r, "Error: PCR_Reset", error);

r = Esys_PCR_Reset(
esys_context,
pcrHandle_handle,
ESYS_TR_PASSWORD,
ESYS_TR_NONE,
ESYS_TR_NONE);
goto_if_error(r, "Error: PCR_Reset", error);

TPMI_YES_NO allocationSuccess;
Expand Down
7 changes: 4 additions & 3 deletions test/integration/fapi-quote-destructive-eventlog.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,6 @@ test_fapi_quote_destructive(FAPI_CONTEXT *context)
0x00, 0x00,
};

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_PcrExtend(context, 16, data, EVENT_SIZE, "{ \"test\": \"myfile\" }");
goto_if_error(r, "Error Fapi_PcrExtend", error);

Expand Down Expand Up @@ -1118,6 +1115,9 @@ test_fapi_quote_destructive(FAPI_CONTEXT *context)
ASSERT(pathlist != NULL);
ASSERT(strlen(pathlist) > ASSERT_SIZE);

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_Delete(context, "/");
goto_if_error(r, "Error Fapi_Delete", error);

Expand All @@ -1136,6 +1136,7 @@ test_fapi_quote_destructive(FAPI_CONTEXT *context)
return EXIT_SUCCESS;

error:
pcr_reset(context, 16);
Fapi_Delete(context, "/");
SAFE_FREE(pubkey_pem);
SAFE_FREE(signature);
Expand Down
7 changes: 4 additions & 3 deletions test/integration/fapi-quote-with-primary.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ test_fapi_quote(FAPI_CONTEXT *context)
0x00, 0x00,
};

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_PcrExtend(context, 16, data, EVENT_SIZE, "{ \"test\": \"myfile\" }");
goto_if_error(r, "Error Fapi_PcrExtend", error);

Expand Down Expand Up @@ -289,6 +286,9 @@ test_fapi_quote(FAPI_CONTEXT *context)
ASSERT(strlen(pathlist) > ASSERT_SIZE);
LOG_INFO("\nPathlist: %s\n", pathlist);

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_Delete(context, "/");
goto_if_error(r, "Error Fapi_Delete", error);

Expand All @@ -305,6 +305,7 @@ test_fapi_quote(FAPI_CONTEXT *context)
return EXIT_SUCCESS;

error:
pcr_reset(context, 16);
Fapi_Delete(context, "/");
if (jso)
json_object_put(jso);
Expand Down
7 changes: 4 additions & 3 deletions test/integration/fapi-quote.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ test_fapi_quote(FAPI_CONTEXT *context)
0x00, 0x00,
};

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_PcrExtend(context, 16, data, EVENT_SIZE, "{ \"test\": \"myfile\" }");
goto_if_error(r, "Error Fapi_PcrExtend", error);

Expand Down Expand Up @@ -341,6 +338,9 @@ test_fapi_quote(FAPI_CONTEXT *context)
goto error;
}

r = pcr_reset(context, 16);
goto_if_error(r, "Error pcr_reset", error);

r = Fapi_Delete(context, "/");
goto_if_error(r, "Error Fapi_Delete", error);

Expand All @@ -357,6 +357,7 @@ test_fapi_quote(FAPI_CONTEXT *context)
return EXIT_SUCCESS;

error:
pcr_reset(context, 16);
Fapi_Delete(context, "/");
if (jso)
json_object_put(jso);
Expand Down

0 comments on commit cc18b1a

Please sign in to comment.