Skip to content

Commit

Permalink
common/rust: extend optional type to support configfs-tsm (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaocheng Dong <xiaocheng.dong@intel.com>
  • Loading branch information
dongx1x authored Apr 18, 2024
1 parent 4864040 commit 3b0ab7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions common/rust/cctrusted_base/src/api_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ use crate::tcg::TcgDigest;
pub struct ExtraArgs {}

// return of API get_cc_report()
#[derive(Default)]
pub struct CcReport {
pub cc_report: Vec<u8>,
pub cc_type: TeeType,
pub cc_aux_blob: Option<Vec<u8>>,
pub cc_report_generation: Option<u32>,
pub cc_provider: Option<String>,
}

/***
Expand Down
28 changes: 14 additions & 14 deletions common/rust/cctrusted_base/src/cc_type.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
use hashbrown::HashMap;
use core::convert::From;

// supported TEE types
#[derive(Clone, Eq, Hash, PartialEq, Debug)]
#[derive(Clone, Eq, Hash, PartialEq, Debug, Default)]
pub enum TeeType {
PLAIN = -1,
TPM = 0,
#[default]
TDX = 1,
SEV = 2,
CCA = 3,
}

// TEE type to type name string mapping
lazy_static! {
pub static ref TEE_NAME_MAP: HashMap<TeeType, String> = {
let mut map: HashMap<TeeType, String> = HashMap::new();
map.insert(TeeType::PLAIN, "PLAIN".to_string());
map.insert(TeeType::TDX, "TDX".to_string());
map.insert(TeeType::SEV, "SEV".to_string());
map.insert(TeeType::CCA, "CCA".to_string());
map.insert(TeeType::TPM, "TPM".to_string());
map
};
impl From<TeeType> for String {
fn from(t: TeeType) -> String {
match t {
TeeType::PLAIN => "PLAIN".to_string(),
TeeType::TPM => "TPM".to_string(),
TeeType::TDX => "TDX".to_string(),
TeeType::SEV => "SEV".to_string(),
TeeType::CCA => "CCA".to_string(),
}
}
}

// public known device node path
Expand All @@ -29,10 +29,10 @@ pub const TEE_TDX_1_0_PATH: &str = "/dev/tdx-guest";
pub const TEE_TDX_1_5_PATH: &str = "/dev/tdx_guest";
pub const TEE_SEV_PATH: &str = "/dev/sev-guest";
pub const TEE_CCA_PATH: &str = "";
pub const TSM_PREFIX: &str = "/sys/kernel/config/tsm/report";

// holds the TEE type info
#[derive(Clone)]
pub struct CcType {
pub tee_type: TeeType,
pub tee_type_str: String,
}

0 comments on commit 3b0ab7d

Please sign in to comment.