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]>
tylerfanelli committed Feb 16, 2024
1 parent 5b5b7c2 commit a8e4e1f
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
@@ -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};
@@ -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 = ();

0 comments on commit a8e4e1f

Please sign in to comment.