tpm

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdentityClassVerified          = "verified"
	IdentityClassCrowdCorroborated = "crowd_corroborated"
	IdentityClassUnverifiedHW      = "unverified_hw"
	IdentityClassSoftware          = "software"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type QuoteResult added in v0.1.4

type QuoteResult struct{}

QuoteResult contains the verified results of a TPM quote. Placeholder for RFC 003 PCR validation fields.

type TestVerifier

type TestVerifier struct {
	VerifyEKCertFn    func(ekCertDER []byte) (string, crypto.PublicKey, error)
	VerifyQuoteFn     func(akPubKeyDER []byte, nonce string, quoteB64 string, pcrValues map[int][]byte) (*QuoteResult, error)
	MakeCredentialFn  func(ekPubKey crypto.PublicKey, akName []byte, secret []byte) ([]byte, error)
	ParseAKPublicFn   func(akParams []byte) ([]byte, []byte, error)
	ExtractEKPubKeyFn func(ekCertDER []byte) (crypto.PublicKey, error)
	EKFingerprintFn   func(ekCertDER []byte) string
	ParseEKCertFn     func(ekCertDER []byte) (*x509.Certificate, error)
}

TestVerifier is a mock TPM verifier for testing.

func (*TestVerifier) EKFingerprint

func (t *TestVerifier) EKFingerprint(ekCertDER []byte) string

func (*TestVerifier) ExtractEKPublicKey

func (t *TestVerifier) ExtractEKPublicKey(ekCertDER []byte) (crypto.PublicKey, error)

func (*TestVerifier) MakeCredential

func (t *TestVerifier) MakeCredential(ekPubKey crypto.PublicKey, akName []byte, secret []byte) ([]byte, error)

func (*TestVerifier) ParseAKPublic

func (t *TestVerifier) ParseAKPublic(akParams []byte) ([]byte, []byte, error)

func (*TestVerifier) ParseEKCert

func (t *TestVerifier) ParseEKCert(ekCertDER []byte) (*x509.Certificate, error)

func (*TestVerifier) VerifyEKCert

func (t *TestVerifier) VerifyEKCert(ekCertDER []byte) (string, crypto.PublicKey, error)

func (*TestVerifier) VerifyQuote

func (t *TestVerifier) VerifyQuote(akPubKeyDER []byte, nonce string, quoteB64 string, pcrValues map[int][]byte) (*QuoteResult, error)

type Verifier

type Verifier interface {
	// VerifyEKCert verifies an EK certificate and returns the identity class.
	VerifyEKCert(ekCertDER []byte) (identityClass string, ekPubKey crypto.PublicKey, err error)

	// VerifyQuote verifies a TPM quote signed by the given AK public key.
	// When pcrValues is non-nil, the quote's PCR digest is verified against
	// the provided values. When nil, PCR validation is skipped.
	VerifyQuote(akPubKeyDER []byte, nonce string, quoteB64 string, pcrValues map[int][]byte) (*QuoteResult, error)

	// MakeCredential creates an encrypted credential challenge for the TPM.
	MakeCredential(ekPubKey crypto.PublicKey, akName []byte, secret []byte) ([]byte, error)

	// ParseAKPublic parses AK parameters and returns the AK public key DER and AK name.
	ParseAKPublic(akParams []byte) (akPubKeyDER []byte, akName []byte, err error)

	// ExtractEKPublicKey extracts the public key from an EK certificate.
	ExtractEKPublicKey(ekCertDER []byte) (crypto.PublicKey, error)

	// EKFingerprint computes SHA-256 fingerprint of an EK certificate.
	EKFingerprint(ekCertDER []byte) string

	// ParseEKCert parses a DER-encoded EK certificate.
	ParseEKCert(ekCertDER []byte) (*x509.Certificate, error)
}

Verifier defines the TPM verification interface.

func NewVerifier

func NewVerifier(cfg config.TPMConfig, logger *slog.Logger) (Verifier, error)

Jump to

Keyboard shortcuts

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