Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion extract/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func EfiState(hash crypto.Hash, events []tcg.Event, registerCfg registerConfig)
exitBootSvcDigest := hasher.Sum(nil)

var efiAppStates []*pb.EfiApp
var efiAppEvents []tcg.Event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we returning these events?

var seenSeparator4 bool
var seenSeparator5 bool
var seenCallingEfiApp bool
Expand Down Expand Up @@ -331,11 +332,25 @@ func EfiState(hash crypto.Hash, events []tcg.Event, registerCfg registerConfig)
seenCallingEfiApp = true
}

if bytes.HasPrefix(event.RawData(), []byte(tcg.SpecificBootOptionPrefix)) {
if evtType != tcg.EFIAction {
return nil, fmt.Errorf("%s%d contains specific boot option event but non EFIAction type: %d",
registerCfg.Name, index, evtType)
}
if !event.DigestVerified() {
return nil, fmt.Errorf("unverified boot option digest for %s%d", registerCfg.Name, index)
}
if !seenCallingEfiApp {
return nil, fmt.Errorf("found boot option event in %s%d before CallingEFIApp event", registerCfg.Name, index)
}
}

if evtType == tcg.EFIBootServicesApplication {
if !seenCallingEfiApp {
return nil, fmt.Errorf("found EFIBootServicesApplication in %s%d before CallingEFIApp event", registerCfg.Name, index)
}
efiAppStates = append(efiAppStates, &pb.EfiApp{Digest: event.ReplayedDigest()})
efiAppEvents = append(efiAppEvents, event)
}

isSeparator, err := checkIfValidSeparator(event, separatorInfo)
Expand Down Expand Up @@ -381,7 +396,10 @@ func EfiState(hash crypto.Hash, events []tcg.Event, registerCfg registerConfig)
// Otherwise, software further down the bootchain could extend bad
// PCR4/RTMR2 measurements.
if seenExitBootServices {
return &pb.EfiState{Apps: efiAppStates}, nil
return &pb.EfiState{
Apps: efiAppStates,
AppEvents: tcg.ConvertToPbEvents(hash, efiAppEvents),
}, nil
}
return nil, nil
}
Expand Down
1 change: 1 addition & 0 deletions proto/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ message EfiState {
// UEFI applications are typically bootloaders such as shim and GRUB.
// These run and are measured using the UEFI LoadImage() service.
repeated EfiApp apps = 1;
repeated Event app_events = 2;
}

// Enum values come from the TCG Algorithm Registry - v1.27 - Table 3.
Expand Down
150 changes: 81 additions & 69 deletions proto/state/state.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tcg/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,14 @@ func UntrustedParseEventType(et uint32) (EventType, error) {

// Constant events used with type "EV_EFI_ACTION".
// Taken from TCG PC Client Platform Firmware Profile Specification,
// Table 17 EV_EFI_ACTION Strings.
// https://trustedcomputinggroup.org/wp-content/uploads/TCG-PC-Client-Platform-Firmware-Profile-Version-1.06-Revision-52_pub-3.pdf
// Table 30 EV_EFI_ACTION Strings.
const (
// Measured when Boot Manager attempts to execute code from a Boot Option.
CallingEFIApplication string = "Calling EFI Application from Boot Option"
CallingEFIApplication string = "Calling EFI Application from Boot Option"
// The specific Boot Option the Boot Manager passes control to.
// The full format is “Booting to <Boot####> Option”.
SpecificBootOptionPrefix string = "Booting to"
ExitBootServicesInvocation string = "Exit Boot Services Invocation"
)

Expand Down
Loading