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

Dcap Evidence Serialization #3521

Merged
merged 17 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
67 changes: 45 additions & 22 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion attest/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub use crate::{
},
};

pub use mc_attest_verifier_types::{VerificationReport, VerificationSignature};
pub use mc_attest_verifier_types::{
DcapEvidence, EvidenceMessage, VerificationReport, VerificationSignature,
};

pub use mc_sgx_core_types::{
Attributes, ConfigId, ConfigSvn, CpuSvn, ExtendedProductId, FamilyId, IsvProductId, IsvSvn,
Expand Down
6 changes: 4 additions & 2 deletions attest/untrusted/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ cfg-if = "1.0"
displaydoc = { version = "0.2", default-features = false }
mc-attest-core = { path = "../core", default-features = false }
mc-attest-verifier = { path = "../verifier", default-features = false }
mc-attestation-verifier = "0.3.1"
mc-attest-verifier-types = { path = "../verifier/types", default-features = false }
mc-attestation-verifier = "0.3.0"
dolanbernard marked this conversation as resolved.
Show resolved Hide resolved
mc-rand = "1.1.0"
mc-sgx-core-types = "0.7.4"
mc-sgx-dcap-ql = "0.7.4"
Expand All @@ -28,7 +29,8 @@ p256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pem
sha2 = { version = "0.10.6", default-features = false }

[dev-dependencies]
mc-attest-verifier-types = { path = "../verifier/types", default-features = false }
mc-util-serial = { path = "../../util/serial" }
prost = { version = "0.11", default-features = false, features = ["prost-derive"] }
x509-cert = { version = "0.2.4", default-features = false, features = ["pem"] }

[build-dependencies]
Expand Down
26 changes: 26 additions & 0 deletions attest/untrusted/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ fn c_struct_as_bytes<T>(c_struct: &T) -> &[u8] {
#[cfg(test)]
mod test {
use super::*;
use mc_attest_core::DcapEvidence;
use mc_attest_verifier::DcapVerifier;
use mc_attest_verifier_types::EnclaveReportDataContents;
use mc_attestation_verifier::{Evidence, TrustedMrEnclaveIdentity};
use mc_sgx_dcap_types::{CertificationData, TcbInfo};
use p256::pkcs8::der::DateTime;
use prost::Message;
use std::time::{SystemTime, UNIX_EPOCH};
use x509_cert::{der::DecodePem, Certificate};

Expand Down Expand Up @@ -270,4 +272,28 @@ mod test {
let verification = verifier.verify(evidence);
assert_eq!(verification.is_success().unwrap_u8(), 1);
}

#[test]
fn test_dcap_evidence_serialization() {
let mut buf: Vec<u8> = vec![];
let uut: DcapEvidence = Default::default();
nick-mobilecoin marked this conversation as resolved.
Show resolved Hide resolved
uut.encode(&mut buf)
.expect("Failed to encode empty DcapEvidence");
let decoded =
DcapEvidence::decode(buf.as_slice()).expect("Failed to decode empty DcapEvidence");
assert_eq!(uut, decoded);
buf.clear();
let report = Report::default();
let quote = SimQuotingEnclave::quote_report(&report).expect("Failed to create quote");
let collateral = SimQuotingEnclave::collateral(&quote);
let mut uut = DcapEvidence {
quote: Some(quote),
collateral: Some(collateral),
};
uut.encode(&mut buf).expect("Failed to encode DcapEvidence");
let decoded = DcapEvidence::decode(buf.as_slice()).expect("Failed to decode DcapEvidence");
assert_eq!(uut, decoded);
uut.clear();
assert_eq!(DcapEvidence::default(), uut);
}
}
2 changes: 2 additions & 0 deletions attest/verifier/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ license = "Apache-2.0"
rust-version = { workspace = true }

[dependencies]
mc-attestation-verifier = "0.2.0"
dolanbernard marked this conversation as resolved.
Show resolved Hide resolved
mc-crypto-digestible = { path = "../../../crypto/digestible" }
mc-crypto-keys = { path = "../../../crypto/keys" }
mc-sgx-core-types = "0.7.4"
mc-sgx-dcap-types = { version = "0.7.4", default-features = false, features = ["alloc"] }
mc-util-encodings = { path = "../../../util/encodings" }
mc-util-serial = { path = "../../../util/serial" }

base64 = { version = "0.21", default-features = false, features = ["alloc"] }
displaydoc = { version = "0.2", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion attest/verifier/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ extern crate alloc;
mod verification;

pub use crate::verification::{
EnclaveReportDataContents, VerificationReport, VerificationSignature,
DcapEvidence, EnclaveReportDataContents, EvidenceMessage, VerificationReport,
VerificationSignature,
};
Loading
Loading