Skip to content

Commit 9a1d2ad

Browse files
authored
cel.AppendEventPCR extends to all PCR banks (#596)
BREAKING CHANGE: cel.AppendEventPCR and cel.AppendEvent stop taking in []crypto.Hash, instead they will get all available PCR banks from the TPM capability. Make AllocatedPCRs public
1 parent 79b9d62 commit 9a1d2ad

File tree

9 files changed

+87
-47
lines changed

9 files changed

+87
-47
lines changed

cel/canonical_eventlog.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/google/go-configfs-tsm/configfs/configfsi"
1313
"github.com/google/go-eventlog/register"
1414
"github.com/google/go-tdx-guest/rtmr"
15+
"github.com/google/go-tpm-tools/client"
1516
"github.com/google/go-tpm/legacy/tpm2"
1617
"github.com/google/go-tpm/tpmutil"
1718
)
@@ -169,14 +170,29 @@ func (c *CEL) AppendEventRTMR(client configfsi.Client, rtmrIndex int, event Cont
169170
}
170171

171172
// AppendEvent appends a new PCR record to the CEL.
172-
// This function is a wrapper of AppendEventPCR, for backward
173-
// compatibility.
174-
func (c *CEL) AppendEvent(tpm io.ReadWriteCloser, pcr int, hashAlgos []crypto.Hash, event Content) error {
175-
return c.AppendEventPCR(tpm, pcr, hashAlgos, event)
173+
//
174+
// Deprecated: Use AppendEventPCR or AppendEventRTMR directly.
175+
func (c *CEL) AppendEvent(tpm io.ReadWriteCloser, pcr int, event Content) error {
176+
return c.AppendEventPCR(tpm, pcr, event)
176177
}
177178

178-
// AppendEventPCR appends a new PCR record to the CEL.
179-
func (c *CEL) AppendEventPCR(tpm io.ReadWriteCloser, pcr int, hashAlgos []crypto.Hash, event Content) error {
179+
// AppendEventPCR appends a new PCR record to the CEL and extend the digest of
180+
// event to the given PCR in all available banks.
181+
func (c *CEL) AppendEventPCR(tpm io.ReadWriteCloser, pcr int, event Content) error {
182+
pcrSels, err := client.AllocatedPCRs(tpm)
183+
if err != nil {
184+
return err
185+
}
186+
187+
var hashAlgos []crypto.Hash
188+
for _, sel := range pcrSels {
189+
hashAlgo, err := sel.Hash.Hash()
190+
if err != nil {
191+
return err
192+
}
193+
hashAlgos = append(hashAlgos, hashAlgo)
194+
}
195+
180196
digestsMap, err := generateDigestMap(hashAlgos, event)
181197
if err != nil {
182198
return err

cel/canonical_eventlog_test.go

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ func TestCELEncodingDecoding(t *testing.T) {
2828
cel := &CEL{}
2929

3030
cosEvent := CosTlv{ImageDigestType, []byte("sha256:781d8dfdd92118436bd914442c8339e653b83f6bf3c1a7a98efcfb7c4fed7483")}
31-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, cosEvent)
31+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, cosEvent)
3232

3333
cosEvent2 := CosTlv{ImageRefType, []byte("docker.io/bazel/experimental/test:latest")}
34-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent2)
34+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent2)
3535

3636
var buf bytes.Buffer
3737
if err := cel.EncodeCEL(&buf); err != nil {
@@ -92,19 +92,19 @@ func TestCELMeasureAndReplay(t *testing.T) {
9292
rand.Read(someEvent2)
9393
cosEvent2 := CosTlv{ImageDigestType, someEvent2}
9494

95-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, cosEvent)
95+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, cosEvent)
9696
appendRtmrEventOrFatal(t, celRTMR, fakeRTMR, CosRTMR, cosEvent)
9797

98-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, cosEvent2)
98+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, cosEvent2)
9999
appendRtmrEventOrFatal(t, celRTMR, fakeRTMR, CosRTMR, cosEvent)
100100

101-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent2)
101+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent2)
102102
appendRtmrEventOrFatal(t, celRTMR, fakeRTMR, CosRTMR, cosEvent2)
103103

