Skip to content

Commit

Permalink
Fix bug in PCR comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
NullHypothesis committed Nov 29, 2024
1 parent b3a8994 commit fb3b68d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/enclave/pcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ func (p PCR) String() string {

// Equal returns true if (and only if) the two given PCR maps are identical.
func (ours PCR) Equal(theirs PCR) bool {
// PCR4 contains a hash over the parent's instance ID, which is known at
// runtime. We ignore it for now, until we have a better solution for how
// to handle this.
delete(ours, 4)
delete(theirs, 4)

if len(ours) != len(theirs) {
return false
}

for i, ourValue := range ours {
// PCR4 contains a hash over the parent's instance ID, which is known at
// runtime. We ignore it for now, until we have a better solution on
// how to handle this.
if i == 4 {
continue
}
theirValue, exists := theirs[i]
if !exists {
return false
Expand Down
10 changes: 10 additions & 0 deletions internal/enclave/pcr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ func TestPCRsEqual(t *testing.T) {
},
want: false,
},
{
name: "one PCR missing",
pcr1: PCR{},
pcr2: PCR{
0: []byte("foo"),
1: []byte("bar"),
2: []byte("baz"),
},
want: false,
},
}

for _, c := range cases {
Expand Down

0 comments on commit fb3b68d

Please sign in to comment.