11//! Data Center Attestation Primitives (DCAP) evidence generation and verification
2- use crate :: attestation:: { measurements:: MultiMeasurements , AttestationError } ;
2+ use crate :: attestation:: { measurements:: MultiMeasurements , tcb_info :: TcbInfo , AttestationError } ;
33
44use configfs_tsm:: QuoteGenerationError ;
55use dcap_qvl:: {
6- collateral:: get_collateral_for_fmspc,
6+ collateral:: { self , get_collateral_for_fmspc} ,
77 quote:: { Quote , Report } ,
88} ;
99use thiserror:: Error ;
@@ -24,7 +24,7 @@ pub async fn verify_dcap_attestation(
2424 expected_input_data : [ u8 ; 64 ] ,
2525 pccs_url : Option < String > ,
2626) -> Result < MultiMeasurements , DcapVerificationError > {
27- let measurements = if cfg ! ( not( test) ) {
27+ let measurements = if ! cfg ! ( not( test) ) {
2828 let now = std:: time:: SystemTime :: now ( )
2929 . duration_since ( std:: time:: UNIX_EPOCH ) ?
3030 . as_secs ( ) ;
@@ -33,14 +33,43 @@ pub async fn verify_dcap_attestation(
3333
3434 let ca = quote. ca ( ) ?;
3535 let fmspc = hex:: encode_upper ( quote. fmspc ( ) ?) ;
36- let collateral = get_collateral_for_fmspc (
36+ let mut collateral = get_collateral_for_fmspc (
3737 & pccs_url. clone ( ) . unwrap_or ( PCS_URL . to_string ( ) ) ,
3838 fmspc,
3939 ca,
4040 false , // Indicates not SGX
4141 )
4242 . await ?;
4343
44+ println ! ( "tcb info {:?}" , collateral. tcb_info) ;
45+ let mut tcb_info: TcbInfo = serde_json:: from_str ( & collateral. tcb_info ) . unwrap ( ) ;
46+
47+ let tcb_levels = tcb_info
48+ . tcb_levels
49+ . into_iter ( )
50+ . map ( |mut tcb_level| {
51+ if & tcb_level. tcb_status == "UpToDate" {
52+ if tcb_level. tcb . sgx_components [ 7 ] . svn > 3 {
53+ tracing:: warn!(
54+ "Overriding tcb info to allow outdated Azure v6 SEAM loader"
55+ ) ;
56+ println ! ( "modifying!" ) ;
57+ tcb_level. tcb . sgx_components [ 7 ] . svn = 3 ;
58+ }
59+ tcb_level
60+ } else {
61+ tcb_level
62+ }
63+ } )
64+ . collect :: < Vec < _ > > ( ) ;
65+
66+ tcb_info. tcb_levels = tcb_levels;
67+
68+ let tcb_info_json = serde_json:: to_string ( & tcb_info) . unwrap ( ) ;
69+ // collateral.tcb_info = tcb_info_json;
70+
71+ println ! ( "tcb info {:?}" , collateral. tcb_info) ;
72+
4473 let _verified_report = dcap_qvl:: verify:: verify ( & input, & collateral, now) ?;
4574
4675 let measurements = MultiMeasurements :: from_dcap_qvl_quote ( & quote) ?;
0 commit comments