@@ -62,7 +62,7 @@ struct AppStateInner {
6262}
6363
6464impl AppStateInner {
65- fn info_attestation ( & self ) -> Result < Option < ra_rpc:: Attestation > > {
65+ fn info_attestation ( & self ) -> Result < ra_rpc:: Attestation > {
6666 self . platform . attestation_for_info ( )
6767 }
6868
@@ -178,9 +178,7 @@ pub struct InternalRpcHandler {
178178
179179pub async fn get_info ( state : & AppState , external : bool ) -> Result < AppInfo > {
180180 let hide_tcb_info = external && !state. config ( ) . app_compose . public_tcbinfo ;
181- let Some ( attestation) = state. inner . info_attestation ( ) ? else {
182- return Ok ( AppInfo :: default ( ) ) ;
183- } ;
181+ let attestation = state. inner . info_attestation ( ) ?;
184182 let app_info = attestation
185183 . decode_app_info ( false )
186184 . context ( "Failed to decode app info" ) ?;
@@ -651,14 +649,7 @@ impl RpcCall<AppState> for ExternalRpcHandler {
651649#[ cfg( test) ]
652650mod tests {
653651 use super :: * ;
654- use crate :: {
655- backend:: {
656- load_versioned_attestation, simulated_attest_response,
657- simulated_certificate_attestation, simulated_info_attestation,
658- simulated_quote_response, PlatformBackend ,
659- } ,
660- config:: { AppComposeWrapper , Config } ,
661- } ;
652+ use crate :: { backend:: PlatformBackend , config:: { AppComposeWrapper , Config } } ;
662653 use dstack_guest_agent_rpc:: { GetAttestationForAppKeyRequest , SignRequest } ;
663654 use ra_tls:: attestation:: VersionedAttestation ;
664655 use dstack_types:: { AppCompose , AppKeys , KeyProvider } ;
@@ -807,24 +798,40 @@ pNs85uhOZE8z2jr8Pg==
807798 }
808799
809800 impl PlatformBackend for TestSimulatorPlatform {
810- fn attestation_for_info ( & self ) -> Result < Option < ra_rpc:: Attestation > > {
811- Ok ( Some ( simulated_info_attestation ( & self . attestation ) ) )
801+ fn attestation_for_info ( & self ) -> Result < ra_rpc:: Attestation > {
802+ Ok ( self . attestation . clone ( ) . into_inner ( ) )
812803 }
813804
814805 fn certificate_attestation ( & self , pubkey : & [ u8 ] ) -> Result < VersionedAttestation > {
815- Ok ( simulated_certificate_attestation ( & self . attestation , pubkey) )
806+ let mut attestation = self . attestation . clone ( ) ;
807+ let report_data = ra_tls:: attestation:: QuoteContentType :: RaTlsCert . to_report_data ( pubkey) ;
808+ attestation. set_report_data ( report_data) ;
809+ Ok ( attestation)
816810 }
817811
818812 fn quote_response (
819813 & self ,
820814 report_data : [ u8 ; 64 ] ,
821815 vm_config : & str ,
822816 ) -> Result < GetQuoteResponse > {
823- simulated_quote_response ( & self . attestation , report_data, vm_config)
817+ let ra_tls:: attestation:: VersionedAttestation :: V0 { attestation } = self . attestation . clone ( ) ;
818+ let mut attestation = attestation;
819+ let Some ( quote) = attestation. tdx_quote_mut ( ) else {
820+ return Err ( anyhow:: anyhow!( "Quote not found" ) ) ;
821+ } ;
822+ quote. quote [ ra_tls:: attestation:: TDX_QUOTE_REPORT_DATA_RANGE ] . copy_from_slice ( & report_data) ;
823+ Ok ( GetQuoteResponse {
824+ quote : quote. quote . to_vec ( ) ,
825+ event_log : serde_json:: to_string ( & quote. event_log ) . context ( "Failed to serialize event log" ) ?,
826+ report_data : report_data. to_vec ( ) ,
827+ vm_config : vm_config. to_string ( ) ,
828+ } )
824829 }
825830
826831 fn attest_response ( & self , _report_data : [ u8 ; 64 ] ) -> Result < AttestResponse > {
827- Ok ( simulated_attest_response ( & self . attestation ) )
832+ Ok ( AttestResponse {
833+ attestation : self . attestation . to_scale ( ) ,
834+ } )
828835 }
829836
830837 fn emit_event ( & self , _event : & str , _payload : & [ u8 ] ) -> Result < ( ) > {
@@ -839,7 +846,7 @@ pNs85uhOZE8z2jr8Pg==
839846 cert_client : dummy_cert_client,
840847 demo_cert : RwLock :: new ( String :: new ( ) ) ,
841848 platform : Arc :: new ( TestSimulatorPlatform {
842- attestation : load_versioned_attestation ( temp_attestation_file. path ( ) ) . unwrap ( ) ,
849+ attestation : VersionedAttestation :: from_scale ( & std :: fs :: read ( temp_attestation_file. path ( ) ) . unwrap ( ) ) . unwrap ( ) ,
843850 } ) ,
844851 } ;
845852
0 commit comments