Skip to content

Commit

Permalink
fetch: Adding Siena and Bergamo support
Browse files Browse the repository at this point in the history
Both Siena and Bergamo processors are classified
under the Genoa family on the AMD Key Distribution
Server. This adds the necessary changes to make
the requests appropriately for those models.

Signed-off-by: Larry Dewey <[email protected]>
  • Loading branch information
larrydewey committed Feb 6, 2024
1 parent 97fbe4f commit 9c7ce21
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ pub enum FetchCmd {
pub enum ProcType {
Milan,
Genoa,
Siena,
Bergamo,
}

impl ProcType {
fn kds_prod_name(&self) -> String {
format!(
"{}",
match self {
ProcType::Genoa | ProcType::Siena | ProcType::Bergamo =>
ProcType::Genoa.to_string(),
_ => self.to_string(),
}
)
}
}

impl FromStr for ProcType {
Expand All @@ -34,6 +49,8 @@ impl FromStr for ProcType {
match input.to_lowercase().as_str() {
"milan" => Ok(ProcType::Milan),
"genoa" => Ok(ProcType::Genoa),
"siena" => Ok(ProcType::Siena),
"bergamo" => Ok(ProcType::Bergamo),
_ => Err(anyhow::anyhow!("Processor type not found!")),
}
}
Expand All @@ -44,6 +61,8 @@ impl fmt::Display for ProcType {
match self {
ProcType::Milan => write!(f, "Milan"),
ProcType::Genoa => write!(f, "Genoa"),
ProcType::Siena => write!(f, "Siena"),
ProcType::Bergamo => write!(f, "Bergamo"),
}
}
}
Expand Down Expand Up @@ -80,7 +99,10 @@ mod cert_authority {
const KDS_CERT_CHAIN: &str = "cert_chain";

// Should make -> https://kdsintf.amd.com/vcek/v1/{SEV_PROD_NAME}/cert_chain
let url: String = format!("{KDS_CERT_SITE}{KDS_VCEK}/{processor_model}/{KDS_CERT_CHAIN}");
let url: String = format!(
"{KDS_CERT_SITE}{KDS_VCEK}/{}/{KDS_CERT_CHAIN}",
processor_model.kds_prod_name()
);

let rsp: Response = get(url).context("Could not get certs from URL")?;

Expand Down Expand Up @@ -165,8 +187,9 @@ mod vcek {
let hw_id: String = hex::encode(att_report.chip_id);

let vcek_url: String = format!(
"{KDS_CERT_SITE}{KDS_VCEK}/{processor_model}/\
"{KDS_CERT_SITE}{KDS_VCEK}/{}/\
{hw_id}?blSPL={:02}&teeSPL={:02}&snpSPL={:02}&ucodeSPL={:02}",
processor_model.kds_prod_name(),
att_report.reported_tcb.bootloader,
att_report.reported_tcb.tee,
att_report.reported_tcb.snp,
Expand Down Expand Up @@ -197,3 +220,23 @@ mod vcek {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::ProcType;

#[test]
fn test_kds_prod_name_milan_base() {
let milan_proc: ProcType = ProcType::Milan;
assert_eq!(milan_proc.kds_prod_name(), ProcType::Milan.to_string());
}

#[test]
fn test_kds_prod_name_genoa_base() {
assert_eq!(ProcType::Genoa.kds_prod_name(), ProcType::Genoa.to_string());
assert_eq!(ProcType::Siena.kds_prod_name(), ProcType::Genoa.to_string());
assert_eq!(
ProcType::Bergamo.kds_prod_name(),
ProcType::Genoa.to_string()
);
}
}

0 comments on commit 9c7ce21

Please sign in to comment.