Skip to content

Commit

Permalink
Parse TCG_PCClientPCREvent structures with an eventSize of 0 (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonweeks authored Apr 14, 2021
1 parent 31ad4f5 commit b6c6a0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 0 additions & 3 deletions attest/eventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,6 @@ func parseRawEvent(r *bytes.Buffer, specID *specIDEvent) (event rawEvent, err er
if err = binary.Read(r, binary.LittleEndian, &h); err != nil {
return event, fmt.Errorf("header deserialization error: %w", err)
}
if h.EventSize == 0 {
return event, errors.New("event data size is 0")
}
if h.EventSize > uint32(r.Len()) {
return event, &eventSizeErr{h.EventSize, r.Len()}
}
Expand Down
24 changes: 24 additions & 0 deletions attest/eventlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package attest

import (
"bytes"
"encoding/json"
"io/ioutil"
"testing"
Expand Down Expand Up @@ -149,6 +150,29 @@ func TestParseEventLogEventSizeTooLarge(t *testing.T) {
}
}

func TestParseEventLogEventSizeZero(t *testing.T) {
data := []byte{
// PCR index
0x4, 0x0, 0x0, 0x0,

// type
0xd, 0x0, 0x0, 0x0,

// Digest
0x94, 0x2d, 0xb7, 0x4a, 0xa7, 0x37, 0x5b, 0x23, 0xea, 0x23,
0x58, 0xeb, 0x3b, 0x31, 0x59, 0x88, 0x60, 0xf6, 0x90, 0x59,

// Event size (0 B)
0x0, 0x0, 0x0, 0x0,

// no "event data"
}

if _, err := parseRawEvent(bytes.NewBuffer(data), nil); err != nil {
t.Fatalf("parsing event log: %v", err)
}
}

func TestParseShortNoAction(t *testing.T) {
// https://trustedcomputinggroup.org/wp-content/uploads/TCG_PCClientSpecPlat_TPM_2p0_1p04_pub.pdf#page=110
// says: "For EV_NO_ACTION events other than the EFI Specification ID event
Expand Down

0 comments on commit b6c6a0c

Please sign in to comment.