coscel

package
v0.0.0-...-b60a159 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CosEventType indicates the CELR event is a COS content
	// TODO: the value needs to be reserved in the CEL spec
	CosEventType uint8 = 80
	// CosEventPCR is the PCR which should be used for CosEventType events.
	CosEventPCR = 13
	// CosRTMR is the RTMR to be extended for COS events
	// According to https://uefi.org/specs/UEFI/2.10/38_Confidential_Computing.html
	// CCELMRIndex      TDX Register
	// 0                   MRTD
	// 1                   RTMR[0]
	// 2                   RTMR[1]
	// 3                   RTMR[2]
	// So:
	// 4                   RTMR[3]
	CosRTMR = 3
	// CosCCELMRIndex is the CCMR index to use in eventlog for COS events.
	CosCCELMRIndex = 4
)

Variables

This section is empty.

Functions

func FormatEnvVar

func FormatEnvVar(name string, value string) (string, error)

FormatEnvVar takes in an environment variable name and its value, run some checks. Concats the name and value by '=' and returns it if valid; returns an error if the name or value is invalid.

func IsCosTlv

func IsCosTlv(t cel.TLV) bool

IsCosTlv check whether t is a COS TLV by its Type value.

func ParseEnvVar

func ParseEnvVar(envvar string) (string, string, error)

ParseEnvVar takes in environment variable as a string (foo=bar), parses it and returns its name and value, or an error if it fails the validation check.

Types

type CosTlv

type CosTlv struct {
	EventType    CosType
	EventContent []byte
}

CosTlv is a specific event type created for the COS (Google Container-Optimized OS), used as a CEL content.

func ParseToCosTlv

func ParseToCosTlv(t cel.TLV) (CosTlv, error)

ParseToCosTlv constructs a CosTlv from t. It will check for the correct COS event type, and unmarshal the nested event.

func (CosTlv) GenerateDigest

func (c CosTlv) GenerateDigest(hashAlgo crypto.Hash) ([]byte, error)

GenerateDigest generates the digest for the given COS TLV. The whole TLV struct will be marshaled to bytes and feed into the hash algo.

func (CosTlv) GetTLV

func (c CosTlv) GetTLV() (cel.TLV, error)

GetTLV returns the TLV representation of the COS TLV.

type CosType

type CosType uint8

CosType represent a COS content type in a CEL record content.

const (
	ImageRefType CosType = iota
	ImageDigestType
	RestartPolicyType
	ImageIDType
	ArgType
	EnvVarType
	OverrideArgType
	OverrideEnvType
	// EventContent is empty on success, or contains an error message on failure.
	LaunchSeparatorType
	MemoryMonitorType
)

Type for COS nested events

Jump to

Keyboard shortcuts

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