mirror of
https://github.com/google/go-attestation.git
synced 2025-01-20 03:16:24 +00:00
Parse TCG_PCClientPCREvent structures with an eventSize of 0 (#212)
This commit is contained in:
parent
31ad4f57fd
commit
b6c6a0c365
@ -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 {
|
if err = binary.Read(r, binary.LittleEndian, &h); err != nil {
|
||||||
return event, fmt.Errorf("header deserialization error: %w", err)
|
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()) {
|
if h.EventSize > uint32(r.Len()) {
|
||||||
return event, &eventSizeErr{h.EventSize, r.Len()}
|
return event, &eventSizeErr{h.EventSize, r.Len()}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package attest
|
package attest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
@ -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) {
|
func TestParseShortNoAction(t *testing.T) {
|
||||||
// https://trustedcomputinggroup.org/wp-content/uploads/TCG_PCClientSpecPlat_TPM_2p0_1p04_pub.pdf#page=110
|
// 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
|
// says: "For EV_NO_ACTION events other than the EFI Specification ID event
|
||||||
|
Loading…
Reference in New Issue
Block a user