attestation

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package attestation verifies the Google Confidential Space attestation token in TeeInfoResponse. Bedrock checks (JWT chain, nonce, challenge, pubkey consistency) always run when Enabled. Measurement checks run only when their allowlist or flag is set.

Index

Constants

View Source
const ReasonMagicPass = "magic_pass"

ReasonMagicPass is the attestation_verify_total reason label callers emit for an accepted magic_pass sentinel (result "ok"). It is deliberately NOT returned by Reason, which classifies only errors — an accepted magic_pass yields a nil error.

Variables

View Source
var (
	ErrDisabled           = errors.New("attestation disabled")
	ErrMagicPassDisabled  = errors.New("magic_pass attestation not allowed")
	ErrChallengeMismatch  = errors.New("attestation challenge does not match sent challenge")
	ErrPubKeyMismatch     = errors.New("TeeInfo and MachineData public keys differ")
	ErrTokenTooOld        = errors.New("attestation token issued too long ago")
	ErrSecBootDisabled    = errors.New("attestation reports secure boot disabled")
	ErrDebugNotAllowed    = errors.New("attestation debug status not in allowlist")
	ErrCodeHashNotAllowed = errors.New("attestation code hash not in allowlist")
	ErrPlatformNotAllowed = errors.New("attestation platform not in allowlist")
	ErrChainIDMismatch    = errors.New("attestation chainID mismatch")
	ErrJWTInvalid         = errors.New("validating attestation JWT")
)
View Source
var ErrorReasons = []string{"challenge_mismatch", "pubkey_mismatch", "chain_id_mismatch", "magic_pass_disabled", "token_too_old", "sec_boot_disabled", "debug_not_allowed", "code_hash_not_allowed", "platform_not_allowed", "jwt_invalid", "other"}

ErrorReasons lists every label Reason returns for a non-nil error. It is the closed error set that metrics pre-initialization enumerates.

Functions

func GoogleCSRoot

func GoogleCSRoot() (*x509.Certificate, error)

GoogleCSRoot returns the embedded Confidential Space root certificate.

func IsMagicPass added in v0.0.19

func IsMagicPass(tir *types.TeeInfoResponse) bool

IsMagicPass reports whether the response carries the tee-node magic_pass sentinel in place of a real attestation token.

func Reason added in v0.0.19

func Reason(err error) string

Reason maps a Verify error to a bounded label for metrics, so callers never derive labels from raw error text (which embeds token ages, hashes, addresses). A nil error yields "ok"; an unrecognized error yields "other".

func Verify

func Verify(tir *types.TeeInfoResponse, sentChallenge common.Hash, cfg *Config) error

Verify validates the attestation in tir against cfg. It runs bedrock checks first (challenge round-trip, pubkey consistency), short-circuits on MagicPass when allowed, then validates the JWT chain, the nonce binding to TeeInfo, and finally the optional claims.

Types

type ActiveChecks

type ActiveChecks struct {
	Audience    bool
	CodeHash    bool
	Platform    bool
	DebugStatus bool
	MaxTokenAge bool
	SecBoot     bool
	MagicPass   bool
}

ActiveChecks reports which optional checks Verify will perform. Used for the startup log line.

type Config

type Config struct {
	Enabled  bool
	RootCert *x509.Certificate // required when Enabled, unless every accepted token is MagicPass

	// Optional CRLs; nil skips the corresponding check.
	LeafCRL         *x509.RevocationList
	IntermediateCRL *x509.RevocationList

	// Audience is the expected aud claim; empty skips the audience check.
	// AllowedImageIDs is the workload image-ID allowlist; empty skips the image_id check.
	Audience        string
	AllowedImageIDs []common.Hash

	// ChainID is the chain ID the TEE must report; a mismatch rejects the response.
	ChainID uint64

	ExpectedCodeHash    []common.Hash // empty → skip
	ExpectedPlatform    []common.Hash // empty → skip
	ExpectedDebugStatus []string      // empty → skip
	MaxTokenAge         time.Duration // 0 → skip
	RequireSecBoot      bool          // false → skip

	// AllowMagicPass accepts the tee-node sentinel; dev/test only.
	AllowMagicPass bool
}

Config controls Verify. When Enabled is false, Verify is a no-op. Each optional check runs only when its setting is non-zero.

func (*Config) Active

func (cfg *Config) Active() ActiveChecks

Active returns the set of optional checks Verify will run for this config.

Jump to

Keyboard shortcuts

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