Documentation
¶
Overview ¶
Package extract has tools for extracting boot and runtime information from measurements.
Index ¶
- Variables
- func DigestEquals(e tcg.Event, b []byte) error
- func EfiState(hash crypto.Hash, events []tcg.Event, registerCfg registerConfig) (*pb.EfiState, error)
- func FirmwareLogState(events []tcg.Event, hash crypto.Hash, registerCfg registerConfig, opts Opts) (*pb.FirmwareLogState, error)
- func GrubStateFromRTMRLog(hash crypto.Hash, events []tcg.Event) (*pb.GrubState, error)
- func GrubStateFromTPMLog(hash crypto.Hash, events []tcg.Event) (*pb.GrubState, error)
- func LinuxKernelStateFromGRUB(grub *pb.GrubState) (*pb.LinuxKernelState, error)
- func PlatformState(hash crypto.Hash, events []tcg.Event) (*pb.PlatformState, error)
- func SecureBootState(replayEvents []tcg.Event, registerCfg registerConfig) (*pb.SecureBootState, error)
- type Bootloader
- type DriverLoadSource
- type Opts
- type SecurebootState
Constants ¶
This section is empty.
Variables ¶
var RTMRRegisterConfig = registerConfig{ Name: "RTMR", FirmwareDriverIdx: 2, SecureBootIdx: 1, EFIAppIdx: 2, ExitBootServicesIdx: 2, GRUBCmdIdx: 3, GRUBFileIdx: 3, GRUBExtracter: GrubStateFromRTMRLog, PlatformExtracter: func(_ crypto.Hash, _ []tcg.Event) (*pb.PlatformState, error) { return &pb.PlatformState{Technology: pb.GCEConfidentialTechnology_INTEL_TDX}, nil }, AdditionalSecureBootIdxEvents: map[tcg.EventType]bool{ tcg.CPUMicrocode: true, tcg.PlatformConfigFlags: true, tcg.TableOfDevices: true, tcg.NonhostConfig: true, tcg.EFIVariableDriverConfig: true, tcg.EFIVariableBoot: true, tcg.EFIAction: true, tcg.EFIHandoffTables2: true, tcg.EFIVariableBoot2: true, tcg.EFIPlatformFirmwareBlob2: true, }, }
RTMRRegisterConfig configures the expected indexes and event types for RTMR-based event logs.
var TPMRegisterConfig = registerConfig{ Name: "PCR", FirmwareDriverIdx: 2, SecureBootIdx: 7, EFIAppIdx: 4, ExitBootServicesIdx: 5, GRUBCmdIdx: 8, GRUBFileIdx: 9, GRUBExtracter: GrubStateFromTPMLog, PlatformExtracter: PlatformState, }
TPMRegisterConfig configures the expected indexes and event types for TPM-based event logs.
Functions ¶
func DigestEquals ¶
DigestEquals returns an error if the Event digest does not match the slice.
func EfiState ¶
func EfiState(hash crypto.Hash, events []tcg.Event, registerCfg registerConfig) (*pb.EfiState, error)
EfiState extracts EFI app information from a UEFI TCG2 firmware event log.
func FirmwareLogState ¶
func FirmwareLogState(events []tcg.Event, hash crypto.Hash, registerCfg registerConfig, opts Opts) (*pb.FirmwareLogState, error)
FirmwareLogState extracts event info from a verified TCG PC Client event log into a FirmwareLogState. It returns an error on failing to parse malformed events.
The returned FirmwareLogState may be a partial FirmwareLogState. In the case of a partially filled state, err will be non-nil. Callers can look for individual errors using `errors.Is`.
It is the caller's responsibility to ensure that the passed events have been replayed (e.g., using `tcg.ParseAndReplay`) against a verified measurement register bank.
func GrubStateFromRTMRLog ¶
GrubStateFromRTMRLog extracts GRUB commands from RTMR2.
func GrubStateFromTPMLog ¶
GrubStateFromTPMLog extracts GRUB commands from PCR8 and GRUB files from 9.
func LinuxKernelStateFromGRUB ¶
func LinuxKernelStateFromGRUB(grub *pb.GrubState) (*pb.LinuxKernelState, error)
LinuxKernelStateFromGRUB extracts the kernel command line from GrubState.
func PlatformState ¶
PlatformState extracts platform information from a UEFI TCG2 firmware event log.
func SecureBootState ¶
func SecureBootState(replayEvents []tcg.Event, registerCfg registerConfig) (*pb.SecureBootState, error)
SecureBootState extracts Secure Boot information from a UEFI TCG2 firmware event log.
Types ¶
type Bootloader ¶
type Bootloader int
Bootloader refers to the second-stage bootloader that loads and transfers execution to the OS kernel.
const ( // UnsupportedLoader refers to a second-stage bootloader that is of an // unsupported type. VerifyAttestation will not parse the PC Client Event // Log for bootloader events. UnsupportedLoader Bootloader = iota // GRUB (https://www.gnu.org/software/grub/). GRUB )
type DriverLoadSource ¶
type DriverLoadSource uint8
DriverLoadSource describes the logical origin of a boot services driver.
const ( UnknownSource DriverLoadSource = iota PciMmioSource )
Known sources for loaded drivers.
type Opts ¶
type Opts struct {
Loader Bootloader
}
Opts gives options for extracting information from an event log.
type SecurebootState ¶
type SecurebootState struct {
Enabled bool
// PlatformKeys enumerates keys which can sign a key exchange key.
PlatformKeys []x509.Certificate
// PlatformKeys enumerates key hashes which can sign a key exchange key.
PlatformKeyHashes [][]byte
// ExchangeKeys enumerates keys which can sign a database of permitted or
// forbidden keys.
ExchangeKeys []x509.Certificate
// ExchangeKeyHashes enumerates key hashes which can sign a database or
// permitted or forbidden keys.
ExchangeKeyHashes [][]byte
// PermittedKeys enumerates keys which may sign binaries to run.
PermittedKeys []x509.Certificate
// PermittedHashes enumerates hashes which permit binaries to run.
PermittedHashes [][]byte
// ForbiddenKeys enumerates keys which must not permit a binary to run.
ForbiddenKeys []x509.Certificate
// ForbiddenKeys enumerates hashes which must not permit a binary to run.
ForbiddenHashes [][]byte
// PreSeparatorAuthority describes the use of a secure-boot key to authorize
// the execution of a binary before the separator.
PreSeparatorAuthority []x509.Certificate
// PostSeparatorAuthority describes the use of a secure-boot key to authorize
// the execution of a binary after the separator.
PostSeparatorAuthority []x509.Certificate
// DriverLoadSourceHints describes the origin of boot services drivers.
// This data is not tamper-proof and must only be used as a hint.
DriverLoadSourceHints []DriverLoadSource
// DMAProtectionDisabled is true if the platform reports during boot that
// DMA protection is supported but disabled.
//
// See: https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-kernel-dma-protection
DMAProtectionDisabled bool
}
SecurebootState describes the secure boot status of a machine, as determined by processing its event log.
func ParseSecurebootState ¶
func ParseSecurebootState(events []tcg.Event, registerCfg registerConfig) (*SecurebootState, error)
ParseSecurebootState parses a series of events to determine the configuration of secure boot on a device. An error is returned if the state cannot be determined, or if the event log is structured in such a way that it may have been tampered post-execution of platform firmware.
func ParseSecurebootStateLegacy ¶
func ParseSecurebootStateLegacy(events []tcg.Event) (*SecurebootState, error)
ParseSecurebootStateLegacy parses a series of events to determine the configuration of secure boot on a device. An error is returned if the state cannot be determined, or if the event log is structured in such a way that it may have been tampered post-execution of platform firmware. ParseSecurebootStateLegacy assumes events are sourced from a TPM event log. It is meant for use with go-attestation.