Skip to content

Commit aca54b3

Browse files
Isaac-Matthewsansasaki
authored andcommitted
enable hex values to be used for tpm_ownerpassword
Signed-off-by: Isaac-Matthews <[email protected]>
1 parent 6087147 commit aca54b3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

keylime-agent.conf

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ idevid_cert = "default"
263263
# Use this option to state the existing TPM ownerpassword.
264264
# This option should be set only when a password is set for the Endorsement
265265
# Hierarchy (e.g. via "tpm2_changeauth -c e").
266+
# In order to use a hex value for the password, use the prefix "hex:"
267+
# For example if tpm2_changeauth -c e "hex:00a1b2c3e4" has run, the config option
268+
# would be 'tpm_ownerpassword = "hex:00a1b2c3e4"'
266269
# If no password was set, keep the empty string "".
267270
#
268271
# To override tpm_ownerpassword, set KEYLIME_AGENT_TPM_OWNERPASSWORD environment

keylime-agent/src/main.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,15 @@ async fn main() -> Result<()> {
295295
// ownership of TPM access, which will not be implemented here.
296296
let tpm_ownerpassword = &config.agent.tpm_ownerpassword;
297297
if !tpm_ownerpassword.is_empty() {
298-
let auth = Auth::try_from(tpm_ownerpassword.as_bytes())?;
298+
let auth = if let Some(hex_ownerpassword) =
299+
tpm_ownerpassword.strip_prefix("hex:")
300+
{
301+
let decoded_ownerpassword =
302+
hex::decode(hex_ownerpassword).map_err(Error::from)?;
303+
Auth::try_from(decoded_ownerpassword)?
304+
} else {
305+
Auth::try_from(tpm_ownerpassword.as_bytes())?
306+
};
299307
ctx.as_mut().tr_set_auth(Hierarchy::Endorsement.into(), auth)
300308
.map_err(|e| {
301309
Error::Configuration(format!(

0 commit comments

Comments
 (0)