tpm2

package
v1.12.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Package tpm2 provides TPM2.0 related functionality helpers.

Index

Constants

View Source
const (
	// EncryptionSchemaVersionErrata is the errata for the encryption schema version.
	// Talos versions older than 1.12 locked to PCR 7 and PCR 11 but the luks json header only
	// saved the PCR 11 value, so if the version is not set or empty we can assume that the keys
	// are sealed to both PCR 7 and PCR 11. If the version is `1` we can be sure that the keys
	// are locked to PCR 11 only.
	EncryptionSchemaVersionErrata = "1"
)

Variables

This section is empty.

Functions

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 CalculateSealingPolicyDigest

func CalculateSealingPolicyDigest(t transport.TPM, spInfo SealingPolicyDigestInfo) ([]byte, error)

CalculateSealingPolicyDigest calculates the sealing policy digest for a given public key and PCRs.

func CreateSelector

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

CreateSelector converts PCR numbers into a bitmask.

func PCRExtend added in v1.8.2

func PCRExtend(pcr int, data []byte) error

PCRExtend hashes the input and extends the PCR with the hash.

func ParsePCRSigningPubKey

func ParsePCRSigningPubKey(file string) (*rsa.PublicKey, error)

ParsePCRSigningPubKey parses a PEM encoded RSA public key.

func PolicyPCRDigest

func PolicyPCRDigest(t transport.TPM, policyHandle tpm2.TPMHandle, pcrSelection tpm2.TPMLPCRSelection) (*tpm2.TPM2BDigest, error)

PolicyPCRDigest executes policyPCR and returns the digest.

func RSAPubKeyTemplate

func RSAPubKeyTemplate(bitlen, exponent int, modulus []byte) tpm2.TPMTPublic

RSAPubKeyTemplate returns a TPM2.0 public key template for RSA keys.

func ReadPCR

func ReadPCR(t transport.TPM, pcr int) ([]byte, error)

ReadPCR reads the value of a single PCR.

func Unseal

func Unseal(sealed SealedResponse) ([]byte, error)

Unseal unseals a sealed blob using the TPM

Types

type BankData

type BankData struct {
	// list of PCR banks
	PCRs []int `json:"pcrs"`
	// Public key of the TPM
	PKFP string `json:"pkfp"`
	// Policy digest
	Pol string `json:"pol"`
	// Signature of the policy digest in base64
	Sig string `json:"sig"`
}

BankData constains data for a specific PCR bank.

type PCRData

type PCRData struct {
	SHA1   []BankData `json:"sha1,omitempty"`
	SHA256 []BankData `json:"sha256,omitempty"`
	SHA384 []BankData `json:"sha384,omitempty"`
	SHA512 []BankData `json:"sha512,omitempty"`
}

PCRData is the data structure for PCR signature json.

func ParsePCRSignature

func ParsePCRSignature() (*PCRData, error)

ParsePCRSignature parses the PCR signature json file.

type SealedResponse

type SealedResponse struct {
	SealedBlobPrivate []byte
	SealedBlobPublic  []byte
	KeyName           []byte
	PolicyDigest      []byte
	PCRs              []int
	PubKeyPCRs        []int
	EncryptionVersion string
	Alg               string
}

SealedResponse is the response from the TPM2.0 Seal operation.

func Seal

func Seal(key []byte, tpmPCRs []int) (*SealedResponse, error)

Seal seals the key using TPM2.0.

type SealingPolicyDigestInfo added in v1.12.0

type SealingPolicyDigestInfo struct {
	PublicKey   string
	PCRs        []int
	ReadPCRFunc func(t transport.TPM, pcr int) ([]byte, error)
}

SealingPolicyDigestInfo holds the information needed to calculate a sealing policy digest.

Jump to

Keyboard shortcuts

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