@@ -12,10 +12,10 @@ use crate::Result;
1212pub struct QvCollateral {
1313 /// TCBInfo in JSON format
1414 /// ref. <https://api.portal.trustedservices.intel.com/content/documentation.html#pcs-tcb-info-model-v3>
15- pub tcb_info_json : Vec < u8 > ,
15+ pub tcb_info_json : String ,
1616 /// QEIdentity in JSON format
1717 /// ref. <https://api.portal.trustedservices.intel.com/content/documentation.html#pcs-enclave-identity-model-v2>
18- pub qe_identity_json : Vec < u8 > ,
18+ pub qe_identity_json : String ,
1919 /// SGX Intel Root CA certificate in DER format
2020 /// ref. <https://certificates.trustedservices.intel.com/Intel_SGX_Provisioning_Certification_RootCA.pem>
2121 pub sgx_intel_root_ca_der : Vec < u8 > ,
@@ -58,8 +58,8 @@ impl QvCollateral {
5858 data. extend_from_slice ( & ( self . sgx_intel_root_ca_crl_der . len ( ) as u32 ) . to_le_bytes ( ) ) ;
5959 data. extend_from_slice ( & ( self . sgx_pck_crl_der . len ( ) as u32 ) . to_le_bytes ( ) ) ;
6060
61- data. extend_from_slice ( & self . tcb_info_json ) ;
62- data. extend_from_slice ( & self . qe_identity_json ) ;
61+ data. extend_from_slice ( self . tcb_info_json . as_bytes ( ) ) ;
62+ data. extend_from_slice ( self . qe_identity_json . as_bytes ( ) ) ;
6363 data. extend_from_slice ( & self . sgx_intel_root_ca_der ) ;
6464 data. extend_from_slice ( & self . sgx_tcb_signing_der ) ;
6565 data. extend_from_slice ( & self . sgx_intel_root_ca_crl_der ) ;
@@ -98,9 +98,10 @@ impl QvCollateral {
9898 bail ! ( "Invalid QvCollateral length" ) ;
9999 }
100100
101- let tcb_info_json = slice[ offset..offset + tcb_info_json_len] . to_vec ( ) ;
101+ let tcb_info_json = String :: from_utf8 ( slice[ offset..offset + tcb_info_json_len] . to_vec ( ) ) ? ;
102102 offset += tcb_info_json_len;
103- let qe_identity_json = slice[ offset..offset + qe_identity_json_len] . to_vec ( ) ;
103+ let qe_identity_json =
104+ String :: from_utf8 ( slice[ offset..offset + qe_identity_json_len] . to_vec ( ) ) ?;
104105 offset += qe_identity_json_len;
105106 let sgx_intel_root_ca_der = slice[ offset..offset + sgx_intel_root_ca_der_len] . to_vec ( ) ;
106107 offset += sgx_intel_root_ca_der_len;
@@ -124,7 +125,7 @@ impl QvCollateral {
124125
125126 /// Returns the TCBInfoV3 struct from the TCBInfo JSON bytes
126127 pub fn get_tcb_info_v3 ( & self ) -> Result < TcbInfoV3 > {
127- let tcb_info_v3: TcbInfoV3 = serde_json:: from_slice ( & self . tcb_info_json ) ?;
128+ let tcb_info_v3: TcbInfoV3 = serde_json:: from_str ( & self . tcb_info_json ) ?;
128129 if tcb_info_v3. tcb_info . version != 3 {
129130 bail ! ( "Invalid TCB Info version: {}" , tcb_info_v3. tcb_info. version) ;
130131 }
@@ -133,7 +134,7 @@ impl QvCollateral {
133134
134135 /// Returns the EnclaveIdentityV2 struct from the QEIdentity JSON bytes
135136 pub fn get_qe_identity_v2 ( & self ) -> Result < EnclaveIdentityV2 > {
136- let qe: EnclaveIdentityV2 = serde_json:: from_slice ( & self . qe_identity_json ) ?;
137+ let qe: EnclaveIdentityV2 = serde_json:: from_str ( & self . qe_identity_json ) ?;
137138 if qe. enclave_identity . version != 2 {
138139 bail ! (
139140 "Invalid QE Identity version: {}" ,
0 commit comments