You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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_kp an enum with ingress and egress variants 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 FromBytes and AsBytes to work for active_kp to 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_kp to handle wrapping behavior
The text was updated successfully, but these errors were encountered:
KeyProtector
s as defined inopenhcl/openhcl_attesation_protocol
(link) maintain the active KP index as a u32.In
openhcl/underhill_attestation/src/lib.rs
, withinpersist_all_key_protectors
, active KP is updated with a straightforward addition assignment operation, which will implicitly wrap when adding tou32::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
active_kp
an enum withingress
andegress
variants that desugars to u32 (for VMGS file compatibility)FromBytes
andAsBytes
to work foractive_kp
to be represented as u32 when reading/writing to an actual VMGSu32::wrapping_add
(link) to make the intent cleareractive_kp
to handle wrapping behaviorThe text was updated successfully, but these errors were encountered: