Skip to content

Commit 3a6ea7d

Browse files
committed
OK
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
1 parent 12ed712 commit 3a6ea7d

File tree

2 files changed

+7
-54
lines changed

2 files changed

+7
-54
lines changed

app/src/commands/enclave.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ fn run_list_keys<E: EnclaveCommandAPI<S>, S: CommitStore>(
142142
"type": "dcap",
143143
"address": eki.address.to_hex_string(),
144144
"attested": true,
145-
"report_data": dcap_quote.report_data().to_string(),
146-
"isv_enclave_quote_status": dcap_quote.tcb_status.to_string(),
145+
"report_data": dcap_quote.report_data()?.to_string(),
146+
"isv_enclave_quote_status": dcap_quote.tcb_status,
147147
"advisory_ids": dcap_quote.advisory_ids,
148-
"attested_at": dcap_quote.attested_at,
148+
"attested_at": dcap_quote.attested_at.to_string(),
149149
}});
150150
} else {
151151
list_json.push(json! {{
Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,18 @@
11
use crate::prelude::*;
22
use crate::serde_base64;
33
use crate::Error;
4-
use crate::ReportData;
54
use lcp_types::Time;
65
use serde::{Deserialize, Serialize};
76

87
#[derive(Debug, Serialize, Deserialize)]
98
pub struct DCAPQuote {
109
#[serde(with = "serde_base64")]
1110
pub raw: Vec<u8>,
12-
pub tcb_status: TcbStatus,
11+
pub tcb_status: String,
1312
pub advisory_ids: Option<Vec<String>>,
1413
pub attested_at: Time,
1514
}
1615

17-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18-
pub enum TcbStatus {
19-
OK,
20-
TcbSwHardeningNeeded,
21-
TcbConfigurationAndSwHardeningNeeded,
22-
TcbConfigurationNeeded,
23-
TcbOutOfDate,
24-
TcbOutOfDateConfigurationNeeded,
25-
TcbRevoked,
26-
TcbUnrecognized,
27-
}
28-
29-
impl TcbStatus {
30-
pub fn from_str(s: &str) -> Self {
31-
return match s {
32-
"UpToDate" => TcbStatus::OK,
33-
"SWHardeningNeeded" => TcbStatus::TcbSwHardeningNeeded,
34-
"ConfigurationAndSWHardeningNeeded" => TcbStatus::TcbConfigurationAndSwHardeningNeeded,
35-
"ConfigurationNeeded" => TcbStatus::TcbConfigurationNeeded,
36-
"OutOfDate" => TcbStatus::TcbOutOfDate,
37-
"OutOfDateConfigurationNeeded" => TcbStatus::TcbOutOfDateConfigurationNeeded,
38-
"Revoked" => TcbStatus::TcbRevoked,
39-
_ => TcbStatus::TcbUnrecognized,
40-
};
41-
}
42-
}
43-
44-
impl ToString for TcbStatus {
45-
fn to_string(&self) -> String {
46-
return match self {
47-
TcbStatus::OK => "UpToDate".to_string(),
48-
TcbStatus::TcbSwHardeningNeeded => "SWHardeningNeeded".to_string(),
49-
TcbStatus::TcbConfigurationAndSwHardeningNeeded => {
50-
"ConfigurationAndSWHardeningNeeded".to_string()
51-
}
52-
TcbStatus::TcbConfigurationNeeded => "ConfigurationNeeded".to_string(),
53-
TcbStatus::TcbOutOfDate => "OutOfDate".to_string(),
54-
TcbStatus::TcbOutOfDateConfigurationNeeded => {
55-
"OutOfDateConfigurationNeeded".to_string()
56-
}
57-
TcbStatus::TcbRevoked => "Revoked".to_string(),
58-
TcbStatus::TcbUnrecognized => "Unrecognized".to_string(),
59-
};
60-
}
61-
}
62-
6316
impl DCAPQuote {
6417
pub fn new(
6518
raw_quote: Vec<u8>,
@@ -69,7 +22,7 @@ impl DCAPQuote {
6922
) -> Self {
7023
DCAPQuote {
7124
raw: raw_quote,
72-
tcb_status: TcbStatus::from_str(&tcb_status),
25+
tcb_status,
7326
advisory_ids,
7427
attested_at,
7528
}
@@ -84,9 +37,9 @@ impl DCAPQuote {
8437
}
8538

8639
#[cfg(feature = "std")]
87-
pub fn report_data(&self) -> ReportData {
40+
pub fn report_data(&self) -> Result<crate::ReportData, Error> {
8841
use dcap_rs::types::quotes::version_3::QuoteV3;
8942
let quote = QuoteV3::from_bytes(&self.raw);
90-
ReportData(quote.isv_enclave_report.report_data)
43+
Ok(crate::ReportData(quote.isv_enclave_report.report_data))
9144
}
9245
}

0 commit comments

Comments
 (0)