@@ -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 } ;
3535pub use crate :: v1:: { Attestation as AttestationV1 , PlatformEvidence , StackEvidence } ;
3636
3737pub const SNP_REPORT_DATA_RANGE : std:: ops:: Range < usize > = 0x50 ..0x90 ;
@@ -757,7 +757,27 @@ impl AttestationV1 {
757757 pub async fn verify_with_time (
758758 self ,
759759 pccs_url : Option < & str > ,
760- _now : Option < SystemTime > ,
760+ now : Option < SystemTime > ,
761+ ) -> Result < VerifiedAttestation > {
762+ self . verify_with_time_with_amd_kds_client ( pccs_url, now, None )
763+ . await
764+ }
765+
766+ /// Verify the quote with a caller-owned AMD KDS client.
767+ pub async fn verify_with_amd_kds_client (
768+ self ,
769+ pccs_url : Option < & str > ,
770+ amd_kds_client : & AmdKdsClient ,
771+ ) -> Result < VerifiedAttestation > {
772+ self . verify_with_time_with_amd_kds_client ( pccs_url, None , Some ( amd_kds_client) )
773+ . await
774+ }
775+
776+ async fn verify_with_time_with_amd_kds_client (
777+ self ,
778+ pccs_url : Option < & str > ,
779+ now : Option < SystemTime > ,
780+ amd_kds_client : Option < & AmdKdsClient > ,
761781 ) -> Result < VerifiedAttestation > {
762782 let AttestationV1 {
763783 version : _,
@@ -836,7 +856,7 @@ impl AttestationV1 {
836856 & nsm. nsm_quote ,
837857 nsm_qvl:: AWS_NITRO_ENCLAVES_ROOT_G1 ,
838858 None ,
839- _now ,
859+ now ,
840860 )
841861 . context ( "NSM attestation verification failed" ) ?;
842862 let Some ( user_data) = verified_report. user_data . clone ( ) else {
@@ -862,11 +882,17 @@ impl AttestationV1 {
862882 cert_chain,
863883 mr_config,
864884 } => {
865- let verified = crate :: amd_sev_snp:: verify_amd_snp_evidence_with_kds_fallback (
866- report,
867- cert_chain,
868- & report_data,
869- ) ?;
885+ let owned_kds_client;
886+ let kds_client = match amd_kds_client {
887+ Some ( client) => client,
888+ None => {
889+ owned_kds_client = AmdKdsClient :: new ( ) ?;
890+ & owned_kds_client
891+ }
892+ } ;
893+ let verified = kds_client
894+ . verify_evidence_with_kds_fallback ( report, cert_chain, & report_data)
895+ . await ?;
870896 verify_snp_mr_config_host_data ( mr_config, & verified. host_data ) ?;
871897 DstackVerifiedReport :: DstackAmdSevSnp ( verified)
872898 }
@@ -1751,18 +1777,44 @@ impl Attestation {
17511777 self ,
17521778 pccs_url : Option < & str > ,
17531779 now : Option < SystemTime > ,
1780+ ) -> Result < VerifiedAttestation > {
1781+ self . verify_with_time_with_amd_kds_client ( pccs_url, now, None )
1782+ . await
1783+ }
1784+
1785+ /// Verify the quote with a caller-owned AMD KDS client.
1786+ pub async fn verify_with_amd_kds_client (
1787+ self ,
1788+ pccs_url : Option < & str > ,
1789+ amd_kds_client : & AmdKdsClient ,
1790+ ) -> Result < VerifiedAttestation > {
1791+ self . verify_with_time_with_amd_kds_client ( pccs_url, None , Some ( amd_kds_client) )
1792+ . await
1793+ }
1794+
1795+ async fn verify_with_time_with_amd_kds_client (
1796+ self ,
1797+ pccs_url : Option < & str > ,
1798+ now : Option < SystemTime > ,
1799+ amd_kds_client : Option < & AmdKdsClient > ,
17541800 ) -> Result < VerifiedAttestation > {
17551801 let report = match & self . quote {
17561802 AttestationQuote :: DstackTdx ( q) => {
17571803 let report = self . verify_tdx ( pccs_url, & q. quote ) . await ?;
17581804 DstackVerifiedReport :: DstackTdx ( report)
17591805 }
17601806 AttestationQuote :: DstackAmdSevSnp ( q) => {
1761- let verified = crate :: amd_sev_snp:: verify_amd_snp_evidence_with_kds_fallback (
1762- & q. report ,
1763- & q. cert_chain ,
1764- & self . report_data ,
1765- ) ?;
1807+ let owned_kds_client;
1808+ let kds_client = match amd_kds_client {
1809+ Some ( client) => client,
1810+ None => {
1811+ owned_kds_client = AmdKdsClient :: new ( ) ?;
1812+ & owned_kds_client
1813+ }
1814+ } ;
1815+ let verified = kds_client
1816+ . verify_evidence_with_kds_fallback ( & q. report , & q. cert_chain , & self . report_data )
1817+ . await ?;
17661818 verify_snp_mr_config_host_data ( & q. mr_config , & verified. host_data ) ?;
17671819 DstackVerifiedReport :: DstackAmdSevSnp ( verified)
17681820 }
0 commit comments