Expand description
SEV-SNP ID block generation and signing.
Adds a signed SNP ID block to an already-built IGVM file as an
[IgvmDirectiveHeader::SnpIdBlock] directive. Two signing modes are
supported:
- Out-of-band (production):
manifestemits the ID block signing payload as<base>-snp.idblockβ the raw [SnpPspIdBlock] bytes, i.e. exactly the content the SNP firmware hashes (SHA-384) and validates. A generic file-content signer (e.g.openssl dgst -sha384 -sign key -out sig.der file) signs those bytes and emits a DER-encoded ECDSA signature file. That signature, plus the signing public key (X.509 cert or SPKI PEM), is fed back viaadd_snp_id_block_signed, which reconstructs the directive without ever holding a private key. - Temporary key (development/test):
add_snp_id_block_temp_keygenerates an ephemeral ECDSA P-384 key, signs the block in-process, and embeds the result. This is for local testing only.
Either way, the launch digest embedded in the block is the SNP measurement
that the igvm crateβs [IgvmSerializer] computes eagerly at construction
time, so the file is measured exactly once. The SNP measurement algorithm
only hashes page-data directives, so adding the SnpIdBlock directive
afterwards does not perturb that launch digest β the embedded ld stays
valid. Its presence signals the IGVM loader to set id_block_en = 1.
StructsΒ§
- SnpImage
Identity π - Identity fields included in an SNP ID block.
ConstantsΒ§
- SHA_
384_ πOUTPUT_ SIZE_ BYTES - SNP_
ECC_ πCOMPONENT_ SIZE_ BYTES - SNP_
ECC_ πKEY_ SIZE_ BYTES - SNP_
ECDSA_ πCURVE_ P384 - SNP_
FAMILY_ ID - SNP family identifier for OpenHCL guests.
- SNP_
ID_ πKEY_ ALGORITHM_ ECDSA_ P384_ SHA384 - SNP_
IMAGE_ ID - SNP image identifier for OpenHCL guests.
FunctionsΒ§
- add_
snp_ id_ block_ signed - Add an SNP ID block using an out-of-band signature (production).
- add_
snp_ πid_ block_ temp_ key - Add an SNP ID block signed by an ephemeral key (development/test only).
- finish π
- Serialize the staged serializer to bytes with a trace of the result size.
- guest_
policy - Read the SNP
GuestPolicyvalue forcompatibility_maskfrom an IGVM file, if present. - id_
block_ πdirective - Assemble an [
IgvmDirectiveHeader::SnpIdBlock] from an ID block plus its signature and public key. Author-key fields are left zeroed (author signing is not used); the directiveβs presence signals the loader to setid_block_en = 1. - id_
block_ signing_ payload - Build the SNP ID block signing payload for an IGVM file.
- id_
block_ πsigning_ payload_ with_ identity - Build an SNP ID block signing payload with an explicit image identity.
- left_
pad_ πbe - Left-pad a big-endian ECC scalar/coordinate to 48 bytes.
- padded_
le_ πcomponent - Zero-pads and reverses a big-endian ECC component into a 72-byte little-endian array as required by the PSP ID block format.
- parse_
der_ πecdsa_ p384 - Parse a DER-encoded ECDSA signature (
SEQUENCE { INTEGER r, INTEGER s }) into its big-endian 48-byte P-384(r, s)components. - parse_
p384_ πpublic_ key - Extract the signerβs ECDSA P-384 public key from a supplied public key.
- parse_
signing_ πpayload - Parse and validate an SNP ID block signing payload (the raw
[
SnpPspIdBlock] bytes emitted bymanifest). - sign_
id_ πblock_ with_ temp_ key - Generate a temporary ECDSA P-384 key pair using the selected
cryptobackend, sign the SHA-384 hash of the ID block, and return the signature - signature_
and_ πverify - Parse a DER ECDSA signature + public key, cryptographically verify the
signature over
signed_bytes(the signing payload the signer signed), and return the IGVM ID block signature and public-key structures (big-endian in, PSP little-endian layout out). - snp_
context π - Locate the SEV-SNP compatibility mask, reject a pre-existing ID block, and
return
(compatibility_mask, guest_policy). - snp_
measurement π - Fetch the cached SNP launch measurement (48-byte SHA-384) from a serializer.