Skip to content

Commit a8f95a6

Browse files
committed
Override outdated SEAM loader
1 parent 4939bd4 commit a8f95a6

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

src/attestation/dcap.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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

44
use configfs_tsm::QuoteGenerationError;
55
use dcap_qvl::{
6-
collateral::get_collateral_for_fmspc,
6+
collateral::{self, get_collateral_for_fmspc},
77
quote::{Quote, Report},
88
};
99
use 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)?;

src/attestation/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pub mod azure;
33
pub mod dcap;
44
pub mod measurements;
5+
pub mod tcb_info;
56

67
use measurements::MultiMeasurements;
78
use parity_scale_codec::{Decode, Encode};

src/attestation/tcb_info.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
4+
#[serde(rename_all = "camelCase")]
5+
pub struct TcbInfo {
6+
pub id: String,
7+
pub version: u8,
8+
pub issue_date: String,
9+
pub next_update: String,
10+
pub fmspc: String,
11+
pub pce_id: String,
12+
pub tcb_type: u32,
13+
pub tcb_evaluation_data_number: u32,
14+
pub tcb_levels: Vec<TcbLevel>,
15+
}
16+
17+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
18+
#[serde(rename_all = "camelCase")]
19+
pub struct TcbLevel {
20+
pub tcb: Tcb,
21+
pub tcb_date: String,
22+
pub tcb_status: String,
23+
#[serde(rename = "advisoryIDs", default)]
24+
pub advisory_ids: Vec<String>,
25+
}
26+
27+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
28+
#[serde(rename_all = "camelCase")]
29+
pub struct Tcb {
30+
#[serde(rename = "sgxtcbcomponents")]
31+
pub sgx_components: Vec<TcbComponents>,
32+
#[serde(rename = "tdxtcbcomponents", default)]
33+
pub tdx_components: Vec<TcbComponents>,
34+
#[serde(rename = "pcesvn")]
35+
pub pce_svn: u16,
36+
}
37+
38+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
39+
#[serde(rename_all = "camelCase")]
40+
pub struct TcbComponents {
41+
pub svn: u8,
42+
}

0 commit comments

Comments
 (0)