rfc-9741

Concise Data Definition Language (CDDL): Additional Control Operators for the Conversion and Processing of Text

C. Bormann
date2025-03 streamIETF areaart wgcbor statusPROPOSED STANDARD pages12 canonicalhttps://www.rfc-editor.org/rfc/rfc9741 doi10.17487/RFC9741
The Concise Data Definition Language (CDDL), standardized in RFC 8610, provides "control operators" as its main language extension point. RFCs have added to this extension point in both an application-specific and a more general way. The present document defines a number of additional generally applicable control operators for text conversion (bytes, integers, printf-style formatting, and JSON) and for an operation on text.

Extracted elements (19)

design-rationale §2.4

A .jsonseq operator for JSON text sequences (RFC 7464) is not provided because no use case for inclusion in CDDL was known at the time of writing; it could be added in a future registration.

cbor, json

design-rationale §2.2

.base10 is defined to match only decimal integers without leading zeros (regex 0|-?[1-9][0-9]*). This opinionated choice increases usability by preventing ambiguous representations.

cbor

design-rationale §2.1

Sloppy variants are defined only for base64 (not base32 or base32hex) because no legacy use of sloppy base32(hex) was known at the time of writing. Base45 is strongly specified to disallow sloppy forms.

cbor

design-rationale §2.1

The base-encoding operators are intentionally opinionated: base64url with padding and base32(hex) with padding are excluded because experience shows these combinations only occur in error. Adding 'c' in .b64c ensures a deliberate choice for classic base64.

cbor

design-rationale §3.1

The .join operator is hard to validate in the general case (requiring full parser functionality), so its use is recommended to be limited to simple arrangements with constant 'marker' elements separating variable elements with no adjacent variable elements without intervening constants.

cbor

design-rationale §2.4

The .json operator provides no way to constrain blank space or serialization order in JSON output; such restrictions (e.g., canonical JSON) are deferred to potential future control operators.

cbor, json

interoperability-note §3.1

For .join, byte sequences in individual array elements need not individually be valid UTF-8; only the final concatenated result must be valid UTF-8 if the target is a text string. This contrasts with RFC 8949 Section 3.2.3.

cbor

interoperability-note §2.4

JSON has known interoperability problems (RFC 7493). Section 2 of RFC 7493 provides requirements that must be followed when using the .json control operator with CDDL's generic data model, particularly regarding numbers outside JSON's interoperable range.

json, cbor

interoperability-note §2.1

The strict base64 control operators (.b64u, .b64c) differ from CDDL's 'b64' literal prefix notation: the control operators only match characters from their specific alphabet, while the 'b64' literal prefix accepts characters from either alphabet.

cbor

normative-requirement §3.1 RECOMMENDED

It is RECOMMENDED that .join implementations provide full coverage at least for the marker-based subset, where constant array elements serve as guideposts to isolate variable elements that need further CDDL-level validation.

cbor

normative-requirement §2.3 MUST NOT

Length modifiers (paragraph 7 of Section 7.23.6.1 of the C standard) MUST NOT be included in the format string of the .printf control operator.

cbor

normative-requirement §2.3 MUST NOT

The 'p' and 'n' conversion specifiers MUST NOT be included in the format string of the .printf control operator.

cbor

protocol-element §2.1

Ten control operators for byte-string-to-text conversion are defined: .b64u (Base64url, no padding), .b64u-sloppy, .b64c (Base64 classic, padding), .b64c-sloppy, .b32 (Base32, no padding), .h32 (Base32 Extended Hex, no padding), .hex (Base16, either case), .hexlc (lower case), .hexuc (upper case), and .b45 (Base45). Each takes a text target and a bytes controller.

cbor, json

protocol-element §2.2

The .base10 control operator models text strings carrying a decimal integer (no leading zeros), matching the regular expression 0|-?[1-9][0-9]*. It is typed text target with int controller and is useful for YANG-JSON uint64/int64 formats.

cbor, json, yang

protocol-element §3.1

The .join control operator builds a text or byte string by concatenating elements of a controller array. The result type matches the kind of the first element; if the result is a text string, it must be valid UTF-8.

cbor, json

protocol-element §2.4

The .json control operator models text strings that embed a complete JSON value. It uses the JSON-to-CBOR conversion rules from Section 6.2 of RFC 8949 (STD94), analogous to the .cbor operator in RFC 8610.

cbor, json

protocol-element §2.3

The .printf control operator models text strings produced by C-style printf formatting. Its controller is an array whose first element is a format string and remaining elements are data items matching the conversion specifications.

cbor, json

registry §4

IANA has registered 14 new control operators (.b64u, .b64u-sloppy, .b64c, .b64c-sloppy, .b45, .b32, .h32, .hex, .hexlc, .hexuc, .base10, .printf, .json, .join) into the 'CDDL Control Operators' registry at IANA.cddl.

registry, cbor, json

security-consideration §5

The security considerations from RFC 8610 Section 5 apply to all control operators defined in this document. For the base-encoding operators in Section 2.1, the security considerations from RFC 4648 Section 12 also apply.

security, cbor