Internet-Draft CBOR Configuration September 2026
Bormann Expires 8 March 2027 [Page]
Workgroup:
CBOR (Concise Binary Object Representation Maintenance and Extensions)
Internet-Draft:
draft-bormann-cbor-configuration-00
Published:
Intended Status:
Informational
Expires:
Author:
C. Bormann
Universität Bremen TZI

CBOR Configuration

Abstract

This document discusses configuration of CBOR processors. Using this information as a basis, it provides WGLC feedback on draft-ietf-cbor-serialization-08.

About This Document

This note is to be removed before publishing as an RFC.

Status information for this document may be found at https://datatracker.ietf.org/doc/draft-bormann-cbor-configuration/.

Discussion of this document takes place on the CBOR (Concise Binary Object Representation Maintenance and Extensions) Working Group mailing list (mailto:cbor@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/cbor/. Subscribe at https://www.ietf.org/mailman/listinfo/cbor/.

Source for this draft and an issue tracker can be found at https://github.com/cabo/configuration.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 8 March 2027.

Table of Contents

1. Introduction

This document discusses configuration of CBOR processors, more specifically, of libraries and other implementations that handle generation and ingestion of encoded CBOR data items for an application. Such a configuration will influence a number of individual services, including serialization (while meeting specific serialization constraints), data model subsetting, and normalization services (Section 2). Of these, only serialization/deserialization is a core service of such a library, but that is often combined with other services for convenience and ease of implementation.

1.1. Conventions and Definitions

For brevity, this revision of this document uses the definitions of RFC 8949 [STD94] and of Section 1.2 of [CDE]. Please do consult these definitions while reading the present document.

Additional Terms:

Service:

A potential function of a CBOR processor implementation. This includes services that are combined with the core services provided by that implementation, for convenience and ease of implementation.

Partial implementation enabler (PIE):

An agreement between producers and consumers of data items used in a CBOR-based protocol that allows for partial implementations on the consumer side.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

2. Configuration

A CBOR application often makes use of a CBOR library (more generally speaking, CBOR implementation) to perform certain services. There may be a need to communicate preferences or instructions from the CBOR application to the CBOR library on how to perform the services; this document uses the term "configuration" in this specific sense.

Some parameters of a configuration mechanism provided may be entirely local, such as memory allocation parameters. Some may be unilateral, i.e., they influence the generated CBOR, but the consuming application does not need to agree to these influences. Some may be interoperability constraints, i.e., certain parameters need to be known on both the producing and the consuming side.

2.1. Partial Implementations

CBOR has been designed to be useful in constrained environments. It therefore embraces partial implementations, i.e., implementations that do not provide access to all the features of the CBOR representation format. Partial implementations often have interoperability considerations: They can only be used for CBOR-based protocols that do not exercise features that have been left out (for instance, a constrained implementation that does not provide floating point values cannot be used for high-resolution timestamps based on CBOR Tag 1). To a certain extent, CBOR-based protocols can accommodate partial implementations: A protocol that uses Tag 1 could restrict the tag content to an integer, enabling the use of partial implementations without floating point support.

While CBOR does embrace partial implementations in this way, this does not mean a receiving CBOR protocol implementation is free to leave out features and expect the CBOR generator to magically know that this will be the case and implement workarounds. Instead, the use of a partial implementation needs to be enabled; the present document speaks about partial implementation enablers.

While there is an infinite number of implementation omissions that could be made in a CBOR implementation, certain omissions are widely employed and therefore may be worth to be explicitly called out, assigning them a name. This facilitates using these names in the definition of a CBOR-based protocol and in the configuration interface of a CBOR generator.

Some of these are about serialization configuration, see Section 2.2; this leads to a small number of easy-to-implement and widely considered useful partial implementation enablers such as "definite-length only" (DLO) or "no integer overlap" (NIO).

Some of these are about data model subsetting (e.g., no floating point), which actually have implications on the application data model and are therefore much more numerous, but also don't need library support (can be left to the control of the application).

2.2. Serialization Configuration

2.2.1. Example: JSON

For a given [JSON] value, there are often a large number of JSON texts that could be used to serialize it. For instance:

  • The number format provides significant serialization variation, e.g., (in the [I-JSON] interpretation) the number 42 can be serialized in an infinite number of ways, as 42, 42.0, 42.00, 42.0000000 (adding trailing insignificant zeros), 42e0, 4.2e1, .42e2, 420e-1 (using exponents in various ways), 42e00, 4.2e01, 4.2e+1, 4.2e+01 (adding sign characters and/or insignificant zeros to an exponent), etc.

  • Each character in a text string may provide a choice between directly including that character in the JSON text and using a \uNNNN or \uHHHH\uLLLL escape; the / character can also be escaped as \/.

  • The serialization of containers (arrays and JSON objects (maps)) provide for the insertion of blank space between elements/entries. Blank space can also be added outside (before or after) a serialized JSON value to make a JSON text.

2.2.1.1. JSON Implementations: Serialization Controls

There are probably a few hundred "serious", open-source general-purpose JSON implementations. These rarely provide controls that choose specific serialization variants, beyond those that relate to human consumption of the serialized JSON text (i.e., pretty printing). With luck, there may be a control for the text string escaping choosing between direct representation of all Unicode characters where JSON allows this vs. an "ASCII-only" mode escaping non-ASCII characters.

2.2.1.2. JSON Deterministic Serialization

A specification for deterministic serialization of JSON data exists [JCS]. This is usually not implemented as a serialization option by general JSON implementations, but by specially made JCS implementations (of which there probably are a couple of dozen "serious", open-source ones in existence). For example, the implementation of JCS number formatting is generally considered highly error-prone.

2.2.2. Example: CBOR

For a given CBOR data item, there are often multiple encoded CBOR data items ("encodings") that can be used to serialize it. Deterministic serializations reduce this number to exactly one variant.

In contrast to JSON, CBOR explicitly embraces partial implementations of the CBOR data format.

A partial implementation at a producer may involve data model subsetting in the CBOR library; unless that data model subsetting is part of the application data model, this may mean limitations to the expressiveness that the producer can make use of. As it is part of the library configuration it hands down, the producer application will be aware of this subsetting and can implement strategies for dealing with this subsetting (e.g., the application might round tag 1 timestamp values to the nearest integer if the additional resolution provided by floating point values is not needed).

If data model subsetting is to enable the consumer to use a partial implementation, the producer needs to be aware of this; this then becomes an interoperability constraint.

This document speaks about a Partial implementation enabler (PIE): An agreement between producers and consumers of data items as defined in a CBOR-based protocol that allows for partial implementations on the consumer side. A PIE may place additional onus on the producer side, including the application (e.g., converting all timestamps to integer in order to avoid the interchange of floating point numbers), and/or reduced onus (no need to encode floating point numbers if they are not used in the data model).

2.2.2.1. CBOR Implementations: Serialization Controls

Handling interoperability in an ecosystem that embraces partial implementations requires more discipline.

2.2.2.2. Deterministic Serialization for CBOR

Deterministic serialization is generally easy to achieve in CBOR and in many cases can be based on a generic implementation (encoder/decoder). There are several different (completed and draft) specifications for deterministic serialization:

  • A common format specified in Section 4.2.2 of RFC 8949 [STD94].

  • A legacy specification in Section 4.2.3 of RFC 8949 [STD94], compatible to a previous specification Section 3.9 of [RFC7049] (called "Canonical CBOR" there). (Common and legacy deterministic serialization differ in the ordering of maps.)

  • [CBOR-42], a "bespoke serialization of CBOR intended for use with the special tag 42 in various end-to-end protocols that came out of the IPFS community".

  • [I-D.draft-ietf-cbor-serialization-08], also based on Section 4.2.2 of RFC 8949 [STD94], but mixing some unrelated data model subsetting into the configuration.

Map sorting obviously requires additional effort in an encoder. Map sorting can help taking an onus off the consumer: Being able to process the map entries in any order can take more code/be less efficient for the consumer than knowing what order they will arrive in. (The latter does require making the order available to the application processing.) (CoAP Option processing is an example for how knowing the order in which entries arrive can be quite beneficial for a constrained implementation.)

2.3. Data Model Subsetting

The CBOR library may be made aware that certain parts of the CBOR generic data model are not used in the application data model of a CBOR application, possibly leading to a reusable subset of the generic data model. In this case, the producer may want to do a poor form of data model validation, and the consumer may do the same or simply reject input that doesn't respect the data model subset. The producer also may want to offer a normalization service (Section 2.4), possibly in support of data model subsetting.

A typical example is a constrained implementation for a platform that doesn't provide a platform type for floating point numbers, or maybe only for float32 and not float64. In the latter case, a normalization service could round float64 numbers to a close float32 number. Whether that is acceptable for the application needs to be defined by the CBOR-based protocol.

A disadvantage of performing data model subsetting in the CBOR library is that, unless there is detail information supplied by some data definition (e.g., an extension to CDDL), it applies equally whole-sale to the entire CBOR data item.

Data model subsetting can be a partial implementation enabler (PIE); a bespoke CBOR consumer does not need to implement parts of the CBOR functionality that are not in the protocol's data model subset.

2.4. Normalization

Normalization services may be a convenient addition to a CBOR library. For example, an application protocol that requires text strings to be in some Unicode normalization form (in many cases where this is needed, that will today be NFC) may want to flip a bit in the encoder configuration instead of doing the processing in the application implementation. Similarly, an application protocol that needs NaNs as a distinct data type but only one NaN value may want the encoder to normalize all NaN values to the chosen one.

Normalization is visible at the application layer; users of CBOR libraries need to be aware of which normalization processes are enabled in the library. The CBOR-based protocol usually does not know (or care) whether the normalized values came from the application or from a normalization service in a library.

As with data model subsetting, a disadvantage of performing normalization in the CBOR library is that, unless it is controlled by some data definition (e.g., an extension to CDDL), it applies whole-sale to the entire CBOR data item. On the other hand, normalization will typically not reach into the internals of CBOR data items, in which case embedded CBOR or homogeneous tagged arrays might not be covered.

3. Other WGLC Feedback

3.1. "New Tag Data Model Rule"

3.2. CDDL Serialization Control Operator

3.3. NaNs (Appendix C)

3.4. Implementation aid (Appendix D)

3.5. Serialization Checking (Appendix H)

3.6. Nits

4. Security Considerations

TODO configuration security

5. IANA Considerations

This document has no IANA actions.

6. References

6.1. Normative References

[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.

6.2. Informative References

[CBOR-42]
Bumblefudge and R. Berjon, "The tag-42 profile of CBOR", Work in Progress, Internet-Draft, draft-caballero-cbor-cbor42-02, , <https://datatracker.ietf.org/doc/html/draft-caballero-cbor-cbor42-02>. FIX ME: https://github.com/ietf-tools/bibxml-service/issues/458
[CDE]
Bormann, C., "CBOR Common Deterministic Encoding (CDE)", Work in Progress, Internet-Draft, draft-ietf-cbor-cde-13, , <https://datatracker.ietf.org/doc/html/draft-ietf-cbor-cde-13>.
[DOI.10.1109_MNET.2024.3352411]
Caviglione, L. and W. Mazurczyk, "You Can’t Do That on Protocols Anymore: Analysis of Covert Channels in IETF Standards", Institute of Electrical and Electronics Engineers (IEEE), IEEE Network vol. 38, no. 5, pp. 255-263, DOI 10.1109/mnet.2024.3352411, , <https://doi.org/10.1109/mnet.2024.3352411>.
[I-D.bormann-cbor-notable-tags]
Bormann, C., "Notable CBOR Tags", Work in Progress, Internet-Draft, draft-bormann-cbor-notable-tags-17, , <https://datatracker.ietf.org/doc/html/draft-bormann-cbor-notable-tags-17>.
[I-D.draft-ietf-cbor-serialization-08]
Lundblade, L., "CBOR Serialization and Determinism", Work in Progress, Internet-Draft, draft-ietf-cbor-serialization-08, , <https://datatracker.ietf.org/doc/html/draft-ietf-cbor-serialization-08>.
[I-JSON]
Bray, T., Ed., "The I-JSON Message Format", RFC 7493, DOI 10.17487/RFC7493, , <https://www.rfc-editor.org/rfc/rfc7493>.
[JCS]
Rundgren, A., Jordan, B., and S. Erdtman, "JSON Canonicalization Scheme (JCS)", RFC 8785, DOI 10.17487/RFC8785, , <https://www.rfc-editor.org/rfc/rfc8785>.
[JSON]
Internet Standard 90, <https://www.rfc-editor.org/info/std90>.
At the time of writing, this STD comprises the following:
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
[RFC7049]
Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, , <https://www.rfc-editor.org/rfc/rfc7049>. Obsoleted by [STD94], cited here for historical interest in legacy Section 3.9 "Canonical CBOR"
[STD94]
Internet Standard 94, <https://www.rfc-editor.org/info/std94>.
At the time of writing, this STD comprises the following:
Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", STD 94, RFC 8949, DOI 10.17487/RFC8949, , <https://www.rfc-editor.org/info/rfc8949>.

Acknowledgments

TODO acknowledge.

Author's Address

Carsten Bormann
Universität Bremen TZI
Postfach 330440
D-28359 Bremen
Germany