Debian Codegraph @

verifier/client.go

raw
1 // Package verifier contains clients for various attestation verifiers.
2 // It is meant for launcher use and testing; the API is not stable.
3 package verifier
4
5 import (
6 "context"
7
8 csattestpb "github.com/GoogleCloudPlatform/confidential-space/server/proto/gen/attestation"
9 attestpb "github.com/google/go-tpm-tools/proto/attest"
10 "github.com/google/go-tpm-tools/verifier/models"
11 "google.golang.org/genproto/googleapis/rpc/status"
12 )
13
14 // Client is a common interface to various attestation verifiers.
15 type Client interface {
16 CreateChallenge(ctx context.Context) (*Challenge, error)
17 VerifyAttestation(ctx context.Context, request VerifyAttestationRequest) (*VerifyAttestationResponse, error)
18 VerifyConfidentialSpace(ctx context.Context, request VerifyAttestationRequest) (*VerifyAttestationResponse, error)
19 }
20
21 // Challenge is the response for CreateChallenge. It is used in the
22 // get challenge part of a remote attestation protocol. The challenge
23 // will be verified as part of VerifyAttestation.
24 type Challenge struct {
25 // Used as audience for GCP credential tokens.
26 Name string
27 // Used to generate attestation.
28 Nonce []byte
29 ConnID string
30 Val []byte
31 Iat []byte
32 Signature []byte
33 }
34
35 type ContainerSignature struct {
36 Payload []byte
37 Signature []byte
38 }
39
40 // VerifyAttestationRequest is passed in on VerifyAttestation. It contains the
41 // Challenge from CreateChallenge, optional GcpCredentials linked to the
42 // attestation, the Attestation generated from the TPM, and optional container image signatures associated with the workload.
43 type VerifyAttestationRequest struct {
44 Challenge *Challenge
45 GcpCredentials [][]byte
46 // Attestation is for TPM attestation
47 Attestation *attestpb.Attestation
48 ContainerImageSignatures []*ContainerSignature
49 TokenOptions *models.TokenOptions
50 // TDCCELAttestation is for TDX CCEL RTMR attestation
51 TDCCELAttestation *TDCCELAttestation
52 }
53
54 type TDCCELAttestation struct {
55 CcelAcpiTable []byte
56 CcelData []byte
57 CanonicalEventLog []byte
58 TdQuote []byte
59 // still needs following two for GCE info
60 AkCert []byte
61 IntermediateCerts [][]byte
62 NvidiaAttestation *csattestpb.NvidiaAttestationReport
63 }
64
65 // VerifyAttestationResponse is the response from a successful
66 // VerifyAttestation call.
67 type VerifyAttestationResponse struct {
68 ClaimsToken []byte
69 PartialErrs []*status.Status
70 }
71
72 // ITAConfig represents the configuration needed to integrate with ITA as a verifier.
73 type ITAConfig struct {
74 ITARegion string
75 ITAKey string
76 }
77
78 // AttestClients contains clients for supported verifier services that can be used to
79 // get attestation tokens.
80 type AttestClients struct {
81 GCA Client
82 ITA Client
83 }
84
85 // HasThirdPartyClient returns true if AttestClients contains an initialzied
86 // third-party verifier client.
87 func (ac *AttestClients) HasThirdPartyClient() bool {
88 return ac.ITA != nil
89 }