measurement

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package measurement provides different collectors to hash files, disks, dmi info and cpuid info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(b []byte, eventDesc string) error

HashBytes extends PCR with a byte array and sends an event to sysfs. the sent event is described via eventDesc.

func HashFile

func HashFile(inputVal string) error

HashFile opens and reads the given file and measures it into the TPM.

inputVal is of format <block device identifier>:<path> (e.g., `sda:/path/to/file` or `UUID:/path/to/file`).

Types

type CPUIDCollector

type CPUIDCollector struct {
	Type     string `json:"type"`
	Location string `json:"location"`
}

CPUIDCollector describes the "cpuid" portion of the policy file.

func (*CPUIDCollector) Collect

func (s *CPUIDCollector) Collect() error

Collect gets the cpuid and extends it into the TPM and stores a copy on disk.

It satisfies the Collector interface.

type Collector

type Collector interface {
	Collect() error
}

All collectors (e.g., cpuid, dmi, etc.) should satisfy this interface. Collectors collect data and extend its hash into a PCR.

func GetCollector

func GetCollector(config []byte) (Collector, error)

GetCollector calls the appropriate init handlers for a particular collector JSON object argument and returns a new Collector Interface.

An error is returned if unmarshalling fails or an unsupported collector is passed as an argument.

func NewCPUIDCollector

func NewCPUIDCollector(config []byte) (Collector, error)

NewCPUIDCollector extracts the "cpuid" portion from the policy file and initializes a new CPUIDCollector structure.

An error is returned if unmarshalling of CPUIDCollector fails.

func NewDmiCollector

func NewDmiCollector(config []byte) (Collector, error)

NewDmiCollector extracts the "dmi" portion from the policy file and initializes a new DmiCollector structure.

It returns an error if unmarshalling of DmiCollector fails.

func NewFileCollector

func NewFileCollector(config []byte) (Collector, error)

NewFileCollector extracts the "files" portion from the policy file and initializes a new FileCollector structure. It returns an error if unmarshalling of FileCollector fails.

func NewStorageCollector

func NewStorageCollector(config []byte) (Collector, error)

NewStorageCollector extracts the "storage" portion from the policy file and initializes a new StorageCollector structure.

It returns an error if unmarshalling of StorageCollector fails.

type DmiCollector

type DmiCollector struct {
	Type     string         `json:"type"`
	Clusters []fieldCluster `json:"events"`
}

DmiCollector describes the "dmi" portion of policy file.

func (*DmiCollector) Collect

func (s *DmiCollector) Collect() error

Collect gets all smbios data, filters is based on the types provided in the policy file, then measures the filtered data into the TPM.

It satisfies the Collector interface.

type FileCollector

type FileCollector struct {
	Type  string   `json:"type"`
	Paths []string `json:"paths"`
}

Describes the "files" portion of policy file.

func (*FileCollector) Collect

func (s *FileCollector) Collect() error

Collect loops over the given file paths and for each file path calls HashFile(), which measures a file into the TPM.

It satisfies the Collector interface.

type StorageCollector

type StorageCollector struct {
	Type  string   `json:"type"`
	Paths []string `json:"paths"`
}

StorageCollector describes the "storage" portion of the policy file.

func (*StorageCollector) Collect

func (s *StorageCollector) Collect() error

Collect loops over the given storage paths and for each storage path calls measureStorageDevice(), which measures a storage device into the TPM.

It satisfies the Collector interface.

Jump to

Keyboard shortcuts

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