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

CBOR/COSE: support sorting of keys #2784

Open
JesusMcCloud opened this issue Aug 16, 2024 · 0 comments
Open

CBOR/COSE: support sorting of keys #2784

JesusMcCloud opened this issue Aug 16, 2024 · 0 comments
Labels

Comments

@JesusMcCloud
Copy link
Contributor

What is your use-case and why do you need this feature?
Current dev branch supports everything required to get COSE/CWT working, but still requires manual sorting of keys (i.e. declaring properties in the correct order).
It would be beneficial if automatic sorting could be triggered with a configuration switch on the CBOR serializer.

Describe the solution you'd like
Ideally, a two-pass serialization strategy should be an optional possibility: First everything is serialized into a tress structure, then sorted, and finally written out.
I am imagining a two-pass solution, because sorting needs to happen after all keys have been transformed into their CBOR-representation. Hence, the order can only be known once all keys are serialized, because sorting happens on serialized keys.
This can still happen somewhat in-place while writing out data during serialization, but some tree-like structure will still be required to shuffle properties around, so directly writing to an output is not an option. Based on what the code currently looks like, I think this should be possible to implement alongside the current encoder (to avoid slowdown, if you don't require auto-sorting) without duplicating code, but with some refactoring.

I can look into that myself, but I'd like to collect feedback first, so that the general strategy is at least somewhat deemed sensible before implementation starts. I'm hesitant to have this one assigned to me right away, because I don't know when I'll get to it. @whyoleg @sandwwraith I'd very much appreciate any thoughts from your side, as your feedback when pushing basic COSE support upstream was invaluable! Of course, I'd also appreciate feedback from anyone, who knows a thing about two about efficient encoding 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant