@@ -20,14 +20,14 @@ pub struct PCSClient {
2020 pcs_or_pccs_url : String ,
2121 /// The URL of the Intel SGX Certificates Service.
2222 certs_service_url : String ,
23- /// Whether to use the early update or standard update to get the TCB info .
24- is_early_update : bool ,
23+ /// The target TCB evaluation data number. If None, the latest TCB evaluation data will be used .
24+ target_tcb_evaluation_data_number : Option < u32 > ,
2525}
2626
2727impl Default for PCSClient {
2828 /// Default PCSClient uses Intel's PCS and Certificates Service URLs.
2929 fn default ( ) -> Self {
30- PCSClient :: new ( INTEL_SGX_PCS_URL , INTEL_SGX_CERTS_URL , false )
30+ PCSClient :: new ( INTEL_SGX_PCS_URL , INTEL_SGX_CERTS_URL , None )
3131 }
3232}
3333
@@ -37,12 +37,16 @@ impl PCSClient {
3737 /// # Arguments
3838 /// * `pcs_or_pccs_url` - The URL of the Provisioning Certification Service (PCS) or Provisioning Certification Caching Service (PCCS).
3939 /// * `certs_service_url` - The URL of the Intel SGX Certificates Service.
40- /// * `is_early_update` - Whether to use the early update policy.
41- pub fn new ( pcs_or_pccs_url : & str , certs_service_url : & str , is_early_update : bool ) -> Self {
40+ /// * `target_tcb_evaluation_data_number` - The target TCB evaluation data number. If None, the latest TCB evaluation data will be used.
41+ pub fn new (
42+ pcs_or_pccs_url : & str ,
43+ certs_service_url : & str ,
44+ target_tcb_evaluation_data_number : Option < u32 > ,
45+ ) -> Self {
4246 PCSClient {
4347 pcs_or_pccs_url : pcs_or_pccs_url. trim_end_matches ( '/' ) . to_string ( ) ,
4448 certs_service_url : certs_service_url. trim_end_matches ( '/' ) . to_string ( ) ,
45- is_early_update ,
49+ target_tcb_evaluation_data_number ,
4650 }
4751 }
4852
@@ -82,13 +86,13 @@ impl PCSClient {
8286 let sgx_extensions = extract_sgx_extensions ( pck_cert)
8387 . map_err ( |e| anyhow ! ( "cannot extract SGX extensions: {}" , e) ) ?;
8488
85- let update_policy = self . update_policy ( ) ;
89+ let tcb_evaludation_policy = self . tcb_evaludation_policy ( ) ;
8690
8791 // get the TCB info of the platform
8892 let ( tcb_info_json, sgx_tcb_signing_der) = {
8993 let fmspc = hex:: encode_upper ( sgx_extensions. fmspc ) ;
9094 let res = http_get ( format ! (
91- "{base_url}/tcb?fmspc={fmspc}&update={update_policy }"
95+ "{base_url}/tcb?fmspc={fmspc}&{tcb_evaludation_policy }"
9296 ) ) ?;
9397 let issuer_chain =
9498 extract_raw_certs ( get_header ( & res, "TCB-Info-Issuer-Chain" ) ?. as_bytes ( ) ) ?;
@@ -97,7 +101,7 @@ impl PCSClient {
97101
98102 // get the QE identity
99103 let qe_identity_json =
100- http_get ( format ! ( "{base_url}/qe/identity?update={update_policy }" ) ) ?. text ( ) ?;
104+ http_get ( format ! ( "{base_url}/qe/identity?{tcb_evaludation_policy }" ) ) ?. text ( ) ?;
101105
102106 let pck_crl_url = if is_sgx_pck_platform_ca_dn ( pck_cert_issuer. subject ( ) ) ? {
103107 format ! ( "{pcs_url}/sgx/certification/v4/pckcrl?ca=platform&encoding=der" )
@@ -179,11 +183,11 @@ impl PCSClient {
179183 } )
180184 }
181185
182- fn update_policy ( & self ) -> & str {
183- if self . is_early_update {
184- "early"
186+ fn tcb_evaludation_policy ( & self ) -> String {
187+ if let Some ( target_tcb_evaluation_data_number ) = self . target_tcb_evaluation_data_number {
188+ format ! ( "tcbEvaluationDataNumber={target_tcb_evaluation_data_number}" )
185189 } else {
186- "standard"
190+ "update=early" . to_string ( )
187191 }
188192 }
189193}
0 commit comments