pub struct IgvmSerializer<'a> { /* private fields */ }corim only.Expand description
Implementations§
Source§impl<'a> IgvmSerializer<'a>
impl<'a> IgvmSerializer<'a>
Sourcepub fn new(file: &'a IgvmFile) -> Result<Self, Error>
pub fn new(file: &'a IgvmFile) -> Result<Self, Error>
Create a new serializer for the given IGVM file.
During construction, the launch measurement is computed for every
platform header in the file whose platform type has a measurement
profile defined by this crate (currently SEV-SNP, TDX, and VBS).
Platform headers with no measurement profile (e.g.,
IgvmPlatformType::NATIVE, IgvmPlatformType::SEV,
IgvmPlatformType::SEV_ES) are silently skipped.
§Errors
Returns Error::MeasurementFailed if measurement computation
fails for any of the file’s measurable platforms (e.g., SEV-SNP
without a IgvmInitializationHeader::GuestPolicy header).
Sourcepub fn measurements(&self) -> &[IgvmPlatformMeasurement]
pub fn measurements(&self) -> &[IgvmPlatformMeasurement]
Get all launch measurements computed for this file.
One entry is present for every measurable platform header in the
file (see new).
Sourcepub fn measurement_for(
&self,
platform: IgvmPlatformType,
) -> Option<&IgvmPlatformMeasurement>
pub fn measurement_for( &self, platform: IgvmPlatformType, ) -> Option<&IgvmPlatformMeasurement>
Get the launch measurement for a specific platform, if the file has a corresponding measurable platform header.
Sourcepub fn corim_for(&self, platform: IgvmPlatformType) -> Option<&[u8]>
pub fn corim_for(&self, platform: IgvmPlatformType) -> Option<&[u8]>
Get the raw CoRIM document bytes effective for the given platform.
Returns the document staged via add_corim if one
exists for the platform, otherwise the document embedded in the base
IGVM file (as produced at generation time). This lets a read-modify-
write caller (for example, one attaching a detached signature) fetch
the document a signature must be verified against without re-scanning
the file’s initialization headers itself.
Returns None if the file has no platform header for platform, or if
no CoRIM document is present for it in either location.
Sourcepub fn add_corim(
&mut self,
platform: IgvmPlatformType,
template: CorimTemplate,
) -> Result<&[u8], Error>
pub fn add_corim( &mut self, platform: IgvmPlatformType, template: CorimTemplate, ) -> Result<&[u8], Error>
Attach a CoRIM endorsement for the given platform.
The generated CoRIM document will be included as an
IgvmInitializationHeader::CorimDocument in the serialized output.
On success, the raw CoRIM bytes that were attached are returned.
For CorimTemplate::LaunchMeasurement, populated measurements
take their digest bytes from the launch measurement computed at
construction time (see new).
§Arguments
platform– The target platform type. Must match a platform header in the file, and must match the platform of theLaunchMeasurementin the template.template– The CoRIM template to instantiate. SeeCorimTemplatefor the supported variants.
Sourcepub fn set_corim_signature(
&mut self,
platform: IgvmPlatformType,
signature: Vec<u8>,
) -> Result<&[u8], Error>
pub fn set_corim_signature( &mut self, platform: IgvmPlatformType, signature: Vec<u8>, ) -> Result<&[u8], Error>
Set the CoRIM signature for a platform while preserving its corresponding CoRIM document.
On serialize, any in-file CoRIM document/signature pair for this platform’s compatibility mask is suppressed and replaced with exactly one CoRIM document (the existing one) and one CoRIM signature.
This keeps CoRIM document/signature ordering valid and avoids callers
needing to reconstruct a full IgvmFile just to patch signatures.
Sourcepub fn add_directive(
&mut self,
directive: IgvmDirectiveHeader,
) -> &IgvmDirectiveHeader
pub fn add_directive( &mut self, directive: IgvmDirectiveHeader, ) -> &IgvmDirectiveHeader
Attach an extra directive header that will be appended when serializing.
This allows callers to stage workflows that need the already-cached
launch measurement from new, then add a directive
derived from that measurement (for example,
IgvmDirectiveHeader::SnpIdBlock) before the final serialize.
Added directives are not included in the measurement cache computed
during new.
Sourcepub fn serialize(&self, output: &mut Vec<u8>) -> Result<(), Error>
pub fn serialize(&self, output: &mut Vec<u8>) -> Result<(), Error>
Serialize the IGVM file to binary format, including any CoRIM
documents that were added via add_corim.
This produces the same binary format as IgvmFile::serialize,
but with additional initialization headers and directives appended.