pcr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package pcr contains code that handles PCR operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateBankData

func CalculateBankData(pcrNumber int, alg tpm2.TPMAlgID, sectionData map[constants.Section]string, rsaKey RSAKey) ([]types.BankData, error)

CalculateBankData calculates the PCR bank data for a given set of UKI file sections.

This mimics the process happening in the TPM when the UKI is being loaded.

func CalculateBankDataForFile

func CalculateBankDataForFile(pcrNumber int, alg tpm2.TPMAlgID, file string, rsaKey RSAKey) ([]types.BankData, error)

func CalculatePolicy

func CalculatePolicy(pcrValue []byte, pcrSelection tpm2.TPMLPCRSelection) ([]byte, error)

CalculatePolicy calculates the policy hash for a given PCR value and PCR selection.

func CreateSelector

func CreateSelector(pcrs []int) ([]byte, error)

CreateSelector converts PCR numbers into a bitmask.

Types

type Digest

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

Digest implements the PCR extension algorithm.

Each time `Extend` is called, the hash of the previous data is prepended to the hash of new data and hashed together.

The initial hash value is all zeroes.

func NewDigest

func NewDigest(alg crypto.Hash) *Digest

NewDigest creates a new Digest with the speified hash algorithm.

func (*Digest) Extend

func (d *Digest) Extend(data []byte)

Extend extends the current hash with the specified data.

func (*Digest) Hash

func (d *Digest) Hash() []byte

Hash returns the current hash value.

type RSAKey

type RSAKey interface {
	crypto.Signer
	PublicRSAKey() *rsa.PublicKey
}

RSAKey is the input for the CalculateBankData function.

type Signature

type Signature struct {
	Digest          string
	SignatureBase64 string
}

Signature returns the hashed signature digest and base64 encoded signature.

func Sign

func Sign(digest []byte, hash crypto.Hash, key crypto.Signer) (*Signature, error)

Sign the digest using specified hash and key.

Jump to

Keyboard shortcuts

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