measurement

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

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 reads file input by user and calls TPM to measure it and store the hash. * * inputVal is of format <block device identifier>:<path> * E.g sda:/path/to/file _OR UUID:/path/to/file * Performs following actions * 1. mount device * 2. Read file on device into a byte slice. * 3. Unmount device * 4. Call tpm package which measures byte slice and stores it.

Types

type CPUIDCollector

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

describes the "cpuid" portion of policy file

func (*CPUIDCollector) Collect

func (s *CPUIDCollector) Collect() error

* Collect satisfies collector interface. It calls various functions to * 1. get the cpuid info from cpuid package * 2. stores hash of the result in the tpm device. * 3. also keeps a copy of the result on disk at location provided in policy file.

type Collector

type Collector interface {
	Collect() error
}

* all collectors (storage, dmi, cpuid, files) should satisfy this * collectors get information and store the hash of that information in pcr * owned by the tpm device.

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. * - 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, * initializes a new CPUIDCollector structure and returns error * if unmarshalling of CPUIDCollector fails

func NewDmiCollector

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

* NewDmiCollector extracts the "dmi" portion from the policy file. * initializes a new DmiCollector structure. * returns error if unmarshalling of DmiCollector fails

func NewFileCollector

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

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

func NewStorageCollector

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

* NewStorageCollector extracts the "storage" portion from the policy file. * initializes a new StorageCollector structure. * returns error if unmarshalling of StorageCollector fails

type DmiCollector

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

describes the "dmi" portion of policy file

func (*DmiCollector) Collect

func (s *DmiCollector) Collect() error

* Collect satisfies collector interface. It calls * 1. smbios package to get all smbios data, * 2. then, filters smbios data based on type provided in policy file, and * 3. the filtered data is then measured into the tpm device.

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 satisfies Collector Interface. It loops over all file paths provided by user * and for each file path, calls HashFile. HashFile measures each file on * that path and stores the result in TPM.

type StorageCollector

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

describes the "storage" portion of policy file

func (*StorageCollector) Collect

func (s *StorageCollector) Collect() error

* Collect satisfies Collector Interface. It loops over all storage paths provided * by user and calls measureStorageDevice for each storage path. storage path is of * form /dev/sda. measureStorageDevice in turn calls tpm * package which further hashes this buffer and extends pcr.

Jump to

Keyboard shortcuts

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