Skip to content

r_parse_message_3: Tolerate unparsable credential-by-value#271

Merged
geonnave merged 5 commits intolake-rs:mainfrom
chrysn-pull-requests:accept-cwt-by-value
May 16, 2024
Merged

r_parse_message_3: Tolerate unparsable credential-by-value#271
geonnave merged 5 commits intolake-rs:mainfrom
chrysn-pull-requests:accept-cwt-by-value

Conversation

@chrysn
Copy link
Copy Markdown
Member

@chrysn chrysn commented May 16, 2024

This enables using CWTs as values, provided that in the same step as where the user expands a credential-by-kid into a full credential, they also parse any non-CCS (or differently shaped CCS) values such as a CWT into the credential (left as it is), the key and the key ID.

This builds on #270 and addresses its usability caveat described in #269 (comment)

I still think we may want to elaborate the CredentialRpk type into differentiating at the type level whether it is valid (has KID, key and credential) or just partial (in the shapes "we parsed it already, it is valid", "we only have the KID" and "we only have the credential value but no keys", possibly others in the future), but that's API rework, and this enables things with the API as we have it.

chrysn added 4 commits May 15, 2024 22:48
Users must already be aware that what is returned could be incomplete
(i.e. have no key) because it could be a credential by key ID; now it
could also be a credential-by-value that is not in a format that the
limited Lakers credentials parser recognizes.
@geonnave
Copy link
Copy Markdown
Collaborator

But what if the credential is indeed invalid?

I think this changes the semantics of the API, as now the application cannot know if the credential was parsed or not.

One hacky way would be to add a .parsed? method to CredentialRPK, and which checks for (1) having a value but (2) not having kid or public key, which would indicate an unparsed credential.

Right now I can't think of a better solution without an API re-design.

@chrysn
Copy link
Copy Markdown
Member Author

chrysn commented May 16, 2024

I don't think that Lakers can be expected to differentiate an invalid credential from one that it just does not understand.

The way it currently exposes properties rather than accessors makes the differentiation between "has no key" and "the key is empty" hard, and improving that may be API change -- we can make the properties private, maybe turn some of them into an Option, and do all kinds of enhancements.

To enhance this change in isolation, we could add an is_complete() method (deprecating reference_only() to use ! is_complete() instead) that also checks whether a key is set. But that is for the convenience of the users to know whether or not they need to provide an actual (possibly hand-crafted) credential. If the user does not check, I'd assume that the same happens as if there was a KID only and the user doesn't upgrade it: The credential, key and KID don't match what is in the EDHOC context, and the operation fails.

@geonnave
Copy link
Copy Markdown
Collaborator

Ok. The spec indeed says in Section 5.3.3: When and how to perform authentication is up to the application.

Since it is not obvious why we are ignoring the error in the proposed change, there could be a comment in the else clause about leaving the credential processing to the application.

@chrysn
Copy link
Copy Markdown
Member Author

chrysn commented May 16, 2024

Good point, comment was added.

@geonnave geonnave merged commit 40f7cd7 into lake-rs:main May 16, 2024
@chrysn chrysn deleted the accept-cwt-by-value branch May 16, 2024 22:40
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.

2 participants