efi

package module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: LGPL-3.0 Imports: 40 Imported by: 47

Documentation

Index

Constants

View Source
const (
	OSIndicationBootToFWUI                   = uefi.EFI_OS_INDICATIONS_BOOT_TO_FW_UI
	OSIndicationTimestampRevocation          = uefi.EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION
	OSIndicationFileCapsuleDeliverySupported = uefi.EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED
	OSIndicationFMPCapsuleSupported          = uefi.EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED
	OSIndicationCapsuleResultVarSupported    = uefi.EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED
	OSIndicationStartOSRecovery              = uefi.EFI_OS_INDICATIONS_START_OS_RECOVERY
	OSIndicationStartPlatformRecovery        = uefi.EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY
	OSIndicationJSONConfigDataRefresh        = uefi.EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH
)
View Source
const (
	BootOptionSupportKey     = uefi.EFI_BOOT_OPTION_SUPPORT_KEY
	BootOptionSupportApp     = uefi.EFI_BOOT_OPTION_SUPPORT_APP
	BootOptionSupportSysPrep = uefi.EFI_BOOT_OPTION_SUPPORT_SYSPREP
	BootOptionSupportCount   = uefi.EFI_BOOT_OPTION_SUPPORT_COUNT
)

Variables

View Source
var (
	ErrCRCCheck         = errors.New("CRC check failed")                       // the partition table header or partition entry CRC check failed
	ErrNoProtectiveMBR  = errors.New("no protective master boot record found") // no protective MBR record was found
	ErrStandardMBRFound = errors.New("a MBR was found")                        // a standard MBR was found

	// ErrInvalidBackupPartitionTableLocation may be returned from
	// ReadPartitionTable when called with the BackupPartitionTable
	// role if the partition table isn't located at the end of the
	// device. Note that the function will still return a valid table
	// in this case.
	ErrInvalidBackupPartitionTableLocation = errors.New("backup partition table not located at end of device")

	// UnusedPartitionType is the type GUID of an unused partition entry.
	UnusedPartitionType GUID
)
View Source
var (
	// These errors gneerally ccrrespnod to errors that are returned from the variable service. They
	// may be returned in other cirumstaces too, particularly because the kernel may map these errors
	// to commonly used error codes, eg, efivarfs at least uses EINVAL
	ErrVarNotExist          = errors.New("variable does not exist")                                                                 // corresponds to EFI_NOT_FOUND
	ErrVarInvalidParam      = errors.New("invalid parameter for variable access")                                                   // corresponds to EFI_INVALID_PARAMETER
	ErrVarDeviceError       = errors.New("variable access failed because of a hardware error")                                      // corresponds to EFI_DEVICE_ERROR
	ErrVarPermission        = errors.New("variable access failed because of insufficient permissions or an authentication failure") // corresponds eo EFI_SECURTY_VIOLATION.
	ErrVarInsufficientSpace = errors.New("insufficient storage space available for variable")                                       // corresponds to EFI_INSUFFICIENT_SPACE.

	// ErrVarWritProtected corresponds to EFI_WRITE_PROTECTED although there are other reasons
	// this error could be returned such as permissions errors in the VFS layer with efivarfs.
	ErrVarWriteProtected = errors.New("variable is write protected")
)
View Source
var DefaultVarContext = newDefaultVarContext()

DefaultVarContext should generally be passed to functions that interact with EFI variables in order to use the default system backend for accessing EFI variables. It is based on a new background context.

On Linux, this uses efivarfs. The kernel rate limits unprivileged users' read accesses to the EFI variable runtime service to 100 accesses per second, after which any thread that attempts to perform a read access will sleep in an uninterruptible state. This makes adding a deadline to the context for sections of code that perform multiple variable reads worthwhile in some cases. Unfortunately, there is no way to determine whether an access will be ratelimited before performing it.

View Source
var EmptyHardDriveSignature = emptyHardDriveSignatureType{}

EmptyHardDriveSignature is an empty HardDriveSignature.

View Source
var (
	// ErrVarsUnavailable indicates that there is no backend available for variable accesses in the current platform
	ErrVarsUnavailable = errors.New("no variable backend is available")
)

Functions

func ComputePeImageDigest

func ComputePeImageDigest(alg crypto.Hash, r io.ReaderAt, sz int64) ([]byte, error)

ComputePeImageDigest computes the digest of the supplied PE image in accordance with the Authenticode specification, using the specified digest algorithm.

func ConvertUTF16ToUTF8

func ConvertUTF16ToUTF8(in []uint16) string

ConvertUTF16ToUTF8 converts the supplied UTF-16 or UCS2 string to a UTF-8 string. If the supplied string is NULL-terminated, then the NULL termination is removed from the string.

func ConvertUTF8ToUCS2 added in v0.1.2

func ConvertUTF8ToUCS2(in string) []uint16

ConvertUTF8ToUCS2 converts the supplied UTF-8 string to a UCS2 string. Any code point outside of the Basic Multilingual Plane cannot be represented by UCS2 and is converted to the replacement character.

func ConvertUTF8ToUTF16

func ConvertUTF8ToUTF16(in string) []uint16

ConvertUTF8ToUTF16 converts the supplied UTF-8 string to a UTF-16 string.

func DeleteBootNextVariable added in v0.9.6

func DeleteBootNextVariable(ctx context.Context) error

DeleteBootNextVariable deletes the option number of the boot entry to try next. In general DefaultVarContext should be supplied to this.

func DeleteLoadOptionVariable added in v0.9.6

func DeleteLoadOptionVariable(ctx context.Context, class LoadOptionClass, n uint16) error

DeleteLoadOptionVariable deletes the load option variable for the specified class and option number. The variable is written to the global namespace. This will succeed even if the variable doesn't already exist. The class must be one of LoadOptionClassDriver, LoadOptionClassSysprep, or LoadOptionClassBoot. In general DefaultVarContext should be supplied to this.

func FormatLoadOptionVariableName added in v1.7.0

func FormatLoadOptionVariableName(class LoadOptionClass, n uint16) string

FormatLoadOptionVariableName returns a variable name for the specified load option class and load option number.

func IsDeployedModeSupported added in v0.9.6

func IsDeployedModeSupported(ctx context.Context) bool

IsDeployedModeSupported indicates whether the firmware is new enough (ie based on at least UEFI 2.5) to support deployed mode. In general, DefaultVarContext should be supplied to this.

func ListLoadOptionNumbers added in v0.9.6

func ListLoadOptionNumbers(ctx context.Context, class LoadOptionClass) ([]uint16, error)

ListLoadOptionNumbers lists the numbers of all of the load option variables for the specified class from the global namespace. The returned numbers will be sorted in ascending order. In general DefaultVarContext should be supplied to this.

func NextAvailableLoadOptionNumber added in v0.9.6

func NextAvailableLoadOptionNumber(ctx context.Context, class LoadOptionClass) (uint16, error)

NextAvailableLoadOptionNumber returns the next available load option number for the specified class, which must be one of LoadOptionClassDriver, LoadOptionClassSysprep, or LoadOptionClassBoot. In general DefaultVarContext should be supplied to this.

func ReadBootCurrentVariable added in v0.9.6

func ReadBootCurrentVariable(ctx context.Context) (uint16, error)

ReadBootCurrentVariable returns the option number used for the current boot. In general DefaultVarContext should be supplied to this.

func ReadBootNextVariable added in v0.9.6

func ReadBootNextVariable(ctx context.Context) (uint16, error)

ReadBootNextVariable returns the option number of the boot entry to try next. In general DefaultVarContext should be supplied to this.

func ReadLoadOrderVariable added in v0.9.6

func ReadLoadOrderVariable(ctx context.Context, class LoadOptionClass) ([]uint16, error)

ReadLoadOrderVariable returns the load option order for the specified class, which must be one of LoadOptionClassDriver, LoadOptionClassSysPrep, or LoadOptionClassBoot. In general DefaultVarContext should be supplied to this.

func ReadPlatformKeyCertificate added in v0.9.7

func ReadPlatformKeyCertificate(ctx context.Context) (*x509.Certificate, error)

ReadPlatformKeyCertificate reads the PK global variable and returns the corresponding certificate, if a platform key is enrolled. If no platform key is enrolled, this will return nil. In general, DefaultVarContext should be supplied to this.

func ReadSecureBootVariable added in v0.9.6

func ReadSecureBootVariable(ctx context.Context) (bool, error)

ReadSecureBootVariable reads the SecureBoot global variable which provides an indication of whether secure boot is enabled. If it returns false, then secure boot is disabled. If it returns true, then it is an indication that secure boot is enabled. In general, DefaultVarContext should be supplied to this.

Note that this function cannot prove that secure boot is enabled. If a platform provides a way to disable secure boot and execute arbitrary code, then the platform or kernel may not tell the truth about this. Obtaining proof that secure boot is enabled would involve the use of attestations and a third party verifier.

func RegisterFWFileNameLookup added in v1.5.0

func RegisterFWFileNameLookup(fn func(GUID) (string, bool))

