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

Split message processing #174

Merged
merged 21 commits into from
Dec 26, 2023

Conversation

geonnave
Copy link
Collaborator

@geonnave geonnave commented Dec 12, 2023

On top of PR #170. Aims to provide the split message processing discussed in issue #99.

Main tasks:

  • split message processing
  • some cleanup of the values stored in the outer state
  • update to only pass cred_x later on (instead of when calling initiator/responder::new EDIT: tracked in Pass CRED_X later on #179
  • update the examples

In addition, as a result of the split there is now IdCred and IdCredOwned. Thus,

Finally, with respect to the EAD:

Copy link
Collaborator

@chrysn chrysn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments inline.

From a final reviewing PoV, I'd hope to see the refactoring in shared and lib separated from the addition of an application, but that can be a split in the PR when it's going out of the draft stage (as keeping them split during development may incur excessive rebasing).

shared/src/lib.rs Outdated Show resolved Hide resolved
lib/src/edhoc.rs Show resolved Hide resolved
shared/src/lib.rs Outdated Show resolved Hide resolved
@geonnave geonnave force-pushed the split-message-processing branch 2 times, most recently from 0e4b41f to 070686d Compare December 18, 2023 19:00
handling of credentials is incomplete in this commit
it will be refactored subsequently
@geonnave
Copy link
Collaborator Author

geonnave commented Dec 19, 2023

Edit: the mapping of tasks in this comment have been moved to the first comment.

api:
- instantiate initial Start state directly from within
  Initiator/Responder
- make c_i/c_r optional: if not provided by the application, will be
  automatically generated
- change order of some parameters

cleanup: remove structs and functions from before the refactor
@geonnave geonnave marked this pull request as ready for review December 20, 2023 12:42
@geonnave
Copy link
Collaborator Author

This is ready for an initial review round. Note that the split begins at 5dd6c72 (previous commits are from PR #170).

@chrysn
Copy link
Collaborator

chrysn commented Dec 20, 2023

This looks to me like it's really independent of #170 (apart from commits such as 49cff1a that applies small fixes).

I'm not sure how you do / want reviews done here, but to me this would be way easier to review if the splitting changes could happen in a branch of their own. Depends a bit on the level of review you want here -- if it's more a rough look you're after, that works here as well. If you prefer commit-by-commit review, that might be more productive on a dedicated branch.

Copy link
Collaborator

@chrysn chrysn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still mid-review, leaving some comments.

For context, the glass through which I'm looking at the code right now is git diff --ignore-all-space 5dd6c72^..geonnave/split-message-processing -- shared lib.

pub x_or_y: BytesP256ElemLen, // ephemeral private key of myself
pub c_i: u8, // connection identifier chosen by the initiator
pub gy_or_gx: BytesP256ElemLen, // g_y or g_x, ephemeral public key of the peer
pub struct Start;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long does generating a key take? (I have no clue, can be just-take-the-few-bytes-of-entropy, can be do-some-complex-GF2-computations). If it's not trivial, it may be a good idea to store the x_or_y already in the Start, as that allows a system to prepare a key while not in use.

(Could also spin that out to an own low-prio issue)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have data for preparing message 1, which as a whole takes about 20 ms, given these conditions: crypto initialisation is stateful (see #94); using the cc310 backend. So it is fast, although software backends might take longer.

lib/src/edhoc.rs Show resolved Hide resolved
@geonnave
Copy link
Collaborator Author

Thanks for the review so far. The type of review I am looking for is about the current state of the API and an overall rough look.

@geonnave geonnave added enhancement New feature or request new feature labels Dec 21, 2023
@chrysn
Copy link
Collaborator

chrysn commented Dec 23, 2023

I think the rough API is good from a high-level PoV. There are lots of details we can enhance, but we can do that progressively once this is in.

One thing probably makes sense to do now because it's a pain to do later: look through the newly introduce type and function names. (Now this can be one commit with grep -i s/.../.../ **/*.rs, later that's bound to cause merge conflicts). Particular candidates are the split functions that are now a and b variants. The process_message_n / prepare_message_n+1 split already works well, so maybe process_message_3a / process_message_3b can become parse_message_3 / verify_message_3, and prepare_message_3a / preparere_mesage_3b can become prepare_message_3 / finalize_message_3 (same for prepare_message_1a/b)

this includes moving the generation of ephemeral keys and selection of
cipher suite to the `initiator/responder::new` functions
@geonnave
Copy link
Collaborator Author

Did changes suggested by @malishav (un-split prepare_message_1 and 3) and the renamings proposed by @chrysn.
Another critical item pointed by @malishav (private key accessed by application) is tracked in #182 and will be fixed ASAP.

@geonnave geonnave merged commit 5e277d8 into openwsn-berkeley:main Dec 26, 2023
27 checks passed
@geonnave geonnave deleted the split-message-processing branch December 26, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants