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

Widen usable C_x range #300

Open
chrysn opened this issue Aug 4, 2024 · 1 comment
Open

Widen usable C_x range #300

chrysn opened this issue Aug 4, 2024 · 1 comment

Comments

@chrysn
Copy link
Collaborator

chrysn commented Aug 4, 2024

Currently we only support the numeric C_x values. This has caused trouble at some interops so far, especially when the peer randomly selects one, or the peer selects b'' before b'00'.

The data structure I propose to use is this:

struct Cx {
    full_encoded: Buffer<MAX_CX_LEN>,
    is_compact: bool,
}

with the validity constraint that:

  • full_encoded is a valid CBOR item that is a byte string in canonical encoding (which, in the expected case that MAX_CX_LEN is <= 25, means that the first byte is always 0x40 masked 0xe0, and masked 0x1f is equal to the length - 1)
  • is_compact is true iff full_encoded.len() == 2 and full_encoded[1..2] is a CBOR item that represents a small integer.

This can have a method to view the full version, to view the content (relevant to OSCORE), and to view the compact version (which is the full version if is_compact == false, else it is full_encoded[1..2]).

@geonnave
Copy link
Collaborator

geonnave commented Aug 5, 2024

I acknowledge that this needs to be fixed.

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

No branches or pull requests

2 participants