()
| 9 | |
| 10 | #[tokio::main] |
| 11 | async fn main() { |
| 12 | println!("=== TDX Attestation Test ===\n"); |
| 13 | |
| 14 | // Test get_report |
| 15 | println!("1. Testing get_report..."); |
| 16 | let report_data = [0u8; 64]; |
| 17 | match tdx_attest::get_report(&report_data) { |
| 18 | Ok(report) => { |
| 19 | println!(" ✓ get_report succeeded"); |
| 20 | println!(" Report size: {} bytes", report.0.len()); |
| 21 | println!(" Report hash: {:02x?}", &report.0[..32]); |
| 22 | } |
| 23 | Err(e) => { |
| 24 | println!(" ✗ get_report failed: {}", e); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // Test get_quote |
| 29 | println!("\n2. Testing get_quote..."); |
| 30 | let report_data = [0x42u8; 64]; |
| 31 | let quote = match tdx_attest::get_quote(&report_data) { |
| 32 | Ok(quote) => { |
| 33 | println!(" ✓ get_quote succeeded"); |
| 34 | println!(" Quote size: {} bytes", quote.len()); |
| 35 | println!(" Quote header: {:02x?}", "e[..32.min(quote.len())]); |
| 36 | Some(quote) |
| 37 | } |
| 38 | Err(e) => { |
| 39 | println!(" ✗ get_quote failed: {}", e); |
| 40 | None |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | // Parse and verify quote with dcap-qvl |
| 45 | if let Some(ref quote) = quote { |
| 46 | println!("\n3. Parsing quote..."); |
| 47 | match Quote::parse(quote) { |
| 48 | Ok(q) => { |
| 49 | println!(" ✓ Quote parsed"); |
| 50 | println!(" Version: {}", q.header.version); |
| 51 | if let Some(report) = q.report.as_td10() { |
| 52 | println!(" MRTD: {}...", hex::encode(&report.mr_td[..16])); |
| 53 | println!(" RTMR3: {}...", hex::encode(&report.rt_mr3[..16])); |
| 54 | } |
| 55 | } |
| 56 | Err(e) => { |
| 57 | println!(" ✗ Quote parse failed: {:?}", e); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | println!("\n4. Verifying quote with PCCS..."); |
| 62 | let pccs_url = std::env::var("PCCS_URL").ok(); |
| 63 | println!( |
| 64 | " PCCS URL: {}", |
| 65 | pccs_url.as_deref().unwrap_or("(default)") |
| 66 | ); |
| 67 | match get_collateral_and_verify(quote, pccs_url.as_deref()).await { |
| 68 | Ok(verified) => { |
nothing calls this directly
no test coverage detected