Skip to content

Commit

Permalink
Dcap debugging helpers (#1346)
Browse files Browse the repository at this point in the history
* introduce attesteer compiler flag

* panic if DCAP collateral registration fails

* revert and just leave logging

* try to get err from null

* try to get err from null...

* cosmetics

* cosmetics

* cosmetics

* cosmetics

* cosmetics
  • Loading branch information
brenzi authored Jun 6, 2023
1 parent 6ce5871 commit 2d9b617
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions core-primitives/enclave-api/src/remote_attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,27 +409,27 @@ impl RemoteAttestation for Enclave {
pck_crl_size: {}\n, \
tcb_info_issuer_chain: {:?}\n, \
tcb_info_issuer_chain_size: {}\n, \
tcb_info: {:?}\n, \
tcb_info: {}\n, \
tcb_info_size: {}\n, \
qe_identity_issuer_chain: {:?}\n, \
qe_identity_issuer_chain_size: {}\n, \
qe_identity: {:?}\n, \
qe_identity: {}\n, \
qe_identity_size: {}\n",
collateral.version,
collateral.tee_type,
std::ffi::CStr::from_ptr(collateral.pck_crl_issuer_chain).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.pck_crl_issuer_chain).to_string_lossy(),
collateral.pck_crl_issuer_chain_size,
std::ffi::CStr::from_ptr(collateral.root_ca_crl).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.root_ca_crl).to_string_lossy(),
collateral.root_ca_crl_size,
std::ffi::CStr::from_ptr(collateral.pck_crl).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.pck_crl).to_string_lossy(),
collateral.pck_crl_size,
std::ffi::CStr::from_ptr(collateral.tcb_info_issuer_chain).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.tcb_info_issuer_chain).to_string_lossy(),
collateral.tcb_info_issuer_chain_size,
std::ffi::CStr::from_ptr(collateral.tcb_info).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.tcb_info).to_string_lossy(),
collateral.tcb_info_size,
std::ffi::CStr::from_ptr(collateral.qe_identity_issuer_chain).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.qe_identity_issuer_chain).to_string_lossy(),
collateral.qe_identity_issuer_chain_size,
std::ffi::CStr::from_ptr(collateral.qe_identity).to_str().unwrap(),
std::ffi::CStr::from_ptr(collateral.qe_identity).to_string_lossy(),
collateral.qe_identity_size,
);
};
Expand Down
1 change: 1 addition & 0 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ offchain-worker = ["itp-settings/offchain-worker"]
production = ["itp-settings/production"]
teeracle = ["itp-settings/teeracle"]
dcap = []
attesteer = []

[dev-dependencies]
# crates.io
Expand Down
9 changes: 5 additions & 4 deletions service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ fn start_worker<E, T, D, InitializationHandler, WorkerModeProvider>(
register_collateral(&node_api, &*enclave, &tee_accountid, is_development_mode, skip_ra);

let trusted_url = config.trusted_worker_url_external();
#[cfg(feature = "dcap")]
#[cfg(feature = "attesteer")]
let marblerun_base_url =
run_config.marblerun_base_url.unwrap_or("http://localhost:9944".to_owned());

#[cfg(feature = "dcap")]
#[cfg(feature = "attesteer")]
fetch_marblerun_events_every_hour(
node_api.clone(),
enclave.clone(),
Expand Down Expand Up @@ -762,10 +762,11 @@ fn register_collateral(
let dcap_quote = enclave.generate_dcap_ra_quote(skip_ra).unwrap();
if !skip_ra {
let (fmspc, _tcb_info) = extract_tcb_info_from_raw_dcap_quote(&dcap_quote).unwrap();

println!("[>] DCAP setup: register QE collateral");
let uxt = enclave.generate_register_quoting_enclave_extrinsic(fmspc).unwrap();
send_extrinsic(uxt, api, accountid, is_development_mode);

println!("[>] DCAP setup: register TCB info");
let uxt = enclave.generate_register_tcb_info_extrinsic(fmspc).unwrap();
send_extrinsic(uxt, api, accountid, is_development_mode);
}
Expand All @@ -784,7 +785,7 @@ fn send_extrinsic(
return None
}

println!("[>] Register the TCB info (send the extrinsic)");
println!("[>] send extrinsic");

match api.submit_and_watch_opaque_extrinsic_until_success(extrinsic.into(), true) {
Ok(xt_report) => {
Expand Down

0 comments on commit 2d9b617

Please sign in to comment.