@@ -31,7 +31,7 @@ use tpm_qvl::verify::VerifiedReport as TpmVerifiedReport;
3131// Re-export TpmQuote from tpm-types
3232pub use tpm_types:: TpmQuote ;
3333
34- use crate :: amd_sev_snp:: VerifiedAmdSnpReport ;
34+ use crate :: amd_sev_snp:: { AmdKdsClient , VerifiedAmdSnpReport } ;
3535use crate :: v1:: {
3636 is_tdx_acpi_data_event, is_tdx_lite_config, strip_tdx_event_log_for_config,
3737 strip_tdx_runtime_event_log,
@@ -768,7 +768,27 @@ impl AttestationV1 {
768768 pub async fn verify_with_time (
769769 self ,
770770 pccs_url : Option < & str > ,
771- _now : Option < SystemTime > ,
771+ now : Option < SystemTime > ,
772+ ) -> Result < VerifiedAttestation > {
773+ self . verify_with_time_with_amd_kds_client ( pccs_url, now, None )
774+ . await
775+ }
776+
777+ /// Verify the quote with a caller-owned AMD KDS client.
778+ pub async fn verify_with_amd_kds_client (
779+ self ,
780+ pccs_url : Option < & str > ,
781+ amd_kds_client : & AmdKdsClient ,
782+ ) -> Result < VerifiedAttestation > {
783+ self . verify_with_time_with_amd_kds_client ( pccs_url, None , Some ( amd_kds_client) )
784+ . await
785+ }
786+
787+ async fn verify_with_time_with_amd_kds_client (
788+ self ,
789+ pccs_url : Option < & str > ,
790+ now : Option < SystemTime > ,
791+ amd_kds_client : Option < & AmdKdsClient > ,
772792 ) -> Result < VerifiedAttestation > {
773793 let AttestationV1 {
774794 version : _,
@@ -847,7 +867,7 @@ impl AttestationV1 {
847867 & nsm. nsm_quote ,
848868 nsm_qvl:: AWS_NITRO_ENCLAVES_ROOT_G1 ,
849869 None ,
850- _now ,
870+ now ,
851871 )
852872 . context ( "NSM attestation verification failed" ) ?;
853873 let Some ( user_data) = verified_report. user_data . clone ( ) else {
@@ -873,11 +893,17 @@ impl AttestationV1 {
873893 cert_chain,
874894 mr_config,
875895 } => {
876- let verified = crate :: amd_sev_snp:: verify_amd_snp_evidence_with_kds_fallback (
877- report,
878- cert_chain,
879- & report_data,
880- ) ?;
896+ let owned_kds_client;
897+ let kds_client = match amd_kds_client {
898+ Some ( client) => client,
899+ None => {
900+ owned_kds_client = AmdKdsClient :: new ( ) ?;
901+ & owned_kds_client
902+ }
903+ } ;
904+ let verified = kds_client
905+ . verify_evidence_with_kds_fallback ( report, cert_chain, & report_data)
906+ . await ?;
881907 verify_snp_mr_config_host_data ( mr_config, & verified. host_data ) ?;
882908 DstackVerifiedReport :: DstackAmdSevSnp ( verified)
883909 }
@@ -1788,18 +1814,44 @@ impl Attestation {
17881814 self ,
17891815 pccs_url : Option < & str > ,
17901816 now : Option < SystemTime > ,
1817+ ) -> Result < VerifiedAttestation > {
1818+ self . verify_with_time_with_amd_kds_client ( pccs_url, now, None )
1819+ . await
1820+ }
1821+
1822+ /// Verify the quote with a caller-owned AMD KDS client.
1823+ pub async fn verify_with_amd_kds_client (
1824+ self ,
1825+ pccs_url : Option < & str > ,
1826+ amd_kds_client : & AmdKdsClient ,
1827+ ) -> Result < VerifiedAttestation > {
1828+ self . verify_with_time_with_amd_kds_client ( pccs_url, None , Some ( amd_kds_client) )
1829+ . await
1830+ }
1831+
1832+ async fn verify_with_time_with_amd_kds_client (
1833+ self ,
1834+ pccs_url : Option < & str > ,
1835+ now : Option < SystemTime > ,
1836+ amd_kds_client : Option < & AmdKdsClient > ,
17911837 ) -> Result < VerifiedAttestation > {
17921838 let report = match & self . quote {
17931839 AttestationQuote :: DstackTdx ( q) => {
17941840 let report = self . verify_tdx ( pccs_url, & q. quote ) . await ?;
17951841 DstackVerifiedReport :: DstackTdx ( report)
17961842 }
17971843 AttestationQuote :: DstackAmdSevSnp ( q) => {
1798- let verified = crate :: amd_sev_snp:: verify_amd_snp_evidence_with_kds_fallback (
1799- & q. report ,
1800- & q. cert_chain ,
1801- & self . report_data ,
1802- ) ?;
1844+ let owned_kds_client;
1845+ let kds_client = match amd_kds_client {
1846+ Some ( client) => client,
1847+ None => {
1848+ owned_kds_client = AmdKdsClient :: new ( ) ?;
1849+ & owned_kds_client
1850+ }
1851+ } ;
1852+ let verified = kds_client
1853+ . verify_evidence_with_kds_fallback ( & q. report , & q. cert_chain , & self . report_data )
1854+ . await ?;
18031855 verify_snp_mr_config_host_data ( & q. mr_config , & verified. host_data ) ?;
18041856 DstackVerifiedReport :: DstackAmdSevSnp ( verified)
18051857 }
0 commit comments