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

Allow applications to pick their C_x #104

Conversation

chrysn
Copy link
Collaborator

@chrysn chrysn commented Sep 30, 2023

Applications may need to pick their own C_x (as opposed to the EDHOC library picking one at random, as it was before) for three reasons:

  • The library doesn't manage the set of contexts, so it can't know which C_x are already in use and which are not.
  • The C_x may be used for other purposes (eg. OSCORE contexts), and might be namespaced there, which also only the application may know. (Silly example, but the application may use the OSCORE context identifiers that correspond to negative C_x for use with ACE-OSCORE profile, and only those with positive C_x for EDHOC).
  • When processing of message 1 and creation of message 2 are split over time (as is necessary when implementing an EDHOC server on the coap-handler interface), it is practical to already decide on a C_R at processing time, store the responder, and dig it up when creating the response -- but that requires the C_R to be decided already at storing time.

This will likely need follow-ups for similarly delegating the choice of {ID_,}CRED_peer to the callers (resolving #99 issues from), but those are separate enough that I'd do them in a separate PR.

These are API breaking changes. They're split in two because I did C_R first, and kept them split to ease review especially on the CI side; when ACK'ed, I'd like to squash them.

@chrysn chrysn force-pushed the more-application-control branch 11 times, most recently from 05b06a5 to be0ab60 Compare September 30, 2023 20:28
@chrysn chrysn marked this pull request as ready for review October 1, 2023 13:56
Copy link
Contributor

@malishav malishav left a comment

Choose a reason for hiding this comment

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

This looks good to me. @geonnave do you want to take a look before merging?

lib/src/lib.rs Outdated
@@ -761,7 +770,8 @@ mod test {
let mut initiator =
EdhocInitiator::new(state, I, G_R, ID_CRED_I, CRED_I, ID_CRED_R, CRED_R);

let message_1 = initiator.prepare_message_1();
let c_i: u8 = generate_connection_identifier_cbor().into();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is .into() needed here (and other similar lines)? The output of generate_connection_identifier_cbor() is already a u8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whether the output of generate_connection_identifier is U8 or u8 used to depend on the back-end; those can go away when rebasing onto remove-hacspec, which is my next step.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh indeed, great!

@geonnave
Copy link
Collaborator

geonnave commented Oct 3, 2023

Thanks @chrysn, it looks good. Left a minor comment. As for merging, maybe we could merge it directly into the remove-hacspec branch I just pushed upstream.

@chrysn chrysn force-pushed the more-application-control branch 5 times, most recently from 8bb8813 to a5dc9ae Compare October 3, 2023 10:42
The change allows applications to pick usable C_x (i.e., C_I and C_R)
values, which they are in a position to decide, because unlike the EDHOC
library, they keep track of all the ongoing exchanges.

The c_wrapper API is *not* changed at this point, because the API change
would be way too subtle (the "out" parameter would be changed to an "in"
parameter).

BREAKING CHANGE: This alters the message 1 and 2 API.
@chrysn
Copy link
Collaborator Author

chrysn commented Oct 3, 2023

This is now only one commit atop #106. Rebasing was a bit of a hassle, but worked in a mixed cherry-pick and manual application approach. Looks like remove-hacspec is in a stable enough shape to rebase onto, at any rate, and things are much easier on that!

From my PoV, this is done once CI says Go.

@geonnave geonnave changed the base branch from main to remove-hacspec October 3, 2023 11:48
@geonnave geonnave changed the base branch from remove-hacspec to main October 3, 2023 11:52
@geonnave geonnave changed the base branch from main to remove-hacspec October 3, 2023 11:52
@geonnave geonnave merged commit 784aab7 into openwsn-berkeley:remove-hacspec Oct 3, 2023
20 checks passed
@geonnave
Copy link
Collaborator

geonnave commented Oct 3, 2023

Great! Merged into remove-hacspec.

@chrysn chrysn deleted the more-application-control branch October 3, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants