From b3424fcd8f0c1913bb0fa799aca671bddee2e937 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Fri, 31 Oct 2025 02:45:15 -0400 Subject: [PATCH] fix(tpm): correctly write the log name, and change the sprout configuration event name --- src/config/loader.rs | 8 ++++++-- src/platform/tpm.rs | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/config/loader.rs b/src/config/loader.rs index 7816711..4c839b7 100644 --- a/src/config/loader.rs +++ b/src/config/loader.rs @@ -24,8 +24,12 @@ fn load_raw_config(options: &SproutOptions) -> Result> { .context("unable to read sprout config file")?; // Measure the sprout.toml into the TPM, if needed and possible. - PlatformTpm::log_event(PlatformTpm::PCR_BOOT_LOADER_CONFIG, &content, "sprout.toml") - .context("unable to measure the sprout.toml file into the TPM")?; + PlatformTpm::log_event( + PlatformTpm::PCR_BOOT_LOADER_CONFIG, + &content, + "sprout: configuration file", + ) + .context("unable to measure the sprout.toml file into the TPM")?; // Return the contents of the sprout config file. Ok(content) diff --git a/src/platform/tpm.rs b/src/platform/tpm.rs index b0c37db..1014beb 100644 --- a/src/platform/tpm.rs +++ b/src/platform/tpm.rs @@ -1,5 +1,6 @@ use crate::utils; use anyhow::{Context, Result}; +use uefi::ResultExt; use uefi::boot::ScopedProtocol; use uefi::proto::tcg::PcrIndex; use uefi::proto::tcg::v2::{PcrEventInputs, Tcg}; @@ -110,13 +111,11 @@ impl PlatformTpm { }; // Encode the description as a UTF-16 little endian string. - let description = description - .encode_utf16() - .flat_map(|c| c.to_le_bytes()) - .collect::>(); + let description = description.as_bytes().to_vec(); // Construct an event input for the TPM. let event = PcrEventInputs::new_in_box(pcr_index, EventType::IPL, &description) + .discard_errdata() .context("unable to construct pcr event inputs")?; // Log the event into the TPM.