From cc18b1a4771784e9890f1e36ddd6996b5c9edcd9 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Wed, 31 Jul 2024 15:18:40 +0200 Subject: [PATCH] Test: Reset PCR16 upon test exit Signed-off-by: Andreas Fuchs --- test/integration/esys-event-sequence-complete.int.c | 8 ++++++++ test/integration/esys-pcr-basic.int.c | 7 +++++++ test/integration/fapi-quote-destructive-eventlog.int.c | 7 ++++--- test/integration/fapi-quote-with-primary.int.c | 7 ++++--- test/integration/fapi-quote.int.c | 7 ++++--- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/test/integration/esys-event-sequence-complete.int.c b/test/integration/esys-event-sequence-complete.int.c index 91ee9525c..66e075d4e 100644 --- a/test/integration/esys-event-sequence-complete.int.c +++ b/test/integration/esys-event-sequence-complete.int.c @@ -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; diff --git a/test/integration/esys-pcr-basic.int.c b/test/integration/esys-pcr-basic.int.c index 38fa5ef36..14e9afc6f 100644 --- a/test/integration/esys-pcr-basic.int.c +++ b/test/integration/esys-pcr-basic.int.c @@ -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; diff --git a/test/integration/fapi-quote-destructive-eventlog.int.c b/test/integration/fapi-quote-destructive-eventlog.int.c index 3e5da1085..b6a9ad930 100644 --- a/test/integration/fapi-quote-destructive-eventlog.int.c +++ b/test/integration/fapi-quote-destructive-eventlog.int.c @@ -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); @@ -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); @@ -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); diff --git a/test/integration/fapi-quote-with-primary.int.c b/test/integration/fapi-quote-with-primary.int.c index 468376d31..93529b6f1 100644 --- a/test/integration/fapi-quote-with-primary.int.c +++ b/test/integration/fapi-quote-with-primary.int.c @@ -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); @@ -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); @@ -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); diff --git a/test/integration/fapi-quote.int.c b/test/integration/fapi-quote.int.c index b112c669e..44e7bfefd 100644 --- a/test/integration/fapi-quote.int.c +++ b/test/integration/fapi-quote.int.c @@ -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); @@ -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); @@ -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);