Skip to content

Commit

Permalink
enable hex values to be used for tpm_ownerpassword
Browse files Browse the repository at this point in the history
Signed-off-by: Isaac-Matthews <[email protected]>
  • Loading branch information
Isaac-Matthews authored and ansasaki committed Apr 26, 2024
1 parent 6087147 commit aca54b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions keylime-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ idevid_cert = "default"
# Use this option to state the existing TPM ownerpassword.
# This option should be set only when a password is set for the Endorsement
# Hierarchy (e.g. via "tpm2_changeauth -c e").
# In order to use a hex value for the password, use the prefix "hex:"
# For example if tpm2_changeauth -c e "hex:00a1b2c3e4" has run, the config option
# would be 'tpm_ownerpassword = "hex:00a1b2c3e4"'
# If no password was set, keep the empty string "".
#
# To override tpm_ownerpassword, set KEYLIME_AGENT_TPM_OWNERPASSWORD environment
Expand Down
10 changes: 9 additions & 1 deletion keylime-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,15 @@ async fn main() -> Result<()> {
// ownership of TPM access, which will not be implemented here.
let tpm_ownerpassword = &config.agent.tpm_ownerpassword;
if !tpm_ownerpassword.is_empty() {
let auth = Auth::try_from(tpm_ownerpassword.as_bytes())?;
let auth = if let Some(hex_ownerpassword) =
tpm_ownerpassword.strip_prefix("hex:")
{
let decoded_ownerpassword =
hex::decode(hex_ownerpassword).map_err(Error::from)?;
Auth::try_from(decoded_ownerpassword)?
} else {
Auth::try_from(tpm_ownerpassword.as_bytes())?
};
ctx.as_mut().tr_set_auth(Hierarchy::Endorsement.into(), auth)
.map_err(|e| {
Error::Configuration(format!(
Expand Down

0 comments on commit aca54b3

Please sign in to comment.