@@ -78,10 +78,13 @@ func TestCELMeasureAndReplay(t *testing.T) {
7878 if err != nil {
7979 t .Fatal (err )
8080 }
81+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
82+
8183 err = tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
8284 if err != nil {
8385 t .Fatal (err )
8486 }
87+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
8588
8689 cel := & CEL {}
8790 celRTMR := & CEL {}
@@ -120,6 +123,18 @@ func TestCELReplayFailTamperedDigest(t *testing.T) {
120123 tpm := test .GetTPM (t )
121124 defer client .CheckedClose (t , tpm )
122125
126+ err := tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
127+ if err != nil {
128+ t .Fatal (err )
129+ }
130+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
131+
132+ err = tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
133+ if err != nil {
134+ t .Fatal (err )
135+ }
136+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
137+
123138 cel := & CEL {}
124139
125140 cosEvent := CosTlv {ImageRefType , []byte ("docker.io/bazel/experimental/test:latest" )}
@@ -147,6 +162,18 @@ func TestCELReplayEmpty(t *testing.T) {
147162 tpm := test .GetTPM (t )
148163 defer client .CheckedClose (t , tpm )
149164
165+ err := tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
166+ if err != nil {
167+ t .Fatal (err )
168+ }
169+
170+ err = tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
171+ if err != nil {
172+ t .Fatal (err )
173+ }
174+
175+ tpm2 .PCRExtend (tpm , tpmutil .Handle (test .DebugPCR ), tpm2 .AlgSHA256 , []byte ("333" ), "" )
176+
150177 cel := & CEL {}
151178 replay (t , cel , tpm , []crypto.Hash {crypto .SHA1 , crypto .SHA256 },
152179 []int {test .DebugPCR , test .ApplicationPCR }, true /*shouldSucceed*/ )
@@ -156,6 +183,18 @@ func TestCELReplayFailMissingPCRsInBank(t *testing.T) {
156183 tpm := test .GetTPM (t )
157184 defer client .CheckedClose (t , tpm )
158185
186+ err := tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
187+ if err != nil {
188+ t .Fatal (err )
189+ }
190+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
191+
192+ err = tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
193+ if err != nil {
194+ t .Fatal (err )
195+ }
196+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .ApplicationPCR ))
197+
159198 cel := & CEL {}
160199
161200 someEvent := make ([]byte , 10 )
@@ -175,6 +214,12 @@ func TestCELMeasureToAllPCRBanks(t *testing.T) {
175214 tpm := test .GetTPM (t )
176215 defer client .CheckedClose (t , tpm )
177216
217+ err := tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
218+ if err != nil {
219+ t .Fatal (err )
220+ }
221+ defer tpm2 .PCRReset (tpm , tpmutil .Handle (test .DebugPCR ))
222+
178223 pcrs , err := client .ReadAllPCRs (tpm )
179224 if err != nil {
180225 t .Fatal (err )
0 commit comments