Explicitly handle overflow when updating `openhcl/underhill_attestation_protocol`'s `vmgs::KeyProtector` `active_kp` field
Open
@mattbodd is already working on this.
Since Jan 9, 2025.
testing
- Dominant language
- Rust
- Stars
- 1.9k
- Forks
- 238
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 100
Description
KeyProtectors as defined in openhcl/openhcl_attesation_protocol (link) maintain the active KP index as a u32.
In openhcl/underhill_attestation/src/lib.rs, within persist_all_key_protectors, active KP is updated with a straightforward addition assignment operation, which will implicitly wrap when adding to u32::MAX. All current usages of the active KP index us modulo arithmetic which will handle arithmetic overflow gracefully and produce desired behavior.
Two suggestions for improvement
- Make
active_kpan enum withingressandegressvariants that desugars to u32 (for VMGS file compatibility)- Pros: clearer than using an arbitrary index value, not susceptible to overflow
- Cons: requires a bit of under-the-hood complexity to allow
FromBytesandAsBytesto work foractive_kpto be represented as u32 when reading/writing to an actual VMGS
- Explicitly use
u32::wrapping_add(link) to make the intent clearer- Pros: makes wrapping behavior expectation explicit, minimal change
- Cons: maintains implicit requirement for usage of
active_kpto handle wrapping behavior
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.