Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeToCBOR(claims *EATClaims, signingKey *ecdsa.PrivateKey, issuer string) ([]byte, error)
- func EncodeToJWT(claims *EATClaims, signingKey *ecdsa.PrivateKey, issuer string) (string, error)
- func GenerateSigningKey() (*ecdsa.PrivateKey, error)
- func LoadSigningKey(path string) (*ecdsa.PrivateKey, error)
- func LoadVerificationKey(path string) (*ecdsa.PublicKey, error)
- func ValidateEATClaims(claims *EATClaims, policy *EATValidationPolicy) error
- func VerificationKeyFingerprint(key *ecdsa.PublicKey) (string, error)
- type CBOREncoder
- type Decoder
- type EATClaims
- func Decode(token []byte, verifyKey *ecdsa.PublicKey) (*EATClaims, error)
- func DecodeCBOR(token []byte, verifyKey *ecdsa.PublicKey) (*EATClaims, error)
- func DecodeJWT(tokenString string, verifyKey *ecdsa.PublicKey) (*EATClaims, error)
- func DecodeVerifiedCBOR(token []byte, verifyKey *ecdsa.PublicKey) (*EATClaims, error)
- func NewEATClaims(report []byte, nonce []byte, platformType attestation.PlatformType) (*EATClaims, error)
- type EATValidationPolicy
- type JWTEncoder
- type SNPExtensions
- type TDXExtensions
- type TDXModuleInfo
- type VTPMExtensions
Constants ¶
const ( DebugEnabled = 0 // Debug is enabled DebugDisabled = 1 // Debug is disabled DebugDisabledSinceBoot = 2 // Debug is disabled since boot DebugPermanentDisable = 3 // Debug is permanently disabled DebugFullPermanentDisable = 4 // Debug is fully and permanently disabled )
DebugStatus constants (RFC 9711 Section 4.2.6).
const ( OEMID_AMD = 3704 // https://www.iana.org/assignments/enterprise-numbers/?q=Advanced+Micro+Devices OEMID_INTEL = 343 // https://www.iana.org/assignments/enterprise-numbers/?q=Intel+Corporation OEMID_MICROSOFT = 311 // https://www.iana.org/assignments/enterprise-numbers/?q=Microsoft+Corporation )
OEMID constants (Private Enterprise Numbers).
const (
IntUseGenericFresh = 1 // General purpose, fresh token
)
IntUse constants (RFC 9711 Section 4.2.5).
const MinNonceLength = 8
MinNonceLength defines the minimum length for EAT nonce in bytes.
Variables ¶
var ( ErrVerificationKeyRequired = errors.New("EAT verification key is required") ErrSignedCBORRequired = errors.New("signed COSE EAT is required") )
var ( ErrInvalidSigningKey = errors.New("invalid EAT signing key") ErrInvalidVerificationKey = errors.New("invalid EAT verification key") )
Functions ¶
func EncodeToCBOR ¶
EncodeToCBOR is a convenience function to encode EAT claims to CBOR.
func EncodeToJWT ¶
EncodeToJWT is a convenience function to encode EAT claims to JWT.
func GenerateSigningKey ¶
func GenerateSigningKey() (*ecdsa.PrivateKey, error)
GenerateSigningKey generates a new ECDSA signing key.
func LoadSigningKey ¶
func LoadSigningKey(path string) (*ecdsa.PrivateKey, error)
LoadSigningKey loads an ES256 private key from a PEM-encoded SEC 1 or PKCS#8 file. Private key files with group or other permission bits are rejected.
func LoadVerificationKey ¶
LoadVerificationKey loads an ES256 public key from a PEM-encoded PKIX public key or X.509 certificate.
func ValidateEATClaims ¶
func ValidateEATClaims(claims *EATClaims, policy *EATValidationPolicy) error
ValidateEATClaims validates EAT claims against policy.
Types ¶
type CBOREncoder ¶
type CBOREncoder struct {
// contains filtered or unexported fields
}
CBOREncoder encodes EAT claims to CBOR format (CWT - CBOR Web Token).
func NewCBOREncoder ¶
func NewCBOREncoder(signingKey *ecdsa.PrivateKey, issuer string) *CBOREncoder
NewCBOREncoder creates a new CBOR encoder.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes EAT tokens (auto-detects JWT vs CBOR).
func NewDecoder ¶
NewDecoder creates a new EAT decoder.
type EATClaims ¶
type EATClaims struct {
// Standard JWT/CWT claims
Issuer string `json:"iss,omitempty" cbor:"1,keyasint,omitempty"`
Subject string `json:"sub,omitempty" cbor:"2,keyasint,omitempty"`
IssuedAt int64 `json:"iat,omitempty" cbor:"6,keyasint,omitempty"`
ExpiresAt int64 `json:"exp,omitempty" cbor:"4,keyasint,omitempty"`
// Core EAT claims (RFC 9711)
Nonce []byte `json:"eat_nonce" cbor:"10,keyasint"` // Freshness/replay protection
UEID []byte `json:"ueid" cbor:"256,keyasint"` // Universal Entity ID
OEMID int `json:"oemid,omitempty" cbor:"258,keyasint,omitempty"` // Hardware OEM ID
HWModel []byte `json:"hwmodel,omitempty" cbor:"259,keyasint,omitempty"` // Hardware model
HWVersion string `json:"hwversion,omitempty" cbor:"260,keyasint,omitempty"` // Hardware version
SWName string `json:"swname,omitempty" cbor:"270,keyasint,omitempty"` // Software name
SWVersion string `json:"swversion,omitempty" cbor:"271,keyasint,omitempty"` // Software version
DebugStatus int `json:"dbgstat" cbor:"263,keyasint"` // Debug status
IntUse int `json:"intuse,omitempty" cbor:"262,keyasint,omitempty"` // Intended use
Measurements []byte `json:"measurements" cbor:"265,keyasint"` // Software measurements
// Platform type indicator
PlatformType string `json:"platform_type"`
// Submodules for vTPM and other components
Submods map[string]interface{} `json:"submods,omitempty" cbor:"266,keyasint,omitempty"`
// Platform-specific extensions (custom claims)
SNPExtensions *SNPExtensions `json:"x-asb-sevsnp,omitempty"`
TDXExtensions *TDXExtensions `json:"x-asb-tdx,omitempty"`
VTPMExtensions *VTPMExtensions `json:"x-asb-vtpm,omitempty"`
// Original binary report (for verification)
RawReport []byte `json:"raw_report,omitempty"`
}
EATClaims represents the Entity Attestation Token claims following RFC 9711.
func DecodeCBOR ¶
DecodeCBOR is a convenience function to decode CBOR EAT token.
func DecodeVerifiedCBOR ¶
DecodeVerifiedCBOR verifies a signed COSE EAT and decodes its claims. Unlike DecodeCBOR, it never accepts plain CBOR or an omitted verification key.
func NewEATClaims ¶
func NewEATClaims(report []byte, nonce []byte, platformType attestation.PlatformType) (*EATClaims, error)
NewEATClaims creates EAT claims from binary attestation report.
func (*EATClaims) MarshalJSON ¶
MarshalJSON implements json.Marshaler for pretty printing.
type EATValidationPolicy ¶
type EATValidationPolicy struct {
RequireEATFormat bool
AllowedFormats []string
MaxTokenAgeSeconds int
RequireClaims []string
VerifySignature bool
}
EATValidationPolicy contains validation rules for EAT tokens.
type JWTEncoder ¶
type JWTEncoder struct {
// contains filtered or unexported fields
}
JWTEncoder encodes EAT claims to JWT format.
func NewJWTEncoder ¶
func NewJWTEncoder(signingKey *ecdsa.PrivateKey, issuer string) *JWTEncoder
NewJWTEncoder creates a new JWT encoder.
type SNPExtensions ¶
type SNPExtensions struct {
Measurement []byte `json:"measurement"` // SNP MEASUREMENT field
TCB string `json:"tcb"` // TCB version info
PlatformInfo uint64 `json:"platform_info"` // PLATFORM_INFO
Policy uint64 `json:"policy"` // POLICY field
FamilyID []byte `json:"family_id,omitempty"` // Family ID
ImageID []byte `json:"image_id,omitempty"` // Image ID
VMPL int `json:"vmpl,omitempty"` // VM Privilege Level
SignatureAlgo int `json:"signature_algo,omitempty"` // Signature algorithm
CurrentTCB uint64 `json:"current_tcb,omitempty"` // Current TCB
ReportedTCB uint64 `json:"reported_tcb,omitempty"` // Reported TCB
ChipID []byte `json:"chip_id,omitempty"` // Chip ID
CommittedTCB uint64 `json:"committed_tcb,omitempty"` // Committed TCB
LaunchTCB uint64 `json:"launch_tcb,omitempty"` // Launch TCB
Signature []byte `json:"signature,omitempty"` // Signature
}
SNPExtensions contains AMD SEV-SNP specific claims.
type TDXExtensions ¶
type TDXExtensions struct {
MRTD []byte `json:"tdx_mrtd"` // MRTD measurement
RTMR0 []byte `json:"tdx_rtmr0"` // Runtime measurement register 0
RTMR1 []byte `json:"tdx_rtmr1"` // Runtime measurement register 1
RTMR2 []byte `json:"tdx_rtmr2"` // Runtime measurement register 2
RTMR3 []byte `json:"tdx_rtmr3"` // Runtime measurement register 3
XFAM uint64 `json:"tdx_xfam"` // Extended features available mask
TDAttributes uint64 `json:"tdx_td_attributes"` // TD attributes
MRConfigID []byte `json:"tdx_mrconfigid,omitempty"` // MR Config ID
MROwner []byte `json:"tdx_mrowner,omitempty"` // MR Owner
MROwnerConfig []byte `json:"tdx_mrownerconfig,omitempty"` // MR Owner Config
MRSEAM []byte `json:"tdx_mrseam,omitempty"` // MR SEAM
TDXModule *TDXModuleInfo `json:"tdx_module,omitempty"` // TDX module info
Signature []byte `json:"tdx_signature,omitempty"` // Quote Signature
}
TDXExtensions contains Intel TDX specific claims.