@@ -23,6 +23,7 @@ import (
2323 "strings"
2424 "testing"
2525
26+ "github.com/google/go-sev-guest/abi"
2627 "github.com/google/go-sev-guest/kds"
2728 kpb "github.com/google/go-sev-guest/proto/fakekds"
2829 "github.com/google/go-sev-guest/verify/trust"
@@ -75,14 +76,14 @@ type RootBundle struct {
7576type FakeKDS struct {
7677 Certs * kpb.Certificates
7778 // Two CERTIFICATE PEMs for ASK, then ARK or ASVK then ARK, per product
78- RootBundles map [string ]RootBundle
79+ RootBundles map [string ]* RootBundle
7980}
8081
8182// FakeKDSFromFile returns a FakeKDS from a path to a serialized fakekds.Certificates message.
8283func FakeKDSFromFile (path string ) (* FakeKDS , error ) {
8384 result := & FakeKDS {
8485 Certs : & kpb.Certificates {},
85- RootBundles : map [string ]RootBundle {
86+ RootBundles : map [string ]* RootBundle {
8687 "Milan" : {
8788 VcekBundle : string (trust .AskArkMilanVcekBytes ),
8889 VlekBundle : string (trust .AskArkMilanVlekBytes ),
@@ -110,14 +111,17 @@ func FakeKDSFromFile(path string) (*FakeKDS, error) {
110111// AMD KDS REST API expectations.
111112func FakeKDSFromSigner (signer * AmdSigner ) (* FakeKDS , error ) {
112113 certs := & kpb.Certificates {}
114+ rootBundles := map [string ]* RootBundle {}
113115 certs .ChipCerts = []* kpb.Certificates_ChipTCBCerts {
114116 {
115117 ChipId : signer .HWID [:],
116118 TcbCerts : map [uint64 ][]byte {
117119 uint64 (signer .TCB ): signer .Vcek .Raw ,
118120 },
121+ Fms : abi .MaskedCpuid1EaxFromSevProduct (signer .Product ),
119122 },
120123 }
124+ productLine := kds .ProductLine (signer .Product )
121125
122126 b := & strings.Builder {}
123127 if err := multierr .Combine (
@@ -126,8 +130,7 @@ func FakeKDSFromSigner(signer *AmdSigner) (*FakeKDS, error) {
126130 ); err != nil {
127131 return nil , fmt .Errorf ("could not encode VCEK root certificates: %v" , err )
128132 }
129- vcekBundle := b .String ()
130- var vlekBundle string
133+ rootBundles [productLine ] = & RootBundle {VcekBundle : b .String ()}
131134 if signer .Asvk != nil {
132135 b := & strings.Builder {}
133136 if err := multierr .Combine (
@@ -136,15 +139,10 @@ func FakeKDSFromSigner(signer *AmdSigner) (*FakeKDS, error) {
136139 ); err != nil {
137140 return nil , fmt .Errorf ("could not encode VLEK root certificates: %v" , err )
138141 }
139- vlekBundle = b .String ()
140- }
141- return & FakeKDS {
142- Certs : certs ,
143- RootBundles : map [string ]RootBundle {"Milan" : {
144- VcekBundle : vcekBundle ,
145- VlekBundle : vlekBundle ,
146- }},
147- }, nil
142+ rootBundles [productLine ].VlekBundle = b .String ()
143+ }
144+
145+ return & FakeKDS {Certs : certs , RootBundles : rootBundles }, nil
148146}
149147
150148// FindChipTcbCerts returns the TcbCerts associated with the given chipID in the database if they
@@ -200,7 +198,7 @@ func GetKDS(t testing.TB) trust.HTTPSGetter {
200198 }
201199 fakeKds := & FakeKDS {
202200 Certs : & kpb.Certificates {},
203- RootBundles : map [string ]RootBundle {"Milan" : {
201+ RootBundles : map [string ]* RootBundle {"Milan" : {
204202 VcekBundle : string (trust .AskArkMilanVcekBytes ),
205203 VlekBundle : string (trust .AskArkMilanVlekBytes ),
206204 },
0 commit comments