Skip to content

Improved return values of pcr_read. #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Superhepper
Copy link
Collaborator

@Superhepper Superhepper commented Oct 18, 2021

This fixes #277 by doing the following:

  • Changed pcr_read to return a DigestList instead of PcrData.

  • Moved PcrData to abstractions and made it possible to construct
    PcrData from rust native types.

  • Added subtract to PcrSelectionList.

  • Added a pcr_read_all functiion to the pcr module
    in abstractions. This function tries to read all the
    values in a PcrSelectionList.

  • Crate tests that verifies that the new functionality actually works

  • Improve the docuemntation

Signed-off-by: Jesper Brynolf [email protected]

@ionut-arm
Copy link
Member

I have one fairly generic question which is: why not put the contents of pcr.rs in pcr/mod.rs?

@Superhepper
Copy link
Collaborator Author

I have one fairly generic question which is: why not put the contents of pcr.rs in pcr/mod.rs?

It is just a one of my own coding style rules to only have documentation and mod statements in mod.rs files. So if I need to create a mod.rs files with code in it I use the other way to create modules.

@wiktor-k
Copy link
Collaborator

For the record it Rust 2018 seems to be leaning on the side of avoiding generic mod.rs and prefer module names in file names: https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html#no-more-modrs

@ionut-arm
Copy link
Member

ionut-arm commented Oct 20, 2021

Hmm, fair, maybe we should keep it consistent at least, but it's not that critical. I think despite that 2018 edition guide, even the standard library seems to alternate between the two ways of dealing with this, and so do the really popular crates. I guess in the end it'll just end up as whatever each developer prefers, don't think I'm very keen on adding rules about that for our repos.

@Superhepper
Copy link
Collaborator Author

I do not think its a critical thing and I do not think I would create any remark for it in a code review either because it is my personal style. Though I agree with you, I would like for it to be consistent.

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, left a few comments, apologies if I'm misunderstanding stuff - I'm not that knowledgeable on PCRs

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch 4 times, most recently from 5bea2ea to f9d71d1 Compare October 24, 2021 21:51
@Superhepper Superhepper linked an issue Oct 25, 2021 that may be closed by this pull request
Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixes look good, I'm ok with the changes overall.

@Superhepper
Copy link
Collaborator Author

Cool, but I need to write some more tests before I am pleased with it.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch 2 times, most recently from 9c996e1 to 6b2b860 Compare October 25, 2021 21:53
@Superhepper
Copy link
Collaborator Author

Superhepper commented Oct 30, 2021

There is currently a bug in this that makes the pcr_bank not getting extended properly when data is added to the PcrData. And that is why the tests are failing.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch 2 times, most recently from 13c85fc to b710312 Compare October 30, 2021 10:10
@Superhepper
Copy link
Collaborator Author

There is currently a bug in this that makes the pcr_bank not getting extended properly when data is added to the PcrData. And that is why the tests are failing.

This has now been fixed.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch from b710312 to 895b721 Compare October 30, 2021 17:51
@Superhepper
Copy link
Collaborator Author

There is currently a bug in the PR when subtracting method of the PcrSelectionList and possible also in the subtract method in the PcrSelection.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch 2 times, most recently from f2906c5 to 33f6e52 Compare October 31, 2021 21:53
@Superhepper
Copy link
Collaborator Author

There is currently a bug in the PR when subtracting method of the PcrSelectionList and possible also in the subtract method in the PcrSelection.

This has now been fixed.

I am still in the process of writing more tests. Please feel free to come up with any suggestions.

@ionut-arm
Copy link
Member

I am still in the process of writing more tests. Please feel free to come up with any suggestions.

I can't say I have enough knowledge on this to come up with some good test cases, maybe @lkatalin has some ideas?

@ionut-arm ionut-arm mentioned this pull request Nov 15, 2021
16 tasks
@Superhepper Superhepper marked this pull request as ready for review November 16, 2021 09:08
@Superhepper
Copy link
Collaborator Author

I have not been able to come up with any additional tests and I have not heard of any bugs so far so I moved this out of WIP status.

@lkatalin
Copy link

Sorry I missed the ping on this and in general apologies for the silence. I have been endeavoring to get more time on this so that it does not continue to sit unmerged. I'm giving it another shot but still blocked on the ActivateCredential error at the moment.

