Enum sev::Generation

source ·
pub enum Generation {
    Naples,
    Rome,
    Milan,
    Genoa,
}
Expand description

A representation for EPYC generational product lines.

Implements type conversion traits to determine which generation a given SEV certificate chain corresponds to. This is helpful for automatically detecting what platform code is running on, as one can simply export the SEV certificate chain and attempt to produce a Generation from it with the TryFrom trait.

§Example


// NOTE: The conversion traits require the `sev` crate to have the
// `openssl` feature enabled.

use std::convert::TryFrom;
use sev::certs::sev::Usage;
use sev::firmware::host::types::Firmware;
use sev::Generation;

let mut firmware = Firmware::open().expect("failed to open /dev/sev");

let chain = firmware.pdh_cert_export()
    .expect("unable to export SEV certificates");

let id = firmware.get_identifier().expect("error fetching identifier");

// NOTE: Requesting a signed CEK from AMD's KDS has been omitted for
// brevity.

let generation = Generation::try_from(&chain).expect("not a SEV/ES chain");
match generation {
    Generation::Naples => println!("Naples"),
    Generation::Rome => println!("Rome"),
}

Variants§

§

Naples

First generation EPYC (SEV).

§

Rome

Second generation EPYC (SEV, SEV-ES).

§

Milan

Third generation EPYC (SEV, SEV-ES, SEV-SNP).

§

Genoa

Fourth generation EPYC (SEV, SEV-ES, SEV-SNP).

Implementations§

source§

impl Generation

source

pub fn titlecase(&self) -> String

Create a title-cased string identifying the SEV generation.

Trait Implementations§

source§

impl Clone for Generation

source§

fn clone(&self) -> Generation

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl TryFrom<String> for Generation

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(val: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Generation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.