Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch: Adding Bergamo and Siena Support #31

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 127 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/cert/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn cmd(export: Export) -> Result<()> {
let mut file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(name.clone())?;

// Write out the contents of the certificate to the file.
Expand Down
8 changes: 6 additions & 2 deletions src/cert/fetch/ca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ pub struct Ca {
}

fn write_cert(path: &PathBuf, bytes: &[u8]) -> Result<()> {
let mut file = OpenOptions::new().create(true).write(true).open(path)?;
let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(path)?;
file.write_all(bytes)
.context("Failed to write certificate!")
}
Expand Down Expand Up @@ -79,6 +83,6 @@ pub fn fetch(url: &str) -> Result<Chain> {
fn ca_chain_url() -> Result<String> {
Ok(format!(
"https://kdsintf.amd.com/vcek/v1/{}/cert_chain",
ProcessorGeneration::current()?.to_string()
ProcessorGeneration::current()?.to_kds_url()
))
}
5 changes: 3 additions & 2 deletions src/cert/fetch/crl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use structopt::StructOpt;
fn crl_url() -> Result<String> {
Ok(format!(
"https://kdsintf.amd.com/vcek/v1/{}/crl",
ProcessorGeneration::current()?.to_string()
ProcessorGeneration::current()?.to_kds_url()
))
}

Expand All @@ -34,10 +34,11 @@ pub fn cmd(crl: Crl) -> Result<()> {

let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(crl.dir_path.join(format!(
"{}.crl",
ProcessorGeneration::current()?.to_string()
ProcessorGeneration::current()?.to_kds_url()
)))?;

file.write_all(&bytes)
Expand Down
5 changes: 3 additions & 2 deletions src/cert/fetch/vcek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn cmd(vcek: Vcek) -> Result<()> {

let mut file = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(vcek.path.join(vcek_name))?;

Expand Down Expand Up @@ -73,10 +74,10 @@ pub fn vcek_url() -> Result<String> {
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))
.context("error fetching identifier")?;
let status = platform_status()?;
let gen = ProcessorGeneration::current()?;
let gen = ProcessorGeneration::current()?.to_kds_url();

Ok(format!("https://kdsintf.amd.com/vcek/v1/{}/{}?blSPL={:02}&teeSPL={:02}&snpSPL={:02}&ucodeSPL={:02}",
gen.to_string(), id, status.reported_tcb_version.bootloader,
gen, id, status.reported_tcb_version.bootloader,
status.reported_tcb_version.tee,
status.reported_tcb_version.snp,
status.reported_tcb_version.microcode))
Expand Down
Loading
Loading