MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / decode_mr_tdx_from_quote

Function decode_mr_tdx_from_quote

dstack-attest/src/attestation.rs:749–791  ·  view source on GitHub ↗
(
    boottime_mr: bool,
    mr_key_provider: &[u8],
    quote: &[u8],
    runtime_events: &[RuntimeEvent],
)

Source from the content-addressed store, hash-verified

747}
748
749fn decode_mr_tdx_from_quote(
750 boottime_mr: bool,
751 mr_key_provider: &[u8],
752 quote: &[u8],
753 runtime_events: &[RuntimeEvent],
754) -> Result<Mrs> {
755 let quote = Quote::parse(quote).context("Failed to parse quote")?;
756 let rtmr3 =
757 replay_runtime_events::<Sha384>(runtime_events, boottime_mr.then_some("boot-mr-done"));
758 let td_report = quote.report.as_td10().context("TDX report not found")?;
759 let mr_system = sha256([
760 &td_report.mr_td[..],
761 &td_report.rt_mr0,
762 &td_report.rt_mr1,
763 &td_report.rt_mr2,
764 mr_key_provider,
765 ]);
766 let mr_aggregated = {
767 let mut hasher = sha2::Sha256::new();
768 for d in [
769 &td_report.mr_td,
770 &td_report.rt_mr0,
771 &td_report.rt_mr1,
772 &td_report.rt_mr2,
773 &rtmr3,
774 ] {
775 hasher.update(d);
776 }
777 if td_report.mr_config_id != [0u8; 48]
778 || td_report.mr_owner != [0u8; 48]
779 || td_report.mr_owner_config != [0u8; 48]
780 {
781 hasher.update(td_report.mr_config_id);
782 hasher.update(td_report.mr_owner);
783 hasher.update(td_report.mr_owner_config);
784 }
785 hasher.finalize().into()
786 };
787 Ok(Mrs {
788 mr_system,
789 mr_aggregated,
790 })
791}
792
793async fn verify_tdx_quote_with_events(
794 pccs_url: Option<&str>,

Callers 1

decode_app_info_exMethod · 0.85

Calls 1

sha256Function · 0.50

Tested by

no test coverage detected