Documentation ¶
Index ¶
- func EqualSystemArtifacts(s0, s1 SystemArtifact) bool
- func GetSubSystemByTypeFromState[SS SubSystem](state *State) (SS, error)
- func GetSystemArtifactByTypeFromState[SA SystemArtifact](state *State) (SA, error)
- func WithSubSystem[SS SubSystem](state *State, callback func(subSystem SS) error) error
- func WithSystemArtifact[SA SystemArtifact](state *State, callback func(systemArtifact SA) error) error
- type Action
- type ActionCoordinates
- type Actions
- type Actor
- type AddressMapper
- type Condition
- type ConvertedBytes
- type Data
- type DataConverter
- type DataConverterFactory
- type DataSource
- type ErrNoSubSystem
- type ErrNoSystemArtifact
- type Flow
- type MappedRanges
- type MeasuredData
- type MeasuredDataSlice
- type NewDataInput
- type NewReferenceInput
- type RawBytes
- type RawBytesGetter
- type Reference
- type References
- func (s References) BySystemArtifact(sa SystemArtifact) References
- func (s References) Exclude(exc ...Reference) References
- func (s References) ForcedBytes() RawBytes
- func (s References) Ranges() pkgbytes.Ranges
- func (s References) RawBytes() RawBytes
- func (s References) Resolve() error
- func (s *References) SortAndMerge()
- func (s References) String() string
- type State
- func (state *State) AddMeasuredData(data Data, trustChain TrustChain, dataSource DataSource) *MeasuredData
- func (state *State) GetCurrentActionCoordinates() ActionCoordinates
- func (state *State) GetDataMeasuredBy(trustChain TrustChain) MeasuredDataSlice
- func (state *State) IncludeSubSystem(subSystem SubSystem)
- func (state *State) IncludeSystemArtifact(systemArtifact SystemArtifact)
- func (state *State) Reset()
- func (state *State) SetFlow(flow Flow)
- func (state *State) String() string
- type StaticStep
- type Step
- type Steps
- type SubSystem
- type SubSystems
- type SystemArtifact
- type SystemArtifactEqualer
- type SystemArtifacts
- type TrustChain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualSystemArtifacts ¶
func EqualSystemArtifacts(s0, s1 SystemArtifact) bool
EqualSystemArtifacts returns true if system artifacts are equal.
func GetSubSystemByTypeFromState ¶
GetSubSystemByTypeFromState extracts a specific SubSystem given its type.
This was supposed to be a method of `*State`, but Go does not support generic methods, so it is a free function.
func GetSystemArtifactByTypeFromState ¶
func GetSystemArtifactByTypeFromState[SA SystemArtifact]( state *State, ) (SA, error)
SystemArtifactExec extracts a specific SystemArtifact given its type.
This was supposed to be a method of `*State`, but Go does not support generic methods, so it is a free function.
func WithSubSystem ¶
WithSubSystem extracts a specific SubSystem given its type.
This was supposed to be a method of `*State`, but Go does not support generic methods, so it is a free function.
func WithSystemArtifact ¶
func WithSystemArtifact[SA SystemArtifact]( state *State, callback func(systemArtifact SA) error, ) error
WithSystemArtifact extracts a specific SystemArtifact given its type.
This was supposed to be a method of `*State`, but Go does not support generic methods, so it is a free function.
Types ¶
type Action ¶
type Action interface { // Apply applies changes to the State. Apply(context.Context, *State) error }
Action describes a single event happening during some boot step.
In contrast to Step, Action implements low-level operations which mutates the State.
An example: measure a specific section in an AMD Manifest
type ActionCoordinates ¶
type ActionCoordinates struct { // Flow is the Flow where the Action is defined. Flow Flow `faker:"flow"` // StepIndex is the index of the Step within the Flow. StepIndex uint // ActionIndex is the index of the Action within the Step. ActionIndex uint }
ActionCoordinates is a set of coordinates, which defines an Action within a Flow.
TODO: make serializable
func (*ActionCoordinates) IsSameStep ¶
func (coords *ActionCoordinates) IsSameStep(cmp ActionCoordinates) bool
IsSameStep returns true if the Flow and StepIndex are the same.
func (*ActionCoordinates) Step ¶
func (coords *ActionCoordinates) Step() Step
Step returns the Step.
type Actor ¶
type Actor interface { // ResponsibleCode is the code which supposedly performs the actions // of this Actor. ResponsibleCode() DataSource }
Actor defines the piece of code responsible for specific Action. This might help to validate if no Action is performed from a non-MeasuredData.
type AddressMapper ¶
type AddressMapper interface { Resolve(SystemArtifact, ...pkgbytes.Range) (pkgbytes.Ranges, error) Unresolve(SystemArtifact, ...pkgbytes.Range) (pkgbytes.Ranges, error) }
AddressMapper maps an address. If is an untyped nil then address should be mapped to itself by the consumer of this interface.
type ConvertedBytes ¶
type ConvertedBytes []byte
ConvertedBytes is the final representation of bytes (for example a digest to be extended to a PCR).
func (ConvertedBytes) String ¶
func (d ConvertedBytes) String() string
String implements fmt.Stringer.
type Data ¶
type Data struct { References Converter DataConverter `faker:"data_converter"` }
Data is byte-data (given directly or by a reference to a SystemArtifact).
func NewData ¶
func NewData[T NewDataInput](in T) *Data
NewData returns a new instance of Data structure, given the actual data to be referenced to.
The returned value is always not nil.
func (*Data) ConvertedBytes ¶
func (d *Data) ConvertedBytes() ConvertedBytes
ConvertedBytes returns the final/converted bytes defined by Data.
func (*Data) ForcedBytes ¶
ForcedBytes returns the bytes provided by SystemArtifacts of type RawBytes.
type DataConverter ¶
type DataConverter interface {
Convert(RawBytes) ConvertedBytes
}
DataConverter is an abstract converter of data. For example SHA1 hasher is a data converter.
type DataConverterFactory ¶
type DataConverterFactory interface {
NewDataConverter() DataConverter
}
DataConverterFactory is a factory of DataConverter.
type DataSource ¶
DataSource is an abstract source of byte-data.
type ErrNoSubSystem ¶
ErrNoSubSystem means the requested SubSystem type was not included into the State.
See also `(*State).IncludeSubSystem()`.
func (ErrNoSubSystem) Error ¶
func (err ErrNoSubSystem) Error() string
Error implements interface `error`.
func (ErrNoSubSystem) String ¶
func (err ErrNoSubSystem) String() string
String implements fmt.Stringer.
func (ErrNoSubSystem) SubSystemTypeIs ¶
func (err ErrNoSubSystem) SubSystemTypeIs(sample SubSystem) bool
SubSystemTypeIs returns true if the underlying type of the provided sample is the same as of the requested SubSystem (which was not included to the State).
type ErrNoSystemArtifact ¶
ErrNoSystemArtifact means the requested SystemArtifact type was not included to the State.
See also `(*State).IncludeSystemArtifact()`.
func (ErrNoSystemArtifact) Error ¶
func (err ErrNoSystemArtifact) Error() string
Error implements interface `error`.
func (ErrNoSystemArtifact) String ¶
func (err ErrNoSystemArtifact) String() string
String implements fmt.Stringer.
func (ErrNoSystemArtifact) SystemArtifactTypeIs ¶
func (err ErrNoSystemArtifact) SystemArtifactTypeIs(sample SystemArtifact) bool
SystemArtifactTypeIs returns true if the underlying type of the provided sample is the same as of the requested SystemArtifact (which was not included to the State).
type Flow ¶
type Flow struct { // Name is the unique name of the Flow. // // Equivalence of Name-s between two flows should guarantee the equivalence // of Steps. Name string // Steps returns the list of Step-s implied by this flow. Steps Steps }
Flow describes steps of the boot process.
type MappedRanges ¶
type MappedRanges struct { AddressMapper AddressMapper `faker:"address_mapper"` Ranges pkgbytes.Ranges }
MappedRanges are ranges, which is mapped (for example ranges in virtual memory).
type MeasuredData ¶
type MeasuredData struct { Data DataSource DataSource `faker:"data_source"` Actor Actor `faker:"actor"` Step Step `faker:"step"` Action Action `faker:"action"` TrustChain TrustChain `faker:"trust_chain"` }
MeasuredData is a piece of Data which was measured by any of TrustChain-s.
type MeasuredDataSlice ¶
type MeasuredDataSlice []MeasuredData
MeasuredDataSlice is a slice of MeasuredData-s.
func (MeasuredDataSlice) References ¶
func (s MeasuredDataSlice) References() References
References returns all References.
func (MeasuredDataSlice) String ¶
func (s MeasuredDataSlice) String() string
String implements fmt.Stringer.
type NewDataInput ¶
type NewDataInput interface { RawBytes | *Reference | References }
NewDataInput is just an interface for function NewData.
type NewReferenceInput ¶
type NewReferenceInput interface { RawBytes }
NewReferenceInput is the input for NewReference function.
Currently we support only RawBytes.
type RawBytes ¶
type RawBytes []byte
RawBytes are the initial (not yet hashed or converted other way) bytes.
func (RawBytes) ConvertBy ¶
func (b RawBytes) ConvertBy(c DataConverter) ConvertedBytes
ConvertBy converts the bytes to final bytes given a DataConverter.
func (RawBytes) Equal ¶
func (b RawBytes) Equal(in SystemArtifact) bool
Equal implements SystemArtifactEqualer.
type RawBytesGetter ¶
type RawBytesGetter interface {
RawBytes() RawBytes
}
RawBytesGetter is an abstract source of RawBytes.
type Reference ¶
type Reference struct { Artifact SystemArtifact `faker:"system_artifact"` MappedRanges }
Reference is a reference to a bytes data in a SystemArtifact.
func NewReference ¶
func NewReference[T NewReferenceInput](in T) *Reference
Reference returns a Reference given a data to reference to.
The returned value is always not nil.
func (*Reference) ResolvedRanges ¶
ResolvedRanges returns Ranges, already resolved using AddressMapper.
type References ¶
type References []Reference
References is a a slice of Reference-s.
func (References) BySystemArtifact ¶
func (s References) BySystemArtifact(sa SystemArtifact) References
BySystemArtifact filters references to only those, who refers to the given SystemArtifact.
func (References) Exclude ¶
func (s References) Exclude(exc ...Reference) References
Exclude returns the references left after subtracting regions from the provided references.
func (References) ForcedBytes ¶
func (s References) ForcedBytes() RawBytes
ForcedBytes returns a concatenation of data of all bytes defined by SystemArtifacts of type RawBytes.
func (References) Ranges ¶
func (s References) Ranges() pkgbytes.Ranges
Ranges concatenates and returns all Ranges together.
func (References) RawBytes ¶
func (s References) RawBytes() RawBytes
RawBytes returns a concatenation of data of all the referenced byte ranges.
func (References) Resolve ¶
func (s References) Resolve() error
Resolve uses AddressMapper-s to resolve addresses to final references.
On success: all AddressMappers will be nil and all Ranges will reference to the actual ranges of the data. On failure an error returned, but some References might be already resolved.
func (*References) SortAndMerge ¶
func (s *References) SortAndMerge()
SortAndMerge sorts References and merges those which touch or overlap.
type State ¶
type State struct { SystemArtifacts SystemArtifacts `faker:"system_artifact_map"` SubSystems SubSystems `faker:"sub_system_map"` CurrentActor Actor `faker:"actor"` CurrentActionCoordinates ActionCoordinates CurrentAction Action `faker:"action"` MeasuredData MeasuredDataSlice }
State describes a virtual state of a machine being booted
func (*State) AddMeasuredData ¶
func (state *State) AddMeasuredData( data Data, trustChain TrustChain, dataSource DataSource, ) *MeasuredData
AddMeasuredData marks given data as protected/measured.
TrustChain defines within which TrustChain this measurement was performed (should not be nil). DataSource defines how the data source was defined in the flow, which made the measurement (should not be nil).
func (*State) GetCurrentActionCoordinates ¶
func (state *State) GetCurrentActionCoordinates() ActionCoordinates
GetCurrentActionCoordinates returns the Action is being performed.
func (*State) GetDataMeasuredBy ¶
func (state *State) GetDataMeasuredBy(trustChain TrustChain) MeasuredDataSlice
GetDataMeasuredBy returns MeasuredData which was measured within the specified TrustChain.
See also (*State).AddMeasuredData().
func (*State) IncludeSubSystem ¶
IncludeSubSystem adds and enables a SubSystem, but each SubSystem type could be added only once.
func (*State) IncludeSystemArtifact ¶
func (state *State) IncludeSystemArtifact(systemArtifact SystemArtifact)
IncludeSystemArtifact adds and enables a SystemArtifact, but each SystemArtifact type could be added only once.
func (*State) Reset ¶
func (state *State) Reset()
Reset returns to the initial state, but tries to keep the already allocated memory.
type StaticStep ¶
type StaticStep Actions
StaticStep is a Step which has a predefined static list of Actions.
type Step ¶
Step describes a single step of a boot process, essential for the measurements. Steps of a flow may vary depending on a State.
In contrast to Action, Step just answers the question "what to do", but does not execute it.
An example: measure specific sections in an AMD Manifest
type SubSystem ¶
type SubSystem interface {
IsInitialized() bool
}
SubSystem is an abstract subsystem of the imaginary/virtual machine, we imitate to boot.
Examples: TPM-backed measured boot, RDMA
type SubSystems ¶
SubSystem is a collection of SubSystem-s with unique types.
type SystemArtifact ¶
SystemArtifact is an abstract data artifact of the emulated system.
Examples: BIOS firmware image, TXT status registers, MSR registers, PRoT firmware image.
type SystemArtifactEqualer ¶
type SystemArtifactEqualer interface {
Equal(SystemArtifact) bool
}
SystemArtifactEqualer is a comparer of a system artifact, semantically similar to bytes.Compare (but for artifacts, instead of bytes).
type SystemArtifacts ¶
type SystemArtifacts map[reflect.Type]SystemArtifact
SystemArtifacts is a collection of SystemArtifact-s with unique types.
func (SystemArtifacts) String ¶
func (m SystemArtifacts) String() string
String implements fmt.Stringer.
type TrustChain ¶
type TrustChain interface { SubSystem }
TrustChain is a SubSystem responsible for maintaining a chain of trust.
Examples: TPM-backed measured boot, DICE-backed measured boot, Signatures-backed verified boot, etc.