Skip to content

Commit

Permalink
Update to mc-sgx-*** 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-mobilecoin committed Mar 9, 2023
1 parent 0d348ec commit 4aa2338
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
4 changes: 2 additions & 2 deletions verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository = "https://github.com/mobilecoinfoundation/attestation"
rust-version = "1.62.1"

[dependencies]
mc-sgx-core-types = "0.4.2"
mc-sgx-core-types = "0.5.0"
subtle = { version = "2.4.0", default-features = false }

[dev-dependencies]
mc-sgx-core-sys-types = "0.4.2"
mc-sgx-core-sys-types = "0.5.0"
yare = "1.0.2"
37 changes: 8 additions & 29 deletions verifier/src/report_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use crate::{VerificationError, Verifier};
use core::fmt::Debug;
use mc_sgx_core_types::{
Attributes, ConfigId, ConfigSvn, IsvSvn, Measurement, MiscellaneousSelect, MrEnclave, MrSigner,
ReportBody, ReportData,
Attributes, ConfigId, ConfigSvn, IsvSvn, MiscellaneousSelect, MrEnclave, MrSigner, ReportBody,
ReportData,
};
use subtle::{ConstantTimeLess, CtOption};

Expand Down Expand Up @@ -56,6 +56,8 @@ report_body_field_accessor! {
ConfigSvn, config_svn;
IsvSvn, isv_svn;
MiscellaneousSelect, miscellaneous_select;
MrEnclave, mr_enclave;
MrSigner, mr_signer;
ReportData, report_data;
}

Expand Down Expand Up @@ -132,7 +134,7 @@ impl IntoVerificationError for ConfigSvn {
impl<E: Accessor<ConfigSvn>> Verifier<E> for GreaterThanEqualVerifier<ConfigSvn> {
type Error = VerificationError;
fn verify(&self, evidence: &E) -> CtOption<Self::Error> {
let expected = self.expected.clone();
let expected = self.expected;
let actual = evidence.get();

// This verifier ensures the actual is greater than or equal to the
Expand All @@ -158,7 +160,7 @@ impl IntoVerificationError for IsvSvn {
impl<E: Accessor<IsvSvn>> Verifier<E> for GreaterThanEqualVerifier<IsvSvn> {
type Error = VerificationError;
fn verify(&self, evidence: &E) -> CtOption<Self::Error> {
let expected = self.expected.clone();
let expected = self.expected;
let actual = evidence.get();

// This verifier ensures the actual is greater than or equal to the
Expand All @@ -185,15 +187,6 @@ impl IntoVerificationError for MrEnclave {
}
}

impl Accessor<MrEnclave> for ReportBody {
fn get(&self) -> MrEnclave {
let Measurement::MrEnclave(mr_enclave) = self.mr_enclave() else {
panic!("`mr_enclave()` should return a Measurement::MrEnclave");
};
mr_enclave
}
}

/// Verifier for ensuring [`MrSigner`] values are equivalent.
pub type MrSignerVerifier = EqualityVerifier<MrSigner>;
impl IntoVerificationError for MrSigner {
Expand All @@ -202,15 +195,6 @@ impl IntoVerificationError for MrSigner {
}
}

impl Accessor<MrSigner> for ReportBody {
fn get(&self) -> MrSigner {
let Measurement::MrSigner(mr_signer) = self.mr_signer() else {
panic!("`mr_signer()` should return a Measurement::MrSigner");
};
mr_signer
}
}

/// Verifier for ensuring [`ReportData`] values are equivalent.
pub type ReportDataVerifier = EqualityVerifier<ReportData>;
impl IntoVerificationError for ReportData {
Expand All @@ -226,7 +210,6 @@ mod test {
use mc_sgx_core_sys_types::{
sgx_attributes_t, sgx_cpu_svn_t, sgx_measurement_t, sgx_report_body_t, sgx_report_data_t,
};
use mc_sgx_core_types::Measurement;
use yare::parameterized;

const REPORT_BODY_SRC: sgx_report_body_t = sgx_report_body_t {
Expand Down Expand Up @@ -327,9 +310,7 @@ mod test {
#[test]
fn report_body_fails_due_to_mr_enclave() {
let report_body = ReportBody::from(&REPORT_BODY_SRC);
let Measurement::MrEnclave(mut mr_enclave) = report_body.mr_enclave() else {
panic!("mr_enclave is not an MrEnclave measurement");
};
let mut mr_enclave = report_body.mr_enclave();
let bytes: &mut [u8] = mr_enclave.as_mut();
bytes[0] += 1;
let verifier = And::new(
Expand All @@ -345,9 +326,7 @@ mod test {
#[test]
fn report_body_fails_due_to_mr_signer() {
let report_body = ReportBody::from(&REPORT_BODY_SRC);
let Measurement::MrSigner(mut mr_signer) = report_body.mr_signer() else {
panic!("mr_signer is not an MrSigner measurement");
};
let mut mr_signer = report_body.mr_signer();
let bytes: &mut [u8] = mr_signer.as_mut();
bytes[0] += 1;
let verifier = And::new(
Expand Down

0 comments on commit 4aa2338

Please sign in to comment.