Documentation
¶
Overview ¶
Provides a dstack SDK Tappd client and related utilities
Author: Franco Barpp Gomes <[email protected]>
Index ¶
- Constants
- type DeriveKeyResponse
- type EventLog
- type QuoteHashAlgorithm
- type TappdClient
- func (c *TappdClient) DeriveKey(ctx context.Context, path string) (*DeriveKeyResponse, error)
- func (c *TappdClient) DeriveKeyWithSubject(ctx context.Context, path string, subject string) (*DeriveKeyResponse, error)
- func (c *TappdClient) DeriveKeyWithSubjectAndAltNames(ctx context.Context, path string, subject string, altNames []string) (*DeriveKeyResponse, error)
- func (c *TappdClient) Info(ctx context.Context) (*TappdInfoResponse, error)
- func (c *TappdClient) TdxQuote(ctx context.Context, reportData []byte) (*TdxQuoteResponse, error)
- func (c *TappdClient) TdxQuoteWithHashAlgorithm(ctx context.Context, reportData []byte, hashAlgorithm QuoteHashAlgorithm) (*TdxQuoteResponse, error)
- type TappdClientOption
- type TappdInfoResponse
- type TcbInfo
- type TdxQuoteResponse
Constants ¶
const INIT_MR = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeriveKeyResponse ¶
type DeriveKeyResponse struct {
Key string `json:"key"`
CertificateChain []string `json:"certificate_chain"`
}
Represents the response from a key derivation request.
type EventLog ¶
type EventLog struct {
IMR int `json:"imr"`
EventType int `json:"event_type"`
Digest string `json:"digest"`
Event string `json:"event"`
EventPayload string `json:"event_payload"`
}
Represents an event log entry in the TCB info
type QuoteHashAlgorithm ¶
type QuoteHashAlgorithm string
Represents the hash algorithm used in TDX quote generation.
const ( SHA256 QuoteHashAlgorithm = "sha256" SHA384 QuoteHashAlgorithm = "sha384" SHA512 QuoteHashAlgorithm = "sha512" SHA3_256 QuoteHashAlgorithm = "sha3-256" SHA3_384 QuoteHashAlgorithm = "sha3-384" SHA3_512 QuoteHashAlgorithm = "sha3-512" KECCAK256 QuoteHashAlgorithm = "keccak256" KECCAK384 QuoteHashAlgorithm = "keccak384" KECCAK512 QuoteHashAlgorithm = "keccak512" RAW QuoteHashAlgorithm = "raw" )
type TappdClient ¶
type TappdClient struct {
// contains filtered or unexported fields
}
Handles communication with the Tappd service.
func NewTappdClient ¶
func NewTappdClient(opts ...TappdClientOption) *TappdClient
Creates a new TappdClient instance based on the provided endpoint. If the endpoint is empty, it will use the simulator endpoint if it is set in the environment through DSTACK_SIMULATOR_ENDPOINT. Otherwise, it will use the default endpoint at /var/run/tappd.sock.
func (*TappdClient) DeriveKey ¶
func (c *TappdClient) DeriveKey(ctx context.Context, path string) (*DeriveKeyResponse, error)
Derives a key from the Tappd service. This wraps DeriveKeyWithSubjectAndAltNames using the path as the subject and an empty altNames.
func (*TappdClient) DeriveKeyWithSubject ¶
func (c *TappdClient) DeriveKeyWithSubject(ctx context.Context, path string, subject string) (*DeriveKeyResponse, error)
Derives a key from the Tappd service. This wraps DeriveKeyWithSubjectAndAltNames using an empty altNames.
func (*TappdClient) DeriveKeyWithSubjectAndAltNames ¶
func (c *TappdClient) DeriveKeyWithSubjectAndAltNames(ctx context.Context, path string, subject string, altNames []string) (*DeriveKeyResponse, error)
Derives a key from the Tappd service, explicitly setting the subject and altNames.
func (*TappdClient) Info ¶
func (c *TappdClient) Info(ctx context.Context) (*TappdInfoResponse, error)
Sends a request to get information about the Tappd instance
func (*TappdClient) TdxQuote ¶
func (c *TappdClient) TdxQuote(ctx context.Context, reportData []byte) (*TdxQuoteResponse, error)
Sends a TDX quote request to the Tappd service using SHA512 as the report data hash algorithm.
func (*TappdClient) TdxQuoteWithHashAlgorithm ¶
func (c *TappdClient) TdxQuoteWithHashAlgorithm(ctx context.Context, reportData []byte, hashAlgorithm QuoteHashAlgorithm) (*TdxQuoteResponse, error)
Sends a TDX quote request to the Tappd service with a specific hash report data hash algorithm. If the hash algorithm is RAW, the report data must be at most 64 bytes - if it's below that, it will be left-padded with zeros.
type TappdClientOption ¶
type TappdClientOption func(*TappdClient)
Functional option for configuring a TappdClient.
func WithEndpoint ¶
func WithEndpoint(endpoint string) TappdClientOption
Sets the endpoint for the TappdClient.
func WithLogger ¶
func WithLogger(logger *slog.Logger) TappdClientOption
Sets the logger for the TappdClient
type TappdInfoResponse ¶
type TappdInfoResponse struct {
AppID string `json:"app_id"`
InstanceID string `json:"instance_id"`
AppCert string `json:"app_cert"`
TcbInfo TcbInfo `json:"tcb_info"`
AppName string `json:"app_name"`
}
Represents the response from an info request
type TcbInfo ¶
type TcbInfo struct {
Mrtd string `json:"mrtd"`
Rtmr0 string `json:"rtmr0"`
Rtmr1 string `json:"rtmr1"`
Rtmr2 string `json:"rtmr2"`
Rtmr3 string `json:"rtmr3"`
EventLog []EventLog `json:"event_log"`
}
Represents the TCB information
type TdxQuoteResponse ¶
Represents the response from a TDX quote request.
func (*TdxQuoteResponse) ReplayRTMRs ¶
func (r *TdxQuoteResponse) ReplayRTMRs() (map[int]string, error)
Replays the RTMR history to calculate final RTMR values