104-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent)
104+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent)
105105
appendRtmrEventOrFatal(t, celRTMR, fakeRTMR, CosRTMR, cosEvent)
106106

107-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent)
107+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent)
108108
appendRtmrEventOrFatal(t, celRTMR, fakeRTMR, CosRTMR, cosEvent)
109109

110110
replay(t, cel, tpm, measuredHashes,
@@ -127,11 +127,11 @@ func TestCELReplayFailTamperedDigest(t *testing.T) {
127127
rand.Read(someEvent2)
128128
cosEvent2 := CosTlv{ImageDigestType, someEvent2}
129129

130-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, cosEvent)
131-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, cosEvent2)
132-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent2)
133-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent)
134-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, cosEvent)
130+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, cosEvent)
131+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, cosEvent2)
132+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent2)
133+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent)
134+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, cosEvent)
135135

136136
modifiedRecord := cel.Records[3]
137137
for hash := range modifiedRecord.Digests {
@@ -162,15 +162,51 @@ func TestCELReplayFailMissingPCRsInBank(t *testing.T) {
162162
someEvent2 := make([]byte, 10)
163163
rand.Read(someEvent2)
164164

165-
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, measuredHashes, CosTlv{ImageRefType, someEvent})
166-
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, measuredHashes, CosTlv{ImageDigestType, someEvent2})
165+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, CosTlv{ImageRefType, someEvent})
166+
appendPcrEventOrFatal(t, cel, tpm, test.ApplicationPCR, CosTlv{ImageDigestType, someEvent2})
167167

168168
replay(t, cel, tpm, measuredHashes,
169169
[]int{test.DebugPCR}, false /*shouldSucceed*/)
170170
replay(t, cel, tpm, measuredHashes,
171171
[]int{test.ApplicationPCR}, false /*shouldSucceed*/)
172172
}
173173

