diff --git a/app/src/commands/enclave.rs b/app/src/commands/enclave.rs index 8798fa6a..77d90982 100644 --- a/app/src/commands/enclave.rs +++ b/app/src/commands/enclave.rs @@ -142,10 +142,10 @@ fn run_list_keys, S: CommitStore>( "type": "dcap", "address": eki.address.to_hex_string(), "attested": true, - "report_data": dcap_quote.report_data().to_string(), - "isv_enclave_quote_status": dcap_quote.tcb_status.to_string(), + "report_data": dcap_quote.report_data()?.to_string(), + "isv_enclave_quote_status": dcap_quote.tcb_status, "advisory_ids": dcap_quote.advisory_ids, - "attested_at": dcap_quote.attested_at, + "attested_at": dcap_quote.attested_at.to_string(), }}); } else { list_json.push(json! {{ diff --git a/modules/attestation-report/src/dcap.rs b/modules/attestation-report/src/dcap.rs index 92c92769..99e96e43 100644 --- a/modules/attestation-report/src/dcap.rs +++ b/modules/attestation-report/src/dcap.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::serde_base64; use crate::Error; -use crate::ReportData; use lcp_types::Time; use serde::{Deserialize, Serialize}; @@ -9,57 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct DCAPQuote { #[serde(with = "serde_base64")] pub raw: Vec, - pub tcb_status: TcbStatus, + pub tcb_status: String, pub advisory_ids: Option>, pub attested_at: Time, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub enum TcbStatus { - OK, - TcbSwHardeningNeeded, - TcbConfigurationAndSwHardeningNeeded, - TcbConfigurationNeeded, - TcbOutOfDate, - TcbOutOfDateConfigurationNeeded, - TcbRevoked, - TcbUnrecognized, -} - -impl TcbStatus { - pub fn from_str(s: &str) -> Self { - return match s { - "UpToDate" => TcbStatus::OK, - "SWHardeningNeeded" => TcbStatus::TcbSwHardeningNeeded, - "ConfigurationAndSWHardeningNeeded" => TcbStatus::TcbConfigurationAndSwHardeningNeeded, - "ConfigurationNeeded" => TcbStatus::TcbConfigurationNeeded, - "OutOfDate" => TcbStatus::TcbOutOfDate, - "OutOfDateConfigurationNeeded" => TcbStatus::TcbOutOfDateConfigurationNeeded, - "Revoked" => TcbStatus::TcbRevoked, - _ => TcbStatus::TcbUnrecognized, - }; - } -} - -impl ToString for TcbStatus { - fn to_string(&self) -> String { - return match self { - TcbStatus::OK => "UpToDate".to_string(), - TcbStatus::TcbSwHardeningNeeded => "SWHardeningNeeded".to_string(), - TcbStatus::TcbConfigurationAndSwHardeningNeeded => { - "ConfigurationAndSWHardeningNeeded".to_string() - } - TcbStatus::TcbConfigurationNeeded => "ConfigurationNeeded".to_string(), - TcbStatus::TcbOutOfDate => "OutOfDate".to_string(), - TcbStatus::TcbOutOfDateConfigurationNeeded => { - "OutOfDateConfigurationNeeded".to_string() - } - TcbStatus::TcbRevoked => "Revoked".to_string(), - TcbStatus::TcbUnrecognized => "Unrecognized".to_string(), - }; - } -} - impl DCAPQuote { pub fn new( raw_quote: Vec, @@ -69,7 +22,7 @@ impl DCAPQuote { ) -> Self { DCAPQuote { raw: raw_quote, - tcb_status: TcbStatus::from_str(&tcb_status), + tcb_status, advisory_ids, attested_at, } @@ -84,9 +37,9 @@ impl DCAPQuote { } #[cfg(feature = "std")] - pub fn report_data(&self) -> ReportData { + pub fn report_data(&self) -> Result { use dcap_rs::types::quotes::version_3::QuoteV3; let quote = QuoteV3::from_bytes(&self.raw); - ReportData(quote.isv_enclave_report.report_data) + Ok(crate::ReportData(quote.isv_enclave_report.report_data)) } }