| Internet-Draft | CBOR Configuration | September 2026 |
| Bormann | Expires 8 March 2027 | [Page] |
This document discusses configuration of CBOR processors. Using this information as a basis, it provides WGLC feedback on draft-ietf-cbor-serialization-08.¶
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.¶
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.¶
Copyright (c) 2026 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
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.¶
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:¶
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.¶
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.¶
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.¶
Serialization constraints restrict the serialization variants available for CBOR data items.¶
This may be motivated by enabling a partial implementation on the consumer side which has to deal with fewer variants.¶
In the area of serialization, the CBOR application may want to make use of deterministic serialization, which needs to be explicitly configured on the producer side and usually (depending on application requirements) also on the consumer side.¶
Data model subsetting may be a service requested by an application that does not need to handle certain CBOR data items. For instance, a CBOR application may not need to handle floating point values. This can enable compiling the library used with special flags to save the code space that would be needed (partial implementation enabler). Data model subsetting on the consumer side typically is an interoperability constraint (certain values can no longer be interchanged).¶
Normalization services may be provided by a CBOR library as a service that offloads some application code into the library, e.g., if the application desires to have all text strings sent in a Unicode Normalization Form (such as NFC). In certain cases, normalization services may be performed at the consuming side before ingested CBOR is handed to the application; this needs to be handled with caution as the application no longer sees what was actually interchanged.¶
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).¶
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.¶
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.¶
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.¶
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).¶
Handling interoperability in an ecosystem that embraces partial implementations requires more discipline.¶
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.)¶
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.¶
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.¶
TODO configuration security¶
This document has no IANA actions.¶
TODO acknowledge.¶