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 ¶
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 ¶
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") )
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
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".
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.