Skip to content
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

PcrEventInputs alloc-only method? #780

Open
RaitoBezarius opened this issue Apr 29, 2023 · 4 comments
Open

PcrEventInputs alloc-only method? #780

RaitoBezarius opened this issue Apr 29, 2023 · 4 comments

Comments

@RaitoBezarius
Copy link
Contributor

Hi there (again me), I am doing some TPM2 stuff with the library.

I see that PcrEventInputs::new_in_buffer is available, but requires the user to perform the allocation, it is a bit suboptimal because the required size requires using computations of the sizes (basically copying the first line in the impl).

This could be awesome with a PcrEventInputs::new which does the allocation for us.

@RaitoBezarius
Copy link
Contributor Author

Furthermore, I realize that EventHeader is not public, thus, I don't see how to get the memory size using core::mem::size_of unfortunately.

@phip1611
Copy link
Contributor

phip1611 commented May 3, 2023

Thanks for the report, good catch. The allocation should happen automatically, indeed.

@nicholasbishop
Copy link
Contributor

Furthermore, I realize that EventHeader is not public, thus, I don't see how to get the memory size using core::mem::size_of unfortunately.

I think the simplest thing to do here is just allocate a reasonable static size. It's OK for the buffer to be bigger than necessary, it just can't be smaller. For example: https://chromium.googlesource.com/chromiumos/platform/crdyboot/+/refs/heads/main/libcrdy/src/tpm.rs#132

That said, adding a new method to create a boxed allocation would also be good, I'll take a look at doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants