Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,19 @@ func SupportedTcbLevelsFromCollateral(quote any, options *Options) (pcs.TcbLevel
}
}

// GetPPID extracts the PPID from the PCK certificate chain in the quote.
func GetPPID(quote any) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to add this into the CLI, or do we expect users to call this function from their libraries?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to add this to the CLI, or do we expect users to call this function directly from their libraries?

chain, err := ExtractChainFromQuote(quote)
if err != nil {
return "", err
}
exts, err := pcs.PckCertificateExtensions(chain.PCKCertificate)
if err != nil {
return "", err
}
return exts.PPID, nil
}

// tdxQuoteV4 verifies the QuoteV4 protobuf representation of an attestation quote's signature
// based on the quote's SignatureAlgo, provided the certificate chain is valid.
func tdxQuoteV4(ctx context.Context, quote *pb.QuoteV4, options *Options) error {
Expand Down
18 changes: 18 additions & 0 deletions verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,24 @@ func TestSupportedTcbLevelsFromCollateral(t *testing.T) {
})
}

func TestGetPPID(t *testing.T) {
quote, err := abi.QuoteToProto(testdata.RawQuote)
if err != nil {
t.Fatal(err)
}
ppid, err := GetPPID(quote)
if err != nil {
t.Fatal(err)
}
// The PPID is bytes 89d... which is hex encoded in pcs.PckExtensions
// In TestPckCertificateExtensions, expected ppidBytes is []byte{8, 157, 223, 219, 156, 3, 89, 200, 42, 59, 199, 113, 146, 57, 87, 78}
// Hex: 089ddfdb9c0359c82a3bc7719239574e
wantPPID := "089ddfdb9c0359c82a3bc7719239574e"
if ppid != wantPPID {
t.Errorf("GetPPID() = %q, want %q", ppid, wantPPID)
}
}

var rawTdxQuoteFuncs = map[string]func([]byte, *Options) error{
"RawTdxQuote": RawTdxQuote,
"RawTdxQuoteContext": func(quote []byte, options *Options) error {
Expand Down
Loading