Skip to content

Commit 9616d79

Browse files
authored
Merge pull request #19 from datachainlab/fix-collateral-json-string
Fix type of `QvCollateral`'s json values to string Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
2 parents 1c52677 + d97e7c4 commit 9616d79

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

crates/pcs/src/client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ impl PCSClient {
8282
))?;
8383
let issuer_chain =
8484
extract_raw_certs(get_header(&res, "TCB-Info-Issuer-Chain")?.as_bytes())?;
85-
(res.bytes()?.to_vec(), issuer_chain[0].clone())
85+
(res.text()?, issuer_chain[0].clone())
8686
};
8787

8888
// get the QE identity
89-
let qe_identity_json = http_get(format!("{base_url}/qe/identity?update={update_policy}"))?
90-
.bytes()?
91-
.to_vec();
89+
let qe_identity_json =
90+
http_get(format!("{base_url}/qe/identity?update={update_policy}"))?.text()?;
9291

9392
let pck_crl_url = match get_x509_subject_cn(pck_cert_issuer).as_str() {
9493
"Intel SGX PCK Platform CA" => format!("{base_url}/pckcrl?ca=platform&encoding=der"),

crates/quote-verifier/src/collateral.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use crate::Result;
1212
pub 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: {}",

crates/quote-verifier/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ mod quote_verifier_tests {
7676
#[test]
7777
fn test_verifyv3() {
7878
let collaterals = QvCollateral {
79-
tcb_info_json: include_bytes!("../../../data/v3/tcbinfov3_00906ED50000.json").to_vec(),
80-
qe_identity_json: include_bytes!("../../../data/v3/qeidentityv2.json").to_vec(),
79+
tcb_info_json: include_str!("../../../data/v3/tcbinfov3_00906ED50000.json").to_string(),
80+
qe_identity_json: include_str!("../../../data/v3/qeidentityv2.json").to_string(),
8181
sgx_intel_root_ca_der: include_bytes!(
8282
"../../../data/Intel_SGX_Provisioning_Certification_RootCA.cer"
8383
)
@@ -134,8 +134,8 @@ mod quote_verifier_tests {
134134
#[test]
135135
fn test_verifyv4() {
136136
let collaterals = QvCollateral {
137-
tcb_info_json: include_bytes!("../../../data/v4/tcbinfov3_00806f050000.json").to_vec(),
138-
qe_identity_json: include_bytes!("../../../data/v4/qeidentityv2_apiv4.json").to_vec(),
137+
tcb_info_json: include_str!("../../../data/v4/tcbinfov3_00806f050000.json").to_string(),
138+
qe_identity_json: include_str!("../../../data/v4/qeidentityv2_apiv4.json").to_string(),
139139
sgx_intel_root_ca_der: include_bytes!(
140140
"../../../data/Intel_SGX_Provisioning_Certification_RootCA.cer"
141141
)

crates/quote-verifier/src/quotes/version_3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ mod tests {
182182
.unwrap();
183183

184184
let collateral = QvCollateral {
185-
tcb_info_json: serde_json::to_vec(&tcb_info).unwrap(),
186-
qe_identity_json: serde_json::to_vec(&qe_identity).unwrap(),
185+
tcb_info_json: serde_json::to_string(&tcb_info).unwrap(),
186+
qe_identity_json: serde_json::to_string(&qe_identity).unwrap(),
187187
sgx_intel_root_ca_der: root_ca.cert.to_der().unwrap(),
188188
sgx_tcb_signing_der: tcb_certchain.cert.to_der().unwrap(),
189189
sgx_intel_root_ca_crl_der: root_ca_crl,
1.57 KB
Binary file not shown.

zkvm/risc0/src/methods.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
pub const DCAP_QUOTE_VERIFIER_ID: [u32; 8] = [1899810625, 477674516, 2284155673, 144601314, 1476267439, 1192845965, 2114671039, 4035334195];
3-
pub const DCAP_QUOTE_VERIFIER_ID_STR: &str = "41cf3c7114bc781c19732588e2709e08af0dfe578d621947bf510b7e335086f0";
2+
pub const DCAP_QUOTE_VERIFIER_ID: [u32; 8] = [483828460, 459610919, 1188057978, 2178293476, 1749789425, 4194043372, 1381224536, 1377785701];
3+
pub const DCAP_QUOTE_VERIFIER_ID_STR: &str = "eca2d61c271b651b7a53d046e41ed681f1aa4b68ec05fcf958d0535265571f52";
44
pub const DCAP_QUOTE_VERIFIER_ELF: &[u8] = include_bytes!("../artifacts/dcap-quote-verifier");

0 commit comments

Comments
 (0)