Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion cert-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ impl CertRequestClient {
let pubkey = key.public_key_der();
let report_data = QuoteContentType::RaTlsCert.to_report_data(&pubkey);
let attestation = match attestation_override {
Some(attestation) => attestation,
Some(mut attestation) => {
attestation.set_report_data(report_data);
attestation
}
None => ra_rpc::Attestation::quote(&report_data)
.context("Failed to get quote for cert pubkey")?
.into_versioned(),
Expand Down
13 changes: 13 additions & 0 deletions dstack-attest/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@ impl VersionedAttestation {
}
}

/// Set the report_data field in the attestation and in the raw TDX quote bytes (offset 568..632).
/// This is used by the simulator to patch a canned attestation with the correct report_data
/// that binds to the actual TLS public key.
pub fn set_report_data(&mut self, report_data: [u8; 64]) {
let VersionedAttestation::V0 { attestation } = self;
attestation.report_data = report_data;
if let Some(tdx_quote) = attestation.tdx_quote_mut() {
if tdx_quote.quote.len() >= 632 {
tdx_quote.quote[568..632].copy_from_slice(&report_data);
}
}
}

/// Strip data for certificate embedding (e.g. keep RTMR3 event logs only).
pub fn into_stripped(mut self) -> Self {
let VersionedAttestation::V0 { attestation } = &mut self;
Expand Down