openwsn-berkeley / lakers

EDHOC implemented in Rust, optimized for microcontrollers, with bindings for C and Python.
https://crates.io/crates/lakers
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Typestatification #128

Closed chrysn closed 8 months ago

chrysn commented 8 months ago

(Please ignore the "Move crypto operations" commit, this is just based on #127).

In the high level API (edhoc.rs is left for later, turned out to work easily that way), passing the initiator by &mut is replaced by passing it by value, and receiving a new object with different APIs in return. This ensures at build time that functions are only called when suitable -- previously this would have the low-level implementation's checks at runtime. As a side effect, the Copy+Clone derives (that could easily be used to break EDHOC's security) could be removed, obsoleting #114 bit by bit.

This picks up discussion from around https://github.com/openwsn-berkeley/edhoc-rs/issues/99#issuecomment-1748436544.

In order to make this practical, the C API is removed; it may later be reintroduced using higher level abstractions.

Current state: So far this only alters the initiator, not the responder. It also doesn't change API too much. Seeing whether this breaks anything that I did not test; next steps (maybe right in this PR) is typestating the responder.

geonnave commented 8 months ago

Thanks for this PR! I went through and it looks good to me.

geonnave commented 8 months ago

Same comment as here, just waiting for a hax build.

geonnave commented 8 months ago

Same as this comment, no issues with hax.

geonnave commented 8 months ago

@malishav I am ok with merging this. Do you wish to provide any input?