@@ -27,6 +27,14 @@ use dcap_types::{EnclaveIdentityV2TcbStatus, Status, TcbInfoV3TcbStatus};
2727use dcap_types:: { ECDSA_256_WITH_P256_CURVE , INTEL_QE_VENDOR_ID } ;
2828use x509_parser:: certificate:: X509Certificate ;
2929
30+ /// The TCB info of the QE
31+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
32+ pub struct QETCB {
33+ pub tcb_evaluation_data_number : u32 ,
34+ pub tcb_status : EnclaveIdentityV2TcbStatus ,
35+ pub advisory_ids : Vec < String > ,
36+ }
37+
3038/// common_verify_and_fetch_tcb is a common function that verifies the quote and fetches the TCB info
3139///
3240/// # Arguments
@@ -46,7 +54,6 @@ use x509_parser::certificate::X509Certificate;
4654///
4755/// * A tuple containing:
4856/// * The TCB status of the QE
49- /// * The advisory IDs of the QE
5057/// * The SGX extensions from the PCK leaf certificate
5158/// * The TCB info
5259/// * The validity intersection of all collaterals
@@ -62,13 +69,7 @@ fn common_verify_and_fetch_tcb(
6269 qe_cert_data : & CertData ,
6370 collaterals : & IntelCollateral ,
6471 current_time : u64 ,
65- ) -> Result < (
66- EnclaveIdentityV2TcbStatus ,
67- Vec < String > ,
68- SgxExtensions ,
69- TcbInfo ,
70- ValidityIntersection ,
71- ) > {
72+ ) -> Result < ( QETCB , SgxExtensions , TcbInfo , ValidityIntersection ) > {
7273 // get the certchain embedded in the ecda quote signature data
7374 // this can be one of 5 types, and we only support type 5
7475 // https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/aa239d25a437a28f3f4de92c38f5b6809faac842/QuoteGeneration/quote_wrapper/common/inc/sgx_quote_3.h#L63C4-L63C112
@@ -143,41 +144,28 @@ fn common_verify_and_fetch_tcb(
143144 } ;
144145
145146 // validate QE Report and Quote Body
146- let ( qe_tcb_status, advisory_ids, pck_cert_sgx_extensions) = {
147- let ( qe_tcb_status, advisory_ids) = verify_qe_report (
148- qe_report,
149- ecdsa_attestation_pubkey,
150- qe_auth_data,
151- & qeidentityv2,
152- & pck_leaf_cert,
153- qe_report_signature,
154- ) ?;
155- verify_quote_attestation (
156- quote_header,
157- quote_body,
158- ecdsa_attestation_pubkey,
159- ecdsa_attestation_signature,
160- )
161- . context ( "Invalid quote attestation" ) ?;
162-
163- (
164- qe_tcb_status,
165- advisory_ids,
166- extract_sgx_extensions ( & pck_leaf_cert) ?,
167- )
168- } ;
147+ let qe_tcb = verify_qe_report (
148+ qe_report,
149+ ecdsa_attestation_pubkey,
150+ qe_auth_data,
151+ & qeidentityv2,
152+ & pck_leaf_cert,
153+ qe_report_signature,
154+ ) ?;
155+ verify_quote_attestation (
156+ quote_header,
157+ quote_body,
158+ ecdsa_attestation_pubkey,
159+ ecdsa_attestation_signature,
160+ )
161+ . context ( "Invalid quote attestation" ) ?;
162+ let pck_cert_sgx_extensions = extract_sgx_extensions ( & pck_leaf_cert) ?;
169163
170164 if !validity. validate ( ) {
171165 bail ! ( "Validity intersection provided from collaterals is invalid" ) ;
172166 }
173167
174- Ok ( (
175- qe_tcb_status,
176- advisory_ids,
177- pck_cert_sgx_extensions,
178- tcb_info,
179- validity,
180- ) )
168+ Ok ( ( qe_tcb, pck_cert_sgx_extensions, tcb_info, validity) )
181169}
182170
183171fn check_quote_header ( quote_header : & QuoteHeader , expected_quote_version : u16 ) -> Result < ( ) > {
@@ -206,7 +194,7 @@ fn verify_qe_report(
206194 qeidentityv2 : & EnclaveIdentityV2 ,
207195 pck_leaf_cert : & X509Certificate ,
208196 qe_report_signature : & [ u8 ; 64 ] ,
209- ) -> Result < ( EnclaveIdentityV2TcbStatus , Vec < String > ) > {
197+ ) -> Result < QETCB > {
210198 // validate QEReport then get TCB Status
211199 if !validate_qe_report_data (
212200 & qe_report. report_data ,
@@ -228,7 +216,14 @@ fn verify_qe_report(
228216
229217 // https://github.com/intel/SGX-TDX-DCAP-QuoteVerificationLibrary/blob/29bd3b0a3b46c1159907d656b45f378f97e7e686/Src/AttestationLibrary/src/Verifiers/EnclaveReportVerifier.cpp#L92
230218 // https://github.com/intel/SGX-TDX-DCAP-QuoteVerificationLibrary/blob/7e5b2a13ca5472de8d97dd7d7024c2ea5af9a6ba/Src/AttestationLibrary/src/Verifiers/QuoteVerifier.cpp#L286
231- get_qe_tcbstatus ( qe_report. isv_svn , & qeidentityv2. enclave_identity . tcb_levels )
219+ let ( tcb_status, advisory_ids) =
220+ get_qe_tcbstatus ( qe_report. isv_svn , & qeidentityv2. enclave_identity . tcb_levels ) ?;
221+
222+ Ok ( QETCB {
223+ tcb_evaluation_data_number : qeidentityv2. enclave_identity . tcb_evaluation_data_number ,
224+ tcb_status,
225+ advisory_ids,
226+ } )
232227}
233228
234229/// Verify the attestation signature for the quote (header + body) using the attestation public key
0 commit comments