From 804c4eaf3b5c61463097efc1bf8d4b4552f14630 Mon Sep 17 00:00:00 2001 From: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:43:43 +0000 Subject: [PATCH 1/2] fix(sev-snp): accept version 5 attestation reports SEV-SNP firmware 1.58 and later returns version 5 attestation reports, which put LAUNCH_MIT_VECTOR and CURRENT_MIT_VECTOR in bytes that sev 6.0.0 parses as reserved and requires to be zero. On such hosts every report fails to parse ("Skipped bytes were expected to be zeroed"), so an SNP guest stops at boot when it reads its HOST_DATA, and the KMS cannot verify SNP guests. Bump sev to 6.3.0, which parses and re-serializes version 5 reports, and let sev-snp-qvl verify versions 3 to 5: it rejected anything newer than 3, and the fields it reads are laid out the same in version 5. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com> --- dstack/Cargo.lock | 84 ++++++++----------- dstack/Cargo.toml | 2 +- dstack/crates/mock-attestation/src/sev_snp.rs | 17 ++-- dstack/sev-snp-qvl/src/lib.rs | 23 ++++- 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/dstack/Cargo.lock b/dstack/Cargo.lock index 6b4dae1d2..0c01edef4 100644 --- a/dstack/Cargo.lock +++ b/dstack/Cargo.lock @@ -597,9 +597,23 @@ dependencies = [ [[package]] name = "bitfield" -version = "0.15.0" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c821a6e124197eb56d907ccc2188eab1038fb919c914f47976e64dd8dbc855d1" +checksum = "b45721c9db4c7a20899d05efb7ad9235f50b256e980db30ffb229abf732934c3" +dependencies = [ + "bitfield-macros", +] + +[[package]] +name = "bitfield-macros" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0cb6f3d4773a2107b94cbeccaa5b5f0b35a88389b5d522d13d659f64317b22d" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] [[package]] name = "bitflags" @@ -1818,34 +1832,13 @@ dependencies = [ "ctutils", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys 0.4.1", -] - [[package]] name = "dirs" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ - "dirs-sys 0.5.0", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users 0.4.6", - "windows-sys 0.48.0", + "dirs-sys", ] [[package]] @@ -1856,7 +1849,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", - "redox_users 0.5.2", + "redox_users", "windows-sys 0.61.2", ] @@ -2563,7 +2556,7 @@ dependencies = [ "bon", "clap", "dcap-qvl", - "dirs 6.0.0", + "dirs", "dstack-api-auth", "dstack-build-info", "dstack-kms-rpc", @@ -6297,17 +6290,6 @@ dependencies = [ "bitflags 2.11.1", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom 0.2.17", - "libredox", - "thiserror 1.0.69", -] - [[package]] name = "redox_users" version = "0.5.2" @@ -7404,17 +7386,17 @@ dependencies = [ [[package]] name = "sev" -version = "6.0.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ac277517d8fffdf3c41096323ed705b3a7c75e397129c072fb448339839d0f" +checksum = "d295a3e215c5c2a7d16bebd55c29e6e379599287846c5f9c6e7ef7e334383ced" dependencies = [ "base64 0.22.1", "bincode 1.3.3", "bitfield", - "bitflags 1.3.2", + "bitflags 2.11.1", "byteorder", "codicon", - "dirs 5.0.1", + "dirs", "hex", "iocuddle", "lazy_static", @@ -7867,6 +7849,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sync_wrapper" version = "1.0.2" @@ -9179,15 +9172,6 @@ dependencies = [ "windows-link 0.2.1", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/dstack/Cargo.toml b/dstack/Cargo.toml index 75e20bdba..24c85f247 100644 --- a/dstack/Cargo.toml +++ b/dstack/Cargo.toml @@ -180,7 +180,7 @@ hpke = { version = "0.15.1", default-features = false, features = ["alloc", "get hex-literal = "1.0.0" prost = "0.13.5" prost-types = "0.13.5" -sev = { version = "=6.0.0", default-features = false, features = ["snp", "crypto_nossl"] } +sev = { version = "=6.3.0", default-features = false, features = ["snp", "crypto_nossl"] } scale = { version = "3.7.4", package = "parity-scale-codec", features = [ "derive", ] } diff --git a/dstack/crates/mock-attestation/src/sev_snp.rs b/dstack/crates/mock-attestation/src/sev_snp.rs index edcbc659d..940fde983 100644 --- a/dstack/crates/mock-attestation/src/sev_snp.rs +++ b/dstack/crates/mock-attestation/src/sev_snp.rs @@ -129,13 +129,16 @@ impl SevSnpGenerator { measurement: [u8; 48], ) -> Result { let mut encoded = Vec::new(); - AttestationReport::default().write_bytes(&mut encoded)?; - encoded[0..4].copy_from_slice(&2u32.to_le_bytes()); - encoded[52..56].copy_from_slice(&1u32.to_le_bytes()); - encoded[0x50..0x90].copy_from_slice(&report_data); - encoded[0x90..0xc0].copy_from_slice(&measurement); - encoded[0xc0..0xe0].copy_from_slice(&host_data); - encoded[0x1a0..0x1e0].copy_from_slice(&CHIP_ID); + let mut report = AttestationReport { + version: 2, + sig_algo: 1, + ..Default::default() + }; + *report.report_data = report_data; + *report.measurement = measurement; + *report.host_data = host_data; + *report.chip_id = CHIP_ID; + report.write_bytes(&mut encoded)?; self.sign(&mut encoded)?; Ok(SevSnpEvidence { report: encoded, diff --git a/dstack/sev-snp-qvl/src/lib.rs b/dstack/sev-snp-qvl/src/lib.rs index 128bbc104..7b0449d47 100644 --- a/dstack/sev-snp-qvl/src/lib.rs +++ b/dstack/sev-snp-qvl/src/lib.rs @@ -1098,7 +1098,9 @@ fn amd_snp_product_candidates_for_report(report: &AttestationReport) -> Result Result> { match report.version { 2 => return Ok(None), - 3 => {} + // v5 (firmware 1.58+) adds the mitigation vectors; the fields used + // here are laid out as in v3. + 3..=5 => {} version => bail!("unsupported amd sev-snp report version: {version}"), } @@ -1216,7 +1218,7 @@ fn parse_certificate(cert: &CertBytes, name: &str) -> Result { } fn validate_amd_snp_report_policy(report: &AttestationReport) -> Result<()> { - if !matches!(report.version, 2 | 3) { + if !matches!(report.version, 2..=5) { bail!("unsupported amd sev-snp report version: {}", report.version); } if report.vmpl != 0 { @@ -1903,6 +1905,23 @@ mod tests { validate_amd_snp_report_policy(&report).unwrap(); } + #[test] + fn report_v5_is_accepted_and_newer_versions_are_not() { + let mut report = base_report(); + report.version = 5; + report.cpuid_fam_id = Some(0x1a); + report.cpuid_mod_id = Some(0x02); + validate_amd_snp_report_policy(&report).unwrap(); + assert_eq!( + amd_snp_product_candidates_for_report(&report).unwrap(), + vec![AmdSnpProduct::Turin] + ); + + report.version = 6; + assert!(validate_amd_snp_report_policy(&report).is_err()); + assert!(amd_snp_product_candidates_for_report(&report).is_err()); + } + fn base_report() -> AttestationReport { AttestationReport { version: 2, From 866727574b5e1397b2db135ae078f0f6754a00ff Mon Sep 17 00:00:00 2001 From: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com> Date: Thu, 3 Dec 2026 20:49:48 +0000 Subject: [PATCH 2/2] test(sev-snp): add offline Turin firmware 1.58 v5 attestation fixture Add a real AMD EPYC Turin (fw 1.58.10) version 5 SEV-SNP attestation fixture with non-zero launch_mit_vector/current_mit_vector (0x7fff) plus pinned Turin ASK/VCEK certificates, and verify the v5 parsing, offline hardware chain, app_info decoding, and SEV-SNP launch/os_image_hash binding paths in dstack-attest/tests/sev_snp_verify.rs. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com> --- REUSE.toml | 3 + .../tests/sev_snp_fixture.README.md | 10 ++ .../tests/sev_snp_turin_v5_ask.pem | 37 ++++++ .../tests/sev_snp_turin_v5_attestation.bin | Bin 0 -> 4179 bytes .../tests/sev_snp_turin_v5_vcek.pem | 30 +++++ dstack/dstack-attest/tests/sev_snp_verify.rs | 105 ++++++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 dstack/dstack-attest/tests/sev_snp_turin_v5_ask.pem create mode 100644 dstack/dstack-attest/tests/sev_snp_turin_v5_attestation.bin create mode 100644 dstack/dstack-attest/tests/sev_snp_turin_v5_vcek.pem diff --git a/REUSE.toml b/REUSE.toml index 6e7e20c64..ef48d937a 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -111,6 +111,9 @@ path = [ "dstack/dstack-attest/tests/sev_snp_attestation.bin", "dstack/dstack-attest/tests/sev_snp_ask.pem", "dstack/dstack-attest/tests/sev_snp_vcek.pem", + "dstack/dstack-attest/tests/sev_snp_turin_v5_attestation.bin", + "dstack/dstack-attest/tests/sev_snp_turin_v5_ask.pem", + "dstack/dstack-attest/tests/sev_snp_turin_v5_vcek.pem", "dstack/sev-snp-qvl/testdata/amd-milan.crl", "dstack/nsm-attest/tests/nitro_attestation.bin", "dstack/nsm-qvl/tests/nitro_attestation.bin", diff --git a/dstack/dstack-attest/tests/sev_snp_fixture.README.md b/dstack/dstack-attest/tests/sev_snp_fixture.README.md index 3d52ef946..01f527f83 100644 --- a/dstack/dstack-attest/tests/sev_snp_fixture.README.md +++ b/dstack/dstack-attest/tests/sev_snp_fixture.README.md @@ -10,12 +10,22 @@ Real AMD SEV-SNP attestation captured from a live dstack CVM, used by ## Files +### Milan (report version 2) + | File | Description | | --- | --- | | `sev_snp_attestation.bin` | `VersionedAttestation` (SCALE V0) — the full attestation as produced inside the CVM. Contains the 1184-byte SNP report + the `mr_config` document. | | `sev_snp_ask.pem` | AMD SEV intermediate cert (ASK, `CN=SEV-Milan`) for the chip that signed the report. | | `sev_snp_vcek.pem` | Per-chip VCEK (`CN=SEV-VCEK`) for the report's `chip_id` + reported TCB. | +### Turin (firmware 1.58, report version 5) + +| File | Description | +| --- | --- | +| `sev_snp_turin_v5_attestation.bin` | `VersionedAttestation` (SCALE V0) captured from a clean `attest-test` CVM (`key_provider = "none"`) on an AMD EPYC Turin host running SEV-SNP firmware `1.58.10`. Contains a version 5 1184-byte SNP report with non-zero `launch_mit_vector`/`current_mit_vector` (`0x7fff`) + split `sev_snp_measurement` + `mr_config`. | +| `sev_snp_turin_v5_ask.pem` | AMD SEV intermediate cert (ASK, `CN=SEV-Turin`) for the chip that signed the report. | +| `sev_snp_turin_v5_vcek.pem` | Per-chip VCEK (`CN=SEV-VCEK`) for the report's 8-byte Turin `chip_id` + reported TCB (`fmcSPL=1, blSPL=3, teeSPL=3, snpSPL=8, ucodeSPL=118`). | + The AMD root key (ARK) is **not** bundled — `sev-snp-qvl` uses its built-in ARK, so the test verifies the full chain ARK → ASK → VCEK → report signature with nothing fetched from AMD KDS (fully offline / deterministic). diff --git a/dstack/dstack-attest/tests/sev_snp_turin_v5_ask.pem b/dstack/dstack-attest/tests/sev_snp_turin_v5_ask.pem new file mode 100644 index 000000000..ba57582ae --- /dev/null +++ b/dstack/dstack-attest/tests/sev_snp_turin_v5_ask.pem @@ -0,0 +1,37 @@ +-----BEGIN CERTIFICATE----- +MIIG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ltqf +Em4Kl/cc4f+H6bEwhj1QKAN2ipRf+mP0NfzJb+6ZHNsOvyq/WByYpLXV9JJoiDW/ +8RZwPU/Mn7IuQBauCy78G7FS0ta3q1et74faYBBgeJ6awEasa25CvmsmlU0R +-----END CERTIFICATE----- diff --git a/dstack/dstack-attest/tests/sev_snp_turin_v5_attestation.bin b/dstack/dstack-attest/tests/sev_snp_turin_v5_attestation.bin new file mode 100644 index 0000000000000000000000000000000000000000..125109a82a6335aeb8c535e5a0731caaa1eecfb2 GIT binary patch literal 4179 zcmeHKTZklA8J^AJ8Uw~e;zJ@!NQW44=Tdd5sxJfk(AS!pnR9x&r@E`paZOv-u4{L1 zS6^#)vlvj=c*{dTF#!d|)qo;KH((IsOTa)9G!GIV6q5%ZWWj(j=u7;&XJ=>Koh2KT zJlW7)UFW}l|M&mZy>#>oAOFzO{_E)em-oCL0gWR^kKPWKv3;GkJ{;QdaAon~c+=r% zV6Pw!rLR-F>FvfN_x}FHBc*RV`oj0$`i}O>3m3n9;y2IE&f-rz{}uMJCy$*txBR_- zp1kY)-H(5i>BT30pxk9WRrn!3{?J#y`_sR@^x&VrwDjQR^Kbs^owbWz<#mH_cic44 z|449>V-FaA|J57vLx1_vAMbqm&Ica*{8qi$e)Yn|SKkTFroZ^^d%X5>yzjO-syDup zPrm&2J^xs7Zj{{G$-e(P){iXB-~0FPp5L?Izuua+4_@nA&;0JSOV2)j?CBqW^V<&} z-~Q#--`e@vqqWMV`|pj9JulAU&TZmvpSVwZ>DLZ@`t8e?S8tZ#^mCVg@{0?1i`lc! zyt(5?A9>@o)kkjcd{|rm`HN3J_O(Aech9AVpA(io_1D*5`LzG1`#(!>=I8(CA20$J zj-E;B{eIiCQtK%zBjwU*OUQA^GI+zuS(yxRr>`OGU_7j*)dlBWoB2XM-B=IBCf; zvsOBt&1MlVh&(SiU>Ml5c7Mcwp@ z(mPix7Bf1sbB>wQvzCyt9Xl)7oS8vL${2=aNys*I)3ij(M7gvh*}7xuI&VwJ$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zg7R9G+g)o0(ukXCgLJVn&{1;+eT`elbxq__W!vf&hFy*?Z%ww=%yGCjs3oJVyi-(_ zo+1ioIXxqkyni(aGv literal 0 HcmV?d00001 diff --git a/dstack/dstack-attest/tests/sev_snp_turin_v5_vcek.pem b/dstack/dstack-attest/tests/sev_snp_turin_v5_vcek.pem new file mode 100644 index 000000000..7c27e2943 --- /dev/null +++ b/dstack/dstack-attest/tests/sev_snp_turin_v5_vcek.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFGDCCAsygAwIBAgIUNvE7iSbkKDttsPhDWLK92Iad4LowQQYJKoZIhvcNAQEK +MDSgDzANBglghkgBZQMEAgIFAKEcMBoGCSqGSIb3DQEBCDANBglghkgBZQMEAgIF +AKIDAgEwMHsxFDASBgNVBAsMC0VuZ2luZWVyaW5nMQswCQYDVQQGEwJVUzEUMBIG +A1UEBwwLU2FudGEgQ2xhcmExCzAJBgNVBAgMAkNBMR8wHQYDVQQKDBZBZHZhbmNl +ZCBNaWNybyBEZXZpY2VzMRIwEAYDVQQDDAlTRVYtVHVyaW4wHhcNMjYxMjAyMTg0 +ODQ0WhcNMzMxMjAyMTg0ODQ0WjB6MRQwEgYDVQQLDAtFbmdpbmVlcmluZzELMAkG +A1UEBhMCVVMxFDASBgNVBAcMC1NhbnRhIENsYXJhMQswCQYDVQQIDAJDQTEfMB0G +A1UECgwWQWR2YW5jZWQgTWljcm8gRGV2aWNlczERMA8GA1UEAwwIU0VWLVZDRUsw +djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQANBf2SBRcM4tKBLQDewY5s6IPzhGEmJuj +LUBSbtXScSHQo9eXtLRRHMUbKx/CVj2xQhihxQNnqUuQWMrCF3hgxYwq2CksfSi7 +nwYnTUmUky/nYWFPZk4RDiNuQuyHvxijgdowgdcwEAYJKwYBBAGceAEBBAMCAQEw +FAYJKwYBBAGceAECBAcWBVR1cmluMBEGCisGAQQBnHgBAwkEAwIBATARBgorBgEE +AZx4AQMBBAMCAQMwEQYKKwYBBAGceAEDAgQDAgEDMBEGCisGAQQBnHgBAwMEAwIB +CDARBgorBgEEAZx4AQMFBAMCAQAwEQYKKwYBBAGceAEDBgQDAgEAMBEGCisGAQQB +nHgBAwcEAwIBADARBgorBgEEAZx4AQMIBAMCAXYwFQYJKwYBBAGceAEEBAh6G831 +FPYtZjBBBgkqhkiG9w0BAQowNKAPMA0GCWCGSAFlAwQCAgUAoRwwGgYJKoZIhvcN +AQEIMA0GCWCGSAFlAwQCAgUAogMCATADggIBAHHtnhY4Tlyp8BTyDI+MzkzMAm2d +y3POjIYq23dN5lFP9q1bzk97oKzGoB3vQuiDnEnMwPzQa3fav4GRb8SQ45IfPjcX +yUydTTdyAoRT3Ep721eimKpdIvifPw6nxz3hCrbiC2f4YEhcKwDM1ukQrAhUaFcn +Wwb3jLFCClW0PNR1bhEVMsGwuIC3X8Fg+e9fbaUV4PRyLXvCPH+DBJLQpbaccJ5m +JJ9UoaD/7LyC4LeEHY4k1pyGIrfxiCALJZSb+PZFUcPJfZtdCbupaDs6j7F81EyW +n9YRa1AmWijAnSEDH1NUrMNWa8/JgMixNnjlHULbQHAYxxb52T959Ujv97q7EsAl +gTPnTda5J/LTZEZKgOmSNsTDEZ0gVAfw9B3HMf3RigDWRo7xLPQ4YWpr0amia/6W +1qjo3V6MPsLj+frIpnyAFpbUKaacFUKXXtQ/OwpGn8AfER8uXtE5FwSbh8zXGxI+ +LXCc5rhcl0+sIJivcdlMB1YGW69SyeexejKzSzqxhL2edF4RrBxKE8k+VQ/y5Hno +QfvjdA5YQmcTRAk1nJS+29Vyc56jFj7FKJIBeyOLmikDawV6iypRpY/yG2gHWS7o +KixaTuZeKOClVz5HMFmxpCXPlYk8/82SNliBicFIZG/lHaAbLdX4T72bL/wMvSrj +K3Vk5NZvtlFQPA+/ +-----END CERTIFICATE----- diff --git a/dstack/dstack-attest/tests/sev_snp_verify.rs b/dstack/dstack-attest/tests/sev_snp_verify.rs index fc6750fba..9eb6bbe0e 100644 --- a/dstack/dstack-attest/tests/sev_snp_verify.rs +++ b/dstack/dstack-attest/tests/sev_snp_verify.rs @@ -22,6 +22,13 @@ const SEV_ASK_PEM: &[u8] = include_bytes!("sev_snp_ask.pem"); /// Per-chip VCEK (CN=SEV-VCEK) for the report's chip_id + reported TCB. const SEV_VCEK_PEM: &[u8] = include_bytes!("sev_snp_vcek.pem"); +/// Real SEV-SNP version 5 attestation captured on an AMD EPYC Turin (fw 1.58) host. +const SEV_TURIN_V5_ATTESTATION_BIN: &[u8] = include_bytes!("sev_snp_turin_v5_attestation.bin"); +/// AMD SEV intermediate (ASK / CN=SEV-Turin) for the Turin chip that signed the v5 report. +const SEV_TURIN_V5_ASK_PEM: &[u8] = include_bytes!("sev_snp_turin_v5_ask.pem"); +/// Per-chip VCEK (CN=SEV-VCEK) for the Turin v5 report's chip_id + reported TCB. +const SEV_TURIN_V5_VCEK_PEM: &[u8] = include_bytes!("sev_snp_turin_v5_vcek.pem"); + /// report_data marker passed to `dstack-util quote-report` when capturing the fixture. const REPORT_DATA_MARKER: &[u8] = b"attest-test-fixture-2026"; @@ -488,3 +495,101 @@ fn configured_tcb_requirements_judge_the_real_report() { // Milan-X's minimum says nothing about Milan. assert_eq!(verify(&requirement("00a00f12", reported.microcode)), ""); } + +#[test] +fn verify_sev_snp_turin_v5_attestation_bin() { + let versioned = VersionedAttestation::from_scale(SEV_TURIN_V5_ATTESTATION_BIN) + .expect("decode Turin v5 VersionedAttestation"); + let VersionedAttestation::V0 { attestation } = versioned else { + panic!("expected V0 attestation"); + }; + + assert_eq!( + attestation.report_data, + expected_report_data(), + "outer attestation report_data marker" + ); + + let AttestationQuote::DstackAmdSevSnp(quote) = &attestation.quote else { + panic!("expected an AMD SEV-SNP quote"); + }; + assert_eq!(quote.report.len(), 1184, "raw SNP report length"); + // Firmware 1.58+ produces version 5 reports with non-zero launch/current + // mitigation vectors at 0x1f8..0x208, which sev 6.0.0 rejected as reserved. + assert_eq!( + u32::from_le_bytes(quote.report[0..4].try_into().unwrap()), + 5, + "Turin fixture must be a version 5 SNP report" + ); + assert_ne!( + u64::from_le_bytes(quote.report[0x1f8..0x200].try_into().unwrap()), + 0, + "Turin v5 fixture must exercise non-zero launch_mit_vector" + ); + assert_ne!( + u64::from_le_bytes(quote.report[0x200..0x208].try_into().unwrap()), + 0, + "Turin v5 fixture must exercise non-zero current_mit_vector" + ); + + // Offline hardware verification: builtin Turin ARK -> ASK -> VCEK -> v5 report signature. + let verified = verify_amd_snp_attestation(&AmdSnpAttestationInput { + report: "e.report, + ask_pem: SEV_TURIN_V5_ASK_PEM, + vcek_pem: SEV_TURIN_V5_VCEK_PEM, + }) + .expect("verify Turin v5 SEV-SNP attestation offline"); + + assert_eq!( + verified.report_data, + expected_report_data(), + "signed report_data marker" + ); + assert_ne!(verified.measurement, [0u8; 48], "measurement must be set"); + assert_ne!(verified.host_data, [0u8; 32], "host_data must be set"); + + // Unverified parsing (used by guest boot + app-info decode) must also accept v5 reports. + let app_info = attestation + .decode_app_info(false) + .expect("decode app_info from Turin v5 attestation"); + assert_eq!( + hex::encode(&app_info.app_id), + "d75966d3902db1bf9d7718f092dd35bbf8622297", + "decoded app_id from Turin v5 attestation" + ); + + // End-to-end offline OS image binding against the native split-measurement config. + let binding = verify_sev_launch( + &verified.measurement, + &verified.host_data, + &attestation.config, + ) + .expect("recompute SEV launch + verify os_image_hash for Turin v5"); + let config_value: serde_json::Value = + serde_json::from_str(&attestation.config).expect("config json"); + assert_eq!( + hex::encode(&binding.os_image_hash), + config_value["os_image_hash"] + .as_str() + .expect("os_image_hash"), + "verified os_image_hash" + ); + assert_eq!( + binding.mr_config.app_id.as_deref(), + Some(app_info.app_id.as_slice()), + "mr_config app_id bound by HOST_DATA" + ); + + // Flipping a byte in the v5 mitigation vector invalidates the VCEK signature. + let mut tampered = quote.report.clone(); + tampered[0x1f8] ^= 0x01; + assert!( + verify_amd_snp_attestation(&AmdSnpAttestationInput { + report: &tampered, + ask_pem: SEV_TURIN_V5_ASK_PEM, + vcek_pem: SEV_TURIN_V5_VCEK_PEM, + }) + .is_err(), + "tampering launch_mit_vector in a v5 report must fail signature verification" + ); +}