@@ -265,6 +265,13 @@ impl VersionedAttestation {
265265 }
266266 }
267267
268+ /// Get report_data payload if present.
269+ pub fn report_data_payload ( & self ) -> Option < & str > {
270+ match self {
271+ Self :: V0 { attestation } => attestation. report_data_payload ( ) ,
272+ }
273+ }
274+
268275 /// Get app info
269276 pub fn decode_app_info ( & self , boottime_mr : bool ) -> Result < AppInfo > {
270277 match self {
@@ -274,7 +281,9 @@ impl VersionedAttestation {
274281
275282 /// Strip data for certificate embedding (e.g. keep RTMR3 event logs only).
276283 pub fn into_stripped ( mut self ) -> Self {
277- let VersionedAttestation :: V0 { attestation } = & mut self ;
284+ let attestation = match & mut self {
285+ VersionedAttestation :: V0 { attestation } => attestation,
286+ } ;
278287 if let Some ( tdx_quote) = attestation. tdx_quote_mut ( ) {
279288 tdx_quote. event_log = tdx_quote
280289 . event_log
@@ -290,6 +299,10 @@ impl VersionedAttestation {
290299#[ derive( Clone , Encode , Decode ) ]
291300pub enum AttestationQuote {
292301 DstackTdx ( TdxQuote ) ,
302+ DstackTdxWithPayload {
303+ quote : TdxQuote ,
304+ report_data_payload : String ,
305+ } ,
293306 DstackGcpTdx ,
294307 DstackNitroEnclave ,
295308}
@@ -298,6 +311,7 @@ impl AttestationQuote {
298311 pub fn mode ( & self ) -> AttestationMode {
299312 match self {
300313 AttestationQuote :: DstackTdx { .. } => AttestationMode :: DstackTdx ,
314+ AttestationQuote :: DstackTdxWithPayload { .. } => AttestationMode :: DstackTdx ,
301315 AttestationQuote :: DstackGcpTdx => AttestationMode :: DstackGcpTdx ,
302316 AttestationQuote :: DstackNitroEnclave => AttestationMode :: DstackNitroEnclave ,
303317 }
@@ -324,9 +338,20 @@ pub struct Attestation<R = ()> {
324338}
325339
326340impl < T > Attestation < T > {
341+ pub fn report_data_payload ( & self ) -> Option < & str > {
342+ match & self . quote {
343+ AttestationQuote :: DstackTdxWithPayload {
344+ report_data_payload,
345+ ..
346+ } => Some ( report_data_payload) ,
347+ _ => None ,
348+ }
349+ }
350+
327351 pub fn tdx_quote_mut ( & mut self ) -> Option < & mut TdxQuote > {
328352 match & mut self . quote {
329353 AttestationQuote :: DstackTdx ( quote) => Some ( quote) ,
354+ AttestationQuote :: DstackTdxWithPayload { quote, .. } => Some ( quote) ,
330355 AttestationQuote :: DstackGcpTdx => None ,
331356 AttestationQuote :: DstackNitroEnclave => None ,
332357 }
@@ -335,6 +360,7 @@ impl<T> Attestation<T> {
335360 pub fn tdx_quote ( & self ) -> Option < & TdxQuote > {
336361 match & self . quote {
337362 AttestationQuote :: DstackTdx ( quote) => Some ( quote) ,
363+ AttestationQuote :: DstackTdxWithPayload { quote, .. } => Some ( quote) ,
338364 AttestationQuote :: DstackGcpTdx => None ,
339365 AttestationQuote :: DstackNitroEnclave => None ,
340366 }
@@ -473,7 +499,8 @@ impl<T: GetDeviceId> Attestation<T> {
473499 . context ( "Failed to decode os image hash" ) ?
474500 . os_image_hash ;
475501 let mrs = match & self . quote {
476- AttestationQuote :: DstackTdx ( q) => {
502+ AttestationQuote :: DstackTdx ( q)
503+ | AttestationQuote :: DstackTdxWithPayload { quote : q, .. } => {
477504 self . decode_mr_tdx ( boottime_mr, & mr_key_provider, q) ?
478505 }
479506 AttestationQuote :: DstackGcpTdx | AttestationQuote :: DstackNitroEnclave => {
@@ -620,7 +647,7 @@ impl Attestation {
620647 }
621648 } ;
622649 let config = match & quote {
623- AttestationQuote :: DstackTdx ( _) => {
650+ AttestationQuote :: DstackTdx ( _) | AttestationQuote :: DstackTdxWithPayload { .. } => {
624651 read_vm_config ( ) . context ( "Failed to read VM config" ) ?
625652 }
626653 AttestationQuote :: DstackGcpTdx | AttestationQuote :: DstackNitroEnclave => {
@@ -646,7 +673,8 @@ impl Attestation {
646673 _now : Option < SystemTime > ,
647674 ) -> Result < VerifiedAttestation > {
648675 let report = match & self . quote {
649- AttestationQuote :: DstackTdx ( q) => {
676+ AttestationQuote :: DstackTdx ( q)
677+ | AttestationQuote :: DstackTdxWithPayload { quote : q, .. } => {
650678 let report = self . verify_tdx ( pccs_url, & q. quote ) . await ?;
651679 DstackVerifiedReport :: DstackTdx ( report)
652680 }
@@ -669,6 +697,43 @@ impl Attestation {
669697 VersionedAttestation :: V0 { attestation : self }
670698 }
671699
700+ /// Wrap into a versioned attestation carrying the report_data payload preimage
701+ /// inside a payload-aware TDX quote variant.
702+ pub fn into_versioned_with_report_data_payload (
703+ self ,
704+ report_data_payload : String ,
705+ ) -> VersionedAttestation {
706+ let Attestation {
707+ quote,
708+ runtime_events,
709+ report_data,
710+ config,
711+ report,
712+ } = self ;
713+ let quote = match quote {
714+ AttestationQuote :: DstackTdx ( quote) => AttestationQuote :: DstackTdxWithPayload {
715+ quote,
716+ report_data_payload,
717+ } ,
718+ AttestationQuote :: DstackTdxWithPayload { quote, .. } => {
719+ AttestationQuote :: DstackTdxWithPayload {
720+ quote,
721+ report_data_payload,
722+ }
723+ }
724+ other => other,
725+ } ;
726+ VersionedAttestation :: V0 {
727+ attestation : Attestation {
728+ quote,
729+ runtime_events,
730+ report_data,
731+ config,
732+ report,
733+ } ,
734+ }
735+ }
736+
672737 /// Verify the quote
673738 pub async fn verify_with_ra_pubkey (
674739 self ,
0 commit comments