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

vmsdk/rust: algin interface of event logs replay #30

Merged
merged 1 commit into from
Apr 2, 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
20 changes: 0 additions & 20 deletions src/rust/cctrusted_vm/src/cvm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::tdvm::TdxVM;
use anyhow::*;
use cctrusted_base::api_data::ReplayResult;
use cctrusted_base::cc_type::*;
use cctrusted_base::tcg::EventLogEntry;
use cctrusted_base::tcg::{TcgAlgorithmRegistry, TcgDigest};
Expand Down Expand Up @@ -62,25 +61,6 @@ pub trait CVM {
count: Option<u32>,
) -> Result<Vec<EventLogEntry>, anyhow::Error>;

/***
replay retrived CVM eventlogs
Args:
array of eventlogs
Returns:
A struct containing the replay result arranged by IMR index and hash algorithm.
Layer 1 key of the struct is the IMR index, the value is another dict which using the
hash algorithm as the key and the replayed measurement as value.
Sample value:
[
0: [{ 4: <measurement_replayed>},{ 12: <measurement_replayed>},]
1: { 12: <measurement_replayed>},
]
*/
fn replay_eventlog(
&self,
eventlogs: Vec<EventLogEntry>,
) -> Result<Vec<ReplayResult>, anyhow::Error>;

/***
retrive CVM type

Expand Down
10 changes: 0 additions & 10 deletions src/rust/cctrusted_vm/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ impl CCTrustedApi for API {
}
}

// CCTrustedApi trait function: replay eventlogs of a CVM
fn replay_cc_eventlog(
eventlogs: Vec<EventLogEntry>,
) -> Result<Vec<ReplayResult>, anyhow::Error> {
match build_cvm() {
Ok(cvm) => cvm.replay_eventlog(eventlogs),
Err(e) => Err(anyhow!("[replay_cc_eventlog] error create cvm: {:?}", e)),
}
}

// CCTrustedApi trait function: get default algorithm of a CVM
fn get_default_algorithm() -> Result<Algorithm, anyhow::Error> {
match build_cvm() {
Expand Down
8 changes: 0 additions & 8 deletions src/rust/cctrusted_vm/src/tdvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::cvm::*;
use anyhow::*;
use cctrusted_base::api_data::ReplayResult;
use cctrusted_base::cc_type::*;
use cctrusted_base::eventlog::EventLogs;
use cctrusted_base::tcg::*;
Expand Down Expand Up @@ -593,13 +592,6 @@ impl CVM for TdxVM {
eventlogs.select(start, count)
}

fn replay_eventlog(
&self,
eventlogs: Vec<EventLogEntry>,
) -> Result<Vec<ReplayResult>, anyhow::Error> {
EventLogs::replay(eventlogs, TdxRTMR::max_index().into())
}

// CVM trait function: retrive CVM type
fn get_cc_type(&self) -> CcType {
self.cc_type.clone()
Expand Down
Loading