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: Basic Support for Tags #2359

Closed
wants to merge 6 commits into from

Conversation

JesusMcCloud
Copy link

@JesusMcCloud JesusMcCloud commented Jul 10, 2023

Introduces basic support for CBOR tags.

Basic means that no semantic checks are performed yet, so you freely use reserved tags (e.g. serialize a cornucopia of fruit and other produce using tags reserved for dates, URIs, MIME messages, negative bignums and so forth) and no error will be thrown.

  • New annotations ValueTags and KeyTags to specify tags for keys and values, respectively
    • Tags can be nested freely as specified in the annotations
    • By default, tags will be validated upon deserialization. If no annotations are present on a property, validation is omitted. Behaviour can be customized (see below).
    • By default, tags will be written as annotated. Behaviour can be customized (see below).
  • Introduces the following configuration parameters to the Cbor class (names are self-explanatory):
    • writeKeyTags
    • writeValueTags
    • verifyKeyTags
    • verifyValueTags

This is the first PR in a series of planned enhancements, but we still consider it valuable on its own (as it also affects #1560).

In the long run, we plan to support semantically correct serialization for all reserved CBOR tags. This includes separate contributions to koltinx.datetime and the native support for self-describing CBOR. The latter of which is planned to enable the deserialization of CBOR structures, while also enabling access to the original underlying raw byte-string. This is a crucial features for conveniently working with (i.e. verifying) signed data. (Which, in turn, is a requirement for a 100% pure Kotlin multiplatform COSE implementation.)
Hence, we want to use this opportunity to also collect early feedback from those who are more familiar with kotlinx.serialization than we are.

(ofc, this should be squashed prior to merging/rebasing)

@JesusMcCloud
Copy link
Author

Superseded by #2412. closing this one…

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.

None yet

1 participant