Skip to content

Commit 00d3a9f

Browse files
authored
Merge pull request #541 from eidolons-ai/simulator-realistic-certificates
Make simulator certs more realistic
2 parents f085aef + c84948b commit 00d3a9f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

cert-client/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ impl CertRequestClient {
102102
let pubkey = key.public_key_der();
103103
let report_data = QuoteContentType::RaTlsCert.to_report_data(&pubkey);
104104
let attestation = match attestation_override {
105-
Some(attestation) => attestation,
105+
Some(mut attestation) => {
106+
attestation.set_report_data(report_data);
107+
attestation
108+
}
106109
None => ra_rpc::Attestation::quote(&report_data)
107110
.context("Failed to get quote for cert pubkey")?
108111
.into_versioned(),

dstack-attest/src/attestation.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ impl VersionedAttestation {
267267
}
268268
}
269269

270+
/// Set the report_data field in the attestation and in the raw TDX quote bytes (offset 568..632).
271+
/// This is used by the simulator to patch a canned attestation with the correct report_data
272+
/// that binds to the actual TLS public key.
273+
pub fn set_report_data(&mut self, report_data: [u8; 64]) {
274+
let VersionedAttestation::V0 { attestation } = self;
275+
attestation.report_data = report_data;
276+
if let Some(tdx_quote) = attestation.tdx_quote_mut() {
277+
if tdx_quote.quote.len() >= 632 {
278+
tdx_quote.quote[568..632].copy_from_slice(&report_data);
279+
}
280+
}
281+
}
282+
270283
/// Strip data for certificate embedding (e.g. keep RTMR3 event logs only).
271284
pub fn into_stripped(mut self) -> Self {
272285
let VersionedAttestation::V0 { attestation } = &mut self;

0 commit comments

Comments
 (0)