174+
func TestCELMeasureToAllPCRBanks(t *testing.T) {
175+
tpm := test.GetTPM(t)
176+
defer client.CheckedClose(t, tpm)
177+
178+
pcrs, err := client.ReadAllPCRs(tpm)
179+
if err != nil {
180+
t.Fatal(err)
181+
}
182+
for _, bank := range pcrs {
183+
// make sure debug pcr is empty before the append
184+
if !isZeroBytes(bank.Pcrs[uint32(test.DebugPCR)]) {
185+
t.Fatalf("PCR %d in bank %s is not empty before appending event", test.DebugPCR, bank.Hash.String())
186+
}
187+
}
188+
189+
cel := &CEL{}
190+
someEvent := make([]byte, 10)
191+
appendPcrEventOrFatal(t, cel, tpm, test.DebugPCR, CosTlv{ImageRefType, someEvent})
192+
193+
pcrs, err = client.ReadAllPCRs(tpm)
194+
if err != nil {
195+
t.Fatal(err)
196+
}
197+
for _, bank := range pcrs {
198+
// make sure debug pcr is NOT empty after the append
199+
if isZeroBytes(bank.Pcrs[uint32(test.DebugPCR)]) {
200+
t.Fatalf("PCR %d in bank %s is empty after appending event", test.DebugPCR, bank.Hash.String())
201+
}
202+
}
203+
}
204+
205+
func isZeroBytes(bs []byte) bool {
206+
allZeros := make([]byte, len(bs))
207+
return bytes.Equal(allZeros, bs)
208+
}
209+
174210
func replay(t *testing.T, cel *CEL, tpm io.ReadWriteCloser, measuredHashes []crypto.Hash, pcrs []int, shouldSucceed bool) {
175211
for _, hash := range measuredHashes {
176212
tpm2Hash, err := tpm2.HashToAlgorithm(hash)
@@ -217,8 +253,8 @@ func replayRTMR(t *testing.T, cel *CEL, rtmr *fakertmr.RtmrSubsystem, rtmrs []in
217253
}
218254
}
219255

220-
func appendPcrEventOrFatal(t *testing.T, cel *CEL, tpm io.ReadWriteCloser, pcr int, hashAlgos []crypto.Hash, event Content) {
221-
if err := cel.AppendEventPCR(tpm, pcr, hashAlgos, event); err != nil {
256+
func appendPcrEventOrFatal(t *testing.T, cel *CEL, tpm io.ReadWriteCloser, pcr int, event Content) {
257+
if err := cel.AppendEventPCR(tpm, pcr, event); err != nil {
222258
t.Fatalf("failed to append PCR event: %v", err)
223259
}
224260
}

cel/cos_tlv_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestCosEventlog(t *testing.T) {
4242
for _, testEvent := range testEvents {
4343
cosEvent := CosTlv{testEvent.cosNestedEventType, testEvent.eventPayload}
4444

45-
if err := cel.AppendEventPCR(tpm, testEvent.pcr, measuredHashes, cosEvent); err != nil {
45+
if err := cel.AppendEventPCR(tpm, testEvent.pcr, cosEvent); err != nil {
4646
t.Fatal(err)
4747
}
4848
}

client/attest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (k *Key) Attest(opts AttestOpts) (*pb.Attestation, error) {
276276
if len(opts.Nonce) == 0 {
277277
return nil, fmt.Errorf("provided nonce must not be empty")
278278
}
279-
sels, err := allocatedPCRs(k.rw)
279+
sels, err := AllocatedPCRs(k.rw)
280280
if err != nil {
281281
return nil, err
282282
}

client/pcr.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const (
2626
// CertifyHashAlgTpm is the hard-coded algorithm used in certify PCRs.
2727
const CertifyHashAlgTpm = tpm2.AlgSHA256
2828

29-
// allocatedPCRs returns a list of selections corresponding to the TPM's implemented PCRs.
30-
func allocatedPCRs(rw io.ReadWriter) ([]tpm2.PCRSelection, error) {
29+
// AllocatedPCRs returns a list of selections corresponding to the TPM's implemented PCRs.
30+
func AllocatedPCRs(rw io.ReadWriter) ([]tpm2.PCRSelection, error) {
3131
caps, moreData, err := tpm2.GetCapability(rw, tpm2.CapabilityPCRs, math.MaxUint32, 0)
3232
if err != nil {
3333
return nil, fmt.Errorf("listing implemented PCR banks: %w", err)
@@ -80,7 +80,7 @@ func ReadPCRs(rw io.ReadWriter, sel tpm2.PCRSelection) (*pb.PCRs, error) {
8080

8181
// ReadAllPCRs fetches all the PCR values from all implemented PCR banks.
8282
func ReadAllPCRs(rw io.ReadWriter) ([]*pb.PCRs, error) {
83-
sels, err := allocatedPCRs(rw)
83+
sels, err := AllocatedPCRs(rw)
8484
if err != nil {
8585
return nil, err
8686
}

go.work.sum

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9Gz
1717
cloud.google.com/go v0.115.1/go.mod h1:DuujITeaufu3gL68/lOFIirVNJwQeyf5UXyi+Wbgknc=
1818
cloud.google.com/go v0.117.0/go.mod h1:ZbwhVTb1DBGt2Iwb3tNO6SEK4q+cplHZmLWH+DelYYc=
1919
cloud.google.com/go v0.118.3/go.mod h1:Lhs3YLnBlwJ4KA6nuObNMZ/fCbOQBPuWKPoE0Wa/9Vc=
20-
cloud.google.com/go v0.120.0/go.mod h1:/beW32s8/pGRuj4IILWQNd4uuebeT4dkOhKmkfit64Q=
2120
cloud.google.com/go v0.120.1/go.mod h1:56Vs7sf/i2jYM6ZL9NYlC82r04PThNcPS5YgFmb0rp8=
2221
cloud.google.com/go v0.121.1 h1:S3kTQSydxmu1JfLRLpKtxRPA7rSrYPRPEUmL/PavVUw=
2322
cloud.google.com/go v0.121.1/go.mod h1:nRFlrHq39MNVWu+zESP2PosMWA0ryJw8KUBZ2iZpxbw=
@@ -444,7 +443,6 @@ cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7
444443
cloud.google.com/go/iam v1.1.8/go.mod h1:GvE6lyMmfxXauzNq8NbgJbeVQNspG+tcdL/W8QO1+zE=
445444
cloud.google.com/go/iam v1.2.0/go.mod h1:zITGuWgsLZxd8OwAlX+eMFgZDXzBm7icj1PVTYG766Q=
446445
cloud.google.com/go/iam v1.2.2/go.mod h1:0Ys8ccaZHdI1dEUilwzqng/6ps2YB6vRsjIe00/+6JY=
447-
cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE=
448446
cloud.google.com/go/iap v1.7.1/go.mod h1:WapEwPc7ZxGt2jFGB/C/bm+hP0Y6NXzOYGjpPnmMS74=
449447
cloud.google.com/go/iap v1.9.1/go.mod h1:SIAkY7cGMLohLSdBR25BuIxO+I4fXJiL06IBL7cy/5Q=
450448
cloud.google.com/go/iap v1.9.4/go.mod h1:vO4mSq0xNf/Pu6E5paORLASBwEmphXEjgCFg7aeNu1w=
@@ -491,8 +489,6 @@ cloud.google.com/go/logging v1.4.2 h1:Mu2Q75VBDQlW1HlBMjTX4X84UFR73G1TiLlRYc/b7t
491489
cloud.google.com/go/logging v1.4.2/go.mod h1:jco9QZSx8HiVVqLJReq7z7bVdj0P1Jb9PDFs63T+axo=
492490
cloud.google.com/go/logging v1.8.1 h1:26skQWPeYhvIasWKm48+Eq7oUqdcdbwsCVwz5Ys0FvU=
493491
cloud.google.com/go/logging v1.8.1/go.mod h1:TJjR+SimHwuC8MZ9cjByQulAMgni+RkXeI3wwctHJEI=
494-
cloud.google.com/go/logging v1.13.0 h1:7j0HgAp0B94o1YRDqiqm26w4q1rDMH7XNRU34lJXHYc=
495-
cloud.google.com/go/logging v1.13.0/go.mod h1:36CoKh6KA/M0PbhPKMq6/qety2DCAErbhXT62TuXALA=
496492
cloud.google.com/go/longrunning v0.5.0/go.mod h1:0JNuqRShmscVAhIACGtskSAWtqtOoPkwP0YF1oVEchc=
497493
cloud.google.com/go/longrunning v0.5.2 h1:u+oFqfEwwU7F9dIELigxbe0XVnBAo9wqMuQLA50CZ5k=
498494
cloud.google.com/go/longrunning v0.5.2/go.mod h1:nqo6DQbNV2pXhGDbDMoN2bWz68MjZUzqv2YttZiveCs=
@@ -503,8 +499,6 @@ cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodE
503499
cloud.google.com/go/longrunning v0.6.0/go.mod h1:uHzSZqW89h7/pasCWNYdUpwGz3PcVWhrWupreVPYLts=
504500
cloud.google.com/go/longrunning v0.6.2/go.mod h1:k/vIs83RN4bE3YCswdXC5PFfWVILjm3hpEUlSko4PiI=
505501
cloud.google.com/go/longrunning v0.6.6/go.mod h1:hyeGJUrPHcx0u2Uu1UFSoYZLn4lkMrccJig0t4FI7yw=
506-
cloud.google.com/go/longrunning v0.6.7 h1:IGtfDWHhQCgCjwQjV9iiLnUta9LBCo8R9QmAFsS/PrE=
507-
cloud.google.com/go/longrunning v0.6.7/go.mod h1:EAFV3IZAKmM56TyiE6VAP3VoTzhZzySwI/YI1s/nRsY=
508502
cloud.google.com/go/managedidentities v1.6.2/go.mod h1:5c2VG66eCa0WIq6IylRk3TBW83l161zkFvCj28X7jn8=
509503
cloud.google.com/go/managedidentities v1.6.5/go.mod h1:fkFI2PwwyRQbjLxlm5bQ8SjtObFMW3ChBGNqaMcgZjI=
510504
cloud.google.com/go/managedidentities v1.6.7/go.mod h1:UzslJgHnc6luoyx2JV19cTCi2Fni/7UtlcLeSYRzTV8=
@@ -729,6 +723,7 @@ cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2u
729723
cloud.google.com/go/storage v1.41.0/go.mod h1:J1WCa/Z2FcgdEDuPUY8DxT5I+d9mFKsCepp5vR6Sq80=
730724
cloud.google.com/go/storage v1.42.0/go.mod h1:HjMXRFq65pGKFn6hxj6x3HCyR41uSB72Z0SO/Vn6JFQ=
731725
cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0=
726+
cloud.google.com/go/storage v1.50.0/go.mod h1:l7XeiD//vx5lfqE3RavfmU9yvk5Pp0Zhcv482poyafY=
732727
cloud.google.com/go/storage v1.53.0/go.mod h1:7/eO2a/srr9ImZW9k5uufcNahT2+fPb8w5it1i5boaA=
733728
cloud.google.com/go/storagetransfer v1.10.1/go.mod h1:rS7Sy0BtPviWYTTJVWCSV4QrbBitgPeuK4/FKa4IdLs=
734729
cloud.google.com/go/storagetransfer v1.10.4/go.mod h1:vef30rZKu5HSEf/x1tK3WfWrL0XVoUQN/EPDRGPzjZs=
@@ -853,8 +848,10 @@ github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4p
853848
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.2/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0=
854849
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.1/go.mod h1:itPGVDKf9cC/ov4MdvJ2QZ0khw4bfoo9jzwTJlaxy2k=
855850
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0/go.mod h1:yAZHSGnqScoU556rBOVkwLze6WP5N+U11RHuWaGVxwY=
851+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.50.0/go.mod h1:ZV4VOm0/eHR06JLrXWe09068dHpr3TRpY9Uo7T+anuA=
856852
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0/go.mod h1:BnBReJLvVYx2CS/UHOgVz2BXKXD9wsQPxZug20nZhd0=
857853
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.51.0/go.mod h1:SZiPHWGOOk3bl8tkevxkoiwPgsIl6CwrWcbwjfHZpdM=
854+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.50.0/go.mod h1:otE2jQekW/PqXk1Awf5lmfokJx4uwuqcj1ab5SpGeW0=
858855
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0/go.mod h1:otE2jQekW/PqXk1Awf5lmfokJx4uwuqcj1ab5SpGeW0=
859856
github.com/Microsoft/cosesign1go v1.2.0/go.mod h1:1La/HcGw19rRLhPW0S6u55K6LKfti+GQSgGCtrfhVe8=
860857
github.com/Microsoft/didx509go v0.0.3/go.mod h1:wWt+iQsLzn3011+VfESzznLIp/Owhuj7rLF7yLglYbk=
@@ -1525,7 +1522,6 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
15251522
github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
15261523
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
15271524
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1528-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
15291525
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
15301526
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
15311527
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
@@ -1594,7 +1590,6 @@ go.etcd.io/etcd/server/v3 v3.5.13/go.mod h1:K/8nbsGupHqmr5MkgaZpLlH1QdX1pcNQLAkO
15941590
go.etcd.io/gofail v0.1.0/go.mod h1:VZBCXYGZhHAinaBiiqYvuDynvahNsAyLFwB3kEHKz1M=
15951591
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk=
15961592
go.mozilla.org/pkcs7 v0.9.0/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk=
1597-
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
15981593
go.opentelemetry.io/contrib v0.20.0 h1:ubFQUn0VCZ0gPwIoJfBJVpeBlyRMxu8Mm/huKWYd9p0=
15991594
go.opentelemetry.io/contrib/detectors/gcp v1.29.0/go.mod h1:GW2aWZNwR2ZxDLdv8OyC2G8zkRoQBuURgV7RPQgcPoU=
16001595
go.opentelemetry.io/contrib/detectors/gcp v1.35.0/go.mod h1:qGWP8/+ILwMRIUf9uIVLloR1uo5ZYAslM4O6OqUi1DA=
@@ -1652,10 +1647,8 @@ go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+Gf
16521647
go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E=
16531648
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
16541649
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
1655-
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
16561650
go.opentelemetry.io/otel/sdk/metric v1.29.0/go.mod h1:6zZLdCl2fkauYoZIOn/soQIDSWFmNSRcICarHfuhNJQ=
16571651
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
1658-
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
16591652
go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk=
16601653
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
16611654
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=

launcher/agent/agent.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package agent
88
import (
99
"bytes"
1010
"context"
11-
"crypto"
1211
"encoding/base64"
1312
"fmt"
1413
"io"
@@ -37,8 +36,6 @@ import (
3736
"github.com/google/go-tpm-tools/verifier/util"
3837
)
3938

40-
var defaultCELHashAlgo = []crypto.Hash{crypto.SHA256, crypto.SHA1}
41-
4239
const (
4340
audienceSTS = "https://sts.googleapis.com"
4441
)
@@ -295,7 +292,7 @@ func (t *tpmAttestRoot) GetCEL() *cel.CEL {
295292
}
296293

297294
func (t *tpmAttestRoot) Extend(c cel.Content) error {
298-
return t.cosCel.AppendEventPCR(t.tpm, cel.CosEventPCR, defaultCELHashAlgo, c)
295+
return t.cosCel.AppendEventPCR(t.tpm, cel.CosEventPCR, c)
299296
}
300297

301298
func (t *tpmAttestRoot) Attest(nonce []byte) (any, error) {

server/eventlog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ func TestParsingCELEventLog(t *testing.T) {
995995
for _, testEvent := range testCELEvents {
996996
cosEvent := cel.CosTlv{EventType: testEvent.cosNestedEventType, EventContent: testEvent.eventPayload}
997997

998-
if err := coscel.AppendEventPCR(tpm, testEvent.pcr, implementedHashes, cosEvent); err != nil {
998+
if err := coscel.AppendEventPCR(tpm, testEvent.pcr, cosEvent); err != nil {
999999
t.Fatal(err)
10001000
}
10011001
}

server/verify_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import (
3030
"google.golang.org/protobuf/testing/protocmp"
3131
)
3232

33-
var measuredHashes = []crypto.Hash{crypto.SHA1, crypto.SHA256}
34-
3533
func getDigestHash(input string) []byte {
3634
inputDigestHash := sha256.New()
3735
inputDigestHash.Write([]byte(input))
@@ -313,7 +311,7 @@ func TestVerifyAttestationWithCEL(t *testing.T) {
313311
}
314312
for _, testEvent := range testEvents {
315313
cosEvent := cel.CosTlv{EventType: testEvent.cosNestedEventType, EventContent: testEvent.eventPayload}
316-
if err := coscel.AppendEventPCR(rwc, testEvent.pcr, measuredHashes, cosEvent); err != nil {
314+
if err := coscel.AppendEventPCR(rwc, testEvent.pcr, cosEvent); err != nil {
317315
t.Fatal(err)
318316
}
319317
}
@@ -385,11 +383,11 @@ func TestVerifyFailWithTamperedCELContent(t *testing.T) {
385383
cosEvent := cel.CosTlv{EventType: cel.ImageRefType, EventContent: []byte("docker.io/bazel/experimental/test:latest")}
386384
cosEvent2 := cel.CosTlv{EventType: cel.ImageDigestType, EventContent: []byte("sha256:781d8dfdd92118436bd914442c8339e653b83f6bf3c1a7a98efcfb7c4fed7483")}
387385

388-
if err := c.AppendEventPCR(rwc, cel.CosEventPCR, measuredHashes, cosEvent); err != nil {
386+
if err := c.AppendEventPCR(rwc, cel.CosEventPCR, cosEvent); err != nil {
389387
t.Fatalf("failed to append event: %v", err)
390388
}
391389

392-
if err := c.AppendEventPCR(rwc, cel.CosEventPCR, measuredHashes, cosEvent2); err != nil {
390+
if err := c.AppendEventPCR(rwc, cel.CosEventPCR, cosEvent2); err != nil {
393391
t.Fatalf("failed to append event: %v", err)
394392
}
395393

0 commit comments

Comments
 (0)