Skip to content

Commit b6c6a0c

Browse files
authored
Parse TCG_PCClientPCREvent structures with an eventSize of 0 (#212)
1 parent 31ad4f5 commit b6c6a0c

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

attest/eventlog.go

-3
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,6 @@ func parseRawEvent(r *bytes.Buffer, specID *specIDEvent) (event rawEvent, err er
657657
if err = binary.Read(r, binary.LittleEndian, &h); err != nil {
658658
return event, fmt.Errorf("header deserialization error: %w", err)
659659
}
660-
if h.EventSize == 0 {
661-
return event, errors.New("event data size is 0")
662-
}
663660
if h.EventSize > uint32(r.Len()) {
664661
return event, &eventSizeErr{h.EventSize, r.Len()}
665662
}

attest/eventlog_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package attest
1616

1717
import (
18+
"bytes"
1819
"encoding/json"
1920
"io/ioutil"
2021
"testing"
@@ -149,6 +150,29 @@ func TestParseEventLogEventSizeTooLarge(t *testing.T) {
149150
}
150151
}
151152

153+
func TestParseEventLogEventSizeZero(t *testing.T) {
154+
data := []byte{
155+
// PCR index
156+
0x4, 0x0, 0x0, 0x0,
157+
158+
// type
159+
0xd, 0x0, 0x0, 0x0,
160+
161+
// Digest
162+
0x94, 0x2d, 0xb7, 0x4a, 0xa7, 0x37, 0x5b, 0x23, 0xea, 0x23,
163+
0x58, 0xeb, 0x3b, 0x31, 0x59, 0x88, 0x60, 0xf6, 0x90, 0x59,
164+
165+
// Event size (0 B)
166+
0x0, 0x0, 0x0, 0x0,
167+
168+
// no "event data"
169+
}
170+
171+
if _, err := parseRawEvent(bytes.NewBuffer(data), nil); err != nil {
172+
t.Fatalf("parsing event log: %v", err)
173+
}
174+
}
175+
152176
func TestParseShortNoAction(t *testing.T) {
153177
// https://trustedcomputinggroup.org/wp-content/uploads/TCG_PCClientSpecPlat_TPM_2p0_1p04_pub.pdf#page=110
154178
// says: "For EV_NO_ACTION events other than the EFI Specification ID event

0 commit comments

Comments
 (0)