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 #1

Closed
wants to merge 6 commits into from
Closed

CBOR: Basic Support for Tags #1

wants to merge 6 commits into from

Conversation

JesusMcCloud
Copy link
Collaborator

@JesusMcCloud JesusMcCloud commented Jul 5, 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 Kotlin#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.

@JesusMcCloud JesusMcCloud requested a review from nodh July 5, 2023 17:47
@JesusMcCloud JesusMcCloud changed the base branch from master to dev July 5, 2023 17:49
@JesusMcCloud JesusMcCloud force-pushed the feature/cborTags branch 2 times, most recently from 12a139c to f3f5976 Compare July 5, 2023 17:54
@JesusMcCloud JesusMcCloud changed the title Feature/cbor tags CBOR: Basic Support for Tags Jul 10, 2023
Copy link

@nodh nodh left a comment

Choose a reason for hiding this comment

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

Works great, but small changes requested

@JesusMcCloud
Copy link
Collaborator Author

submitting to upstream

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