@@ -827,20 +827,11 @@ func RotateAIKCert(ctx context.Context, req *RotateAIKCertReq) error {
827827 }
828828
829829 // Get EK Public Key from RoT database.
830- fetchEKResp , err := req .Deps .FetchEK (ctx , & FetchEKReq {
831- Serial : resp .GetControlCardId ().GetChassisSerialNumber (),
832- Supplier : resp .GetControlCardId ().GetChassisManufacturer (),
833- })
830+ fetchEKResp , err := fetchEK (ctx , req .Deps , resp .GetControlCardId ())
834831 if err != nil {
835- err = fmt .Errorf ("failed to fetch EK public key for control card %s: %w" , prototext .Format (resp .GetControlCardId ()), err )
836- log .ErrorContext (ctx , err )
837- return err
838- }
839- if fetchEKResp == nil {
840- err = fmt .Errorf ("failed to fetch EK public key: RoT database returned an empty response" )
841- log .ErrorContext (ctx , err )
842- return err
832+ return fmt .Errorf ("failed to fetch EK: %w" , err )
843833 }
834+
844835 ekPublicKey := fetchEKResp .EkPublicKey
845836 ekAlgo := tpm12 .AlgRSA
846837 ekEncScheme := EsRSAEsOAEPSHA1MGF1
@@ -1017,10 +1008,10 @@ func verifyIdentityWithHMACChallenge(ctx context.Context, controlCardSelection *
10171008 return nil , nil , nil , fmt .Errorf ("failed to get control card vendor ID: %w" , err )
10181009 }
10191010
1020- // Get EK Public Key (or PPK) from RoT database.
1021- fetchEKResp , err := fetchEKPublicKey (ctx , deps , controlCardVendorID .GetControlCardId ())
1011+ // Get EK (or PPK) from RoT database.
1012+ fetchEKResp , err := fetchEK (ctx , deps , controlCardVendorID .GetControlCardId ())
10221013 if err != nil {
1023- return nil , nil , nil , fmt .Errorf ("failed to fetch EK: %w" , err )
1014+ return nil , nil , nil , fmt .Errorf ("failed to fetch EK/PPK : %w" , err )
10241015 }
10251016
10261017 // Create HMAC Challenge request.
@@ -1075,14 +1066,14 @@ func verifyIdentityWithHMACChallenge(ctx context.Context, controlCardSelection *
10751066 return controlCardVendorID .GetControlCardId (), iakPubKey , idevidPubKey , nil
10761067}
10771068
1078- // fetchEKPublicKey fetches the EK Public Key from the RoT database.
1079- func fetchEKPublicKey (ctx context.Context , client ROTDBClient , cardID * cpb.ControlCardVendorId ) (* FetchEKResp , error ) {
1069+ // fetchEK fetches the stored EK or PPK from the RoT database.
1070+ func fetchEK (ctx context.Context , client ROTDBClient , cardID * cpb.ControlCardVendorId ) (* FetchEKResp , error ) {
10801071 fetchEKResp , err := client .FetchEK (ctx , & FetchEKReq {
1081- Serial : cardID .GetChassisSerialNumber (),
1072+ Serial : cardID .GetControlCardSerial (),
10821073 Supplier : cardID .GetChassisManufacturer (),
10831074 })
10841075 if err != nil {
1085- return nil , fmt .Errorf ("failed to fetch EK public key for control card %s: %w" , prototext .Format (cardID ), err )
1076+ return nil , fmt .Errorf ("failed to fetch EK/PPK for control card %s: %w" , prototext .Format (cardID ), err )
10861077 }
10871078 if fetchEKResp == nil {
10881079 return nil , fmt .Errorf ("%w: RoT database returned an empty FetchEKResp for control card %s" , ErrInvalidResponse , prototext .Format (cardID ))
0 commit comments