Skip to content

Commit

Permalink
Change from passing verifier to passing measurements
Browse files Browse the repository at this point in the history
Previously many interfaces that wished to attest to an enclave would
create and pass a verifier down to the logic that would eventually try
and verify the enclave's report.
Now these interfaces pass in a `Vec<TrustedMeasurement>` with all of the
measurements they wish to verify against. This isolates the logic for
how an enclave report is verified to support different verification
methods based on EPID vs DCAP.
  • Loading branch information
nick-mobilecoin committed Jun 2, 2023
1 parent 1c83f2f commit 1ccb67c
Show file tree
Hide file tree
Showing 69 changed files with 631 additions and 455 deletions.
37 changes: 15 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions attest/ake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sgx-sim = [
[dependencies]
mc-attest-core = { path = "../../attest/core", default-features = false }
mc-attest-verifier = { path = "../../attest/verifier", default-features = false }
mc-attest-verifier-config = { path = "../../attest/verifier/config", default-features = false }
mc-crypto-keys = { path = "../../crypto/keys", default-features = false }
mc-crypto-noise = { path = "../../crypto/noise", default-features = false }

Expand Down
16 changes: 8 additions & 8 deletions attest/ake/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::mealy::{Input as MealyInput, Output as MealyOutput};
use alloc::vec::Vec;
use core::marker::PhantomData;
use mc_attest_core::VerificationReport;
use mc_attest_verifier::Verifier;
use mc_attest_verifier_config::TrustedMeasurement;
use mc_crypto_keys::Kex;
use mc_crypto_noise::{
HandshakeIX, HandshakeNX, HandshakePattern, NoiseCipher, NoiseDigest, ProtocolName,
Expand Down Expand Up @@ -223,8 +223,8 @@ where
pub(crate) local_identity: KexAlgo::Private,
/// This is the local node's ias report.
pub(crate) ias_report: VerificationReport,
/// This is the verifier used to examine the initiator's IAS report
pub(crate) verifier: Verifier,
/// The measurements that the initiator's IAS report must conform to
pub(crate) measurements: Vec<TrustedMeasurement>,

/// The auth request input, including payload, if any
pub(crate) data: AuthRequestOutput<HandshakeIX, KexAlgo, Cipher, DigestAlgo>,
Expand All @@ -248,12 +248,12 @@ where
data: AuthRequestOutput<HandshakeIX, KexAlgo, Cipher, DigestAlgo>,
local_identity: KexAlgo::Private,
ias_report: VerificationReport,
verifier: Verifier,
measurements: impl Into<Vec<TrustedMeasurement>>,
) -> Self {
Self {
local_identity,
ias_report,
verifier,
measurements: measurements.into(),
data,
}
}
Expand Down Expand Up @@ -287,14 +287,14 @@ impl MealyOutput for AuthResponseOutput {}
/// The authentication response is combined with a verifier for the initiator.
pub struct AuthResponseInput {
pub(crate) data: Vec<u8>,
pub(crate) verifier: Verifier,
pub(crate) measurements: Vec<TrustedMeasurement>,
}

impl AuthResponseInput {
pub fn new(data: AuthResponseOutput, verifier: Verifier) -> Self {
pub fn new(data: AuthResponseOutput, measurements: impl Into<Vec<TrustedMeasurement>>) -> Self {
Self {
data: data.0,
verifier,
measurements: measurements.into(),
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion attest/ake/src/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
};
use alloc::vec::Vec;
use mc_attest_core::{ReportDataMask, VerificationReport};
use mc_attest_verifier::{Verifier, DEBUG_ENCLAVE};
use mc_crypto_keys::{Kex, ReprBytes};
use mc_crypto_noise::{
HandshakeIX, HandshakeNX, HandshakeOutput, HandshakePattern, HandshakeState, HandshakeStatus,
Expand Down Expand Up @@ -162,7 +163,9 @@ where
let remote_report = VerificationReport::decode(output.payload.as_slice())
.map_err(|_e| Error::ReportDeserialization)?;

let mut verifier = input.verifier;
let measurements = input.measurements;
let mut verifier = Verifier::default();
verifier.measurements(&measurements).debug(DEBUG_ENCLAVE);

// We are not returning the report data and instead returning the raw report
// since that also includes the signature and certificate chain.
Expand Down
27 changes: 14 additions & 13 deletions attest/ake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod test {
use aes_gcm::Aes256Gcm;
use mc_attest_core::Quote;
use mc_attest_net::{Client, RaClient};
use mc_attest_verifier::{MrSignerVerifier, Verifier, IAS_SIM_ROOT_ANCHORS};
use mc_attest_verifier_config::{TrustedMeasurement, TrustedMrSignerMeasurement};
use mc_crypto_keys::{X25519Private, X25519Public, X25519};
use mc_util_encodings::{FromBase64, ToX64};
use mc_util_from_random::FromRandom;
Expand Down Expand Up @@ -78,17 +78,14 @@ mod test {
.report_body()
.expect("Could not retrieve report body from cached report");

// Construct a report verifier that will check the MRSIGNER, product ID, and
// security version
let mr_signer = MrSignerVerifier::new(
report_body.mr_signer(),
let advisories: &[&str] = &[];
let mr_signer = TrustedMeasurement::from(TrustedMrSignerMeasurement::new(
&report_body.mr_signer().into(),
report_body.product_id(),
report_body.security_version(),
);

let mut verifier = Verifier::new(&[IAS_SIM_ROOT_ANCHORS])
.expect("Could not construct verifier with sim root anchors");
verifier.mr_signer(mr_signer).debug(true);
advisories,
));
let measurements = [mr_signer];

let initiator = Start::new(RESPONDER_ID_STR.into());
let responder = Start::new(RESPONDER_ID_STR.into());
Expand All @@ -101,15 +98,19 @@ mod test {

// initiator = authpending, responder = start

let auth_request_input =
NodeAuthRequestInput::new(auth_request_output, identity, ias_report, verifier.clone());
let auth_request_input = NodeAuthRequestInput::new(
auth_request_output,
identity,
ias_report,
measurements.clone(),
);
let (responder, auth_response_output) = responder
.try_next(&mut csprng, auth_request_input)
.expect("Responder could not process auth request");

// initiator = authpending, responder = ready

let auth_response_input = AuthResponseInput::new(auth_response_output, verifier);
let auth_response_input = AuthResponseInput::new(auth_response_output, measurements);
let (initiator, _) = initiator
.try_next(&mut csprng, auth_response_input)
.expect("Initiator not process auth response");
Expand Down
5 changes: 4 additions & 1 deletion attest/ake/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
};
use alloc::vec::Vec;
use mc_attest_core::{ReportDataMask, VerificationReport};
use mc_attest_verifier::{Verifier, DEBUG_ENCLAVE};
use mc_crypto_keys::{Kex, ReprBytes};
use mc_crypto_noise::{
HandshakeIX, HandshakeNX, HandshakePattern, HandshakeState, HandshakeStatus, NoiseCipher,
Expand Down Expand Up @@ -139,7 +140,9 @@ where
input.local_identity,
)?;

let mut verifier = input.verifier;
let measurements = input.measurements;
let mut verifier = Verifier::default();
verifier.measurements(&measurements).debug(DEBUG_ENCLAVE);

// Parse the received IAS report
let remote_report = VerificationReport::decode(payload.as_slice())
Expand Down
12 changes: 12 additions & 0 deletions attest/core/src/types/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ impl From<[u8; SGX_HASH_SIZE]> for MrEnclave {
}
}

impl From<MrEnclave> for [u8; SGX_HASH_SIZE] {
fn from(mr_enclave: MrEnclave) -> Self {
mr_enclave.0.m
}
}

/// An opaque type for MRSIGNER values.
///
/// A MRSIGNER value is a cryptographic hash of the public key an enclave
Expand All @@ -40,6 +46,12 @@ impl From<[u8; SGX_HASH_SIZE]> for MrSigner {
}
}

impl From<MrSigner> for [u8; SGX_HASH_SIZE] {
fn from(mr_signer: MrSigner) -> Self {
mr_signer.0.m
}
}

impl_sgx_newtype_for_bytestruct! {
MrEnclave, sgx_measurement_t, SGX_HASH_SIZE, m;
MrSigner, sgx_measurement_t, SGX_HASH_SIZE, m;
Expand Down
1 change: 1 addition & 0 deletions attest/verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ias-dev = []

[dependencies]
mc-attest-core = { path = "../core", default-features = false }
mc-attest-verifier-config = { path = "config", default-features = false }
mc-common = { path = "../../common", default-features = false }
mc-sgx-css = { path = "../../sgx/css", default-features = false }
mc-sgx-types = { path = "../../sgx/types", default-features = false }
Expand Down
Loading

0 comments on commit 1ccb67c

Please sign in to comment.