RegisterFWFileNameLookup registers a function that can map guids to strings for well known names, and these will be displayed by FWFileDevicePathNode.String and FWFileDevicePathNode.ToString if the flags argument is marked as display only. Note that this does make the string representation of the path unparseable, if the string is being used in such a way (this package doesn't yet have any ways of parsing device paths that are in string form).

Just importing github.com/canonical/go-efilib/guids is sufficient to register a function that does this. It's included in a separate and optional package for systems that are concerned about binary size.

func RegisterFWVolNameLookup added in v1.5.0

func RegisterFWVolNameLookup(fn func(GUID) (string, bool))

RegisterFWVolNameLookup registers a function that can map guids to strings for well known names, and these will be displayed by FWVolDevicePathNode.String and FWVolDevicePathNode.ToString if the flags argument is marked as display only. Note that this does make the string representation of the path unparseable, if the string is being used in such a way (this package doesn't yet have any ways of parsing device paths that are in string form).

Just importing github.com/canonical/go-efilib/guids is sufficient to register a function that does this. It's included in a separate and optional package for systems that are concerned about binary size.

func RegisterMediaFvFileNameLookup deprecated added in v0.9.9

func RegisterMediaFvFileNameLookup(fn func(GUID) (string, bool))

RegisterMediaFvFileNameLookup registers a function that can map guids to strings for well known names, and these will be displayed by FWFileDevicePathNode.String and FWFileDevicePathNode.ToString if the flags argument is marked as display only. Note that this does make the string representation of the path unparseable, if the string is being used in such a way (this package doesn't yet have any ways of parsing device paths that are in string form).

Just importing github.com/canonical/go-efilib/guids is sufficient to register a function that does this. It's included in a separate and optional package for systems that are concerned about binary size.

Deprecated: use RegisterFWFileNameLookup.

func RegisterMediaFvNameLookup deprecated added in v1.0.0

func RegisterMediaFvNameLookup(fn func(GUID) (string, bool))

RegisterMediaFvNameLookup registers a function that can map guids to strings for well known names, and these will be displayed by FWVolDevicePathNode.String and FWVolDevicePathNode.ToString if the flags argument is marked as display only. Note that this does make the string representation of the path unparseable, if the string is being used in such a way (this package doesn't yet have any ways of parsing device paths that are in string form).

Just importing github.com/canonical/go-efilib/guids is sufficient to register a function that does this. It's included in a separate and optional package for systems that are concerned about binary size.

Deprecated: use RegisterFWVolNameLookup.

func WithDefaultVarsBackend added in v1.1.0

func WithDefaultVarsBackend(ctx context.Context) context.Context

WithDefaultVarsBackend adds the default system backend for accessing EFI variables to an existing context. It allows for usage of any context other than the internally created background one.

On Linux, this uses efivarfs. The kernel rate limits unprivileged users' read accesses to the EFI variable runtime service to 100 accesses per second, after which any thread that attempts to perform a read access will sleep in an uninterruptible state. This makes adding a deadline to the context for sections of code that perform multiple variable reads worthwhile in some cases. Unfortunately, there is no way to determine whether an access will be ratelimited before performing it.

func WriteBootNextVariable added in v0.9.6

func WriteBootNextVariable(ctx context.Context, n uint16) error

WriteBootNextVariable writes the option number of the boot entry to try next. In general DefaultVarContext should be supplied to this.

func WriteLoadOptionVariable added in v0.9.6

func WriteLoadOptionVariable(ctx context.Context, class LoadOptionClass, n uint16, option *LoadOption) error

WriteLoadOptionVariable writes the supplied LoadOption to a variable for the specified class and option number. The variable is written to the global namespace. This will overwrite any variable that already exists. The class must be one of LoadOptionClassDriver, LoadOptionClassSysprep, or LoadOptionClassBoot. In general DefaultVarContext should be supplied to this.

func WriteLoadOrderVariable added in v0.9.6

func WriteLoadOrderVariable(ctx context.Context, class LoadOptionClass, order []uint16) error

WriteLoadOrderVariable writes the load option order for the specified class, which must be one of LoadOptionClassDriver, LoadOptionClassSysprep, or LoadOptionClassBoot. In general DefaultVarContext should be supplied to this.

This will check that each entry corresponds to a valid load option before writing the new order.

func WriteOSIndicationsVariable added in v0.9.6

func WriteOSIndicationsVariable(ctx context.Context, value OSIndications) error

WriteOSIndicationsVariable writes the supplied value to the OsIndications global variable in order to send commands to the firmware for the next boot. In general DefaultVarContext should be supplied to this.

func WriteVariable added in v0.1.2

func WriteVariable(ctx context.Context, name string, guid GUID, attrs VariableAttributes, data []byte) error

WriteVariable writes the supplied data value with the specified attributes to the EFI variable with the specified name and GUID. In general, DefaultVarContext or the result of WithDefaultVarsBackend should be supplied to this. This will return an error if the context is done.

If the variable already exists, the specified attributes must match the existing attributes with the exception of AttributeAppendWrite.

If the variable does not exist, it will be created.

Types

type ACPIDevicePathNode

type ACPIDevicePathNode struct {
	HID EISAID // Compressed hardware ID
	UID uint32 // Unique ID
}

ACPIDevicePathNode corresponds to an ACPI device path node.

func (*ACPIDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *ACPIDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*ACPIDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*ACPIDevicePathNode) String

func (n *ACPIDevicePathNode) String() string

String implements fmt.Stringer.

func (*ACPIDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*ACPIDevicePathNode) Write

func (n *ACPIDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type ACPIExtendedDevicePathNode

type ACPIExtendedDevicePathNode struct {
	HID    EISAID
	UID    uint32
	CID    EISAID
	HIDStr string
	UIDStr string
	CIDStr string
}

ACPIExtendedDevicePathNode corresponds to an ACPI device path node and is used where a CID field is required or a string field is required for HID or UID.

func (*ACPIExtendedDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *ACPIExtendedDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*ACPIExtendedDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*ACPIExtendedDevicePathNode) String

func (n *ACPIExtendedDevicePathNode) String() string

String implements fmt.Stringer.

func (*ACPIExtendedDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*ACPIExtendedDevicePathNode) Write

Write implements [DevicePathNode.Write].

type ATAPIControllerRole

type ATAPIControllerRole uint8

ATAPIControllerRole describes the port that an IDE device is connected to.

const (
	ATAPIControllerPrimary   ATAPIControllerRole = 0
	ATAPIControllerSecondary ATAPIControllerRole = 1
)

func (ATAPIControllerRole) String added in v0.3.0

func (r ATAPIControllerRole) String() string

String implements fmt.Stringer.

type ATAPIDevicePathNode

type ATAPIDevicePathNode struct {
	Controller ATAPIControllerRole
	Drive      ATAPIDriveRole
	LUN        uint16 // Logical unit number
}

ATAPIDevicePathNode corresponds to an ATA device path node.

func (*ATAPIDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *ATAPIDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*ATAPIDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*ATAPIDevicePathNode) String

func (n *ATAPIDevicePathNode) String() string

String implements fmt.Stringer.

func (*ATAPIDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*ATAPIDevicePathNode) Write

func (n *ATAPIDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type ATAPIDriveRole

type ATAPIDriveRole uint8

ATAPIDriveRole describes the role of a device on a specific IDE port.

const (
	ATAPIDriveMaster ATAPIDriveRole = 0
	ATAPIDriveSlave  ATAPIDriveRole = 1
)

func (ATAPIDriveRole) String added in v0.3.0

func (r ATAPIDriveRole) String() string

String implements fmt.Stringer.

type BootOptionSupport added in v0.9.6

type BootOptionSupport uint32

BootOptionSupport provides a way for the firmware to indicate certain boot options that are supported.

func ReadBootOptionSupportVariable added in v0.9.6

func ReadBootOptionSupportVariable(ctx context.Context) (BootOptionSupport, error)

ReadBootOptionSupportVariable returns the value of the BootOptionSupport variable in the global namespace. In general DefaultVarContext should be supplied to this.

func (BootOptionSupport) KeyCount added in v0.9.6

func (s BootOptionSupport) KeyCount() uint8

KeyCount returns the supported number of key presses (up to 3).

type CDROMDevicePathNode

type CDROMDevicePathNode struct {
	BootEntry      uint32
	PartitionStart uint64
	PartitionSize  uint64
}

CDROMDevicePathNode corresponds to a CDROM device path node.

func (*CDROMDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *CDROMDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*CDROMDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*CDROMDevicePathNode) String

func (n *CDROMDevicePathNode) String() string

String implements fmt.Stringer.

func (*CDROMDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*CDROMDevicePathNode) Write

func (n *CDROMDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type DeviceLogicalUnitDevicePathNode

type DeviceLogicalUnitDevicePathNode struct {
	LUN uint8
}

func (*DeviceLogicalUnitDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *DeviceLogicalUnitDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*DeviceLogicalUnitDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*DeviceLogicalUnitDevicePathNode) String

String implements fmt.Stringer.

func (*DeviceLogicalUnitDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*DeviceLogicalUnitDevicePathNode) Write

Write implements [DevicePathNode.Write].

type DevicePath

type DevicePath []DevicePathNode

DevicePath represents a complete device path with the first node representing the root.

func DevicePathFindFirstOccurrence added in v1.3.0

func DevicePathFindFirstOccurrence[T DevicePathNode](p DevicePath) DevicePath

DevicePathFindFirstOccurrence finds the first occurrence of the device path node with the specified type and returns it and the remaining components of the device path.

func ReadDevicePath

func ReadDevicePath(r io.Reader) (out DevicePath, err error)

ReadDevicePath decodes a device path from the supplied io.Reader. It will read until it finds a termination node or an error occurs.

func (DevicePath) Bytes added in v0.2.0

func (p DevicePath) Bytes() ([]byte, error)

Bytes returns the serialized form of this device path.

func (DevicePath) Format added in v1.7.0

func (p DevicePath) Format(s fmt.State, c rune)

Format implements fmt.Formatter. For the 's', 'v', 'x' and 'X' verbs, the '+' flag turns off the DevicePathDisplayOnly flag to make the string more verbose. The '#' flag enables conversions of firmware GUIDs to well-known names where these are known.

func (DevicePath) Formatter deprecated added in v1.5.0

func (p DevicePath) Formatter() fmt.Formatter

Deprecated: Use [Format].

func (DevicePath) Matches added in v0.9.6

func (p DevicePath) Matches(other DevicePath) DevicePathMatch

Matches indicates whether other matches this path in some way, and returns the type of match. If either path is a HD() short-form path, this may return DevicePathShortFormHDMatch. If either path is a UsbWwid() short-form path, this may return DevicePathShortFormUSBWWIDMatch. If either path is a UsbClass() short-form path, this may return DevicePathShortFormUSBClassMatch. If either path is a file path short-form path, this may return DevicePathShortFormFileMatch. This returns DevicePathFullMatch if the supplied path fully matches, and DevicePathNoMatch if there is no match.

func (DevicePath) ShortFormType added in v1.3.1

func (p DevicePath) ShortFormType() DevicePathShortFormType

ShortFormType returns whether this is a short-form type of path, and if so, what type of short-form path. The UEFI boot manager is required to handle a certain set of well defined short-form paths that begin with a specific component.

func (DevicePath) String

func (p DevicePath) String() string

String implements fmt.Stringer, and returns the display only string. For more control, use DevicePath.ToString.

func (DevicePath) ToString added in v0.3.0

func (p DevicePath) ToString(flags DevicePathToStringFlags) string

ToString returns a string representation of this device path with the supplied flags.

func (DevicePath) Write

func (p DevicePath) Write(w io.Writer) error

Write serializes the complete device path to w.

type DevicePathMatch added in v0.9.6

type DevicePathMatch int

DevicePathMatch indicates how a device path matched

const (
	// DevicePathNoMatch indicates that a pair of device paths did not match.
	DevicePathNoMatch DevicePathMatch = iota

	// DevicePathFullMatch indicates that a pair of device paths fully matched.
	DevicePathFullMatch

	// DevicePathShortFormHDMatch indicates that one device path begins with a
	// *[HardDriveDevicePathNode] and matches the end of the longer device path.
	DevicePathShortFormHDMatch

	// DevicePathShortFormUSBWWIDMatch indicates that one device path begins with
	// a *[USBWWIDDevicePathNode] and matches the end of the longer device path.
	DevicePathShortFormUSBWWIDMatch

	// DevicePathShortFormUSBClassMatch indicates that one device path begins with
	// a *[USBClassDevicePathNode] and matches the end of the longer device path.
	DevicePathShortFormUSBClassMatch

	// DevicePathShortFormFileMatch indicates that one device path begins with a
	// [FilePathDevicePathNode] and matches the end of the longer device path.
	DevicePathShortFormFileMatch
)

type DevicePathNode

type DevicePathNode interface {
	CompoundType() DevicePathNodeCompoundType                 // Return the compound type of this node
	AsGenericDevicePathNode() (*GenericDevicePathNode, error) // Convert this node to a GenericDevicePathNode

	// String should return a string for this node, equivalent to
	// ToString(DevicePathNodeDisplayOnly|DevicePathNodeAllowShortcuts).
	// For more control, use ToString
	String() string

	ToString(flags DevicePathToStringFlags) string // Return a string for this node
	Write(w io.Writer) error                       // Serialize this node to the supplied io.Writer
}

DevicePathNode represents a single node in a device path.

type DevicePathNodeCompoundType added in v1.5.0

type DevicePathNodeCompoundType uint16

DevicePathNodeCompoundType describes the compound type of a device path node, comprised of the type and sub-type.

const (
	DevicePathNodePCIType      DevicePathNodeCompoundType = devicePathNodePCIType      // nodes of this type are implemented by *PCIDevicePathNode
	DevicePathNodeVendorHWType DevicePathNodeCompoundType = devicePathNodeVendorHWType // nodes of this type are implemented by *VendorDevicePathNode

	DevicePathNodeACPIType         DevicePathNodeCompoundType = devicePathNodeACPIType         // nodes of this type are implemented by *ACPIDevicePathNode
	DevicePathNodeACPIExtendedType DevicePathNodeCompoundType = devicePathNodeACPIExtendedType // nodes of this type are implemented by *ACPIExtendedDevicePathNode

	DevicePathNodeATAPIType             DevicePathNodeCompoundType = devicePathNodeATAPIType             // nodes of this type are implemented by *ATAPIDevicePathNode
	DevicePathNodeSCSIType              DevicePathNodeCompoundType = devicePathNodeSCSIType              // nodes of this type are implemented by *SCSIDevicePathNode
	DevicePathNodeUSBType               DevicePathNodeCompoundType = devicePathNodeUSBType               // nodes of this type are implemented by *USBDevicePathNode
	DevicePathNodeUSBClassType          DevicePathNodeCompoundType = devicePathNodeUSBClassType          // nodes of this type are implemented by *USBClassDevicePathNode
	DevicePathNodeVendorMsgType         DevicePathNodeCompoundType = devicePathNodeVendorMsgType         // nodes of this type are implemented by *VendorDevicePathNode
	DevicePathNodeMACAddrType           DevicePathNodeCompoundType = devicePathNodeMACAddrType           // nodes of this type are implemented by *MACAddrDevicePathNode
	DevicePathNodeIPv4Type              DevicePathNodeCompoundType = devicePathNodeIPv4Type              // nodes of this type are implemented by *IPv4DevicePathNode
	DevicePathNodeIPv6Type              DevicePathNodeCompoundType = devicePathNodeIPv6Type              // nodes of this type are implemented by *IPv6DevicePathNode
	DevicePathNodeUSBWWIDType           DevicePathNodeCompoundType = devicePathNodeUSBWWIDType           // nodes of this type are implemented by *USBWWIDDevicePathNode
	DevicePathNodeDeviceLogicalUnitType DevicePathNodeCompoundType = devicePathNodeDeviceLogicalUnitType // nodes of this type are implemented by *DeviceLogicalUnitDevicePathNode
	DevicePathNodeSATAType              DevicePathNodeCompoundType = devicePathNodeSATAType              // nodes of this type are implemented by *SATADevicePathNode
	DevicePathNodeNVMENamespaceType     DevicePathNodeCompoundType = devicePathNodeNVMENamespaceType     // nodes of this type are implemented by *NVMENamespaceDevicePathNode

	DevicePathNodeHardDriveType           DevicePathNodeCompoundType = devicePathNodeHardDriveType           // nodes of this type are implemented by *HardDriveDevicePathNode
	DevicePathNodeCDROMType               DevicePathNodeCompoundType = devicePathNodeCDROMType               // nodes of this type are implemented by *CDROMDevicePathNode
	DevicePathNodeVendorMediaType         DevicePathNodeCompoundType = devicePathNodeVendorMediaType         // nodes of this type are implemented by *VendorDevicePathNode
	DevicePathNodeFilePathType            DevicePathNodeCompoundType = devicePathNodeFilePathType            // nodes of this type are implemented by FilePathDevicePathNode
	DevicePathNodeFwFileType              DevicePathNodeCompoundType = devicePathNodeFwFileType              // nodes of this type are implemented by FWFileDevicePathNode
	DevicePathNodeFwVolType               DevicePathNodeCompoundType = devicePathNodeFwVolType               // nodes of this type are implemented by FWVolDevicePathNode
	DevicePathNodeRelativeOffsetRangeType DevicePathNodeCompoundType = devicePathNodeRelativeOffsetRangeType // nodes of this type are implemented by *RelativeOffsetRangeDevicePathNode
)

func (DevicePathNodeCompoundType) IsValid added in v1.5.0

func (t DevicePathNodeCompoundType) IsValid() bool

IsValid indicates whether this compound type is valid. If either the type or sub-type are 0, then it is invalid.

func (DevicePathNodeCompoundType) SubType added in v1.5.0

Subtype returns the devicepath node sub-type.

func (DevicePathNodeCompoundType) Type added in v1.5.0

Type returns the devicepath node type.

type DevicePathNodeSubType added in v1.5.0

type DevicePathNodeSubType uint8

DevicePathNodeSubType is the sub-type of a device path node. The meaning of this depends on the DevicePathNodeType.

const (
	DevicePathNodeHWPCISubType    DevicePathNodeSubType = uefi.HW_PCI_DP
	DevicePathNodeHWVendorSubType DevicePathNodeSubType = uefi.HW_VENDOR_DP

	DevicePathNodeACPISubType         DevicePathNodeSubType = uefi.ACPI_DP
	DevicePathNodeACPIExtendedSubType DevicePathNodeSubType = uefi.ACPI_EXTENDED_DP

	DevicePathNodeMsgATAPISubType             DevicePathNodeSubType = uefi.MSG_ATAPI_DP
	DevicePathNodeMsgSCSISubType              DevicePathNodeSubType = uefi.MSG_SCSI_DP
	DevicePathNodeMsgUSBSubType               DevicePathNodeSubType = uefi.MSG_USB_DP
	DevicePathNodeMsgUSBClassSubType          DevicePathNodeSubType = uefi.MSG_USB_CLASS_DP
	DevicePathNodeMsgVendorSubType            DevicePathNodeSubType = uefi.MSG_VENDOR_DP
	DevicePathNodeMsgMACAddrSubType           DevicePathNodeSubType = uefi.MSG_MAC_ADDR_DP
	DevicePathNodeMsgIPv4SubType              DevicePathNodeSubType = uefi.MSG_IPv4_DP
	DevicePathNodeMsgIPv6SubType              DevicePathNodeSubType = uefi.MSG_IPv6_DP
	DevicePathNodeMsgUSBWWIDSubType           DevicePathNodeSubType = uefi.MSG_USB_WWID_DP
	DevicePathNodeMsgDeviceLogicalUnitSubType DevicePathNodeSubType = uefi.MSG_DEVICE_LOGICAL_UNIT_DP
	DevicePathNodeMsgSATASubType              DevicePathNodeSubType = uefi.MSG_SATA_DP
	DevicePathNodeMsgNVMENamespaceSubType     DevicePathNodeSubType = uefi.MSG_NVME_NAMESPACE_DP

	DevicePathNodeMediaHardDriveSubType           DevicePathNodeSubType = uefi.MEDIA_HARDDRIVE_DP
	DevicePathNodeMediaCDROMSubType               DevicePathNodeSubType = uefi.MEDIA_CDROM_DP
	DevicePathNodeMediaVendorSubType              DevicePathNodeSubType = uefi.MEDIA_VENDOR_DP
	DevicePathNodeMediaFilePathSubType            DevicePathNodeSubType = uefi.MEDIA_FILEPATH_DP
	DevicePathNodeMediaFwFileSubType              DevicePathNodeSubType = uefi.MEDIA_PIWG_FW_FILE_DP
	DevicePathNodeMediaFwVolSubType               DevicePathNodeSubType = uefi.MEDIA_PIWG_FW_VOL_DP
	DevicePathNodeMediaRelativeOffsetRangeSubType DevicePathNodeSubType = uefi.MEDIA_RELATIVE_OFFSET_RANGE_DP
)

type DevicePathNodeType added in v1.5.0

type DevicePathNodeType uint8

DevicePathNodeType is the type of a device path node.

func (DevicePathNodeType) String added in v1.5.0

func (t DevicePathNodeType) String() string

String implements fmt.Stringer.

type DevicePathShortFormType added in v1.3.1

type DevicePathShortFormType int

DevicePathShortFormType describes whether a path is a recognized short-form path, and what type it is.

const (
	// DevicePathNotShortForm indicates that a path is not a recognized short-form path
	DevicePathNotShortForm DevicePathShortFormType = iota

	// DevicePathShortFormHD indicates that a path is a HD() short-form path
	DevicePathShortFormHD

	// DevicePathShortFormUSBWWID indicates that a path is a UsbWwid() short-form path
	DevicePathShortFormUSBWWID

	// DevicePathShortFormUSBClass indicates that a path is a UsbClass() short-form path
	DevicePathShortFormUSBClass

	// DevicePathShortFormURI indicates that a path is a Uri() short-form path. Note that
	// this package does not currently directly support device paths containing URIs.
	DevicePathShortFormURI

	// DevicePathShortFormFilePath indicates that a path is a file path short-form path
	DevicePathShortFormFilePath
)

func (DevicePathShortFormType) IsShortForm added in v1.3.1

func (t DevicePathShortFormType) IsShortForm() bool

IsShortForm whether the current form is a short-form value (ie, not DevicePathNotShortForm).

type DevicePathSubType

type DevicePathSubType = DevicePathNodeSubType

DevicePathSubType is the sub-type of a device path node. The meaning of this depends on the DevicePathNodeType. Deprecated: use DevicePathNodeSubType.

type DevicePathToStringFlags added in v0.3.0

type DevicePathToStringFlags int

DevicePathToStringFlags defines flags for DevicePath.ToString and DevicePathNode.ToString.

const (
	// DevicePathDisplayOnly indicates that each node is converted
	// to the shorter text representation.
	DevicePathDisplayOnly DevicePathToStringFlags = 1 << 0

	// DevicePathAllowVendorShortcuts indicates that that vendor
	// specific device path nodes should print using a type-specific
	// format based on the vendor GUID, if it is recognized.
	DevicePathAllowVendorShortcuts DevicePathToStringFlags = 1 << 1

	// DevicePathDisplayFWGUIDNames indicates that firmware volume
	// and firmware file device path nodes should print the industry
	// standard name for a GUID, if it is recognized and if lookup
	// functions have been registered with RegisterFWVolNameLookup
	// and RegisterFWFileNameLookup. This only works with
	// DevicePathDisplayOnly.
	DevicePathDisplayFWGUIDNames DevicePathToStringFlags = 1 << 2
)

func (DevicePathToStringFlags) AllowVendorShortcuts added in v1.5.0

func (f DevicePathToStringFlags) AllowVendorShortcuts() bool

func (DevicePathToStringFlags) DisplayFWGUIDNames added in v1.5.0

func (f DevicePathToStringFlags) DisplayFWGUIDNames() bool

func (DevicePathToStringFlags) DisplayOnly added in v0.3.0

func (f DevicePathToStringFlags) DisplayOnly() bool

type DevicePathType

type DevicePathType = DevicePathNodeType

DevicePathType is the type of a device path node. Deprecated: use DevicePathNodeType.

type EISAID

type EISAID uint32

EISAID represents a compressed EISA PNP ID

func NewEISAID

func NewEISAID(vendor string, product uint16) (EISAID, error)

func (EISAID) Product

func (id EISAID) Product() uint16

Product returns the product ID.

func (EISAID) String

func (id EISAID) String() string

String implements fmt.Stringer.

func (EISAID) Vendor

func (id EISAID) Vendor() string

Vendor returns the 3-letter vendor ID.

type EUI48 added in v1.5.0

type EUI48 [6]uint8

EUI48 represents a EUI-48 (48-bit Extended Unique Identifier).

func (EUI48) AsEUI64 added in v1.5.0

func (id EUI48) AsEUI64() EUI64

AsEUI64 returns this identifier as EUI-64.

func (EUI48) Bytes32 added in v1.5.0

func (id EUI48) Bytes32() [32]byte

Bytes32 implements [MACAddress.Bytes32].

func (EUI48) String added in v1.5.0

func (id EUI48) String() string

String implements fmt.Stringer.

func (EUI48) Type added in v1.5.0

func (EUI48) Type() MACAddressType

Type implements [MACAddress.Type].

type EUI64 added in v1.5.0

type EUI64 [8]uint8

EUI64 represents a EUI-64 (64-bit Extended Unique Identifier).

func (EUI64) AsEUI48 added in v1.5.0

func (id EUI64) AsEUI48() (EUI48, error)

AsEUI48 returns this identifier as EUI-48, if it is a valid EUI-48.

func (EUI64) Bytes32 added in v1.5.0

func (id EUI64) Bytes32() [32]uint8

Bytes implements [MACAddress.Bytes32].

func (EUI64) String added in v1.5.0

func (id EUI64) String() string

String implements fmt.Stringer.

func (EUI64) Type added in v1.5.0

func (EUI64) Type() MACAddressType

Type implements [MACAddress.Type].

type FWFileDevicePathNode added in v1.5.0

type FWFileDevicePathNode GUID

FWFileDevicePathNode corresponds to a firmware volume file device path node.

func (FWFileDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n FWFileDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (FWFileDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (FWFileDevicePathNode) String added in v1.5.0

func (n FWFileDevicePathNode) String() string

String implements fmt.Stringer.

func (FWFileDevicePathNode) ToString added in v1.5.0

ToString implements [DevicePathNode.ToString].

func (FWFileDevicePathNode) Write added in v1.5.0

func (n FWFileDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type FWVolDevicePathNode added in v1.5.0

type FWVolDevicePathNode GUID

FWVolDevicePathNode corresponds to a firmware volume device path node.

func (FWVolDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n FWVolDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (FWVolDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (FWVolDevicePathNode) String added in v1.5.0

func (n FWVolDevicePathNode) String() string

String implements fmt.Stringer.

func (FWVolDevicePathNode) ToString added in v1.5.0

ToString implements [DevicePathNode.ToString].

func (FWVolDevicePathNode) Write added in v1.5.0

func (n FWVolDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type FilePathDevicePathNode

type FilePathDevicePathNode string

FilePathDevicePathNode corresponds to a file path device path node.

func NewFilePathDevicePathNode

func NewFilePathDevicePathNode(path string) (out FilePathDevicePathNode)

NewFilePathDevicePathNode constructs a new FilePathDevicePathNode from the supplied path, converting the OS native separators to EFI separators ("\") and prepending a separator to the start of the path if one doesn't already exist.

func (FilePathDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n FilePathDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (FilePathDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (FilePathDevicePathNode) String

func (n FilePathDevicePathNode) String() string

String implements fmt.Stringer.

func (FilePathDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (FilePathDevicePathNode) Write

Write implements [DevicePathNode.Write].

type GUID

type GUID [16]byte

GUID corresponds to the EFI_GUID type.

var (
	// HashAlgorithmSHA1Guid corresponds to the SHA1 algorithm.
	HashAlgorithmSHA1Guid GUID = GUID(uefi.EFI_HASH_ALGORITHM_SHA1_GUID)

	// HashAlgorithmSHA256Guid corresponds to the SHA256 algorithm.
	HashAlgorithmSHA256Guid GUID = GUID(uefi.EFI_HASH_ALGORITHM_SHA256_GUID)

	// HashAlgorithmSHA224Guid corresponds to the SHA224 algorithm.
	HashAlgorithmSHA224Guid GUID = GUID(uefi.EFI_HASH_ALGORITHM_SHA224_GUID)

	// HashAlgorithmSHA384Guid corresponds to the SHA384 algorithm.
	HashAlgorithmSHA384Guid GUID = GUID(uefi.EFI_HASH_ALGORITHM_SHA384_GUID)

	// HashAlgorithmSHA412Guid corresponds to the SHA512 algorithm.
	HashAlgorithmSHA512Guid GUID = GUID(uefi.EFI_HASH_ALGORITHM_SHA512_GUID)

	// CertTypeRSA2048SHA256Guid is used to define the type of a
	// WinCertificateGUID that corresponds to a PKCS#1-v1.5 encoded RSA2048
	// SHA256 signature and is implemented by the *WinCertificateGUIDPKCS1v15
	// type.
	CertTypeRSA2048SHA256Guid GUID = GUID(uefi.EFI_CERT_TYPE_RSA2048_SHA256_GUID)

	// CertTypePKCS7Guid is used to define the type of a WinCertificateGUID
	// that corresponds to a detached PKCS#7 signature and is implemented by
	// the *WinCertificatePKCS7 type.
	CertTypePKCS7Guid GUID = GUID(uefi.EFI_CERT_TYPE_PKCS7_GUID)

	// CertSHA1Guid is used to define the type of a signature list that
	// contains a SHA1 digest.
	CertSHA1Guid GUID = GUID(uefi.EFI_CERT_SHA1_GUID)

	// CertSHA256Guid is used to define the type of a signature list that
	// contains a SHA-256 digest.
	CertSHA256Guid GUID = GUID(uefi.EFI_CERT_SHA256_GUID)

	// CertSHA224Guid is used to define the type of a signature list that
	// contains a SHA-224 digest.
	CertSHA224Guid GUID = GUID(uefi.EFI_CERT_SHA224_GUID)

	// CertSHA384Guid is used to define the type of a signature list that
	// contains a SHA-384 digest.
	CertSHA384Guid GUID = GUID(uefi.EFI_CERT_SHA384_GUID)

	// CertSHA512Guid is used to define the type of a signature list that
	// contains a SHA-512 digest.
	CertSHA512Guid GUID = GUID(uefi.EFI_CERT_SHA512_GUID)

	// CertRSA2048Guid is used to define the type of a signature list that
	// contains RSA2048 public keys.
	CertRSA2048Guid GUID = GUID(uefi.EFI_CERT_RSA2048_GUID)

	// CertRSA2048SHA1Guid is used to define the type of a signature list
	// that contains SHA1 digests of RSA2048 public keys.
	CertRSA2048SHA1Guid GUID = GUID(uefi.EFI_CERT_RSA2048_SHA1_GUID)

	// CertRSA2048SHA256Guid is used to define the type of a signature list
	// that contains SHA-256 digesta of RSA2048 public keya.
	CertRSA2048SHA256Guid GUID = GUID(uefi.EFI_CERT_RSA2048_SHA256_GUID)

	// CertX509Guid is used to define the type of a signature list that
	// contains a DER encoded X.509 certificate.
	CertX509Guid GUID = GUID(uefi.EFI_CERT_X509_GUID)

	// CertX509SHA256Guid is used to define the type of a signature list
	// that contains the SHA-256 digest of the TBS content of a X.509
	// certificate, and a revocation time.
	CertX509SHA256Guid GUID = GUID(uefi.EFI_CERT_X509_SHA256_GUID)

	// CertX509SHA384Guid is used to define the type of a signature list
	// that contains the SHA-384 digest of the TBS content of a X.509
	// certificate, and a revocation time.
	CertX509SHA384Guid GUID = GUID(uefi.EFI_CERT_X509_SHA384_GUID)

	// CertX509SHA512Guid is used to define the type of a signature list
	// that contains the SHA-512 digest of the TBS content of a X.509
	// certificate, and a revocation time.
	CertX509SHA512Guid GUID = GUID(uefi.EFI_CERT_X509_SHA512_GUID)

	// GlobalVariable is the namespace for many variables within the UEFI specification.
	GlobalVariable GUID = GUID(uefi.EFI_GLOBAL_VARIABLE)

	// ImageSecurityDatabaseGuid is the namespace for signature databases defined
	// byt the UEFI specification.
	ImageSecurityDatabaseGuid GUID = GUID(uefi.EFI_IMAGE_SECURITY_DATABASE_GUID)

	PCAnsiGuid                         GUID = GUID(uefi.EFI_PC_ANSI_GUID)
	VT100Guid                          GUID = GUID(uefi.EFI_VT_100_GUID)
	VT100PlusGuid                      GUID = GUID(uefi.EFI_VT_100_PLUS_GUID)
	VTUTF8Guid                         GUID = GUID(uefi.EFI_VT_UTF8_GUID)
	DevicePathMessagingUARTFlowControl GUID = GUID(uefi.DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL)
	SASDevicePathGuid                  GUID = GUID(uefi.EFI_SAS_DEVICE_PATH_GUID)

	DebugPortProtocolGuid GUID = GUID(uefi.EFI_DEBUGPORT_PROTOCOL_GUID)
)

func DecodeGUIDString

func DecodeGUIDString(s string) (GUID, error)

DecodeGUIDString decodes the supplied GUID string. The string must have the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" and may be surrounded by curly braces.

func MakeGUID

func MakeGUID(a uint32, b, c, d uint16, e [6]uint8) GUID

MakeGUID makes a new GUID from the supplied arguments.

func ReadGUID

func ReadGUID(r io.Reader) (out GUID, err error)

ReadGUID reads a EFI_GUID from the supplied io.Reader.

func (GUID) A added in v0.1.2

func (guid GUID) A() uint32

func (GUID) B added in v0.1.2

func (guid GUID) B() uint16

func (GUID) C added in v0.1.2

func (guid GUID) C() uint16

func (GUID) D added in v0.1.2

func (guid GUID) D() uint16

func (GUID) E added in v0.1.2

func (guid GUID) E() [6]uint8

func (GUID) String

func (guid GUID) String() string

String implements fmt.Stringer.

type GUIDHardDriveSignature added in v0.3.0

type GUIDHardDriveSignature GUID

GUIDHardDriveSignature is a HardDriveSignature for GPT drives.

func (GUIDHardDriveSignature) Data added in v0.3.0

func (s GUIDHardDriveSignature) Data() (out [16]uint8)

Data implements [HardDriveSignature.Data].

func (GUIDHardDriveSignature) String added in v0.3.0

func (s GUIDHardDriveSignature) String() string

String implements fmt.Stringer.

func (GUIDHardDriveSignature) Type added in v0.3.0

Type implements [HardDriveSignature.Type].

type GenericDevicePathNode added in v0.1.2

type GenericDevicePathNode struct {
	Type    DevicePathNodeType
	SubType DevicePathSubType // the meaning of the sub-type depends on the Type field.
	Data    []byte            // An opaque blob of data associated with this node
}

GenericDevicePathNode corresponds to a device path nodes with a type that is not handled by this package

func (*GenericDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *GenericDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*GenericDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*GenericDevicePathNode) String added in v0.1.2

func (n *GenericDevicePathNode) String() string

String implements fmt.Stringer.

func (*GenericDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*GenericDevicePathNode) Write added in v0.1.2

func (n *GenericDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type HardDriveDevicePathNode

type HardDriveDevicePathNode struct {
	PartitionNumber uint32             // 1-indexed partition number
	PartitionStart  uint64             // Starting LBA
	PartitionSize   uint64             // Size in number of LBAs
	Signature       HardDriveSignature // Signature, the type of which is implementation specific (GPT vs MBR)
	MBRType         MBRType            // Legacy MBR or GPT
}

HardDriveDevicePathNode corresponds to a hard drive device path node.

func NewHardDriveDevicePathNodeFromDevice

func NewHardDriveDevicePathNodeFromDevice(r io.ReaderAt, totalSz, blockSz int64, part int) (*HardDriveDevicePathNode, error)

NewHardDriveDevicePathNodeFromDevice constructs a HardDriveDevicePathNode for the specified partition on the supplied device reader. The device's total size and logical block size must be supplied.

func (*HardDriveDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *HardDriveDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*HardDriveDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*HardDriveDevicePathNode) String

func (n *HardDriveDevicePathNode) String() string

ToString implements [DevicePathNode.ToString].

func (*HardDriveDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*HardDriveDevicePathNode) Write

func (n *HardDriveDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type HardDriveSignature added in v0.3.0

type HardDriveSignature interface {
	fmt.Stringer
	Data() [16]uint8              // the raw signature data
	Type() HardDriveSignatureType // Signature type
}

HardDriveSignature is an abstraction for a unique hard drive identifier.

type HardDriveSignatureType added in v0.3.0

type HardDriveSignatureType uint8

HardDriveSignatureType describes the type of unique identifier associated with a hard drive.

const (
	// NoHardDriveSignature indicates there is no signature. This can
	// be represented by the value EmptyHardDriveSignature.
	NoHardDriveSignature HardDriveSignatureType = uefi.NO_DISK_SIGNATURE

	// HardDriveSignatureTypeMBR indicates that the unique identifier
	// is a MBR unique signature. This is represented by the
	// MBRHardDriveSignature type.
	HardDriveSignatureTypeMBR HardDriveSignatureType = uefi.SIGNATURE_TYPE_MBR

	// HardDriveSignatureTypeGUID indicates that the unique identifier
	// is a GUID. This is represented by the GUIDHardDriveSignature type.
	HardDriveSignatureTypeGUID HardDriveSignatureType = uefi.SIGNATURE_TYPE_GUID
)

func (HardDriveSignatureType) String added in v0.3.0

func (t HardDriveSignatureType) String() string

String implements fmt.Stringer.

type IPProtocol added in v1.5.0

type IPProtocol uint16

IPProtocol describes an IP protocol

const (
	IPProtocolTCP IPProtocol = uefi.RFC_1700_TCP_PROTOCOL
	IPProtocolUDP IPProtocol = uefi.RFC_1700_UDP_PROTOCOL
)

func (IPProtocol) String added in v1.5.0

func (p IPProtocol) String() string

String implements fmt.Stringer.

type IPv4Address added in v1.5.0

type IPv4Address [4]uint8

IPv4Address corresponds to an IP v4 address.

func (IPv4Address) AsNetIPAddr added in v1.5.0

func (a IPv4Address) AsNetIPAddr() netip.Addr

AsNetIPAddr returns the address as a netip.Addr.

func (IPv4Address) String added in v1.5.0

func (a IPv4Address) String() string

String implements fmt.Stringer.

type IPv4AddressOrigin added in v1.5.0

type IPv4AddressOrigin bool

IPv4AddressOrigin describes how an IP v4 address was assigned.

const (
	IPv4AddressDHCPAssigned IPv4AddressOrigin = false // Assigned by a DHCP server.
	StaticIPv4Address       IPv4AddressOrigin = true  // Statically assigned.
)

func (IPv4AddressOrigin) String added in v1.5.0

func (o IPv4AddressOrigin) String() string

String implements fmt.Stringer.

type IPv4DevicePathNode added in v1.5.0

type IPv4DevicePathNode struct {
	LocalAddress       IPv4Address       // Local IP address
	RemoteAddress      IPv4Address       // Remote IP address
	LocalPort          uint16            // Local port (if Protocol is IPProtocolTCP or IPProtocolUDP)
	RemotePort         uint16            // Remote port (if Protocol is IPProtocolTCP or IPProtocolUDP)
	Protocol           IPProtocol        // IP protocol
	LocalAddressOrigin IPv4AddressOrigin // The origin of the local address (static or DHCP)
	GatewayAddress     IPv4Address       // Gateway IP address
	SubnetMask         IPv4Address       // Used to determine the range of IP addresses on the subnet associated with LocalAddress
}

IPv4DevicePathNode corresponds to an IPv4 address device path node.

func (*IPv4DevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *IPv4DevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*IPv4DevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*IPv4DevicePathNode) String added in v1.5.0

func (n *IPv4DevicePathNode) String() string

String implements fmt.Stringer.

func (*IPv4DevicePathNode) ToString added in v1.5.0

ToString implements [DevicePathNode.ToString].

func (*IPv4DevicePathNode) Write added in v1.5.0

func (n *IPv4DevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type IPv6Address added in v1.5.0

type IPv6Address [16]uint8

IPv6Address corresponds to an IP v6 address.

func (IPv6Address) AsNetIPAddr added in v1.5.0

func (a IPv6Address) AsNetIPAddr() netip.Addr

AsNetIPAddr returns the address as a netip.Addr.

func (IPv6Address) String added in v1.5.0

func (a IPv6Address) String() string

String implements fmt.Stringer.

type IPv6AddressOrigin added in v1.5.0

type IPv6AddressOrigin uint8

IPv6AddressOrigin describes how an IP v6 address was assigned.

const (
	StaticIPv6Address        IPv6AddressOrigin = 0 // Statically assigned.
	IPv6AddressSLAACAssigned IPv6AddressOrigin = 1 // Assigned using SLAAC.
	IPv6AddressDHCPAssigned  IPv6AddressOrigin = 2 // Assigned by a DHCPv6 server.
)

func (IPv6AddressOrigin) String added in v1.5.0

func (o IPv6AddressOrigin) String() string

String implements fmt.Stringer.

type IPv6DevicePathNode added in v1.5.0

type IPv6DevicePathNode struct {
	LocalAddress       IPv6Address       // Local IP address
	RemoteAddress      IPv6Address       // Remote IP address
	LocalPort          uint16            // Local port (if Protocol is IPProtocolTCP or IPProtocolUDP)
	RemotePort         uint16            // Remote port (if Protocol is IPProtocolTCP or IPProtocolUDP)
	Protocol           IPProtocol        // IP protocol
	LocalAddressOrigin IPv6AddressOrigin // The origin of the local address (static, SLAAC, or DHCPv6)
	PrefixLength       uint8             // Prefix length in bits - used to determine the range of IP addresses on the subnet associated with LocalAddress
	GatewayAddress     IPv6Address       // Gateway IP address
}

IPv6DevicePathNode corresponds to an IPv6 address device path node.

func (*IPv6DevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *IPv6DevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*IPv6DevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*IPv6DevicePathNode) String added in v1.5.0

func (n *IPv6DevicePathNode) String() string

String implements fmt.Stringer.

func (*IPv6DevicePathNode) ToString added in v1.5.0

ToString implements [DevicePathNode.ToString].

func (*IPv6DevicePathNode) Write added in v1.5.0

func (n *IPv6DevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type InconsistentSecureBootModeError added in v0.9.6

type InconsistentSecureBootModeError struct {
	// contains filtered or unexported fields
}

InconsistentSecureBootModeError is returned from ComputeSecureBootMode if some of the variables are in an inconsistent state.

func (*InconsistentSecureBootModeError) Error added in v0.9.6

func (*InconsistentSecureBootModeError) Unwrap added in v0.9.6

type InvalidGPTHeaderError

type InvalidGPTHeaderError string

func (InvalidGPTHeaderError) Error

func (e InvalidGPTHeaderError) Error() string

type LBA

type LBA uint64

LBA corresponds to the EFI_LBA type.

type LoadOption

type LoadOption struct {
	Attributes   LoadOptionAttributes
	Description  string
	FilePath     DevicePath
	OptionalData []byte
}

LoadOption corresponds to the EFI_LOAD_OPTION type.

func ReadBootNextLoadOptionVariable added in v0.9.6

func ReadBootNextLoadOptionVariable(ctx context.Context) (*LoadOption, error)

ReadBootNextLoadOptionVariable returns the LoadOption for the boot entry to try next. In general DefaultVarContext should be supplied to this.

func ReadLoadOption

func ReadLoadOption(r io.Reader) (out *LoadOption, err error)

ReadLoadOption reads a LoadOption from the supplied io.Reader. Due to the way that EFI_LOAD_OPTION is defined, where there is no size encoded for the OptionalData field, this function will consume all of the bytes available from the supplied reader.

func ReadLoadOptionVariable added in v0.9.6

func ReadLoadOptionVariable(ctx context.Context, class LoadOptionClass, n uint16) (*LoadOption, error)

ReadLoadOptionVariable returns the LoadOption for the specified class and option number. The variable is read from the global namespace. In general DefaultVarContext should be supplied to this.

func ReadOrderedLoadOptionVariables added in v0.9.6

func ReadOrderedLoadOptionVariables(ctx context.Context, class LoadOptionClass) ([]*LoadOption, error)

ReadOrderedLoadOptionVariables returns a list of LoadOptions in the order in which they will be tried by the boot manager for the specified class. The variables are all read from the global namespace. Where class is LoadOptionClassDriver, LoadOptionClassSysPrep, or LoadOptionClassBoot, this will use the corresponding *Order variable. It will skip entries for which there isn't a corresponding variable. Where class is LoadOptionClassPlatformRecovery, the order is determined by the variable names. In general DefaultVarContext should be supplied to this.

func (*LoadOption) Bytes added in v0.2.0

func (o *LoadOption) Bytes() ([]byte, error)

Bytes returns the serialized form of this load option.

func (*LoadOption) IsActive added in v0.9.6

func (o *LoadOption) IsActive() bool

IsActive indicates whether the attributes has the LOAD_OPTION_ACTIVE flag set. These will be tried automatically if they are in BootOrder.

func (*LoadOption) IsAppCategory added in v0.9.6

func (o *LoadOption) IsAppCategory() bool

IsAppCategory indicates whether the attributes has the LOAD_OPTION_CATEGORY_APP flag set.

func (*LoadOption) IsBootCategory added in v0.9.6

func (o *LoadOption) IsBootCategory() bool

IsBootCategory indicates whether the attributes has the LOAD_OPTION_CATEGORY_BOOT flag set. These applications are typically part of the boot process.

func (*LoadOption) IsVisible added in v0.9.6

func (o *LoadOption) IsVisible() bool

IsVisible indicates whether the attributes does not have the LOAD_OPTION_HIDDEN flag set.

func (*LoadOption) String

func (o *LoadOption) String() string

String implements fmt.Stringer.

func (*LoadOption) Write

func (o *LoadOption) Write(w io.Writer) error

Write serializes this load option to the supplied io.Writer.

type LoadOptionAttributes added in v0.1.2

type LoadOptionAttributes uint32

LoadOptionAttributes corresponds to the attributes of a load option

func (LoadOptionAttributes) IsAppCategory added in v0.9.6

func (a LoadOptionAttributes) IsAppCategory() bool

IsAppCategory indicates whether the attributes has the LOAD_OPTION_CATEGORY_APP flag set.

func (LoadOptionAttributes) IsBootCategory added in v0.9.6

func (a LoadOptionAttributes) IsBootCategory() bool

IsBootCategory indicates whether the attributes has the LOAD_OPTION_CATEGORY_BOOT flag set. These applications are typically part of the boot process.

type LoadOptionClass added in v0.9.6

type LoadOptionClass string

LoadOptionClass describes a class of load option

const (
	// LoadOptionClassDriver corresponds to drivers that are processed before
	// normal boot options and before the initial ready to boot signal.
	LoadOptionClassDriver LoadOptionClass = "Driver"

	// LadOptionClassSysPrep corresponds to system preparation applications that
	// are processed before normal boot options and before the initial
	// ready to boot signal.
	LoadOptionClassSysPrep LoadOptionClass = "SysPrep"

	// LoadOptionClassBoot corresponds to normal boot applications.
	LoadOptionClassBoot LoadOptionClass = "Boot"

	// LoadOptionClassPlatformRecovery corresponds to platform supplied recovery
	// applications.
	LoadOptionClassPlatformRecovery LoadOptionClass = "PlatformRecovery"
)

func ScanLoadOptionVariableName added in v1.7.0

func ScanLoadOptionVariableName(name string) (LoadOptionClass, uint16, error)

ScanLoadOptionVariableName returns the load option class and load option number from the specified variable name. This will return an error if the supplied name is too short, contains an unrecognized load option class or an invalid load option number.

type MACAddrDevicePathNode added in v1.5.0

type MACAddrDevicePathNode struct {
	MACAddress MACAddress
	IfType     NetworkInterfaceType
}

MACAddrDevicePathNode corresponds to a MAC address device path node.

func (*MACAddrDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *MACAddrDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*MACAddrDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*MACAddrDevicePathNode) String added in v1.5.0

func (n *MACAddrDevicePathNode) String() string

String implements fmt.Stringer.

func (*MACAddrDevicePathNode) ToString added in v1.5.0

ToString implements [DevicePathNode.ToString].

func (*MACAddrDevicePathNode) Write added in v1.5.0

func (n *MACAddrDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type MACAddress added in v1.5.0

type MACAddress interface {
	fmt.Stringer

	// Bytes32 returns the address as a 32-byte left-aligned, zero padded array,
	// which is how MAC addresses are represented in UEFI.
	Bytes32() [32]uint8

	Type() MACAddressType // Address type
}

MACAddress is an abstraction for a MAC address.

type MACAddressType added in v1.5.0

type MACAddressType int

MACAddressType describes the type of a MAC address.

const (
	MACAddressTypeUnknown MACAddressType = iota // an unknown address type
	MACAddressTypeEUI48                         // EUI-48 address type
	MACAddressTypeEUI64                         // EUI-64 address type
)

type MBRHardDriveSignature added in v0.3.0

type MBRHardDriveSignature uint32

MBRHardDriveSignature is a HardDriveSignature for legacy MBR drives.

func (MBRHardDriveSignature) Data added in v0.3.0

func (s MBRHardDriveSignature) Data() (out [16]uint8)

Data implements [HardDriveSignature.Data].

func (MBRHardDriveSignature) String added in v0.3.0

func (s MBRHardDriveSignature) String() string

String implements fmt.Stringer.

func (MBRHardDriveSignature) Type added in v0.3.0

Type implements [HardDriveSignature.Type].

type MBRType

type MBRType uint8

MBRType describes a disk header type

const (
	// LegacyMBR indicates that a disk has a MBR header.
	LegacyMBR MBRType = uefi.MBR_TYPE_PCAT

	// GPT indicates that a disk has a GPT header.
	GPT MBRType = uefi.MBR_TYPE_EFI_PARTITION_TABLE_HEADER
)

func (MBRType) String added in v0.3.0

func (t MBRType) String() string

String implements fmt.Stringer.

type MediaFvDevicePathNode deprecated

type MediaFvDevicePathNode = FWVolDevicePathNode

MediaFvDevicePathNode corresponds to a firmware volume device path node.

Deprecated: use FWVolDevicePathNode.

type MediaFvFileDevicePathNode deprecated

type MediaFvFileDevicePathNode = FWFileDevicePathNode

MediaFvFileDevicePathNode corresponds to a firmware volume file device path node.

Deprecated: use FWFileDevicePathNode.

type MediaRelOffsetRangeDevicePathNode

type MediaRelOffsetRangeDevicePathNode struct {
	StartingOffset uint64
	EndingOffset   uint64
}

func (*MediaRelOffsetRangeDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *MediaRelOffsetRangeDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*MediaRelOffsetRangeDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*MediaRelOffsetRangeDevicePathNode) String

String implements fmt.Stringer.

func (*MediaRelOffsetRangeDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*MediaRelOffsetRangeDevicePathNode) Write

Write implements [DevicePathNode.Write].

type NVMENamespaceDevicePathNode

type NVMENamespaceDevicePathNode struct {
	NamespaceID   uint32 // Namespace identifier
	NamespaceUUID EUI64  // EUI-64 unique identifier. This is set to 0 where not supported
}

NVMENamespaceDevicePathNode corresponds to a NVME namespace device path node.

func (*NVMENamespaceDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *NVMENamespaceDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*NVMENamespaceDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*NVMENamespaceDevicePathNode) String

func (n *NVMENamespaceDevicePathNode) String() string

String implements fmt.Stringer.

func (*NVMENamespaceDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*NVMENamespaceDevicePathNode) Write

Write implements [DevicePathNode.Write].

type NetworkInterfaceType added in v1.5.0

type NetworkInterfaceType uint8

NetworkInterfaceType describes the type of network hardware.

const (
	NetworkInterfaceTypeReserved NetworkInterfaceType = 0
	NetworkInterfaceTypeEthernet NetworkInterfaceType = 1
)

type OSIndications added in v0.9.6

type OSIndications uint64

OSIndications provides a way for the firmware to advertise features to the OS and a way to request the firmware perform a specific action on the next boot.

func ReadOSIndicationsSupportedVariable added in v0.9.6

func ReadOSIndicationsSupportedVariable(ctx context.Context) (OSIndications, error)

ReadOSIndicationsSupportedVariable returns the value of the OSIndicationsSupported variable in the global namespace. In general DefaultVarContext should be supplied to this.

type PCIDevicePathNode

type PCIDevicePathNode struct {
	Function uint8 // Function of device
	Device   uint8 // Device number of PCI bus
}

PCIDevicePathNode corresponds to a PCI device path node.

func (*PCIDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *PCIDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*PCIDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*PCIDevicePathNode) String

func (n *PCIDevicePathNode) String() string

String implements fmt.Stringer.

func (*PCIDevicePathNode) ToString added in v0.3.0

func (*PCIDevicePathNode) Write

func (n *PCIDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type PartitionEntry

type PartitionEntry struct {
	PartitionTypeGUID   GUID
	UniquePartitionGUID GUID
	StartingLBA         LBA
	EndingLBA           LBA
	Attributes          uint64
	PartitionName       string
}

PartitionEntry corresponds to the EFI_PARTITION_ENTRY type.

func ReadPartitionEntries

func ReadPartitionEntries(r io.Reader, num, sz uint32) ([]*PartitionEntry, error)

ReadPartitionEntries reads the specified number of EFI_PARTITION_ENTRY structures of the specified size from the supplied io.Reader. The number and size are typically defined by the partition table header.

func ReadPartitionEntry

func ReadPartitionEntry(r io.Reader) (*PartitionEntry, error)

ReadPartitionEntry reads a single EFI_PARTITION_ENTRY from r.

func (*PartitionEntry) String

func (e *PartitionEntry) String() string

String implements fmt.Stringer.

func (*PartitionEntry) Write

func (e *PartitionEntry) Write(w io.Writer) error

Write serializes this PartitionEntry to w. Note that it doesn't write any bytes beyond the end of the EFI_PARTITION_ENTRY structure, so if the caller is writing several entries and the partition table header defines an entry size of greater than 128 bytes, the caller is responsible for inserting the 0 padding bytes.

type PartitionTable

type PartitionTable struct {
	Hdr     *PartitionTableHeader
	Entries []*PartitionEntry
}

PartitionTable describes a complete GUID partition table.

func ReadPartitionTable

func ReadPartitionTable(r io.ReaderAt, totalSz, blockSz int64, role PartitionTableRole, checkCrc bool) (*PartitionTable, error)

ReadPartitionTable reads a complete GUID partition table from the supplied io.Reader. The total size and logical block size of the device must be supplied - the logical block size is 512 bytes for a file, but must be obtained from the kernel for a block device.

This function expects the device to have a valid protective MBR.

If role is PrimaryPartitionTable, this will read the primary partition table that is located immediately after the protective MBR. If role is BackupPartitionTable, this will read the backup partition table that is located at the end of the device.

If checkCrc is true and either CRC check fails for the requested table, an error will be returned. Setting checkCrc to false disables the CRC checks.

Note that whilst this function checks the integrity of the header and partition table entries, it does not check the contents of the partition table entries.

If role is BackupPartitionTable and the backup table is not located at the end of the device, this will return ErrInvalidBackupPartitionTableLocation along with the valid table.

func (*PartitionTable) String added in v0.4.0

func (t *PartitionTable) String() string

String implements fmt.Stringer.

type PartitionTableHeader

type PartitionTableHeader struct {
	HeaderSize               uint32
	MyLBA                    LBA
	AlternateLBA             LBA
	FirstUsableLBA           LBA
	LastUsableLBA            LBA
	DiskGUID                 GUID
	PartitionEntryLBA        LBA
	NumberOfPartitionEntries uint32
	SizeOfPartitionEntry     uint32
	PartitionEntryArrayCRC32 uint32
}

PartitionTableHeader corresponds to the EFI_PARTITION_TABLE_HEADER type.

func ReadPartitionTableHeader

func ReadPartitionTableHeader(r io.Reader, checkCrc bool) (*PartitionTableHeader, error)

ReadPartitionTableHeader reads a EFI_PARTITION_TABLE_HEADER from the supplied io.Reader. If the header signature or revision is incorrect, an error will be returned. If checkCrc is true and the header has an invalid CRC, an error will be returned. If checkCrc is false, then a CRC check is not performed.

func (*PartitionTableHeader) String added in v0.4.0

func (h *PartitionTableHeader) String() string

func (*PartitionTableHeader) Write

func (h *PartitionTableHeader) Write(w io.Writer) error

Write serializes this PartitionTableHeader to w. The CRC field is computed automatically.

type PartitionTableRole

type PartitionTableRole int

PartitionTableRole describes the role of a partition table.

const (
	PrimaryPartitionTable PartitionTableRole = iota
	BackupPartitionTable
)

type PhysicalAddress

type PhysicalAddress uint64

type SATADevicePathNode

type SATADevicePathNode struct {
	HBAPortNumber            uint16 // The zero indexed port number on the HBA
	PortMultiplierPortNumber uint16 // The port multiplier (or 0xFFFF if the device is connected directly to the HBA)
	LUN                      uint16 // Logical unit number
}

SATADevicePathNode corresponds to a SATA device path node.

func (*SATADevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *SATADevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*SATADevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*SATADevicePathNode) String

func (n *SATADevicePathNode) String() string

String implements fmt.Stringer.

func (*SATADevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*SATADevicePathNode) Write

func (n *SATADevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type SCSIDevicePathNode

type SCSIDevicePathNode struct {
	PUN uint16 // Target ID on the SCSI bus
	LUN uint16 // Logical unit number
}

SCSIDevicePathNode corresponds to a SCSI device path node.

func (*SCSIDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *SCSIDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*SCSIDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*SCSIDevicePathNode) String

func (n *SCSIDevicePathNode) String() string

String implements fmt.Stringer.

func (*SCSIDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*SCSIDevicePathNode) Write

func (n *SCSIDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type SecureBootMode added in v0.9.6

type SecureBootMode int

SecureBootMode describes the secure boot mode of a platform.

const (
	// SetupMode indicates that a platform is in setup mode. In this mode, no platform
	// key is enrolled and secure boot cannot be enabled. Writes to secure boot
	// variables other than PK can be performed without authentication.
	//
	// SetupMode can transition to UserMode by enrolling a platform key, which can be
	// done from the OS by performing a self-signed authenticated write to the PK
	// global variable.
	//
	// Since UEFI 2.5, SetupMode can transition to AuditMode by writing 1 to the
	// AuditMode global variable before ExitBootServices.
	SetupMode SecureBootMode = iota + 1

	// AuditMode indicates that a platform is in audit mode. This mode implies setup
	// mode - no platform key is enrolled and secure boot cannot be enabled. Writes to
	// secure boot variables other than PK can be performed without authentication.
	//
	// AuditMode provides a way of ensuring that the current signature database
	// configuration is able to authenticate an OS without preventing it from booting
	// if authentication fails.
	//
	// AuditMode can transition to DeployedMode by enrolling a platform key, which can be
	// done from the OS by performing a self-signed authenticated write to the PK
	// global variable.
	//
	// AuditMode only exists since UEFI 2.5.
	AuditMode

	// UserMode indicates that a platform is in user mode. In this mode, a platform
	// key is enrolled and secure boot can be enabled (but may be disabled using some
	// platform specific mechanism). Writes to secure boot variables require authentication.
	//
	// UserMode can transition to SetupMode by erasing the platform key, either via
	// some platform specific mechanism or by an authenticated write of an empty payload
	// to the PK global variable.
	//
	// Since UEFI 2.5, UserMode can transition to AuditMode by writing 1 to the AuditMode
	// global variable before ExitBootServices.
	//
	// Since UEFI 2.5, UserMode can transition to DeployedMode by writing 1 to the
	// DeployedMode global variable before ExitBootServices.
	UserMode

	// DeployedMode indicates that a platform is in deployed mode. In this mode, a
	// platform key is enrolled and secure boot can be enabled (but may be disabled using
	// some platform specific mechanism. Writes to secure boot variables require
	// authentication. This is the most secure mode.
	//
	// DeployedMode may transition back to UserMode by some optional platform specific
	// mechanism which clears the DeployedMode variable.
	//
	// DeployedMode exists since UEFI 2.5.
	DeployedMode
)

func ComputeSecureBootMode added in v0.9.6

func ComputeSecureBootMode(ctx context.Context) (SecureBootMode, error)

ComputeSecureBootMode determines the secure boot mode of a platform. In general, DefaultVarContext should be supplied to this.

type SignatureData

type SignatureData struct {
	Owner GUID
	Data  []byte
}

SignatureData corresponds to the EFI_SIGNATURE_DATA type.

func (*SignatureData) Equal

func (d *SignatureData) Equal(other *SignatureData) bool

Equal determines whether other is equal to this SignatureData

func (*SignatureData) Write

func (d *SignatureData) Write(w io.Writer) error

Write serializes this signature data to w.

type SignatureDatabase

type SignatureDatabase []*SignatureList

SignatureDatabase corresponds to a list of EFI_SIGNATURE_LIST structures.

func ReadSignatureDatabase

func ReadSignatureDatabase(r io.Reader) (SignatureDatabase, error)

ReadSignatureDatabase decodes a list of EFI_SIGNATURE_LIST structures from r.

func ReadSignatureDatabaseVariable added in v0.9.6

func ReadSignatureDatabaseVariable(ctx context.Context, desc VariableDescriptor) (SignatureDatabase, error)

ReadSignatureDatabaseVariable reads the signature database from the supplied variable. In general, DefaultVarContext should be supplied to this.

func (SignatureDatabase) Bytes added in v0.2.0

func (db SignatureDatabase) Bytes() ([]byte, error)

Bytes returns the serialized form of this signature database.

func (SignatureDatabase) String

func (db SignatureDatabase) String() string

func (SignatureDatabase) Write

func (db SignatureDatabase) Write(w io.Writer) error

Write serializes this signature database to w.

type SignatureList

type SignatureList struct {
	Type       GUID
	Header     []byte
	Signatures []*SignatureData
}

SignatureList corresponds to the EFI_SIGNATURE_LIST type.

func ReadSignatureList

func ReadSignatureList(r io.Reader) (*SignatureList, error)

ReadSignatureList decodes a single EFI_SIGNATURE_LIST from r.

func (*SignatureList) String

func (l *SignatureList) String() string

func (*SignatureList) Write

func (l *SignatureList) Write(w io.Writer) error

Write serializes this signature list to w.

type USBClass

type USBClass uint8

USBClass defines the base class of a USB interface.

const (
	USBClassAudio       USBClass = 0x01
	USBClassCDCControl  USBClass = 0x02
	USBClassHID         USBClass = 0x03
	USBClassImage       USBClass = 0x06
	USBClassPrinter     USBClass = 0x07
	USBClassMassStorage USBClass = 0x08
	USBClassHub         USBClass = 0x09
	USBClassCDCData     USBClass = 0x0a
	USBClassSmartCard   USBClass = 0x0b
	USBClassVideo       USBClass = 0x0e
	USBClassDiagnostic  USBClass = 0xdc
	USBClassWireless    USBClass = 0xe0
	USBClassAppSpecific USBClass = 0xfe
)

func (USBClass) String added in v1.5.0

func (c USBClass) String() string

String implements fmt.Stringer.

type USBClassDevicePathNode

type USBClassDevicePathNode struct {
	VendorId       uint16
	ProductId      uint16
	DeviceClass    USBClass
	DeviceSubClass USBSubClass
	DeviceProtocol USBProtocol
}

USBClassDevicePathNode corresponds to a USB class device path node.

func (*USBClassDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *USBClassDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*USBClassDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*USBClassDevicePathNode) String

func (n *USBClassDevicePathNode) String() string

String implements fmt.Stringer.

func (*USBClassDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*USBClassDevicePathNode) Write

func (n *USBClassDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type USBDevicePathNode

type USBDevicePathNode struct {
	ParentPortNumber uint8
	InterfaceNumber  uint8
}

USBDevicePathNode corresponds to a USB device path node.

func (*USBDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *USBDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*USBDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*USBDevicePathNode) String

func (n *USBDevicePathNode) String() string

String implements fmt.Stringer.

func (*USBDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*USBDevicePathNode) Write

func (n *USBDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type USBProtocol added in v1.5.0

type USBProtocol uint8

USBProtocol defines the protocol of a USB interface. The meaning of this is dependent on the values of USBClass and USBSubClass.

type USBSubClass added in v1.5.0

type USBSubClass uint8

USBSubClass defines the sub class of a USB interface. The meaning of this is dependent on the value of USBClass.

const (
	USBSubClassAppSpecificFWUpdate           USBSubClass = 0x01
	USBSubClassAppSpecificIRDABridge         USBSubClass = 0x02
	USBSubClassAppSpecificTestAndMeasurement USBSubClass = 0x03
)

type USBWWIDDevicePathNode

type USBWWIDDevicePathNode struct {
	InterfaceNumber uint16
	VendorId        uint16
	ProductId       uint16
	SerialNumber    string
}

USBWWIDDevicePathNode corresponds to a USB WWID device path node.

func (*USBWWIDDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *USBWWIDDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*USBWWIDDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*USBWWIDDevicePathNode) String

func (n *USBWWIDDevicePathNode) String() string

String implements fmt.Stringer.

func (*USBWWIDDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*USBWWIDDevicePathNode) Write

func (n *USBWWIDDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type VariableAttributes

type VariableAttributes uint32

func ReadVariable added in v0.1.2

func ReadVariable(ctx context.Context, name string, guid GUID) ([]byte, VariableAttributes, error)

ReadVariable returns the value and attributes of the EFI variable with the specified name and GUID. In general, DefaultVarContext or the result of WithDefaultVarsBackend should be supplied to this. This will return an error if the context is done.

type VariableAuthentication

type VariableAuthentication struct {
	MonotonicCount uint64
	AuthInfo       WinCertificateGUID
}

VariableAuthentication corresponds to the EFI_VARIABLE_AUTHENTICATION type and is used to authenticate updates to variables with the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute set.

func ReadVariableAuthentication

func ReadVariableAuthentication(r io.Reader) (*VariableAuthentication, error)

ReadVariableAuthentication decodes an authentication header for updating a variable with the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute set.

type VariableAuthentication2

type VariableAuthentication2 struct {
	TimeStamp time.Time
	AuthInfo  WinCertificateGUID
}

VariableAuthentication2 corresponds to the EFI_VARIABLE_AUTHENTICATION_2 type and is used to authenticate updates to variables with the EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute set.

func ReadTimeBasedVariableAuthentication

func ReadTimeBasedVariableAuthentication(r io.Reader) (*VariableAuthentication2, error)

ReadTimeBasedVariableAuthentication decodes an authentication header for updating a variable with the EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute set.

type VariableAuthentication3

type VariableAuthentication3 interface {
	Type() VariableAuthentication3Type // The authentication type (timestamp or nonce)
	NewCert() WinCertificateGUID       // Optional new certificate in order to rotate the signing key for authenticated writes.
	SigningCert() WinCertificateGUID   // The certificate associated with the current signing key.
}

VariableAuthentication3 is used to authenticate updates to variables with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set.

func ReadEnhancedVariableAuthentication

func ReadEnhancedVariableAuthentication(r io.Reader) (VariableAuthentication3, error)

ReadEnhancedVariableAuthentication decodes the authentication header for updating variables with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set.

type VariableAuthentication3CertId

type VariableAuthentication3CertId interface {
	// Type describes the format of this certificate ID.
	Type() VariableAuthentication3CertIdType

	// Matches determines whether the specified certificate matches this ID.
	Matches(cert *x509.Certificate) bool
}

VariableAuthentication3CertId corresponds to the EFI_VARIABLE_AUTHENTICATION_3_CERT_ID type and represents the identification of an authority certificate associated with a variable that has the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set.

type VariableAuthentication3CertIdSHA256 added in v0.9.0

type VariableAuthentication3CertIdSHA256 [32]byte

VariableAuthentication3CertIdSHA256 corresponds to a EFI_VARIABLE_AUTHENTICATION_3_CERT_ID with a type of EFI_VARIABLE_AUTHENTICATION_3_CERT_ID_SHA256 and is the SHA-256 digest of the TBS content of a X.509 certificate.

func (VariableAuthentication3CertIdSHA256) Matches added in v0.9.0

Matches implements [VariableAuthentication3CertId.Matches].

func (VariableAuthentication3CertIdSHA256) Type added in v1.5.0

Type implements [VariableAuthentication3CertId.Type].

type VariableAuthentication3CertIdType added in v1.5.0

type VariableAuthentication3CertIdType uint8

VariableAuthentication3CertIdType describes the format of the certificate ID.

const (
	// VariableAuthentication3CertIdSHA256Type indicates that a
	VariableAuthentication3CertIdSHA256Type VariableAuthentication3CertIdType = uefi.EFI_VARIABLE_AUTHENTICATION_3_CERT_ID_SHA256
)

type VariableAuthentication3Descriptor

type VariableAuthentication3Descriptor interface {
	Type() VariableAuthentication3Type // The authentication type (timestamp or nonce).
	Id() VariableAuthentication3CertId // The ID of the authority associated with the variable.
}

VariableAuthentication3Descriptor corresponds to the authentication descriptor provided when reading the payload of a variable with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set.

func ReadEnhancedAuthenticationDescriptor

func ReadEnhancedAuthenticationDescriptor(r io.Reader) (VariableAuthentication3Descriptor, error)

ReadEnhancedAuthenticationDescriptor decodes the enhanced authentication descriptor from the supplied reader. The supplied reader will typically read from the payload area of a variable with the EFI_VARIABLE_ENHANCED_AUTHENTICATION_ACCESS attribute set.

type VariableAuthentication3Nonce

type VariableAuthentication3Nonce struct {
	Nonce []byte
	// contains filtered or unexported fields
}

VariableAuthentication3Nonce is used to authenticate updates to variables with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set, and a type of EFI_VARIABLE_AUTHENTICATION_3_NONCE_TYPE.

func (*VariableAuthentication3Nonce) NewCert

func (a *VariableAuthentication3Nonce) NewCert() WinCertificateGUID

func (*VariableAuthentication3Nonce) SigningCert

func (a *VariableAuthentication3Nonce) SigningCert() WinCertificateGUID

func (*VariableAuthentication3Nonce) Type added in v0.9.0

Type implements [VariableAuthentication3.Type].

type VariableAuthentication3NonceDescriptor

type VariableAuthentication3NonceDescriptor struct {
	Nonce []byte
	// contains filtered or unexported fields
}

VariableAuthentication3NonceDescriptor corresponds to the authentication descriptor provided when reading the payload of a variable with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set, and a type of EFI_VARIABLE_AUTHENTICATION_3_NONCE_TYPE.

func (*VariableAuthentication3NonceDescriptor) Id added in v0.9.0

Id implements [VariableAuthentication3Descriptor.Id].

func (*VariableAuthentication3NonceDescriptor) Type added in v0.9.0

Type implements [VariableAuthentication3Descriptor.Type].

type VariableAuthentication3Timestamp

type VariableAuthentication3Timestamp struct {
	Timestamp time.Time
	// contains filtered or unexported fields
}

VariableAuthentication3Timestamp is used to authenticate updates to variables with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set, and a type of EFI_VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE.

func (*VariableAuthentication3Timestamp) NewCert

func (a *VariableAuthentication3Timestamp) NewCert() WinCertificateGUID

func (*VariableAuthentication3Timestamp) SigningCert

func (a *VariableAuthentication3Timestamp) SigningCert() WinCertificateGUID

func (*VariableAuthentication3Timestamp) Type added in v0.9.0

Type implements [VariableAuthentication3.Type].

type VariableAuthentication3TimestampDescriptor

type VariableAuthentication3TimestampDescriptor struct {
	TimeStamp time.Time
	// contains filtered or unexported fields
}

VariableAuthentication3TimestampDescriptor corresponds to the authentication descriptor provided when reading the payload of a variable with the EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS attribute set, and a type of EFI_VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE.

func (*VariableAuthentication3TimestampDescriptor) Id added in v0.9.0

Id implements [VariableAuthentication3Descriptor.Id].

func (*VariableAuthentication3TimestampDescriptor) Type added in v0.9.0

Type implements [VariableAuthentication3Descriptor.Type].

type VariableAuthentication3Type added in v0.9.0

type VariableAuthentication3Type int

VariableAuthentication3Type describes the type of VariableAuthentication3.

const (
	// VariableAuthentication3TimestampType indicates that a
	// VariableAuthentication3 is a timestamp based enhanced authentication
	// and is implemented by the *VariableAuthentication3Timestamp type.
	// It also indicates that the VariableAuthentication3Descriptor is
	// implemented by *VariableAuthentication3TimestampDescriptor.
	VariableAuthentication3TimestampType VariableAuthentication3Type = uefi.EFI_VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE

	// VariableAuthentication3iNonceType indicates that a
	// VariableAuthentication3 is a nonce based enhanced authentication
	// and is implemented by the *VariableAuthentication3Nonce type.
	// It also indicates that the VariableAuthentication3Descriptor is
	// implemented by *VariableAuthentication3NonceDescriptor.
	VariableAuthentication3NonceType VariableAuthentication3Type = uefi.EFI_VARIABLE_AUTHENTICATION_3_NONCE_TYPE
)

type VariableDescriptor added in v0.1.2

type VariableDescriptor struct {
	Name string
	GUID GUID
}

VariableDescriptor represents the identity of a variable.

var (
	// PKVariable corresponds to the PK global variable
	PKVariable VariableDescriptor = VariableDescriptor{Name: "PK", GUID: GlobalVariable}

	// KEKVariable corresponds to the KEK global variable
	KEKVariable VariableDescriptor = VariableDescriptor{Name: "KEK", GUID: GlobalVariable}

	// DbVariable corresponds to the authorized signature database variable
	DbVariable VariableDescriptor = VariableDescriptor{Name: "db", GUID: ImageSecurityDatabaseGuid}

	// DbxVariable corresponds to the forbidden signature database variable
	DbxVariable VariableDescriptor = VariableDescriptor{Name: "dbx", GUID: ImageSecurityDatabaseGuid}
)

func ListVariables added in v0.1.2

func ListVariables(ctx context.Context) ([]VariableDescriptor, error)

ListVariables returns a sorted list of variables that can be accessed. In general, DefaultVarContext or the result of WithDefaultVarsBackend should be supplied to this. This will return an error if the context is done.

type VarsBackend added in v0.9.6

type VarsBackend interface {
	Get(name string, guid GUID) (VariableAttributes, []byte, error)
	Set(name string, guid GUID, attrs VariableAttributes, data []byte) error
	List() ([]VariableDescriptor, error)
}

VarsBackend is used by the ReadVariable, WriteVariable and ListVariables functions, and indirectly by other functions in this package to abstract access to a specific backend. A default backend is initialized at process initialization and is available via DefaultVarContext.

type VarsBackend2 added in v1.2.0

type VarsBackend2 interface {
	Get(ctx context.Context, name string, guid GUID) (VariableAttributes, []byte, error)
	Set(ctx context.Context, name string, guid GUID, attrs VariableAttributes, data []byte) error
	List(ctx context.Context) ([]VariableDescriptor, error)
}

VarsBackend2 is like VarsBackend only it takes a context that the backend can use for deadlines or cancellation - this is particularly applicable on systems where there may be multiple writers and writes have to be serialized by the operating system to some degree.

type VarsBackendKey added in v1.0.0

type VarsBackendKey struct{}

VarsBackendKey is used to key a VarsBackend or VarsBackend2 on a context.Context.

type VendorDevicePathNode

type VendorDevicePathNode struct {
	Type DevicePathNodeType // The type of this node
	GUID GUID               // The vendor specific GUID
	Data []byte             // Vendor specific data
}

VendorDevicePathNode corresponds to a vendor specific node.

func (*VendorDevicePathNode) AsGenericDevicePathNode added in v1.5.0

func (n *VendorDevicePathNode) AsGenericDevicePathNode() (*GenericDevicePathNode, error)

AsGenericDevicePathNode implements [DevicePathNode.AsGenericDevicePathNode].

func (*VendorDevicePathNode) CompoundType added in v1.5.0

CompoundType implements [DevicePathNode.CompoundType].

func (*VendorDevicePathNode) String

func (n *VendorDevicePathNode) String() string

String implement fmt.Stringer.

func (*VendorDevicePathNode) ToString added in v0.3.0

ToString implements [DevicePathNode.ToString].

func (*VendorDevicePathNode) Write

func (n *VendorDevicePathNode) Write(w io.Writer) error

Write implements [DevicePathNode.Write].

type WinCertificate

type WinCertificate interface {
	Type() WinCertificateType // Type of this certificate
}

WinCertificate is an interface type corresponding to implementations of WIN_CERTIFICATE.

func ReadWinCertificate

func ReadWinCertificate(r io.Reader) (WinCertificate, error)

ReadWinCertificate decodes a signature (something that is confusingly represented by types with "certificate" in the name in both the UEFI and PE/COFF specifications) from the supplied reader and returns a WinCertificate of the appropriate type. The type returned is dependent on the data, and will be one of *WinCertificateAuthenticode, *WinCertificatePKCS1v15, *WinCertificatePKCS7 or *WinCertificateGUIDPKCS1v15.

type WinCertificateAuthenticode

type WinCertificateAuthenticode struct {
	// contains filtered or unexported fields
}

WinCertificateAuthenticode corresponds to a WIN_CERTIFICATE_EFI_PKCS and represents an Authenticode signature.

func (*WinCertificateAuthenticode) CertLikelyTrustAnchor deprecated added in v0.9.2

func (c *WinCertificateAuthenticode) CertLikelyTrustAnchor(cert *x509.Certificate) bool

CertLikelyTrustAnchor determines if the specified certificate is likely to be a trust anchor for this signature. This is "likely" because it only checks if there are candidate certificate chains rooted to the specified certificate. When attempting to build candidate certificate chains, it considers a certificate to be likely issued by another certificate if:

  • The certificate's issuer matches the issuer's subject.
  • The certificate's Authority Key Identifier keyIdentifier field matches the issuer's Subject Key Identifier.
  • The certificate's signature algorithm is compatible with the issuer's public key algorithm.

It performs no verification of any candidate certificate chains and no verification of the signature.

Deprecated: use [CertWithIDLikelyTrustAnchor].

func (*WinCertificateAuthenticode) CertWithIDLikelyTrustAnchor added in v1.4.0

func (c *WinCertificateAuthenticode) CertWithIDLikelyTrustAnchor(cert X509CertID) bool

CertWithIDLikelyTrustAnchor determines if the specified certificate is likely to be a trust anchor for this signature. This is "likely" because it only checks if there are candidate certificate chains rooted to the specified certificate. When attempting to build candidate certificate chains, it considers a certificate to be likely issued by another certificate if:

  • The certificate's issuer matches the issuer's subject.
  • The certificate's Authority Key Identifier keyIdentifier field matches the issuer's Subject Key Identifier.
  • The certificate's signature algorithm is compatible with the issuer's public key algorithm.

It performs no verification of any candidate certificate chains and no verification of the signature.

func (*WinCertificateAuthenticode) Digest added in v0.9.0

func (c *WinCertificateAuthenticode) Digest() []byte

Digest returns the PE image digest of the image associated with this signature.

func (*WinCertificateAuthenticode) DigestAlgorithm added in v0.9.0

func (c *WinCertificateAuthenticode) DigestAlgorithm() crypto.Hash

func (*WinCertificateAuthenticode) GetSigner added in v0.9.0

GetSigner returns the signing certificate.

func (*WinCertificateAuthenticode) Type added in v0.9.0

Type implements [WinCertificate.Type].

type WinCertificateGUID

type WinCertificateGUID interface {
	WinCertificate
	GUIDType() GUID
}

WinCertificateGUID corresponds to implementations of WIN_CERTIFICATE_UEFI_GUID.

type WinCertificateGUIDPKCS1v15 added in v0.9.0

type WinCertificateGUIDPKCS1v15 struct {
	PublicKey [256]byte
	Signature [256]byte
}

WinCertificateGUIDPKCS1v15 corresponds to a WIN_CERTIFICATE_UEFI_GUID with the EFI_CERT_TYPE_RSA2048_SHA256_GUID type, and represents a RSA2048 SHA256 signature with PKCS#1 v1.5 padding

func (*WinCertificateGUIDPKCS1v15) GUIDType added in v0.9.0

func (c *WinCertificateGUIDPKCS1v15) GUIDType() GUID

GUIDType implements [WinCertificateGUID.GUIDType].

func (*WinCertificateGUIDPKCS1v15) Type added in v0.9.0

Type implements [WinCertificate.Type].

type WinCertificateGUIDUnknown added in v0.9.0

type WinCertificateGUIDUnknown struct {
	Data []byte
	// contains filtered or unexported fields
}

WinCertificateGUIDUnknown corresponds to a WIN_CERTIFICATE_UEFI_GUID with an unknown type.

func (*WinCertificateGUIDUnknown) GUIDType added in v0.9.0

func (c *WinCertificateGUIDUnknown) GUIDType() GUID

GUIDType implements [WinCertificateGUID.GUIDType].

func (*WinCertificateGUIDUnknown) Type added in v0.9.0

Type implements [WinCertificate.Type].

type WinCertificatePKCS1v15 added in v0.1.2

type WinCertificatePKCS1v15 struct {
	HashAlgorithm crypto.Hash
	Signature     [256]byte
}

WinCertificatePKCS1v15 corresponds to the WIN_CERTIFICATE_EFI_PKCS1_15 type and represents a RSA2048 signature with PKCS#1 v1.5 padding.

func (*WinCertificatePKCS1v15) Type added in v0.9.0

Type implements [WinCertificate.Type].

type WinCertificatePKCS7 added in v0.9.0

type WinCertificatePKCS7 struct {
	// contains filtered or unexported fields
}

WinCertificatePKCS7 corresponds to a WIN_CERTIFICATE_UEFI_GUID with the EFI_CERT_TYPE_PKCS7_GUID type, and represents a detached PKCS7 signature.

func (*WinCertificatePKCS7) CertLikelyTrustAnchor added in v0.9.2

func (c *WinCertificatePKCS7) CertLikelyTrustAnchor(cert *x509.Certificate) bool

CertLikelyTrustAnchor determines if the specified certificate is likely to be a trust anchor for this signature. This is "likely" because it only checks if there are candidate certificate chains rooted to the specified certificate. When attempting to build candidate certificate chains, it considers a certificate to be likely issued by another certificate if:

  • The certificate's issuer matches the issuer's subject.
  • The certificate's Authority Key Identifier keyIdentifier field matches the issuer's Subject Key Identifier.
  • The certificate's signature algorithm is compatible with the issuer's public key algorithm.

It performs no verification of any candidate certificate chains and no verification of the signature.

Deprecate: use [CertWithIDLikelyTrustAnchor].

func (*WinCertificatePKCS7) CertWithIDLikelyTrustAnchor added in v1.4.0

func (c *WinCertificatePKCS7) CertWithIDLikelyTrustAnchor(cert X509CertID) bool

CertWithIDLikelyTrustAnchor determines if the specified certificate is likely to be a trust anchor for this signature. This is "likely" because it only checks if there are candidate certificate chains rooted to the specified certificate. When attempting to build candidate certificate chains, it considers a certificate to be likely issued by another certificate if:

  • The certificate's issuer matches the issuer's subject.
  • The certificate's Authority Key Identifier keyIdentifier field matches the issuer's Subject Key Identifier.
  • The certificate's signature algorithm is compatible with the issuer's public key algorithm.

It performs no verification of any candidate certificate chains and no verification of the signature.

func (*WinCertificatePKCS7) GUIDType added in v0.9.0

func (c *WinCertificatePKCS7) GUIDType() GUID

GUIDType implements [WinCertificateGUID.GUIDType].

func (*WinCertificatePKCS7) GetSigners added in v0.9.0

func (c *WinCertificatePKCS7) GetSigners() []*x509.Certificate

GetSigners returns the signing certificates.

func (*WinCertificatePKCS7) Type added in v0.9.0

Type implements [WinCertificate.Type].

type WinCertificateType added in v0.9.0

type WinCertificateType uint16
const (
	// WinCertificateTypeAuthenticode indicates that a WinCertificate
	// is an authenticode signature and is implemented by the
	// *WinCertificateAuthenticode type.
	WinCertificateTypeAuthenticode WinCertificateType = uefi.WIN_CERT_TYPE_PKCS_SIGNED_DATA

	// WinCertificatePKCS1v15 indicates that a WinCertificate is a
	// PKCS#1-v1.5 encoded RSA2048 signature and is implemented by
	// the *WinCertificatePKCS1v15 type.
	WinCertificateTypePKCS1v15 WinCertificateType = uefi.WIN_CERT_TYPE_EFI_PKCS115

	// WinCertificateTypeGUID indicates that a WinCertificate is a
	// signature of a type indicated by a separate GUID and is implemented
	// by a type that implements the WinCertificateGUID interface.
	WinCertificateTypeGUID WinCertificateType = uefi.WIN_CERT_TYPE_EFI_GUID
)

type X509CertID added in v1.4.0

type X509CertID interface {
	RawSubject() []byte                          // The encoded subject
	SubjectKeyId() []byte                        // The subject key ID
	PublicKeyAlgorithm() x509.PublicKeyAlgorithm // The certificate's public key algorithm

	RawIssuer() []byte                           // The encoded issuer
	AuthorityKeyId() []byte                      // The authority key ID
	SignatureAlgorithm() x509.SignatureAlgorithm // The algorithm the issuer used to sign the certificate
}

type X509CertID represents the identity of a X.509 certificate.

func NewX509CertIDFromCertificate added in v1.4.0

func NewX509CertIDFromCertificate(cert *x509.Certificate) X509CertID

NewX509CertIDFromCertificate returns a new X509CertID from the supplied certificate.

Directories

Path Synopsis
cmd
efi_devicepath command
Package guids provides a way to map well known firmware volume and file GUIDs to readable names.
Package guids provides a way to map well known firmware volume and file GUIDs to readable names.
generate command
internal
pe1.14
Package pe implements access to PE (Microsoft Windows Portable Executable) files.
Package pe implements access to PE (Microsoft Windows Portable Executable) files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL