ospkg

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: BSD-2-Clause Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DescriptorVersion int = 1
	// DescriptorExt is the file extension of OS package descriptor file.
	DescriptorExt string = ".json"
)
View Source
const (
	ManifestVersion int = 1
	// ManifestName is the name of OS packages' internal configuration file.
	ManifestName string = "manifest.json"
)
View Source
const (
	// DefaultOSPackageName is the file name of the archive, which is expected to contain
	// the stboot configuration file along with the corresponding files.
	DefaultOSPackageName string = "ospkg.zip"
	// OSPackageExt is the file extension of OS packages.
	OSPackageExt string = ".zip"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Descriptor

type Descriptor struct {
	Version int    `json:"version"`
	PkgURL  string `json:"os_pkg_url"`

	Certificates [][]byte `json:"certificates"`
	Signatures   [][]byte `json:"signatures"`
}

Descriptor represents the descriptor JSON file of an OS package.

func DescriptorFromBytes

func DescriptorFromBytes(data []byte) (*Descriptor, error)

DescriptorFromBytes parses a manifest from a byte slice.

func (*Descriptor) Bytes

func (d *Descriptor) Bytes() ([]byte, error)

Bytes serializes a manifest stuct into a byte slice.

func (*Descriptor) Validate

func (d *Descriptor) Validate() error

Validate returns true if d has valid content.

type FetchMethod added in v0.1.0

type FetchMethod int

FetchMethod controls where to load the OS package from.

const (
	FetchFromNetwork FetchMethod = iota + 1
	FetchFromInitramfs
)

Supported methods to fetch an OS package.

func (FetchMethod) IsValid added in v0.1.0

func (f FetchMethod) IsValid() bool

IsValid returns true if b is a defined FetchMethod value.

func (FetchMethod) MarshalJSON added in v0.1.0

func (f FetchMethod) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (FetchMethod) String added in v0.1.0

func (f FetchMethod) String() string

String implements fmt.Stringer.

func (*FetchMethod) UnmarshalJSON added in v0.1.0

func (f *FetchMethod) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OSManifest

type OSManifest struct {
	Version int    `json:"version"`
	Label   string `json:"label"`

	KernelPath    string `json:"kernel"`
	InitramfsPath string `json:"initramfs"`
	Cmdline       string `json:"cmdline"`
}

OSManifest describes the content and configuration of an OS package loaded by stboot.

func OSManifestFromBytes

func OSManifestFromBytes(data []byte) (*OSManifest, error)

OSManifestFromBytes parses a manifest from a byte slice.

func (*OSManifest) Bytes

func (m *OSManifest) Bytes() ([]byte, error)

Bytes serializes a manifest stuct into a byte slice.

func (*OSManifest) Validate

func (m *OSManifest) Validate() error

Validate returns no.

type OSPackage

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

OSPackage represents an OS package ZIP archive and related data.

func CreateOSPackage

func CreateOSPackage(label, pkgURL, kernel, initramfs, cmdline string) (*OSPackage, error)

CreateOSPackage constructs a OSPackage from the passed files.

func CreateOSPackageCtx added in v0.3.0

func CreateOSPackageCtx(ctx context.Context, label, pkgURL, kernel, initramfs, cmdline string) (*OSPackage, error)

func NewOSPackage

func NewOSPackage(archiveZIP, descriptorJSON []byte) (*OSPackage, error)

NewOSPackage constructs a new OSPackage initialized with raw bytes and valid internal state.

func (*OSPackage) ArchiveBytes

func (osp *OSPackage) ArchiveBytes() ([]byte, error)

ArchiveBytes returns the zip compressed archive part of osp.

func (*OSPackage) ArchiveHash added in v0.2.1

func (osp *OSPackage) ArchiveHash() [32]byte

func (*OSPackage) DescriptorBytes

func (osp *OSPackage) DescriptorBytes() ([]byte, error)

DescriptorBytes returns the descriptor part of osp as serialized bytes.

func (*OSPackage) DescriptorHash added in v0.2.1

func (osp *OSPackage) DescriptorHash() [32]byte

func (*OSPackage) LinuxImage

func (osp *OSPackage) LinuxImage() (boot.LinuxImage, error)

OSImage returns a LinuxImage from osp. LinuxImage implements boot.

func (*OSPackage) Sign

func (osp *OSPackage) Sign(signer crypto.Signer, certDER []byte) error

Signs osp.HashValue. Both the signature and the certificate are stored into the OSPackage.

func (*OSPackage) Verify

func (osp *OSPackage) Verify(rootCert *x509.Certificate) (found, valid int, err error)

Verify determines the number of unique certificates that chain up to (or is the) root certificate and which also produced valid OS package signatures.

Jump to

Keyboard shortcuts

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