Extract gramine_sgx_ias_report
This commit is contained in:
parent
178a738eec
commit
c3e9af7ce9
1 changed files with 14 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
mod cli;
|
||||
|
||||
use std::{
|
||||
error::Error,
|
||||
fs::{read_to_string, File},
|
||||
io::Write,
|
||||
process::Command,
|
||||
|
@ -9,7 +10,7 @@ use std::{
|
|||
use clap::Parser;
|
||||
use quartz_proto::quartz::{core_client::CoreClient, InstantiateRequest};
|
||||
use quartz_relayer::types::InstantiateResponse;
|
||||
use serde_json::json;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::cli::Cli;
|
||||
|
||||
|
@ -21,13 +22,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let response = client.instantiate(InstantiateRequest {}).await?;
|
||||
let response: InstantiateResponse = response.into_inner().try_into()?;
|
||||
|
||||
let ias_report = gramine_sgx_ias_report(response.quote())?;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string(&ias_report).expect("infallible serializer")
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn gramine_sgx_ias_report(quote: &[u8]) -> Result<Value, Box<dyn Error>> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
let quote_file_path = dir.path().join("test.quote");
|
||||
let datareport_file_path = dir.path().join("datareport");
|
||||
let datareportsig_file_path = dir.path().join("datareportsig");
|
||||
|
||||
let mut quote_file = File::create(quote_file_path.clone())?;
|
||||
quote_file.write_all(response.quote())?;
|
||||
quote_file.write_all(quote)?;
|
||||
|
||||
let gramine_sgx_ias_request_output = Command::new("gramine-sgx-ias-request")
|
||||
.arg("report")
|
||||
|
@ -42,10 +53,5 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let report = read_to_string(datareport_file_path)?;
|
||||
let report_sig = read_to_string(datareportsig_file_path)?;
|
||||
let ias_report = json!({"report": report, "reportsig": report_sig});
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string(&ias_report).expect("infallible serializer")
|
||||
);
|
||||
|
||||
Ok(())
|
||||
Ok(ias_report)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue