-
Notifications
You must be signed in to change notification settings - Fork 57
Rust native TPML_TAGGED_PCR_PROPERTY type #308
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
Rust native TPML_TAGGED_PCR_PROPERTY type #308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I haven't worked with PCRs (yet) I've read the PR and it looks OK.
Fixed so that octets not indicated to be used by the sizeOfSelect are ignored. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
9a6bbfb
to
7e6e957
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much like Wiktor, I don't have much experience working with PCRs, so just left a few generic questions/comments.
impl From<PcrSlot> for [u8; TPM2_PCR_SELECT_MAX as usize] { | ||
fn from(pcr_slot: PcrSlot) -> [u8; TPM2_PCR_SELECT_MAX as usize] { | ||
u32::from(pcr_slot).to_le_bytes() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't compile on a platform where TPM2_PCR_SELECT_MAX != 4
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! That is absolutely correct didn't even think about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code have been there for a while and it is a little bit complicated to change. It will depend on what we want to support. I mean the Max value could be anything. It is, as I pointed out earlier, up to the platform specification to specify.
What I think we can do and I think we should do is the following. We should extend PcrSlot enum to support all slots up to 31. The reason for this is because PcrSelectSize already supports a size of four octets. Then we should change the From
native to bindgen type conversions to be TryFrom
and check if the selected value can fit in the bindgen buffer.
I think this should be done by doing one TryFrom for each size. So a buffer with size 4 will have type Error = Infallible;
. But I have not thought about this to much yet.
But it is not something that should be done in this PR I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm happy with this approach - if it's just been moved from here to there and no one complained so far, I think we're good for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to raise an issue for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am going to raise an issue for that.
This commit moves the PcrSlot enum to its own source file and simplifies the conversion from a u32. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
Moves the PcrSelectSize to its own file and adds conversions to and from u8 and to usize. Adds tests for PcrSelectSize. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
Adds the PcrPropertyTag enum. This corresponds to the TPM2_PT_PCR constants. Adds tests for PcrPropertyTag. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
Adds the TaggedPcrSelect type. This corresponds to the TPMS_TAGGED_PCR_SELECT structure. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
Adds the TaggedPcrPropertyList type, this type corresponds to the TPML_TAGGED_PCR_PROPERTY structure. Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
7e6e957
to
66e6d86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR fixes #305 by doing the following.
Fixes a bug in the types that parses octets containing bit fields representing pcr slots.
Adds necessary types needed in order to create the TaggedPcrPropertyList type which is a rust native version of the TPML_TAGGED_PCR_PROPERTY.
Changes CapabilityData to TaggedPcrPropertyList.