Skip to content

Commit b3424fc

Browse files
committed
fix(tpm): correctly write the log name, and change the sprout configuration event name
1 parent afc650f commit b3424fc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/config/loader.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ fn load_raw_config(options: &SproutOptions) -> Result<Vec<u8>> {
2424
.context("unable to read sprout config file")?;
2525

2626
// Measure the sprout.toml into the TPM, if needed and possible.
27-
PlatformTpm::log_event(PlatformTpm::PCR_BOOT_LOADER_CONFIG, &content, "sprout.toml")
28-
.context("unable to measure the sprout.toml file into the TPM")?;
27+
PlatformTpm::log_event(
28+
PlatformTpm::PCR_BOOT_LOADER_CONFIG,
29+
&content,
30+
"sprout: configuration file",
31+
)
32+
.context("unable to measure the sprout.toml file into the TPM")?;
2933

3034
// Return the contents of the sprout config file.
3135
Ok(content)

src/platform/tpm.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::utils;
22
use anyhow::{Context, Result};
3+
use uefi::ResultExt;
34
use uefi::boot::ScopedProtocol;
45
use uefi::proto::tcg::PcrIndex;
56
use uefi::proto::tcg::v2::{PcrEventInputs, Tcg};
@@ -110,13 +111,11 @@ impl PlatformTpm {
110111
};
111112

112113
// Encode the description as a UTF-16 little endian string.
113-
let description = description
114-
.encode_utf16()
115-
.flat_map(|c| c.to_le_bytes())
116-
.collect::<Vec<u8>>();
114+
let description = description.as_bytes().to_vec();
117115

118116
// Construct an event input for the TPM.
119117
let event = PcrEventInputs::new_in_box(pcr_index, EventType::IPL, &description)
118+
.discard_errdata()
120119
.context("unable to construct pcr event inputs")?;
121120

122121
// Log the event into the TPM.

0 commit comments

Comments
 (0)