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

Privatize EADItem details, increase label range to i16 #100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chrysn
Copy link
Collaborator

@chrysn chrysn commented Sep 29, 2023

While it has practical uses (I'd like to utilize the library with https://datatracker.ietf.org/doc/draft-amsuess-core-edhoc-grease/, although that'll need the u16 or practically i32 points), its main purpose is to check whether my understanding of the code is good enough to pass CI.

I'd still ask for reviews towards merging because

  • having fewer pub items makes for a better evolvable library, and
  • I expect that EAD extensions that are somewhat larger will stay clear of the u8 range to leave it for every-byte-counts applications.

fn new(label: u16, is_critical: bool, value: Option<&[u8]>) -> Result<Self, EADNewError> {
let mut label: i16 = label
.try_into()
.map_err(|_| EADNewError::InexpressibleLabel)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think ? (and early returns in general?) is currently not supported by cargo hax into fstar, @W95Psp could you please confirm?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, that should be fine, ? and early returns are supported (they simply produce a bit heavyweight F*)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great, thanks for the clarification!

@@ -88,30 +88,71 @@ mod common {

#[derive(Debug)]
pub struct EADItem {
pub label: u8,
pub is_critical: bool,
pub(crate) label: i16,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are modifying label to support larger ranges, I think we could go ahead and use i32 to support the full specified range for EAD labels (0 to 65536).

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 thought there was no limit in EDHOC -22, but indeed the registry range implies that it's u16 / i17.

The choice between u16+bool and i32 is an implementation detail since the first commit, I think I'd go with the u16+bool version in this case (seeing the CBOR is done manually in edhoc.rs'sencode_ead_item); this can be revisited if CBOR in here ever gets outsourced to a CBOR library.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good!

@geonnave
Copy link
Collaborator

geonnave commented Oct 2, 2023

Thanks for this PR @chrysn. Left a few comments in the code. I assume you were waiting for a feedback before adjusting other impacted areas of the library.

BREAKING CHANGE: EADItem's constructor changed, and its fields became
private.
This increases the usable size of EAD labels to +-65535.

It also adds a bit of CBOR processing, to the point where it may make
sense to use a proper CBOR library instead; that is likely most easily
achieved after completion of [105].

[105]: openwsn-berkeley#105
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