Skip to content

Commit

Permalink
lib: Allow SNP-only CA chain from Generation
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Fanelli <[email protected]>
  • Loading branch information
tylerfanelli committed Feb 16, 2024
1 parent d8e5266 commit 257ccd0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,19 @@ use certs::sev::sev;
#[cfg(all(feature = "sev", feature = "openssl"))]
use certs::sev::ca::{Certificate, Chain as CertSevCaChain};

#[cfg(all(not(feature = "sev"), feature = "snp", feature = "openssl"))]
use certs::snp::ca::Chain as CertSnpCaChain;

#[cfg(all(feature = "sev", feature = "openssl"))]
use certs::sev::builtin as SevBuiltin;

#[cfg(all(not(feature = "sev"), feature = "snp", feature = "openssl"))]
use certs::snp::builtin as SnpBuiltin;

#[cfg(feature = "sev")]
use crate::{certs::sev::sev::Certificate as SevCertificate, error::Indeterminate, launch::sev::*};

#[cfg(any(feature = "sev", feature = "openssl", feature = "snp"))]
#[cfg(any(feature = "sev", feature = "snp"))]
use std::convert::TryFrom;

use std::io::{Read, Write};
Expand Down Expand Up @@ -282,6 +288,24 @@ impl From<Generation> for CertSevCaChain {
}
}

#[cfg(all(not(feature = "sev"), feature = "snp", feature = "openssl"))]
impl From<Generation> for CertSnpCaChain {
fn from(gen: Generation) -> CertSnpCaChain {
let (ark, ask) = match gen {
Generation::Milan => (
SnpBuiltin::milan::ark().unwrap(),
SnpBuiltin::milan::ask().unwrap(),
),
Generation::Genoa => (
SnpBuiltin::genoa::ark().unwrap(),
SnpBuiltin::genoa::ask().unwrap(),
),
};

CertSnpCaChain { ark, ask }
}
}

#[cfg(all(feature = "sev", feature = "openssl"))]
impl TryFrom<&sev::Chain> for Generation {
type Error = ();
Expand Down

0 comments on commit 257ccd0

Please sign in to comment.