Skip to content

Commit

Permalink
vmsdk/rust: algin interface of event logs replay
Browse files Browse the repository at this point in the history
Replay event logs is a common interface and has been moved to
CCTrustedApi trait

Signed-off-by: Xiaocheng Dong <[email protected]>
  • Loading branch information
dongx1x committed Apr 2, 2024
1 parent 95dc2c7 commit 8cec14a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
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

0 comments on commit 8cec14a

Please sign in to comment.