Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/rust: extend optional type to support configfs-tsm #124

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
Loading