config

package
v0.0.0-...-208c66a Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Overview

Package config provides parsing for the armory-boot configuration file format.

Index

Constants

View Source
const DefaultConfigPath = "/boot/armory-boot.conf"

DefaultConfigPath is the default armory-boot configuration file path.

View Source
const DefaultSignaturePath = "/boot/armory-boot.conf.sig"

DefaultSignaturePath is the default armory-boot configuration file signature path.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(buf []byte, s string) (valid bool)

CompareHash computes a SHA256 checksum of the input data, using hardware acceleration (NXP DCP), and compares the computed hash with the one passed as a string with only hexadecimal characters and even length.

As this function is meant for pre-boot use, the entire input buffer is copied in a DMA region for DCP consumption in a single pass, rather than buffering over multiple passes, to reduce DCP command overhead. When used in other contexts callers must ensure that enough DMA space is available.

This function is only meant to be used with `GOOS=tamago GOARCH=arm` on i.MX6 targets.

func Verify

func Verify(buf []byte, sig []byte, pubKey string) (err error)

Verify authenticates an input against a signify/minisign generated signature, pubKey must be the last line of a signify/minisign public key (i.e. without comments).

Types

type Config

type Config struct {
	// KernelPath is the path to a Linux kernel image.
	KernelPath []string `json:"kernel"`

	// DeviceTreeBlobPath is the path to a Linux DTB file.
	DeviceTreeBlobPath []string `json:"dtb"`

	// InitialRamDiskPath is the path to a Linux initrd file.
	InitialRamDiskPath []string `json:"initrd"`

	// CmdLine is the Linux kernel command-line parameters.
	CmdLine string `json:"cmdline"`

	// Unikernel is the path to an ELF unikernel image (e.g. TamaGo).
	UnikernelPath []string `json:"unikernel"`

	// ELF indicates whether the loaded kernel is a unikernel or not.
	ELF bool

	// JSON holds the configuration file contents
	JSON []byte
	// contains filtered or unexported fields
}

Config represents the armory-boot configuration.

func Load

func Load(part *disk.Partition, configPath string, sigPath string, pubKey string) (c *Config, err error)

Load reads an armory-boot configuration file, and optionally its signature, from a disk partition. The public key argument is used for signature authentication, a valid signature path must be present if a key is set.

func (*Config) DeviceTreeBlob

func (c *Config) DeviceTreeBlob() []byte

DeviceTreeBlob returns the contents of the dtb file previously loaded by a successful Load().

func (*Config) InitialRamDisk

func (c *Config) InitialRamDisk() []byte

InitialRamDisk returns the contents of the initrd image previously loaded by a successful Load().

func (*Config) Kernel

func (c *Config) Kernel() []byte

Kernel returns the contents of the kernel image previously loaded by a successful Load().

type PublicKey

type PublicKey struct {
	SignatureAlgorithm [2]byte
	KeyId              [8]byte
	PublicKey          [32]byte
}

func NewPublicKey

func NewPublicKey(publicKeyStr string) (PublicKey, error)

func (*PublicKey) Verify

func (publicKey *PublicKey) Verify(bin []byte, signature Signature) (bool, error)

type Signature

type Signature struct {
	UntrustedComment   string
	SignatureAlgorithm [2]byte
	KeyId              [8]byte
	Signature          [64]byte
	TrustedComment     string
	GlobalSignature    [64]byte
}

func DecodeSignature

func DecodeSignature(in string) (Signature, error)

Jump to

Keyboard shortcuts

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