@ionut-arm
Copy link
Member

@lkatalin - apologies, similarly blocked on other things and couldn't get to poking Keylime more, to get to the bottom of the ActivateCredential issue :(

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch from 33f6e52 to 350e227 Compare November 17, 2021 19:43
@lkatalin
Copy link

@ionut-arm Thanks so much for the fix in #292 ! With that out of the way, I should be able to test this tomorrow.

@lkatalin
Copy link

I'm able to make progress now that the ActivateCredential error is resolved, but testing this is requiring me to make some non-trivial changes to our code - I should have something working and have actual feedback by sometime next week. But if you need to merge in the meantime, please go ahead.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch from 350e227 to 81b8d33 Compare November 20, 2021 14:32
@ionut-arm
Copy link
Member

@Superhepper - can this be merged after the other PRs for adding other abstractions? I would've thought so, just wanted to make sure

@Superhepper
Copy link
Collaborator Author

Yeah, I think so. If nothing comes up that it contains a major bug or something.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch 2 times, most recently from 9563aae to f63200e Compare November 30, 2021 16:58
Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this being merged as is, and if any bug reports/feedback comes back we can fold that in as well.

Comment on lines 43 to 44
/// OBS! This is not the same as how many [PcrSlot]
/// there are in the selection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand this to describe what it does mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better now?

@lkatalin
Copy link

lkatalin commented Dec 3, 2021

@ionut-arm @Superhepper Finally finished rebasing our code on this and can confirm at least with some preliminary commands this works on our end. 👍 Huge thanks for this work and sorry for the wait.

@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch from f63200e to a7a9837 Compare December 3, 2021 06:33
@Superhepper Superhepper requested a review from wiktor-k December 3, 2021 06:37
Copy link
Collaborator

@wiktor-k wiktor-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the comments on the other PR shouldn't we consider AsRef/Deref on a couple of types (e.g. DigestList)? Thoughts? CC @ionut-arm

- Changed pcr_read to return a DigestList instead of PcrData.

- Moved PcrData to abstractions and made it possible to construct
  PcrData from rust native types.

- Added subtract to PcrSelectionList.

- Added a pcr_read_all functiion to the pcr module
  in abstractions. This function tries to read all the
  values in a PcrSelectionList.

- Removed lower limit for DigestList.

- Improved linage between the read pcr list and the read pcr digests
  in tests.

Signed-off-by: Jesper Brynolf <[email protected]>
@Superhepper Superhepper force-pushed the pcr_read_return_types_change branch from a7a9837 to afbe0e9 Compare December 3, 2021 11:12
@wiktor-k wiktor-k self-requested a review December 3, 2021 12:03
Copy link
Collaborator

@wiktor-k wiktor-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 thanks!


/// Returns true if the [PcrBank] is empty
pub fn is_empty(&self) -> bool {
self.bank.is_empty()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's okay here but too bad that now we've got some types that Deref to their inner types and some that don't. But Vecs are quite a lot simpler than BTreeMaps I guess.

@Superhepper Superhepper merged commit 468aefb into parallaxsecond:main Dec 3, 2021
@ionut-arm
Copy link
Member

@lkatalin - please be advised that there has been quite a rush to clean up the Context interface of FFI types, and this might mean that you'd need to make further changes when the 7.0.0 release will eventually come. The release isn't "imminent", but it's worth keeping that in mind. You can, of course, try compiling with the tip of the main branch, and that should give you a fairly accurate view.

@lkatalin
Copy link

lkatalin commented Dec 3, 2021

@lkatalin - please be advised that there has been quite a rush to clean up the Context interface of FFI types, and this might mean that you'd need to make further changes when the 7.0.0 release will eventually come. The release isn't "imminent", but it's worth keeping that in mind. You can, of course, try compiling with the tip of the main branch, and that should give you a fairly accurate view.

@ionut-arm That's very good to know ahead of time, thank you for telling me.

@Superhepper Superhepper deleted the pcr_read_return_types_change branch July 3, 2022 09:47
tgonzalezorlandoarm pushed a commit to tgonzalezorlandoarm/rust-tss-esapi that referenced this pull request Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manually construct PcrData? Re-implement subtract functionality for PcrSelectionList
5 participants