Skip to content

Commit

Permalink
Merge pull request #93 from Freax13/enhancement/apis
Browse files Browse the repository at this point in the history
small improvements for the mushroom library API
  • Loading branch information
Freax13 authored Nov 2, 2024
2 parents 08802e7 + 9af0541 commit 78a495c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions common/loader/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use x86_64::structures::paging::PhysFrame;

use crate::{LoadCommand, LoadCommandPayload};

#[derive(Clone)]
pub struct Input<T> {
pub bytes: T,
pub hash_type: HashType,
Expand Down
15 changes: 10 additions & 5 deletions host/mushroom-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::fmt::{self, Display};

use io::input::{Header, MAX_HASH_SIZE};
use sha2::{Digest, Sha256};
#[cfg(feature = "snp")]
use snp_types::{attestation::TcbVersion, guest_policy::GuestPolicy};
#[cfg(feature = "tdx")]
use tdx_types::td_quote::TeeTcbSvn;
use thiserror::Error;

pub use loader::{HashType, Input};
use thiserror::Error;
#[cfg(feature = "snp")]
pub use snp_types::{attestation::TcbVersion, guest_policy::GuestPolicy};
#[cfg(feature = "tdx")]
pub use tdx_types::td_quote::TeeTcbSvn;

#[cfg(feature = "serde")]
mod hex;
Expand Down Expand Up @@ -204,6 +204,11 @@ impl OutputHash {
len: output.len() as u64,
}
}

/// Verify that the hash matches the byte slice.
pub fn verify(&self, output: &[u8]) -> bool {
*self == Self::new(output)
}
}

impl From<OutputHash> for HashedInput {
Expand Down
6 changes: 4 additions & 2 deletions host/mushroom/src/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use constants::{
};
use loader::Input;
use nix::sys::pthread::pthread_kill;
use snp_types::{guest_policy::GuestPolicy, PageType};
use snp_types::PageType;
use tracing::{debug, info};
use vcek_kds::Vcek;
use volatile::map_field;
use x86_64::{
structures::paging::{PageSize, PhysFrame, Size2MiB, Size4KiB},
Expand All @@ -40,6 +39,9 @@ use crate::{
MushroomResult, SIG_KICK,
};

pub use snp_types::guest_policy::GuestPolicy;
pub use vcek_kds::Vcek;

#[allow(clippy::too_many_arguments)]
pub fn main(
kvm_handle: &KvmHandle,
Expand Down

0 comments on commit 78a495c

Please sign in to comment.