Skip to content

Commit

Permalink
fixup! fixup! WIP: migrate to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
brandsimon committed Nov 20, 2023
1 parent 6cb8f10 commit 2615753
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/tpm2/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn create_primary(
pub fn set_policy(
context: &mut Context,
pcrs: &Vec<PcrSlot>,
session: &AuthSession,
session: AuthSession,
) -> Result<(), DynError> {
let pcr_selection_list = PcrSelectionListBuilder::new()
.with_selection(HashingAlgorithm::Sha256, pcrs.as_slice())
Expand All @@ -156,9 +156,8 @@ pub fn set_policy(
Hierarchy::Endorsement,
)
})?;
let session = start_auth_session(context)?;
context.policy_pcr(
(*session).try_into()?,
session.try_into()?,
hashed_data.clone(),
pcr_sel.clone(),
)?;
Expand Down Expand Up @@ -364,7 +363,7 @@ mod tests {
let mut context = super::create_context()?;
let session = super::start_auth_session(&mut context)?;
let pcrs = vec![super::PcrSlot::Slot4, super::PcrSlot::Slot7];
super::set_policy(&mut context, &pcrs, &session)?;
super::set_policy(&mut context, &pcrs, session)?;
let session_digest =
context.policy_get_digest(session.try_into()?)?;
assert_eq!(
Expand All @@ -378,7 +377,7 @@ mod tests {
);

context.policy_restart(session.try_into()?)?;
super::set_policy(&mut context, &vec![], &session)?;
super::set_policy(&mut context, &vec![], session)?;
let session_digest2 =
context.policy_get_digest(session.try_into()?)?;
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions src/tpm2/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Tpm2SigningConfig {
Digest::try_from(vec![])?
} else {
let session = tpm2::start_auth_session(&mut context)?;
tpm2::set_policy(&mut context, &pcrs, &session)?;
tpm2::set_policy(&mut context, &pcrs, session)?;
context.policy_get_digest(session.try_into()?)?
};
let primary = tpm2::create_primary(
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Tpm2SigningConfig {
tpm2::set_policy(
&mut self.context,
&self.pcrs,
&self.session.try_into()?,
self.session.try_into()?,
)?;
}
let data = MaxBuffer::try_from(message.to_vec())?;
Expand Down

0 comments on commit 2615753

Please sign in to comment.