@@ -131,63 +131,61 @@ impl QuoteVerifier for DcapTdxQuoteVerifier {
131131 true
132132 }
133133
134- fn verify_attestation (
134+ async fn verify_attestation (
135135 & self ,
136136 input : Vec < u8 > ,
137137 cert_chain : & [ CertificateDer < ' _ > ] ,
138138 exporter : [ u8 ; 32 ] ,
139- ) -> impl Future < Output = Result < ( ) , AttestationError > > + Send {
140- async move {
141- let quote_input = compute_report_input ( cert_chain, exporter) ?;
142- let ( platform_measurements, image_measurements) = if cfg ! ( not( test) ) {
143- let now = std:: time:: SystemTime :: now ( )
144- . duration_since ( std:: time:: UNIX_EPOCH )
145- . unwrap ( )
146- . as_secs ( ) ;
147- let quote = Quote :: parse ( & input) . unwrap ( ) ;
148- let ca = quote. ca ( ) . unwrap ( ) ;
149- let fmspc = hex:: encode_upper ( quote. fmspc ( ) . unwrap ( ) ) ;
150- let collateral = get_collateral_for_fmspc ( PCS_URL , fmspc, ca, false )
151- . await
152- . unwrap ( ) ;
153- let _verified_report = dcap_qvl:: verify:: verify ( & input, & collateral, now) . unwrap ( ) ;
154-
155- let quote = Quote :: parse ( & input) . unwrap ( ) ;
156- let measurements = (
157- PlatformMeasurements :: from_dcap_qvl_quote ( & quote) ?,
158- CvmImageMeasurements :: from_dcap_qvl_quote ( & quote) ?,
159- ) ;
160- if get_quote_input_data ( quote. report ) != quote_input {
161- return Err ( AttestationError :: InputMismatch ) ;
162- }
163- measurements
164- } else {
165- // In tests we use mock quotes which will fail to verify
166- let quote = tdx_quote:: Quote :: from_bytes ( & input) . unwrap ( ) ;
167- if quote. report_input_data ( ) != quote_input {
168- return Err ( AttestationError :: InputMismatch ) ;
169- }
170-
171- (
172- PlatformMeasurements :: from_tdx_quote ( & quote) ,
173- CvmImageMeasurements :: from_tdx_quote ( & quote) ,
174- )
175- } ;
176-
177- if let Some ( accepted_platform_measurements) = & self . accepted_platform_measurements {
178- if !accepted_platform_measurements. contains ( & platform_measurements) {
179- panic ! ( "Bad measurements" ) ;
180- }
139+ ) -> Result < ( ) , AttestationError > {
140+ let quote_input = compute_report_input ( cert_chain, exporter) ?;
141+ let ( platform_measurements, image_measurements) = if cfg ! ( not( test) ) {
142+ let now = std:: time:: SystemTime :: now ( )
143+ . duration_since ( std:: time:: UNIX_EPOCH )
144+ . unwrap ( )
145+ . as_secs ( ) ;
146+ let quote = Quote :: parse ( & input) . unwrap ( ) ;
147+ let ca = quote. ca ( ) . unwrap ( ) ;
148+ let fmspc = hex:: encode_upper ( quote. fmspc ( ) . unwrap ( ) ) ;
149+ let collateral = get_collateral_for_fmspc ( PCS_URL , fmspc, ca, false )
150+ . await
151+ . unwrap ( ) ;
152+ let _verified_report = dcap_qvl:: verify:: verify ( & input, & collateral, now) . unwrap ( ) ;
153+
154+ let quote = Quote :: parse ( & input) . unwrap ( ) ;
155+ let measurements = (
156+ PlatformMeasurements :: from_dcap_qvl_quote ( & quote) ?,
157+ CvmImageMeasurements :: from_dcap_qvl_quote ( & quote) ?,
158+ ) ;
159+ if get_quote_input_data ( quote. report ) != quote_input {
160+ return Err ( AttestationError :: InputMismatch ) ;
161+ }
162+ measurements
163+ } else {
164+ // In tests we use mock quotes which will fail to verify
165+ let quote = tdx_quote:: Quote :: from_bytes ( & input) . unwrap ( ) ;
166+ if quote. report_input_data ( ) != quote_input {
167+ return Err ( AttestationError :: InputMismatch ) ;
181168 }
182169
183- if !self
184- . accepted_cvm_image_measurements
185- . contains ( & image_measurements)
186- {
170+ (
171+ PlatformMeasurements :: from_tdx_quote ( & quote) ,
172+ CvmImageMeasurements :: from_tdx_quote ( & quote) ,
173+ )
174+ } ;
175+
176+ if let Some ( accepted_platform_measurements) = & self . accepted_platform_measurements {
177+ if !accepted_platform_measurements. contains ( & platform_measurements) {
187178 panic ! ( "Bad measurements" ) ;
188179 }
189- Ok ( ( ) )
190180 }
181+
182+ if !self
183+ . accepted_cvm_image_measurements
184+ . contains ( & image_measurements)
185+ {
186+ panic ! ( "Bad measurements" ) ;
187+ }
188+ Ok ( ( ) )
191189 }
192190}
193191
0 commit comments